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 | #include <sstream> |
| 18 | |
| 19 | #include "Hwc2TestProperties.h" |
| 20 | |
Marissa Wall | c57468f | 2016-12-15 12:31:12 -0800 | [diff] [blame^] | 21 | Hwc2TestBufferArea::Hwc2TestBufferArea(Hwc2TestCoverage coverage, |
| 22 | const Area& displayArea) |
| 23 | : Hwc2TestProperty(mBufferAreas), |
| 24 | mScalars((coverage == Hwc2TestCoverage::Complete)? mCompleteScalars: |
| 25 | (coverage == Hwc2TestCoverage::Basic)? mBasicScalars: |
| 26 | mDefaultScalars), |
| 27 | mDisplayArea(displayArea) |
| 28 | { |
| 29 | update(); |
| 30 | } |
| 31 | |
| 32 | std::string Hwc2TestBufferArea::dump() const |
| 33 | { |
| 34 | std::stringstream dmp; |
| 35 | const Area& curr = get(); |
| 36 | dmp << "\tbuffer area: width " << curr.width << ", height " << curr.height |
| 37 | << "\n"; |
| 38 | return dmp.str(); |
| 39 | } |
| 40 | |
| 41 | void Hwc2TestBufferArea::setDependent(Hwc2TestSourceCrop* sourceCrop) |
| 42 | { |
| 43 | mSourceCrop = sourceCrop; |
| 44 | updateDependents(); |
| 45 | } |
| 46 | |
| 47 | void Hwc2TestBufferArea::update() |
| 48 | { |
| 49 | mBufferAreas.clear(); |
| 50 | |
| 51 | if (mDisplayArea.width == 0 && mDisplayArea.height == 0) { |
| 52 | mBufferAreas.push_back({0, 0}); |
| 53 | return; |
| 54 | } |
| 55 | |
| 56 | for (auto scalar : mScalars) { |
| 57 | mBufferAreas.push_back({static_cast<int32_t>(scalar * mDisplayArea.width), |
| 58 | static_cast<int32_t>(scalar * mDisplayArea.height)}); |
| 59 | } |
| 60 | |
| 61 | updateDependents(); |
| 62 | } |
| 63 | |
| 64 | void Hwc2TestBufferArea::updateDependents() |
| 65 | { |
| 66 | const Area& curr = get(); |
| 67 | |
| 68 | if (mSourceCrop) |
| 69 | mSourceCrop->updateBufferArea(curr); |
| 70 | } |
| 71 | |
| 72 | const std::vector<float> Hwc2TestBufferArea::mDefaultScalars = { |
| 73 | 1.0f, |
| 74 | }; |
| 75 | |
| 76 | const std::vector<float> Hwc2TestBufferArea::mBasicScalars = { |
| 77 | 1.0f, 0.5f, |
| 78 | }; |
| 79 | |
| 80 | const std::vector<float> Hwc2TestBufferArea::mCompleteScalars = { |
| 81 | 1.0f, 0.75f, 0.5f |
| 82 | }; |
| 83 | |
| 84 | |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 85 | Hwc2TestBlendMode::Hwc2TestBlendMode(Hwc2TestCoverage coverage) |
| 86 | : Hwc2TestProperty(coverage, mCompleteBlendModes, mBasicBlendModes, |
| 87 | mDefaultBlendModes) { } |
| 88 | |
| 89 | std::string Hwc2TestBlendMode::dump() const |
| 90 | { |
| 91 | std::stringstream dmp; |
| 92 | dmp << "\tblend mode: " << getBlendModeName(get()) << "\n"; |
| 93 | return dmp.str(); |
| 94 | } |
| 95 | |
| 96 | const std::vector<hwc2_blend_mode_t> Hwc2TestBlendMode::mDefaultBlendModes = { |
| 97 | HWC2_BLEND_MODE_NONE, |
| 98 | }; |
| 99 | |
| 100 | const std::vector<hwc2_blend_mode_t> Hwc2TestBlendMode::mBasicBlendModes = { |
| 101 | HWC2_BLEND_MODE_NONE, |
| 102 | HWC2_BLEND_MODE_PREMULTIPLIED, |
| 103 | }; |
| 104 | |
| 105 | const std::vector<hwc2_blend_mode_t> Hwc2TestBlendMode::mCompleteBlendModes = { |
| 106 | HWC2_BLEND_MODE_NONE, |
| 107 | HWC2_BLEND_MODE_PREMULTIPLIED, |
| 108 | HWC2_BLEND_MODE_COVERAGE, |
| 109 | }; |
| 110 | |
| 111 | |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 112 | Hwc2TestComposition::Hwc2TestComposition(Hwc2TestCoverage coverage) |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 113 | : Hwc2TestProperty(coverage, mCompleteCompositions, mBasicCompositions, |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 114 | mDefaultCompositions) { } |
| 115 | |
| 116 | std::string Hwc2TestComposition::dump() const |
| 117 | { |
| 118 | std::stringstream dmp; |
| 119 | dmp << "\tcomposition: " << getCompositionName(get()) << "\n"; |
| 120 | return dmp.str(); |
| 121 | } |
| 122 | |
| 123 | const std::vector<hwc2_composition_t> Hwc2TestComposition::mDefaultCompositions = { |
| 124 | HWC2_COMPOSITION_DEVICE, |
| 125 | }; |
| 126 | |
| 127 | const std::vector<hwc2_composition_t> Hwc2TestComposition::mBasicCompositions = { |
| 128 | HWC2_COMPOSITION_CLIENT, |
| 129 | HWC2_COMPOSITION_DEVICE, |
| 130 | }; |
| 131 | |
| 132 | const std::vector<hwc2_composition_t> Hwc2TestComposition::mCompleteCompositions = { |
| 133 | HWC2_COMPOSITION_CLIENT, |
| 134 | HWC2_COMPOSITION_DEVICE, |
| 135 | HWC2_COMPOSITION_SOLID_COLOR, |
| 136 | HWC2_COMPOSITION_CURSOR, |
| 137 | HWC2_COMPOSITION_SIDEBAND, |
| 138 | }; |
Marissa Wall | b72b5c9 | 2016-12-15 12:26:39 -0800 | [diff] [blame] | 139 | |
| 140 | |
| 141 | Hwc2TestDataspace::Hwc2TestDataspace(Hwc2TestCoverage coverage) |
| 142 | : Hwc2TestProperty(coverage, completeDataspaces, basicDataspaces, |
| 143 | defaultDataspaces) { } |
| 144 | |
| 145 | std::string Hwc2TestDataspace::dump() const |
| 146 | { |
| 147 | std::stringstream dmp; |
| 148 | dmp << "\tdataspace: " << get() << "\n"; |
| 149 | return dmp.str(); |
| 150 | } |
| 151 | |
| 152 | const std::vector<android_dataspace_t> Hwc2TestDataspace::defaultDataspaces = { |
| 153 | HAL_DATASPACE_UNKNOWN, |
| 154 | }; |
| 155 | |
| 156 | const std::vector<android_dataspace_t> Hwc2TestDataspace::basicDataspaces = { |
| 157 | HAL_DATASPACE_UNKNOWN, |
| 158 | HAL_DATASPACE_V0_SRGB, |
| 159 | }; |
| 160 | |
| 161 | const std::vector<android_dataspace_t> Hwc2TestDataspace::completeDataspaces = { |
| 162 | HAL_DATASPACE_UNKNOWN, |
| 163 | HAL_DATASPACE_ARBITRARY, |
| 164 | HAL_DATASPACE_STANDARD_SHIFT, |
| 165 | HAL_DATASPACE_STANDARD_MASK, |
| 166 | HAL_DATASPACE_STANDARD_UNSPECIFIED, |
| 167 | HAL_DATASPACE_STANDARD_BT709, |
| 168 | HAL_DATASPACE_STANDARD_BT601_625, |
| 169 | HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED, |
| 170 | HAL_DATASPACE_STANDARD_BT601_525, |
| 171 | HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED, |
| 172 | HAL_DATASPACE_STANDARD_BT2020, |
| 173 | HAL_DATASPACE_STANDARD_BT2020_CONSTANT_LUMINANCE, |
| 174 | HAL_DATASPACE_STANDARD_BT470M, |
| 175 | HAL_DATASPACE_STANDARD_FILM, |
| 176 | HAL_DATASPACE_TRANSFER_SHIFT, |
| 177 | HAL_DATASPACE_TRANSFER_MASK, |
| 178 | HAL_DATASPACE_TRANSFER_UNSPECIFIED, |
| 179 | HAL_DATASPACE_TRANSFER_LINEAR, |
| 180 | HAL_DATASPACE_TRANSFER_SRGB, |
| 181 | HAL_DATASPACE_TRANSFER_SMPTE_170M, |
| 182 | HAL_DATASPACE_TRANSFER_GAMMA2_2, |
| 183 | HAL_DATASPACE_TRANSFER_GAMMA2_8, |
| 184 | HAL_DATASPACE_TRANSFER_ST2084, |
| 185 | HAL_DATASPACE_TRANSFER_HLG, |
| 186 | HAL_DATASPACE_RANGE_SHIFT, |
| 187 | HAL_DATASPACE_RANGE_MASK, |
| 188 | HAL_DATASPACE_RANGE_UNSPECIFIED, |
| 189 | HAL_DATASPACE_RANGE_FULL, |
| 190 | HAL_DATASPACE_RANGE_LIMITED, |
| 191 | HAL_DATASPACE_SRGB_LINEAR, |
| 192 | HAL_DATASPACE_V0_SRGB_LINEAR, |
| 193 | HAL_DATASPACE_SRGB, |
| 194 | HAL_DATASPACE_V0_SRGB, |
| 195 | HAL_DATASPACE_JFIF, |
| 196 | HAL_DATASPACE_V0_JFIF, |
| 197 | HAL_DATASPACE_BT601_625, |
| 198 | HAL_DATASPACE_V0_BT601_625, |
| 199 | HAL_DATASPACE_BT601_525, |
| 200 | HAL_DATASPACE_V0_BT601_525, |
| 201 | HAL_DATASPACE_BT709, |
| 202 | HAL_DATASPACE_V0_BT709, |
| 203 | HAL_DATASPACE_DEPTH, |
| 204 | }; |
Marissa Wall | 2b1f530 | 2016-12-15 12:27:20 -0800 | [diff] [blame] | 205 | |
| 206 | |
Marissa Wall | 600a73b | 2016-12-15 12:30:39 -0800 | [diff] [blame] | 207 | Hwc2TestDisplayFrame::Hwc2TestDisplayFrame(Hwc2TestCoverage coverage, |
| 208 | const Area& displayArea) |
| 209 | : Hwc2TestProperty(mDisplayFrames), |
| 210 | mFrectScalars((coverage == Hwc2TestCoverage::Complete)? mCompleteFrectScalars: |
| 211 | (coverage == Hwc2TestCoverage::Basic)? mBasicFrectScalars: |
| 212 | mDefaultFrectScalars), |
| 213 | mDisplayArea(displayArea) |
| 214 | { |
| 215 | update(); |
| 216 | } |
| 217 | |
| 218 | std::string Hwc2TestDisplayFrame::dump() const |
| 219 | { |
| 220 | std::stringstream dmp; |
| 221 | const hwc_rect_t& displayFrame = get(); |
| 222 | dmp << "\tdisplay frame: left " << displayFrame.left << ", top " |
| 223 | << displayFrame.top << ", right " << displayFrame.right |
| 224 | << ", bottom " << displayFrame.bottom << "\n"; |
| 225 | return dmp.str(); |
| 226 | } |
| 227 | |
| 228 | void Hwc2TestDisplayFrame::update() |
| 229 | { |
| 230 | mDisplayFrames.clear(); |
| 231 | |
| 232 | if (mDisplayArea.width == 0 && mDisplayArea.height == 0) { |
| 233 | mDisplayFrames.push_back({0, 0, 0, 0}); |
| 234 | return; |
| 235 | } |
| 236 | |
| 237 | for (const auto& frectScalar : mFrectScalars) { |
| 238 | mDisplayFrames.push_back({ |
| 239 | static_cast<int>(frectScalar.left * mDisplayArea.width), |
| 240 | static_cast<int>(frectScalar.top * mDisplayArea.height), |
| 241 | static_cast<int>(frectScalar.right * mDisplayArea.width), |
| 242 | static_cast<int>(frectScalar.bottom * mDisplayArea.height)}); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | const std::vector<hwc_frect_t> Hwc2TestDisplayFrame::mDefaultFrectScalars = { |
| 247 | {0.0, 0.0, 1.0, 1.0}, |
| 248 | }; |
| 249 | |
| 250 | const std::vector<hwc_frect_t> Hwc2TestDisplayFrame::mBasicFrectScalars = { |
| 251 | {0.0, 0.0, 1.0, 1.0}, |
| 252 | {0.0, 0.0, 1.0, 0.05}, |
| 253 | {0.0, 0.95, 1.0, 1.0}, |
| 254 | }; |
| 255 | |
| 256 | const std::vector<hwc_frect_t> Hwc2TestDisplayFrame::mCompleteFrectScalars = { |
| 257 | {0.0, 0.0, 1.0, 1.0}, |
| 258 | {0.0, 0.05, 1.0, 0.95}, |
| 259 | {0.0, 0.05, 1.0, 1.0}, |
| 260 | {0.0, 0.0, 1.0, 0.05}, |
| 261 | {0.0, 0.95, 1.0, 1.0}, |
| 262 | {0.25, 0.0, 0.75, 0.35}, |
| 263 | {0.25, 0.25, 0.75, 0.75}, |
| 264 | }; |
| 265 | |
| 266 | |
Marissa Wall | 2b1f530 | 2016-12-15 12:27:20 -0800 | [diff] [blame] | 267 | Hwc2TestPlaneAlpha::Hwc2TestPlaneAlpha(Hwc2TestCoverage coverage) |
| 268 | : Hwc2TestProperty(coverage, mCompletePlaneAlphas, mBasicPlaneAlphas, |
| 269 | mDefaultPlaneAlphas) { } |
| 270 | |
| 271 | std::string Hwc2TestPlaneAlpha::dump() const |
| 272 | { |
| 273 | std::stringstream dmp; |
| 274 | dmp << "\tplane alpha: " << get() << "\n"; |
| 275 | return dmp.str(); |
| 276 | } |
| 277 | |
| 278 | const std::vector<float> Hwc2TestPlaneAlpha::mDefaultPlaneAlphas = { |
| 279 | 1.0f, |
| 280 | }; |
| 281 | |
| 282 | const std::vector<float> Hwc2TestPlaneAlpha::mBasicPlaneAlphas = { |
| 283 | 1.0f, 0.0f, |
| 284 | }; |
| 285 | |
| 286 | const std::vector<float> Hwc2TestPlaneAlpha::mCompletePlaneAlphas = { |
| 287 | 1.0f, 0.75f, 0.5f, 0.25f, 0.0f, |
| 288 | }; |
Marissa Wall | ac10819 | 2016-12-15 12:27:48 -0800 | [diff] [blame] | 289 | |
| 290 | |
Marissa Wall | c57468f | 2016-12-15 12:31:12 -0800 | [diff] [blame^] | 291 | Hwc2TestSourceCrop::Hwc2TestSourceCrop(Hwc2TestCoverage coverage, |
| 292 | const Area& bufferArea) |
| 293 | : Hwc2TestProperty(mSourceCrops), |
| 294 | mFrectScalars((coverage == Hwc2TestCoverage::Complete)? mCompleteFrectScalars: |
| 295 | (coverage == Hwc2TestCoverage::Basic)? mBasicFrectScalars: |
| 296 | mDefaultFrectScalars), |
| 297 | mBufferArea(bufferArea) |
| 298 | { |
| 299 | update(); |
| 300 | } |
| 301 | |
| 302 | std::string Hwc2TestSourceCrop::dump() const |
| 303 | { |
| 304 | std::stringstream dmp; |
| 305 | const hwc_frect_t& sourceCrop = get(); |
| 306 | dmp << "\tsource crop: left " << sourceCrop.left << ", top " |
| 307 | << sourceCrop.top << ", right " << sourceCrop.right << ", bottom " |
| 308 | << sourceCrop.bottom << "\n"; |
| 309 | return dmp.str(); |
| 310 | } |
| 311 | |
| 312 | void Hwc2TestSourceCrop::updateBufferArea(const Area& bufferArea) |
| 313 | { |
| 314 | mBufferArea = bufferArea; |
| 315 | update(); |
| 316 | } |
| 317 | |
| 318 | void Hwc2TestSourceCrop::update() |
| 319 | { |
| 320 | mSourceCrops.clear(); |
| 321 | |
| 322 | if (mBufferArea.width == 0 && mBufferArea.height == 0) { |
| 323 | mSourceCrops.push_back({0, 0, 0, 0}); |
| 324 | return; |
| 325 | } |
| 326 | |
| 327 | for (const auto& frectScalar : mFrectScalars) { |
| 328 | mSourceCrops.push_back({ |
| 329 | frectScalar.left * mBufferArea.width, |
| 330 | frectScalar.top * mBufferArea.height, |
| 331 | frectScalar.right * mBufferArea.width, |
| 332 | frectScalar.bottom * mBufferArea.height}); |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | const std::vector<hwc_frect_t> Hwc2TestSourceCrop::mDefaultFrectScalars = { |
| 337 | {0.0, 0.0, 1.0, 1.0}, |
| 338 | }; |
| 339 | |
| 340 | const std::vector<hwc_frect_t> Hwc2TestSourceCrop::mBasicFrectScalars = { |
| 341 | {0.0, 0.0, 1.0, 1.0}, |
| 342 | {0.0, 0.0, 0.5, 0.5}, |
| 343 | {0.5, 0.5, 1.0, 1.0}, |
| 344 | }; |
| 345 | |
| 346 | const std::vector<hwc_frect_t> Hwc2TestSourceCrop::mCompleteFrectScalars = { |
| 347 | {0.0, 0.0, 1.0, 1.0}, |
| 348 | {0.0, 0.0, 0.5, 0.5}, |
| 349 | {0.5, 0.5, 1.0, 1.0}, |
| 350 | {0.0, 0.0, 0.25, 0.25}, |
| 351 | {0.25, 0.25, 0.75, 0.75}, |
| 352 | }; |
| 353 | |
| 354 | |
Marissa Wall | ac10819 | 2016-12-15 12:27:48 -0800 | [diff] [blame] | 355 | Hwc2TestTransform::Hwc2TestTransform(Hwc2TestCoverage coverage) |
| 356 | : Hwc2TestProperty(coverage, mCompleteTransforms, mBasicTransforms, |
| 357 | mDefaultTransforms) { } |
| 358 | |
| 359 | std::string Hwc2TestTransform::dump() const |
| 360 | { |
| 361 | std::stringstream dmp; |
| 362 | dmp << "\ttransform: " << getTransformName(get()) << "\n"; |
| 363 | return dmp.str(); |
| 364 | } |
| 365 | |
| 366 | const std::vector<hwc_transform_t> Hwc2TestTransform::mDefaultTransforms = { |
| 367 | static_cast<hwc_transform_t>(0), |
| 368 | }; |
| 369 | |
| 370 | const std::vector<hwc_transform_t> Hwc2TestTransform::mBasicTransforms = { |
| 371 | static_cast<hwc_transform_t>(0), |
| 372 | HWC_TRANSFORM_FLIP_H, |
| 373 | HWC_TRANSFORM_FLIP_V, |
| 374 | HWC_TRANSFORM_ROT_90, |
| 375 | }; |
| 376 | |
| 377 | const std::vector<hwc_transform_t> Hwc2TestTransform::mCompleteTransforms = { |
| 378 | static_cast<hwc_transform_t>(0), |
| 379 | HWC_TRANSFORM_FLIP_H, |
| 380 | HWC_TRANSFORM_FLIP_V, |
| 381 | HWC_TRANSFORM_ROT_90, |
| 382 | HWC_TRANSFORM_ROT_180, |
| 383 | HWC_TRANSFORM_ROT_270, |
| 384 | HWC_TRANSFORM_FLIP_H_ROT_90, |
| 385 | HWC_TRANSFORM_FLIP_V_ROT_90, |
| 386 | }; |