• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _HWC2_TEST_LAYER_H
18 #define _HWC2_TEST_LAYER_H
19 
20 #include <android-base/unique_fd.h>
21 #include <unordered_map>
22 
23 #include "Hwc2TestBuffer.h"
24 #include "Hwc2TestProperties.h"
25 
26 #define HWC2_INCLUDE_STRINGIFICATION
27 #define HWC2_USE_CPP11
28 #include <hardware/hwcomposer2.h>
29 #undef HWC2_INCLUDE_STRINGIFICATION
30 #undef HWC2_USE_CPP11
31 
32 class Hwc2TestLayer {
33 public:
34     Hwc2TestLayer(Hwc2TestCoverage coverage, const Area& displayArea);
35 
36     Hwc2TestLayer(Hwc2TestCoverage coverage, const Area& displayArea,
37             const std::unordered_map<Hwc2TestPropertyName,
38             Hwc2TestCoverage>& coverage_exceptions);
39 
40     std::string dump() const;
41 
42     int getBuffer(buffer_handle_t* outHandle,
43             android::base::unique_fd* outAcquireFence);
44     int getBuffer(buffer_handle_t* outHandle, int32_t* outAcquireFence);
45 
46     void setZOrder(uint32_t zOrder);
47     void setVisibleRegion(const android::Region& region);
48 
49     void reset();
50     bool advance();
51 
52     hwc2_blend_mode_t      getBlendMode() const;
53     Area                   getBufferArea() const;
54     hwc_color_t            getColor() const;
55     hwc2_composition_t     getComposition() const;
56     hwc_rect_t             getCursorPosition() const;
57     android_dataspace_t    getDataspace() const;
58     hwc_rect_t             getDisplayFrame() const;
59     float                  getPlaneAlpha() const;
60     hwc_frect_t            getSourceCrop() const;
61     hwc_region_t           getSurfaceDamage() const;
62     hwc_transform_t        getTransform() const;
63     hwc_region_t           getVisibleRegion() const;
64     uint32_t               getZOrder() const;
65 
66     bool advanceBlendMode();
67     bool advanceBufferArea();
68     bool advanceColor();
69     bool advanceComposition();
70     bool advanceCursorPosition();
71     bool advanceDataspace();
72     bool advanceDisplayFrame();
73     bool advancePlaneAlpha();
74     bool advanceSourceCrop();
75     bool advanceSurfaceDamage();
76     bool advanceTransform();
77     bool advanceVisibleRegion();
78 
79 private:
80     std::array<Hwc2TestContainer*, 10> mProperties = {{
81         &mTransform, &mColor, &mDataspace, &mPlaneAlpha, &mSourceCrop,
82         &mSurfaceDamage, &mBlendMode, &mBufferArea, &mDisplayFrame,
83         &mComposition
84     }};
85 
86     Hwc2TestBuffer mBuffer;
87 
88     Hwc2TestBlendMode mBlendMode;
89     Hwc2TestBufferArea mBufferArea;
90     Hwc2TestColor mColor;
91     Hwc2TestComposition mComposition;
92     Hwc2TestDataspace mDataspace;
93     Hwc2TestDisplayFrame mDisplayFrame;
94     Hwc2TestPlaneAlpha mPlaneAlpha;
95     Hwc2TestSourceCrop mSourceCrop;
96     Hwc2TestSurfaceDamage mSurfaceDamage;
97     Hwc2TestTransform mTransform;
98     Hwc2TestVisibleRegion mVisibleRegion;
99 
100     uint32_t mZOrder = UINT32_MAX;
101 };
102 
103 #endif /* ifndef _HWC2_TEST_LAYER_H */
104