1 /* 2 * Copyright (C) 2015 The Android Open Source Project 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 20 #include "drmhwcomposer.h" 21 #include "worker.h" 22 23 #include <queue> 24 25 namespace android { 26 27 class VirtualCompositorWorker : public Worker { 28 public: 29 VirtualCompositorWorker(); 30 ~VirtualCompositorWorker() override; 31 32 int Init(); 33 void QueueComposite(hwc_display_contents_1_t *dc); 34 35 protected: 36 void Routine() override; 37 38 private: 39 struct VirtualComposition { 40 UniqueFd outbuf_acquire_fence; 41 std::vector<UniqueFd> layer_acquire_fences; 42 int release_timeline; 43 }; 44 45 int CreateNextTimelineFence(); 46 int FinishComposition(int timeline); 47 void Compose(std::unique_ptr<VirtualComposition> composition); 48 49 std::queue<std::unique_ptr<VirtualComposition>> composite_queue_; 50 int timeline_fd_; 51 int timeline_; 52 int timeline_current_; 53 }; 54 } 55 56 #endif 57