1 /* 2 * Copyright (C) 2022 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_HWC_COMPOSER_H 18 #define ANDROID_HWC_COMPOSER_H 19 20 #include <android-base/unique_fd.h> 21 22 #include <functional> 23 #include <tuple> 24 #include <unordered_map> 25 #include <vector> 26 27 #include "Common.h" 28 #include "DisplayChanges.h" 29 #include "DrmClient.h" 30 31 namespace aidl::android::hardware::graphics::composer3::impl { 32 33 class Display; 34 35 class FrameComposer { 36 public: ~FrameComposer()37 virtual ~FrameComposer() {} 38 39 virtual HWC3::Error init() = 0; 40 41 using HotplugCallback = std::function<void(bool /*connected*/, // 42 uint32_t /*id*/, // 43 uint32_t /*width*/, // 44 uint32_t /*height*/, // 45 uint32_t /*dpiX*/, // 46 uint32_t /*dpiY*/, // 47 uint32_t /*refreshRate*/)>; 48 49 virtual HWC3::Error registerOnHotplugCallback(const HotplugCallback& cb) = 0; 50 51 virtual HWC3::Error unregisterOnHotplugCallback() = 0; 52 53 virtual HWC3::Error onDisplayCreate(Display* display) = 0; 54 55 virtual HWC3::Error onDisplayDestroy(Display* display) = 0; 56 57 virtual HWC3::Error onDisplayClientTargetSet(Display* display) = 0; 58 59 // Determines if this composer can compose the given layers and requests 60 // changes for layers that can't not be composed. 61 virtual HWC3::Error validateDisplay(Display* display, DisplayChanges* outChanges) = 0; 62 63 // Performs the actual composition of layers and presents the composed result 64 // to the display. 65 virtual HWC3::Error presentDisplay( 66 Display* display, ::android::base::unique_fd* outDisplayFence, 67 std::unordered_map<int64_t, ::android::base::unique_fd>* outLayerFences) = 0; 68 69 virtual HWC3::Error onActiveConfigChange(Display* display) = 0; 70 getDrmPresenter()71 virtual const DrmClient* getDrmPresenter() const { return nullptr; } 72 }; 73 74 } // namespace aidl::android::hardware::graphics::composer3::impl 75 76 #endif 77