1/* 2 * Copyright (c) 2023 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_DEVICE 17#define HDI_TEST_DEVICE 18#include <map> 19#include <memory> 20#include "v1_0/include/idisplay_buffer.h" 21#include "v1_2/include/idisplay_composer_interface.h" 22#include "v1_2/display_composer_type.h" 23#include "hdi_test_device_common.h" 24#include "hdi_test_display.h" 25#include "hdi_test_layer.h" 26 27namespace OHOS { 28namespace HDI { 29namespace Display { 30namespace TEST { 31using namespace OHOS::HDI::Display::Buffer::V1_0; 32using namespace OHOS::HDI::Display::Composer::V1_2; 33class HdiTestDevice { 34public: 35 static HdiTestDevice& GetInstance(); 36 static void HotPlug(uint32_t outputId, bool connected, void* data); 37 38 int32_t InitDevice(); 39 40 std::shared_ptr<IDisplayBuffer> GetGrallocInterface() 41 { 42 return gralloc_; 43 } 44 45 sptr<Composer::V1_2::IDisplayComposerInterface> &GetDeviceInterface() 46 { 47 return displayDevice_; 48 } 49 std::shared_ptr<HdiTestDisplay> GetDisplayFromId(uint32_t id); 50 std::shared_ptr<HdiTestDisplay> GetFirstDisplay(); 51 void Clear() const; 52 std::vector<uint32_t> GetDevIds() const; 53 54private: 55 std::shared_ptr<HdiTestDisplay> FindDisplayOrCreate(uint32_t id); 56 57 std::map<uint32_t, std::shared_ptr<HdiTestDisplay>> displays_; 58 sptr<Composer::V1_2::IDisplayComposerInterface> displayDevice_; 59 std::shared_ptr<IDisplayBuffer> gralloc_ = nullptr; 60 std::vector<uint32_t> displayIds_; 61}; 62} // OHOS 63} // HDI 64} // Display 65} // TEST 66 67#endif // HDI_TEST_DEVICE 68