1 /* 2 * Copyright (C) 2021 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 #pragma once 18 19 #include <aidlcommonsupport/NativeHandle.h> 20 21 using AidlNativeHandle = aidl::android::hardware::common::NativeHandle; 22 23 namespace aidl::android::hardware::graphics::composer3::impl { 24 25 /// Some IResourceManager functions return a replaced buffer and that buffer should be 26 // released later (at the time of IBufferReleaser object destruction) 27 class IBufferReleaser { 28 public: 29 virtual ~IBufferReleaser() = default; 30 }; 31 32 class IResourceManager { 33 public: 34 static std::unique_ptr<IResourceManager> create(); 35 using RemoveDisplay = std::function<void(int64_t display, bool isVirtual, 36 const std::vector<int64_t>& layers)>; 37 virtual ~IResourceManager() = default; 38 virtual std::unique_ptr<IBufferReleaser> createReleaser(bool isBuffer) = 0; 39 40 virtual void clear(RemoveDisplay removeDisplay) = 0; 41 virtual bool hasDisplay(int64_t display) = 0; 42 virtual int32_t addPhysicalDisplay(int64_t display) = 0; 43 virtual int32_t addVirtualDisplay(int64_t display, uint32_t outputBufferCacheSize) = 0; 44 virtual int32_t removeDisplay(int64_t display) = 0; 45 virtual int32_t setDisplayClientTargetCacheSize(int64_t display, 46 uint32_t clientTargetCacheSize) = 0; 47 virtual int32_t getDisplayClientTargetCacheSize(int64_t display, size_t* outCacheSize) = 0; 48 virtual int32_t getDisplayOutputBufferCacheSize(int64_t display, size_t* outCacheSize) = 0; 49 virtual int32_t addLayer(int64_t display, int64_t layer, uint32_t bufferCacheSize) = 0; 50 virtual int32_t removeLayer(int64_t display, int64_t layer) = 0; 51 virtual void setDisplayMustValidateState(int64_t display, bool mustValidate) = 0; 52 virtual bool mustValidateDisplay(int64_t display) = 0; 53 virtual int32_t getDisplayReadbackBuffer(int64_t display, const buffer_handle_t handle, 54 buffer_handle_t& outHandle, 55 IBufferReleaser* bufReleaser) = 0; 56 virtual int32_t getDisplayClientTarget(int64_t display, uint32_t slot, bool fromCache, 57 const buffer_handle_t handle, 58 buffer_handle_t& outHandle, 59 IBufferReleaser* bufReleaser) = 0; 60 virtual int32_t getDisplayOutputBuffer(int64_t display, uint32_t slot, bool fromCache, 61 const buffer_handle_t handle, 62 buffer_handle_t& outHandle, 63 IBufferReleaser* bufReleaser) = 0; 64 virtual int32_t getLayerBuffer(int64_t display, int64_t layer, uint32_t slot, 65 bool fromCache, 66 const buffer_handle_t rawHandle, 67 buffer_handle_t& outBufferHandle, 68 IBufferReleaser* bufReleaser) = 0; 69 virtual int32_t getLayerSidebandStream(int64_t display, int64_t layer, 70 const buffer_handle_t rawHandle, 71 buffer_handle_t& outStreamHandle, 72 IBufferReleaser* bufReleaser) = 0; 73 }; 74 75 } // namespace aidl::android::hardware::graphics::composer3::impl 76