1 // Copyright 2022 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expresso or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #include <future> 18 #include <optional> 19 #include <vector> 20 21 #include "BorrowedImage.h" 22 #include "Hwc2.h" 23 24 namespace gfxstream { 25 26 // Thread hostile and should only be called from the same single thread. 27 class Compositor { 28 public: ~Compositor()29 virtual ~Compositor() {} 30 31 struct CompositionRequestLayer { 32 std::unique_ptr<BorrowedImageInfo> source; 33 ComposeLayer props; 34 }; 35 36 struct CompositionRequest { 37 std::unique_ptr<BorrowedImageInfo> target; 38 std::vector<CompositionRequestLayer> layers; 39 }; 40 41 using CompositionFinishedWaitable = std::shared_future<void>; 42 43 virtual CompositionFinishedWaitable compose(const CompositionRequest& compositionRequest) = 0; 44 onImageDestroyed(uint32_t imageId)45 virtual void onImageDestroyed(uint32_t imageId) {} 46 }; 47 48 } // namespace gfxstream 49