blob: f54c8c814ee85e43127bdb0e1064a9205350ab8b [file] [log] [blame]
Marissa Wall6bd8bfd2016-12-15 12:25:31 -08001/*
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 Wallffc67da2016-12-15 12:26:09 -080020#include <array>
Marissa Wall6bd8bfd2016-12-15 12:25:31 -080021#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
29enum class Hwc2TestCoverage {
30 Default = 0,
31 Basic,
32 Complete,
33};
34
35
Marissa Wallffc67da2016-12-15 12:26:09 -080036class Hwc2TestContainer {
Marissa Wall6bd8bfd2016-12-15 12:25:31 -080037public:
Marissa Wallffc67da2016-12-15 12:26:09 -080038 virtual ~Hwc2TestContainer() = default;
39
40 /* Resets the container */
41 virtual void reset() = 0;
42
43 /* Attempts to advance to the next valid value. Returns true if one can be
44 * found */
45 virtual bool advance() = 0;
46
47 virtual std::string dump() const = 0;
48};
49
50
51template <class T>
52class Hwc2TestProperty : public Hwc2TestContainer {
53public:
54 Hwc2TestProperty(Hwc2TestCoverage coverage,
55 const std::vector<T>& completeList, const std::vector<T>& basicList,
56 const std::vector<T>& defaultList)
57 : Hwc2TestProperty((coverage == Hwc2TestCoverage::Complete)? completeList:
58 (coverage == Hwc2TestCoverage::Basic)? basicList : defaultList) { }
59
Marissa Wall6bd8bfd2016-12-15 12:25:31 -080060 Hwc2TestProperty(const std::vector<T>& list)
61 : mList(list) { }
62
Marissa Wallffc67da2016-12-15 12:26:09 -080063 void reset() override
Marissa Wall6bd8bfd2016-12-15 12:25:31 -080064 {
65 mListIdx = 0;
66 }
67
Marissa Wallffc67da2016-12-15 12:26:09 -080068 bool advance() override
Marissa Wall6bd8bfd2016-12-15 12:25:31 -080069 {
70 if (mListIdx + 1 < mList.size()) {
71 mListIdx++;
72 return true;
73 }
74 reset();
75 return false;
76 }
77
Marissa Wallffc67da2016-12-15 12:26:09 -080078 T get() const
Marissa Wall6bd8bfd2016-12-15 12:25:31 -080079 {
80 return mList.at(mListIdx);
81 }
82
Marissa Wall6bd8bfd2016-12-15 12:25:31 -080083protected:
84 const std::vector<T>& mList;
85 size_t mListIdx = 0;
86};
87
88
Marissa Wallffc67da2016-12-15 12:26:09 -080089class Hwc2TestBlendMode : public Hwc2TestProperty<hwc2_blend_mode_t> {
90public:
91 Hwc2TestBlendMode(Hwc2TestCoverage coverage);
92
93 std::string dump() const override;
94
95protected:
96 static const std::vector<hwc2_blend_mode_t> mDefaultBlendModes;
97 static const std::vector<hwc2_blend_mode_t> mBasicBlendModes;
98 static const std::vector<hwc2_blend_mode_t> mCompleteBlendModes;
99};
100
101
Marissa Wall6bd8bfd2016-12-15 12:25:31 -0800102class Hwc2TestComposition : public Hwc2TestProperty<hwc2_composition_t> {
103public:
104 Hwc2TestComposition(Hwc2TestCoverage coverage);
105
106 std::string dump() const override;
107
108protected:
109 static const std::vector<hwc2_composition_t> mDefaultCompositions;
110 static const std::vector<hwc2_composition_t> mBasicCompositions;
111 static const std::vector<hwc2_composition_t> mCompleteCompositions;
112};
113
Marissa Wallb72b5c92016-12-15 12:26:39 -0800114
115class Hwc2TestDataspace : public Hwc2TestProperty<android_dataspace_t> {
116public:
117 Hwc2TestDataspace(Hwc2TestCoverage coverage);
118
119 std::string dump() const override;
120
121protected:
122 static const std::vector<android_dataspace_t> defaultDataspaces;
123 static const std::vector<android_dataspace_t> basicDataspaces;
124 static const std::vector<android_dataspace_t> completeDataspaces;
125};
126
Marissa Wall2b1f5302016-12-15 12:27:20 -0800127
128class Hwc2TestPlaneAlpha : public Hwc2TestProperty<float> {
129public:
130 Hwc2TestPlaneAlpha(Hwc2TestCoverage coverage);
131
132 std::string dump() const override;
133
134protected:
135 static const std::vector<float> mDefaultPlaneAlphas;
136 static const std::vector<float> mBasicPlaneAlphas;
137 static const std::vector<float> mCompletePlaneAlphas;
138};
139
Marissa Wall6bd8bfd2016-12-15 12:25:31 -0800140#endif /* ifndef _HWC2_TEST_PROPERTIES_H */