blob: 885cf31d4ac519ad5f3bbc4a2aa01061a4125f2b [file] [log] [blame]
Haixia Shid21f5282015-10-05 14:35:09 -07001/*
Adrian Salido0e892682017-03-01 14:57:39 -08002 * Copyright (C) 2015-2016 The Android Open Source Project
Haixia Shid21f5282015-10-05 14:35:09 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_VIRTUAL_COMPOSITOR_WORKER_H_
18#define ANDROID_VIRTUAL_COMPOSITOR_WORKER_H_
19
Zach Reizner7642c922015-10-29 10:11:16 -070020#include "drmhwcomposer.h"
Adrian Salido0e892682017-03-01 14:57:39 -080021#include "queue_worker.h"
Haixia Shid21f5282015-10-05 14:35:09 -070022
23namespace android {
24
Adrian Salido0e892682017-03-01 14:57:39 -080025struct VirtualComposition {
26 UniqueFd outbuf_acquire_fence;
27 std::vector<UniqueFd> layer_acquire_fences;
28 int release_timeline;
29};
30
31class VirtualCompositorWorker : public QueueWorker<VirtualComposition> {
Haixia Shid21f5282015-10-05 14:35:09 -070032 public:
33 VirtualCompositorWorker();
Haixia Shi479412c2015-10-27 10:40:48 -070034 ~VirtualCompositorWorker() override;
Haixia Shid21f5282015-10-05 14:35:09 -070035
36 int Init();
37 void QueueComposite(hwc_display_contents_1_t *dc);
38
39 protected:
Adrian Salido0e892682017-03-01 14:57:39 -080040 void ProcessWork(std::unique_ptr<VirtualComposition> composition);
Haixia Shid21f5282015-10-05 14:35:09 -070041
42 private:
Haixia Shid21f5282015-10-05 14:35:09 -070043 int CreateNextTimelineFence();
44 int FinishComposition(int timeline);
Haixia Shid21f5282015-10-05 14:35:09 -070045
Haixia Shid21f5282015-10-05 14:35:09 -070046 int timeline_fd_;
47 int timeline_;
48 int timeline_current_;
49};
50}
51
52#endif