1 /* 2 * Copyright (c) 2019, The Linux Foundation. All rights reserved. 3 * Not a Contribution. 4 * 5 * Copyright (C) 2017 The Android Open Source Project 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 #ifndef __QTICOMPOSERHANDLEIMPORTER_H__ 21 #define __QTICOMPOSERHANDLEIMPORTER_H__ 22 23 #include <android/hardware/graphics/mapper/2.0/IMapper.h> 24 #include <android/hardware/graphics/mapper/3.0/IMapper.h> 25 #include <utils/Mutex.h> 26 27 namespace vendor { 28 namespace qti { 29 namespace hardware { 30 namespace display { 31 namespace composer { 32 namespace V3_0 { 33 34 using IMapperV2 = ::android::hardware::graphics::mapper::V2_0::IMapper; 35 using IMapperV3 = ::android::hardware::graphics::mapper::V3_0::IMapper; 36 using ::android::sp; 37 using ::android::Mutex; 38 using ::android::hardware::hidl_handle; 39 40 class ComposerHandleImporter { 41 public: 42 ComposerHandleImporter(); 43 44 // In IComposer, any buffer_handle_t is owned by the caller and we need to 45 // make a clone for hwcomposer2. We also need to translate empty handle 46 // to nullptr. This function does that, in-place. 47 bool importBuffer(buffer_handle_t& handle); 48 void freeBuffer(buffer_handle_t handle); 49 void initialize(); 50 void cleanup(); 51 52 private: 53 Mutex mLock; 54 bool mInitialized = false; 55 sp<IMapperV2> mMapper_V2; 56 sp<IMapperV3> mMapper_V3; 57 }; 58 59 } // namespace V3_0 60 } // namespace composer 61 } // namespace display 62 } // namespace hardware 63 } // namespace qti 64 } // namespace vendor 65 66 #endif // __QTICOMPOSERHANDLEIMPORTER_H__ 67