1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 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 express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HDI_TEST_DISPLAY_H 17 #define HDI_TEST_DISPLAY_H 18 #include <cinttypes> 19 #include "display_device.h" 20 #include "display_gralloc.h" 21 #include "display_type.h" 22 #include "display_test.h" 23 #include "hdi_test_device_common.h" 24 #include "hdi_test_layer.h" 25 26 namespace OHOS { 27 namespace HDI { 28 namespace DISPLAY { 29 namespace TEST { 30 class HdiTestDisplay { 31 public: 32 HdiTestDisplay(uint32_t id, DeviceFuncs &deviceFunc); ~HdiTestDisplay()33 virtual ~HdiTestDisplay() {}; 34 int32_t Init(); 35 int32_t GetModeInfoFromId(int32_t id, DisplayModeInfo &modeInfo); 36 std::shared_ptr<HdiTestLayer> CreateHdiTestLayer(LayerInfo &info); 37 std::shared_ptr<HdiTestLayer> CreateHdiTestLayer(uint32_t w, uint32_t h); 38 int32_t Commit(); 39 int32_t PrepareDisplayLayers(); GetCurrentMode()40 DisplayModeInfo GetCurrentMode() const 41 { 42 return mCurrentMode; 43 } 44 int32_t RegDisplayVBlankCallback(VBlankCallback cb, void *data); 45 int32_t SetDisplayVsyncEnabled(bool enabled); 46 std::shared_ptr<HdiTestLayer> GetLayerFromId(uint32_t id); GetLayers()47 std::unordered_map<uint32_t, std::shared_ptr<HdiTestLayer>> &GetLayers() 48 { 49 return mLayerMaps; 50 } 51 void Clear(); SnapShot()52 BufferHandle *SnapShot() 53 { 54 DISPLAY_TEST_LOGD("client fb phyaddr %" PRIx64 " virtual addr %p", mCurrentFb->phyAddr, mCurrentFb->virAddr); 55 return mCurrentFb; 56 } 57 58 private: GetDeviceFuncs()59 const DeviceFuncs &GetDeviceFuncs() const 60 { 61 return mDeviceFunc; 62 } 63 int32_t RefreshLayersCompType(); 64 int32_t GetLayersReleaseFence(); 65 uint32_t mActiveModeId = 0; 66 DisplayModeInfo mCurrentMode = { 0 }; 67 uint32_t mId; 68 DeviceFuncs mDeviceFunc = { 0 }; 69 70 DisplayCapability mCap; 71 std::vector<DisplayModeInfo> mModes; 72 std::unordered_map<uint32_t, std::shared_ptr<HdiTestLayer>> mLayerMaps; 73 std::unique_ptr<HdiTestLayer> mClientLayer; 74 BufferHandle *mCurrentFb; 75 bool mNeedFlushFb = false; 76 }; 77 } // OHOS 78 } // HDI 79 } // DISPLAY 80 } // TEST 81 82 #endif // HDI_TEST_DISPLAY_H