Haixia Shi | d21f528 | 2015-10-05 14:35:09 -0700 | [diff] [blame] | 1 | /* |
Adrian Salido | 0e89268 | 2017-03-01 14:57:39 -0800 | [diff] [blame] | 2 | * Copyright (C) 2015-2016 The Android Open Source Project |
Haixia Shi | d21f528 | 2015-10-05 14:35:09 -0700 | [diff] [blame] | 3 | * |
| 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 Reizner | 7642c92 | 2015-10-29 10:11:16 -0700 | [diff] [blame] | 20 | #include "drmhwcomposer.h" |
Adrian Salido | 0e89268 | 2017-03-01 14:57:39 -0800 | [diff] [blame] | 21 | #include "queue_worker.h" |
Haixia Shi | d21f528 | 2015-10-05 14:35:09 -0700 | [diff] [blame] | 22 | |
| 23 | namespace android { |
| 24 | |
Adrian Salido | 0e89268 | 2017-03-01 14:57:39 -0800 | [diff] [blame] | 25 | struct VirtualComposition { |
| 26 | UniqueFd outbuf_acquire_fence; |
| 27 | std::vector<UniqueFd> layer_acquire_fences; |
| 28 | int release_timeline; |
| 29 | }; |
| 30 | |
| 31 | class VirtualCompositorWorker : public QueueWorker<VirtualComposition> { |
Haixia Shi | d21f528 | 2015-10-05 14:35:09 -0700 | [diff] [blame] | 32 | public: |
| 33 | VirtualCompositorWorker(); |
Haixia Shi | 479412c | 2015-10-27 10:40:48 -0700 | [diff] [blame] | 34 | ~VirtualCompositorWorker() override; |
Haixia Shi | d21f528 | 2015-10-05 14:35:09 -0700 | [diff] [blame] | 35 | |
| 36 | int Init(); |
| 37 | void QueueComposite(hwc_display_contents_1_t *dc); |
| 38 | |
| 39 | protected: |
Adrian Salido | 0e89268 | 2017-03-01 14:57:39 -0800 | [diff] [blame] | 40 | void ProcessWork(std::unique_ptr<VirtualComposition> composition); |
Haixia Shi | d21f528 | 2015-10-05 14:35:09 -0700 | [diff] [blame] | 41 | |
| 42 | private: |
Haixia Shi | d21f528 | 2015-10-05 14:35:09 -0700 | [diff] [blame] | 43 | int CreateNextTimelineFence(); |
| 44 | int FinishComposition(int timeline); |
Haixia Shi | d21f528 | 2015-10-05 14:35:09 -0700 | [diff] [blame] | 45 | |
Haixia Shi | d21f528 | 2015-10-05 14:35:09 -0700 | [diff] [blame] | 46 | int timeline_fd_; |
| 47 | int timeline_; |
| 48 | int timeline_current_; |
| 49 | }; |
| 50 | } |
| 51 | |
| 52 | #endif |