• 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_LAYER_H
17 #define HDI_TEST_LAYER_H
18 #include <queue>
19 #include "display_gralloc.h"
20 #include "display_layer.h"
21 
22 namespace OHOS {
23 namespace HDI {
24 namespace DISPLAY {
25 namespace TEST {
26 class HdiGrallocBuffer {
27 public:
28     HdiGrallocBuffer(uint32_t w, uint32_t h, PixelFormat fmt);
29     ~HdiGrallocBuffer();
Get()30     BufferHandle *Get() const
31     {
32         return mBufferHandle;
33     }
34     void SetReleaseFence(int fd);
35     void SetAcquirceFence(int fd);
GetAcquireFence()36     int GetAcquireFence() const
37     {
38         return mAcquireFence;
39     }
GetReleaseFence()40     int GetReleaseFence() const
41     {
42         return mReleaseFence;
43     }
44 
45 private:
46     BufferHandle *mBufferHandle = nullptr;
47     int mAcquireFence = -1;
48     int mReleaseFence = -1;
49 };
50 
51 class HdiTestLayer {
52 public:
53     HdiTestLayer(LayerInfo &info, uint32_t id, uint32_t displayId);
54     virtual ~HdiTestLayer();
55     int32_t Init();
56     int32_t PreparePresent();
57 
GetId()58     uint32_t GetId() const
59     {
60         return mId;
61     }
GetCompType()62     CompositionType GetCompType() const
63     {
64         return mCompType;
65     }
66 
67     HdiGrallocBuffer *GetFrontBuffer();
68     HdiGrallocBuffer *GetBackBuffer();
69     HdiGrallocBuffer *AcquireBackBuffer();
70 
71     int32_t SwapFrontToBackQ();
72     int32_t SwapBackToFrontQ();
73 
74     void SetLayerSize(IRect &rect);
75     void SetLayerCrop(IRect &rect);
76     void SetZorder(uint32_t zorder);
77     void SetCompType(CompositionType type);
78     void SetReleaseFence(int fd);
79     void SetAlpha(LayerAlpha alpha);
80     void SetBlendType(BlendType type);
81     void SetTransform(TransformType transform);
82 
83 private:
84     uint32_t mId;
85     uint32_t mDisplayID;
86     std::queue<std::unique_ptr<HdiGrallocBuffer>> mFrontBuffers;
87     std::queue<std::unique_ptr<HdiGrallocBuffer>> mBackBuffers;
88     LayerInfo mLayerInfo = { 0 };
89 
90     CompositionType mCompType = COMPOSITION_CLIENT;
91     IRect mDisplayRect = { 0 };
92     IRect mCropRect = { 0 };
93     uint32_t mZorder = 0;
94     LayerAlpha mAlpha = { 0 };
95     BlendType mBlendType = BLEND_SRC;
96     std::unique_ptr<HdiGrallocBuffer> mCurrentBuffer;
97     TransformType mTransform = ROTATE_NONE;
98 };
99 } // OHOS
100 } // HDI
101 } // DISPLAY
102 } // TEST
103 
104 #endif // HDI_TEST_LAYER_H