Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 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_PROPERTIES_H |
| 18 | #define _HWC2_TEST_PROPERTIES_H |
| 19 | |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 20 | #include <array> |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 21 | #include <vector> |
| 22 | |
| 23 | #define HWC2_INCLUDE_STRINGIFICATION |
| 24 | #define HWC2_USE_CPP11 |
| 25 | #include <hardware/hwcomposer2.h> |
| 26 | #undef HWC2_INCLUDE_STRINGIFICATION |
| 27 | #undef HWC2_USE_CPP11 |
| 28 | |
| 29 | enum class Hwc2TestCoverage { |
| 30 | Default = 0, |
| 31 | Basic, |
| 32 | Complete, |
| 33 | }; |
| 34 | |
Marissa Wall | 600a73b | 2016-12-15 12:30:39 -0800 | [diff] [blame^] | 35 | typedef struct { |
| 36 | int32_t width; |
| 37 | int32_t height; |
| 38 | } Area; |
| 39 | |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 40 | |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 41 | class Hwc2TestContainer { |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 42 | public: |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 43 | virtual ~Hwc2TestContainer() = default; |
| 44 | |
| 45 | /* Resets the container */ |
| 46 | virtual void reset() = 0; |
| 47 | |
| 48 | /* Attempts to advance to the next valid value. Returns true if one can be |
| 49 | * found */ |
| 50 | virtual bool advance() = 0; |
| 51 | |
| 52 | virtual std::string dump() const = 0; |
| 53 | }; |
| 54 | |
| 55 | |
| 56 | template <class T> |
| 57 | class Hwc2TestProperty : public Hwc2TestContainer { |
| 58 | public: |
| 59 | Hwc2TestProperty(Hwc2TestCoverage coverage, |
| 60 | const std::vector<T>& completeList, const std::vector<T>& basicList, |
| 61 | const std::vector<T>& defaultList) |
| 62 | : Hwc2TestProperty((coverage == Hwc2TestCoverage::Complete)? completeList: |
| 63 | (coverage == Hwc2TestCoverage::Basic)? basicList : defaultList) { } |
| 64 | |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 65 | Hwc2TestProperty(const std::vector<T>& list) |
| 66 | : mList(list) { } |
| 67 | |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 68 | void reset() override |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 69 | { |
| 70 | mListIdx = 0; |
| 71 | } |
| 72 | |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 73 | bool advance() override |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 74 | { |
| 75 | if (mListIdx + 1 < mList.size()) { |
| 76 | mListIdx++; |
| 77 | return true; |
| 78 | } |
| 79 | reset(); |
| 80 | return false; |
| 81 | } |
| 82 | |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 83 | T get() const |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 84 | { |
| 85 | return mList.at(mListIdx); |
| 86 | } |
| 87 | |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 88 | protected: |
| 89 | const std::vector<T>& mList; |
| 90 | size_t mListIdx = 0; |
| 91 | }; |
| 92 | |
| 93 | |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 94 | class Hwc2TestBlendMode : public Hwc2TestProperty<hwc2_blend_mode_t> { |
| 95 | public: |
| 96 | Hwc2TestBlendMode(Hwc2TestCoverage coverage); |
| 97 | |
| 98 | std::string dump() const override; |
| 99 | |
| 100 | protected: |
| 101 | static const std::vector<hwc2_blend_mode_t> mDefaultBlendModes; |
| 102 | static const std::vector<hwc2_blend_mode_t> mBasicBlendModes; |
| 103 | static const std::vector<hwc2_blend_mode_t> mCompleteBlendModes; |
| 104 | }; |
| 105 | |
| 106 | |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 107 | class Hwc2TestComposition : public Hwc2TestProperty<hwc2_composition_t> { |
| 108 | public: |
| 109 | Hwc2TestComposition(Hwc2TestCoverage coverage); |
| 110 | |
| 111 | std::string dump() const override; |
| 112 | |
| 113 | protected: |
| 114 | static const std::vector<hwc2_composition_t> mDefaultCompositions; |
| 115 | static const std::vector<hwc2_composition_t> mBasicCompositions; |
| 116 | static const std::vector<hwc2_composition_t> mCompleteCompositions; |
| 117 | }; |
| 118 | |
Marissa Wall | b72b5c9 | 2016-12-15 12:26:39 -0800 | [diff] [blame] | 119 | |
| 120 | class Hwc2TestDataspace : public Hwc2TestProperty<android_dataspace_t> { |
| 121 | public: |
| 122 | Hwc2TestDataspace(Hwc2TestCoverage coverage); |
| 123 | |
| 124 | std::string dump() const override; |
| 125 | |
| 126 | protected: |
| 127 | static const std::vector<android_dataspace_t> defaultDataspaces; |
| 128 | static const std::vector<android_dataspace_t> basicDataspaces; |
| 129 | static const std::vector<android_dataspace_t> completeDataspaces; |
| 130 | }; |
| 131 | |
Marissa Wall | 2b1f530 | 2016-12-15 12:27:20 -0800 | [diff] [blame] | 132 | |
Marissa Wall | 600a73b | 2016-12-15 12:30:39 -0800 | [diff] [blame^] | 133 | class Hwc2TestDisplayFrame : public Hwc2TestProperty<hwc_rect_t> { |
| 134 | public: |
| 135 | Hwc2TestDisplayFrame(Hwc2TestCoverage coverage, const Area& displayArea); |
| 136 | |
| 137 | std::string dump() const override; |
| 138 | |
| 139 | protected: |
| 140 | void update(); |
| 141 | |
| 142 | const std::vector<hwc_frect_t>& mFrectScalars; |
| 143 | const static std::vector<hwc_frect_t> mDefaultFrectScalars; |
| 144 | const static std::vector<hwc_frect_t> mBasicFrectScalars; |
| 145 | const static std::vector<hwc_frect_t> mCompleteFrectScalars; |
| 146 | |
| 147 | Area mDisplayArea; |
| 148 | |
| 149 | std::vector<hwc_rect_t> mDisplayFrames; |
| 150 | }; |
| 151 | |
| 152 | |
Marissa Wall | 2b1f530 | 2016-12-15 12:27:20 -0800 | [diff] [blame] | 153 | class Hwc2TestPlaneAlpha : public Hwc2TestProperty<float> { |
| 154 | public: |
| 155 | Hwc2TestPlaneAlpha(Hwc2TestCoverage coverage); |
| 156 | |
| 157 | std::string dump() const override; |
| 158 | |
| 159 | protected: |
| 160 | static const std::vector<float> mDefaultPlaneAlphas; |
| 161 | static const std::vector<float> mBasicPlaneAlphas; |
| 162 | static const std::vector<float> mCompletePlaneAlphas; |
| 163 | }; |
| 164 | |
Marissa Wall | ac10819 | 2016-12-15 12:27:48 -0800 | [diff] [blame] | 165 | |
| 166 | class Hwc2TestTransform : public Hwc2TestProperty<hwc_transform_t> { |
| 167 | public: |
| 168 | Hwc2TestTransform(Hwc2TestCoverage coverage); |
| 169 | |
| 170 | std::string dump() const override; |
| 171 | |
| 172 | protected: |
| 173 | static const std::vector<hwc_transform_t> mDefaultTransforms; |
| 174 | static const std::vector<hwc_transform_t> mBasicTransforms; |
| 175 | static const std::vector<hwc_transform_t> mCompleteTransforms; |
| 176 | }; |
| 177 | |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 178 | #endif /* ifndef _HWC2_TEST_PROPERTIES_H */ |