• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DEVICE
17 #define HDI_TEST_DEVICE
18 #include <map>
19 #include <memory>
20 #include "display_device.h"
21 #include "display_gralloc.h"
22 #include "display_layer.h"
23 #include "hdi_test_device_common.h"
24 #include "hdi_test_display.h"
25 #include "hdi_test_layer.h"
26 
27 namespace OHOS {
28 namespace HDI {
29 namespace DISPLAY {
30 namespace TEST {
31 class HdiTestDevice {
32 public:
33     static HdiTestDevice &GetInstance();
34     static void HotPlug(uint32_t outputId, bool connected, void *data);
35     int32_t InitDevice();
36 
GetGrallocFuncs()37     GrallocFuncs &GetGrallocFuncs()
38     {
39         return *mGrallocFuncs;
40     }
GetLayerFuncs()41     LayerFuncs &GetLayerFuncs()
42     {
43         return *mLayerFuncs;
44     }
GetDeviceFuncs()45     DeviceFuncs &GetDeviceFuncs()
46     {
47         return *mDeviceFuncs;
48     }
49 
50     std::shared_ptr<HdiTestDisplay> GetDisplayFromId(uint32_t id);
51     std::shared_ptr<HdiTestDisplay> GetFirstDisplay();
52     void Clear();
53 
54 private:
55     std::shared_ptr<HdiTestDisplay> FindDisplayOrCreate(uint32_t id);
56 
57     std::map<uint32_t, std::shared_ptr<HdiTestDisplay>> mDisplays;
58     DeviceFuncs *mDeviceFuncs = nullptr;
59     LayerFuncs *mLayerFuncs = nullptr;
60     GrallocFuncs *mGrallocFuncs = nullptr;
61 };
62 } // OHOS
63 } // HDI
64 } // DISPLAY
65 } // TEST
66 
67 #endif // HDI_TEST_DEVICE