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> |
Marissa Wall | ad76181 | 2016-12-15 12:32:24 -0800 | [diff] [blame^] | 18 | #include <cutils/log.h> |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 19 | |
| 20 | #include "Hwc2TestProperties.h" |
| 21 | |
Marissa Wall | c57468f | 2016-12-15 12:31:12 -0800 | [diff] [blame] | 22 | Hwc2TestBufferArea::Hwc2TestBufferArea(Hwc2TestCoverage coverage, |
| 23 | const Area& displayArea) |
| 24 | : Hwc2TestProperty(mBufferAreas), |
| 25 | mScalars((coverage == Hwc2TestCoverage::Complete)? mCompleteScalars: |
| 26 | (coverage == Hwc2TestCoverage::Basic)? mBasicScalars: |
| 27 | mDefaultScalars), |
| 28 | mDisplayArea(displayArea) |
| 29 | { |
| 30 | update(); |
| 31 | } |
| 32 | |
| 33 | std::string Hwc2TestBufferArea::dump() const |
| 34 | { |
| 35 | std::stringstream dmp; |
| 36 | const Area& curr = get(); |
| 37 | dmp << "\tbuffer area: width " << curr.width << ", height " << curr.height |
| 38 | << "\n"; |
| 39 | return dmp.str(); |
| 40 | } |
| 41 | |
| 42 | void Hwc2TestBufferArea::setDependent(Hwc2TestSourceCrop* sourceCrop) |
| 43 | { |
| 44 | mSourceCrop = sourceCrop; |
Marissa Wall | ad76181 | 2016-12-15 12:32:24 -0800 | [diff] [blame^] | 45 | if (mSourceCrop) { |
| 46 | mSourceCrop->updateBufferArea(get()); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | void Hwc2TestBufferArea::setDependent(Hwc2TestSurfaceDamage* surfaceDamage) |
| 51 | { |
| 52 | mSurfaceDamage = surfaceDamage; |
| 53 | if (mSurfaceDamage) { |
| 54 | mSurfaceDamage->updateBufferArea(get()); |
| 55 | } |
Marissa Wall | c57468f | 2016-12-15 12:31:12 -0800 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void Hwc2TestBufferArea::update() |
| 59 | { |
| 60 | mBufferAreas.clear(); |
| 61 | |
| 62 | if (mDisplayArea.width == 0 && mDisplayArea.height == 0) { |
| 63 | mBufferAreas.push_back({0, 0}); |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | for (auto scalar : mScalars) { |
| 68 | mBufferAreas.push_back({static_cast<int32_t>(scalar * mDisplayArea.width), |
| 69 | static_cast<int32_t>(scalar * mDisplayArea.height)}); |
| 70 | } |
| 71 | |
| 72 | updateDependents(); |
| 73 | } |
| 74 | |
| 75 | void Hwc2TestBufferArea::updateDependents() |
| 76 | { |
| 77 | const Area& curr = get(); |
| 78 | |
| 79 | if (mSourceCrop) |
| 80 | mSourceCrop->updateBufferArea(curr); |
Marissa Wall | ad76181 | 2016-12-15 12:32:24 -0800 | [diff] [blame^] | 81 | if (mSurfaceDamage) |
| 82 | mSurfaceDamage->updateBufferArea(curr); |
Marissa Wall | c57468f | 2016-12-15 12:31:12 -0800 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | const std::vector<float> Hwc2TestBufferArea::mDefaultScalars = { |
| 86 | 1.0f, |
| 87 | }; |
| 88 | |
| 89 | const std::vector<float> Hwc2TestBufferArea::mBasicScalars = { |
| 90 | 1.0f, 0.5f, |
| 91 | }; |
| 92 | |
| 93 | const std::vector<float> Hwc2TestBufferArea::mCompleteScalars = { |
| 94 | 1.0f, 0.75f, 0.5f |
| 95 | }; |
| 96 | |
| 97 | |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 98 | Hwc2TestBlendMode::Hwc2TestBlendMode(Hwc2TestCoverage coverage) |
| 99 | : Hwc2TestProperty(coverage, mCompleteBlendModes, mBasicBlendModes, |
| 100 | mDefaultBlendModes) { } |
| 101 | |
| 102 | std::string Hwc2TestBlendMode::dump() const |
| 103 | { |
| 104 | std::stringstream dmp; |
| 105 | dmp << "\tblend mode: " << getBlendModeName(get()) << "\n"; |
| 106 | return dmp.str(); |
| 107 | } |
| 108 | |
Marissa Wall | ee24278 | 2016-12-15 12:30:12 -0800 | [diff] [blame] | 109 | void Hwc2TestBlendMode::setDependent(Hwc2TestColor* color) |
| 110 | { |
| 111 | mColor = color; |
| 112 | updateDependents(); |
| 113 | } |
| 114 | |
| 115 | void Hwc2TestBlendMode::updateDependents() |
| 116 | { |
| 117 | if (mColor) |
| 118 | mColor->updateBlendMode(get()); |
| 119 | } |
| 120 | |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 121 | const std::vector<hwc2_blend_mode_t> Hwc2TestBlendMode::mDefaultBlendModes = { |
| 122 | HWC2_BLEND_MODE_NONE, |
| 123 | }; |
| 124 | |
| 125 | const std::vector<hwc2_blend_mode_t> Hwc2TestBlendMode::mBasicBlendModes = { |
| 126 | HWC2_BLEND_MODE_NONE, |
| 127 | HWC2_BLEND_MODE_PREMULTIPLIED, |
| 128 | }; |
| 129 | |
| 130 | const std::vector<hwc2_blend_mode_t> Hwc2TestBlendMode::mCompleteBlendModes = { |
| 131 | HWC2_BLEND_MODE_NONE, |
| 132 | HWC2_BLEND_MODE_PREMULTIPLIED, |
| 133 | HWC2_BLEND_MODE_COVERAGE, |
| 134 | }; |
| 135 | |
| 136 | |
Marissa Wall | ee24278 | 2016-12-15 12:30:12 -0800 | [diff] [blame] | 137 | Hwc2TestColor::Hwc2TestColor(Hwc2TestCoverage coverage, |
| 138 | hwc2_blend_mode_t blendMode) |
| 139 | : Hwc2TestProperty(mColors), |
| 140 | mBaseColors((coverage == Hwc2TestCoverage::Complete)? mCompleteBaseColors: |
| 141 | (coverage == Hwc2TestCoverage::Basic)? mBasicBaseColors: |
| 142 | mDefaultBaseColors), |
| 143 | mBlendMode(blendMode) |
| 144 | { |
| 145 | update(); |
| 146 | } |
| 147 | |
| 148 | std::string Hwc2TestColor::dump() const |
| 149 | { |
| 150 | std::stringstream dmp; |
| 151 | const hwc_color_t& color = get(); |
| 152 | dmp << "\tcolor: r " << std::to_string(color.r) << ", g " |
| 153 | << std::to_string(color.g) << ", b " << std::to_string(color.b) |
| 154 | << ", a " << std::to_string(color.a) << "\n"; |
| 155 | return dmp.str(); |
| 156 | } |
| 157 | |
| 158 | void Hwc2TestColor::updateBlendMode(hwc2_blend_mode_t blendMode) |
| 159 | { |
| 160 | mBlendMode = blendMode; |
| 161 | update(); |
| 162 | } |
| 163 | |
| 164 | void Hwc2TestColor::update() |
| 165 | { |
| 166 | if (mBlendMode != HWC2_BLEND_MODE_PREMULTIPLIED) { |
| 167 | mColors = mBaseColors; |
| 168 | return; |
| 169 | } |
| 170 | |
| 171 | mColors.clear(); |
| 172 | |
| 173 | for (const hwc_color_t& baseColor : mBaseColors) { |
| 174 | if (baseColor.a >= baseColor.r && baseColor.a >= baseColor.g |
| 175 | && baseColor.a >= baseColor.b) { |
| 176 | mColors.push_back(baseColor); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | } |
| 181 | |
| 182 | const std::vector<hwc_color_t> Hwc2TestColor::mDefaultBaseColors = { |
| 183 | {UINT8_MAX, UINT8_MAX, UINT8_MAX, UINT8_MAX}, |
| 184 | }; |
| 185 | |
| 186 | const std::vector<hwc_color_t> Hwc2TestColor::mBasicBaseColors = { |
| 187 | {UINT8_MAX, UINT8_MAX, UINT8_MAX, UINT8_MAX}, |
| 188 | { 0, 0, 0, 0}, |
| 189 | }; |
| 190 | |
| 191 | const std::vector<hwc_color_t> Hwc2TestColor::mCompleteBaseColors = { |
| 192 | {UINT8_MAX, UINT8_MAX, UINT8_MAX, UINT8_MAX}, |
| 193 | {UINT8_MAX, UINT8_MAX, UINT8_MAX, 0}, |
| 194 | {UINT8_MAX, UINT8_MAX, 0, UINT8_MAX}, |
| 195 | {UINT8_MAX, UINT8_MAX, 0, 0}, |
| 196 | {UINT8_MAX, 0, UINT8_MAX, UINT8_MAX}, |
| 197 | {UINT8_MAX, 0, UINT8_MAX, 0}, |
| 198 | {UINT8_MAX, 0, 0, UINT8_MAX}, |
| 199 | {UINT8_MAX, 0, 0, 0}, |
| 200 | { 0, UINT8_MAX, UINT8_MAX, UINT8_MAX}, |
| 201 | { 0, UINT8_MAX, UINT8_MAX, 0}, |
| 202 | { 0, UINT8_MAX, 0, UINT8_MAX}, |
| 203 | { 0, UINT8_MAX, 0, 0}, |
| 204 | { 0, 0, UINT8_MAX, UINT8_MAX}, |
| 205 | { 0, 0, UINT8_MAX, 0}, |
| 206 | { 0, 0, 0, UINT8_MAX}, |
| 207 | { 0, 0, 0, 0}, |
| 208 | }; |
| 209 | |
| 210 | |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 211 | Hwc2TestComposition::Hwc2TestComposition(Hwc2TestCoverage coverage) |
Marissa Wall | ffc67da | 2016-12-15 12:26:09 -0800 | [diff] [blame] | 212 | : Hwc2TestProperty(coverage, mCompleteCompositions, mBasicCompositions, |
Marissa Wall | 6bd8bfd | 2016-12-15 12:25:31 -0800 | [diff] [blame] | 213 | mDefaultCompositions) { } |
| 214 | |
| 215 | std::string Hwc2TestComposition::dump() const |
| 216 | { |
| 217 | std::stringstream dmp; |
| 218 | dmp << "\tcomposition: " << getCompositionName(get()) << "\n"; |
| 219 | return dmp.str(); |
| 220 | } |
| 221 | |
| 222 | const std::vector<hwc2_composition_t> Hwc2TestComposition::mDefaultCompositions = { |
| 223 | HWC2_COMPOSITION_DEVICE, |
| 224 | }; |
| 225 | |
| 226 | const std::vector<hwc2_composition_t> Hwc2TestComposition::mBasicCompositions = { |
| 227 | HWC2_COMPOSITION_CLIENT, |
| 228 | HWC2_COMPOSITION_DEVICE, |
| 229 | }; |
| 230 | |
| 231 | const std::vector<hwc2_composition_t> Hwc2TestComposition::mCompleteCompositions = { |
| 232 | HWC2_COMPOSITION_CLIENT, |
| 233 | HWC2_COMPOSITION_DEVICE, |
| 234 | HWC2_COMPOSITION_SOLID_COLOR, |
| 235 | HWC2_COMPOSITION_CURSOR, |
| 236 | HWC2_COMPOSITION_SIDEBAND, |
| 237 | }; |
Marissa Wall | b72b5c9 | 2016-12-15 12:26:39 -0800 | [diff] [blame] | 238 | |
| 239 | |
| 240 | Hwc2TestDataspace::Hwc2TestDataspace(Hwc2TestCoverage coverage) |
| 241 | : Hwc2TestProperty(coverage, completeDataspaces, basicDataspaces, |
| 242 | defaultDataspaces) { } |
| 243 | |
| 244 | std::string Hwc2TestDataspace::dump() const |
| 245 | { |
| 246 | std::stringstream dmp; |
| 247 | dmp << "\tdataspace: " << get() << "\n"; |
| 248 | return dmp.str(); |
| 249 | } |
| 250 | |
| 251 | const std::vector<android_dataspace_t> Hwc2TestDataspace::defaultDataspaces = { |
| 252 | HAL_DATASPACE_UNKNOWN, |
| 253 | }; |
| 254 | |
| 255 | const std::vector<android_dataspace_t> Hwc2TestDataspace::basicDataspaces = { |
| 256 | HAL_DATASPACE_UNKNOWN, |
| 257 | HAL_DATASPACE_V0_SRGB, |
| 258 | }; |
| 259 | |
| 260 | const std::vector<android_dataspace_t> Hwc2TestDataspace::completeDataspaces = { |
| 261 | HAL_DATASPACE_UNKNOWN, |
| 262 | HAL_DATASPACE_ARBITRARY, |
| 263 | HAL_DATASPACE_STANDARD_SHIFT, |
| 264 | HAL_DATASPACE_STANDARD_MASK, |
| 265 | HAL_DATASPACE_STANDARD_UNSPECIFIED, |
| 266 | HAL_DATASPACE_STANDARD_BT709, |
| 267 | HAL_DATASPACE_STANDARD_BT601_625, |
| 268 | HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED, |
| 269 | HAL_DATASPACE_STANDARD_BT601_525, |
| 270 | HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED, |
| 271 | HAL_DATASPACE_STANDARD_BT2020, |
| 272 | HAL_DATASPACE_STANDARD_BT2020_CONSTANT_LUMINANCE, |
| 273 | HAL_DATASPACE_STANDARD_BT470M, |
| 274 | HAL_DATASPACE_STANDARD_FILM, |
| 275 | HAL_DATASPACE_TRANSFER_SHIFT, |
| 276 | HAL_DATASPACE_TRANSFER_MASK, |
| 277 | HAL_DATASPACE_TRANSFER_UNSPECIFIED, |
| 278 | HAL_DATASPACE_TRANSFER_LINEAR, |
| 279 | HAL_DATASPACE_TRANSFER_SRGB, |
| 280 | HAL_DATASPACE_TRANSFER_SMPTE_170M, |
| 281 | HAL_DATASPACE_TRANSFER_GAMMA2_2, |
| 282 | HAL_DATASPACE_TRANSFER_GAMMA2_8, |
| 283 | HAL_DATASPACE_TRANSFER_ST2084, |
| 284 | HAL_DATASPACE_TRANSFER_HLG, |
| 285 | HAL_DATASPACE_RANGE_SHIFT, |
| 286 | HAL_DATASPACE_RANGE_MASK, |
| 287 | HAL_DATASPACE_RANGE_UNSPECIFIED, |
| 288 | HAL_DATASPACE_RANGE_FULL, |
| 289 | HAL_DATASPACE_RANGE_LIMITED, |
| 290 | HAL_DATASPACE_SRGB_LINEAR, |
| 291 | HAL_DATASPACE_V0_SRGB_LINEAR, |
| 292 | HAL_DATASPACE_SRGB, |
| 293 | HAL_DATASPACE_V0_SRGB, |
| 294 | HAL_DATASPACE_JFIF, |
| 295 | HAL_DATASPACE_V0_JFIF, |
| 296 | HAL_DATASPACE_BT601_625, |
| 297 | HAL_DATASPACE_V0_BT601_625, |
| 298 | HAL_DATASPACE_BT601_525, |
| 299 | HAL_DATASPACE_V0_BT601_525, |
| 300 | HAL_DATASPACE_BT709, |
| 301 | HAL_DATASPACE_V0_BT709, |
| 302 | HAL_DATASPACE_DEPTH, |
| 303 | }; |
Marissa Wall | 2b1f530 | 2016-12-15 12:27:20 -0800 | [diff] [blame] | 304 | |
| 305 | |
Marissa Wall | 600a73b | 2016-12-15 12:30:39 -0800 | [diff] [blame] | 306 | Hwc2TestDisplayFrame::Hwc2TestDisplayFrame(Hwc2TestCoverage coverage, |
| 307 | const Area& displayArea) |
| 308 | : Hwc2TestProperty(mDisplayFrames), |
| 309 | mFrectScalars((coverage == Hwc2TestCoverage::Complete)? mCompleteFrectScalars: |
| 310 | (coverage == Hwc2TestCoverage::Basic)? mBasicFrectScalars: |
| 311 | mDefaultFrectScalars), |
| 312 | mDisplayArea(displayArea) |
| 313 | { |
| 314 | update(); |
| 315 | } |
| 316 | |
| 317 | std::string Hwc2TestDisplayFrame::dump() const |
| 318 | { |
| 319 | std::stringstream dmp; |
| 320 | const hwc_rect_t& displayFrame = get(); |
| 321 | dmp << "\tdisplay frame: left " << displayFrame.left << ", top " |
| 322 | << displayFrame.top << ", right " << displayFrame.right |
| 323 | << ", bottom " << displayFrame.bottom << "\n"; |
| 324 | return dmp.str(); |
| 325 | } |
| 326 | |
| 327 | void Hwc2TestDisplayFrame::update() |
| 328 | { |
| 329 | mDisplayFrames.clear(); |
| 330 | |
| 331 | if (mDisplayArea.width == 0 && mDisplayArea.height == 0) { |
| 332 | mDisplayFrames.push_back({0, 0, 0, 0}); |
| 333 | return; |
| 334 | } |
| 335 | |
| 336 | for (const auto& frectScalar : mFrectScalars) { |
| 337 | mDisplayFrames.push_back({ |
| 338 | static_cast<int>(frectScalar.left * mDisplayArea.width), |
| 339 | static_cast<int>(frectScalar.top * mDisplayArea.height), |
| 340 | static_cast<int>(frectScalar.right * mDisplayArea.width), |
| 341 | static_cast<int>(frectScalar.bottom * mDisplayArea.height)}); |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | const std::vector<hwc_frect_t> Hwc2TestDisplayFrame::mDefaultFrectScalars = { |
| 346 | {0.0, 0.0, 1.0, 1.0}, |
| 347 | }; |
| 348 | |
| 349 | const std::vector<hwc_frect_t> Hwc2TestDisplayFrame::mBasicFrectScalars = { |
| 350 | {0.0, 0.0, 1.0, 1.0}, |
| 351 | {0.0, 0.0, 1.0, 0.05}, |
| 352 | {0.0, 0.95, 1.0, 1.0}, |
| 353 | }; |
| 354 | |
| 355 | const std::vector<hwc_frect_t> Hwc2TestDisplayFrame::mCompleteFrectScalars = { |
| 356 | {0.0, 0.0, 1.0, 1.0}, |
| 357 | {0.0, 0.05, 1.0, 0.95}, |
| 358 | {0.0, 0.05, 1.0, 1.0}, |
| 359 | {0.0, 0.0, 1.0, 0.05}, |
| 360 | {0.0, 0.95, 1.0, 1.0}, |
| 361 | {0.25, 0.0, 0.75, 0.35}, |
| 362 | {0.25, 0.25, 0.75, 0.75}, |
| 363 | }; |
| 364 | |
| 365 | |
Marissa Wall | 2b1f530 | 2016-12-15 12:27:20 -0800 | [diff] [blame] | 366 | Hwc2TestPlaneAlpha::Hwc2TestPlaneAlpha(Hwc2TestCoverage coverage) |
| 367 | : Hwc2TestProperty(coverage, mCompletePlaneAlphas, mBasicPlaneAlphas, |
| 368 | mDefaultPlaneAlphas) { } |
| 369 | |
| 370 | std::string Hwc2TestPlaneAlpha::dump() const |
| 371 | { |
| 372 | std::stringstream dmp; |
| 373 | dmp << "\tplane alpha: " << get() << "\n"; |
| 374 | return dmp.str(); |
| 375 | } |
| 376 | |
| 377 | const std::vector<float> Hwc2TestPlaneAlpha::mDefaultPlaneAlphas = { |
| 378 | 1.0f, |
| 379 | }; |
| 380 | |
| 381 | const std::vector<float> Hwc2TestPlaneAlpha::mBasicPlaneAlphas = { |
| 382 | 1.0f, 0.0f, |
| 383 | }; |
| 384 | |
| 385 | const std::vector<float> Hwc2TestPlaneAlpha::mCompletePlaneAlphas = { |
| 386 | 1.0f, 0.75f, 0.5f, 0.25f, 0.0f, |
| 387 | }; |
Marissa Wall | ac10819 | 2016-12-15 12:27:48 -0800 | [diff] [blame] | 388 | |
| 389 | |
Marissa Wall | c57468f | 2016-12-15 12:31:12 -0800 | [diff] [blame] | 390 | Hwc2TestSourceCrop::Hwc2TestSourceCrop(Hwc2TestCoverage coverage, |
| 391 | const Area& bufferArea) |
| 392 | : Hwc2TestProperty(mSourceCrops), |
| 393 | mFrectScalars((coverage == Hwc2TestCoverage::Complete)? mCompleteFrectScalars: |
| 394 | (coverage == Hwc2TestCoverage::Basic)? mBasicFrectScalars: |
| 395 | mDefaultFrectScalars), |
| 396 | mBufferArea(bufferArea) |
| 397 | { |
| 398 | update(); |
| 399 | } |
| 400 | |
| 401 | std::string Hwc2TestSourceCrop::dump() const |
| 402 | { |
| 403 | std::stringstream dmp; |
| 404 | const hwc_frect_t& sourceCrop = get(); |
| 405 | dmp << "\tsource crop: left " << sourceCrop.left << ", top " |
| 406 | << sourceCrop.top << ", right " << sourceCrop.right << ", bottom " |
| 407 | << sourceCrop.bottom << "\n"; |
| 408 | return dmp.str(); |
| 409 | } |
| 410 | |
| 411 | void Hwc2TestSourceCrop::updateBufferArea(const Area& bufferArea) |
| 412 | { |
| 413 | mBufferArea = bufferArea; |
| 414 | update(); |
| 415 | } |
| 416 | |
| 417 | void Hwc2TestSourceCrop::update() |
| 418 | { |
| 419 | mSourceCrops.clear(); |
| 420 | |
| 421 | if (mBufferArea.width == 0 && mBufferArea.height == 0) { |
| 422 | mSourceCrops.push_back({0, 0, 0, 0}); |
| 423 | return; |
| 424 | } |
| 425 | |
| 426 | for (const auto& frectScalar : mFrectScalars) { |
| 427 | mSourceCrops.push_back({ |
| 428 | frectScalar.left * mBufferArea.width, |
| 429 | frectScalar.top * mBufferArea.height, |
| 430 | frectScalar.right * mBufferArea.width, |
| 431 | frectScalar.bottom * mBufferArea.height}); |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | const std::vector<hwc_frect_t> Hwc2TestSourceCrop::mDefaultFrectScalars = { |
| 436 | {0.0, 0.0, 1.0, 1.0}, |
| 437 | }; |
| 438 | |
| 439 | const std::vector<hwc_frect_t> Hwc2TestSourceCrop::mBasicFrectScalars = { |
| 440 | {0.0, 0.0, 1.0, 1.0}, |
| 441 | {0.0, 0.0, 0.5, 0.5}, |
| 442 | {0.5, 0.5, 1.0, 1.0}, |
| 443 | }; |
| 444 | |
| 445 | const std::vector<hwc_frect_t> Hwc2TestSourceCrop::mCompleteFrectScalars = { |
| 446 | {0.0, 0.0, 1.0, 1.0}, |
| 447 | {0.0, 0.0, 0.5, 0.5}, |
| 448 | {0.5, 0.5, 1.0, 1.0}, |
| 449 | {0.0, 0.0, 0.25, 0.25}, |
| 450 | {0.25, 0.25, 0.75, 0.75}, |
| 451 | }; |
| 452 | |
| 453 | |
Marissa Wall | ad76181 | 2016-12-15 12:32:24 -0800 | [diff] [blame^] | 454 | Hwc2TestSurfaceDamage::Hwc2TestSurfaceDamage(Hwc2TestCoverage coverage) |
| 455 | : Hwc2TestProperty(mSurfaceDamages), |
| 456 | mRegionScalars((coverage == Hwc2TestCoverage::Complete)? mCompleteRegionScalars: |
| 457 | (coverage == Hwc2TestCoverage::Basic)? mBasicRegionScalars: |
| 458 | mDefaultRegionScalars) |
| 459 | { |
| 460 | update(); |
| 461 | } |
| 462 | |
| 463 | Hwc2TestSurfaceDamage::~Hwc2TestSurfaceDamage() |
| 464 | { |
| 465 | freeSurfaceDamages(); |
| 466 | } |
| 467 | |
| 468 | std::string Hwc2TestSurfaceDamage::dump() const |
| 469 | { |
| 470 | std::stringstream dmp; |
| 471 | |
| 472 | const hwc_region_t& curr = get(); |
| 473 | dmp << "\tsurface damage: region count " << curr.numRects << "\n"; |
| 474 | for (size_t i = 0; i < curr.numRects; i++) { |
| 475 | const hwc_rect_t& rect = curr.rects[i]; |
| 476 | dmp << "\t\trect: left " << rect.left << ", top " << rect.top |
| 477 | << ", right " << rect.right << ", bottom " << rect.bottom << "\n"; |
| 478 | } |
| 479 | |
| 480 | return dmp.str(); |
| 481 | } |
| 482 | |
| 483 | void Hwc2TestSurfaceDamage::updateBufferArea(const Area& bufferArea) |
| 484 | { |
| 485 | mBufferArea = bufferArea; |
| 486 | update(); |
| 487 | } |
| 488 | |
| 489 | void Hwc2TestSurfaceDamage::update() |
| 490 | { |
| 491 | freeSurfaceDamages(); |
| 492 | |
| 493 | if (mBufferArea.width == 0 && mBufferArea.height == 0) { |
| 494 | mSurfaceDamages.push_back({0, nullptr}); |
| 495 | return; |
| 496 | } |
| 497 | |
| 498 | hwc_region_t damage; |
| 499 | |
| 500 | for (const auto& regionScalar : mRegionScalars) { |
| 501 | damage.numRects = regionScalar.size(); |
| 502 | |
| 503 | if (damage.numRects > 0) { |
| 504 | hwc_rect_t* rects = new hwc_rect_t[damage.numRects]; |
| 505 | if (!rects) { |
| 506 | ALOGW("failed to allocate new hwc_rect_t array"); |
| 507 | continue; |
| 508 | } |
| 509 | |
| 510 | for (size_t i = 0; i < damage.numRects; i++) { |
| 511 | rects[i].left = regionScalar[i].left * mBufferArea.width; |
| 512 | rects[i].top = regionScalar[i].top * mBufferArea.height; |
| 513 | rects[i].right = regionScalar[i].right * mBufferArea.width; |
| 514 | rects[i].bottom = regionScalar[i].bottom * mBufferArea.height; |
| 515 | } |
| 516 | |
| 517 | damage.rects = static_cast<hwc_rect_t const*>(rects); |
| 518 | } else { |
| 519 | damage.rects = nullptr; |
| 520 | } |
| 521 | |
| 522 | mSurfaceDamages.push_back(damage); |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | void Hwc2TestSurfaceDamage::freeSurfaceDamages() |
| 527 | { |
| 528 | for (const auto& surfaceDamage : mSurfaceDamages) { |
| 529 | if (surfaceDamage.numRects > 0 && surfaceDamage.rects) |
| 530 | delete[] surfaceDamage.rects; |
| 531 | } |
| 532 | mSurfaceDamages.clear(); |
| 533 | } |
| 534 | |
| 535 | const std::vector<std::vector<hwc_frect_t>> Hwc2TestSurfaceDamage::mDefaultRegionScalars = { |
| 536 | {{}}, |
| 537 | }; |
| 538 | |
| 539 | const std::vector<std::vector<hwc_frect_t>> Hwc2TestSurfaceDamage::mBasicRegionScalars = { |
| 540 | {{}}, |
| 541 | {{0.0, 0.0, 1.0, 1.0}}, |
| 542 | }; |
| 543 | |
| 544 | const std::vector<std::vector<hwc_frect_t>> Hwc2TestSurfaceDamage::mCompleteRegionScalars = { |
| 545 | {{}}, |
| 546 | {{0.0, 0.0, 1.0, 1.0}}, |
| 547 | {{0.0, 0.0, 0.5, 0.5}, {0.5, 0.5, 1.0, 1.0}}, |
| 548 | }; |
| 549 | |
| 550 | |
Marissa Wall | ac10819 | 2016-12-15 12:27:48 -0800 | [diff] [blame] | 551 | Hwc2TestTransform::Hwc2TestTransform(Hwc2TestCoverage coverage) |
| 552 | : Hwc2TestProperty(coverage, mCompleteTransforms, mBasicTransforms, |
| 553 | mDefaultTransforms) { } |
| 554 | |
| 555 | std::string Hwc2TestTransform::dump() const |
| 556 | { |
| 557 | std::stringstream dmp; |
| 558 | dmp << "\ttransform: " << getTransformName(get()) << "\n"; |
| 559 | return dmp.str(); |
| 560 | } |
| 561 | |
| 562 | const std::vector<hwc_transform_t> Hwc2TestTransform::mDefaultTransforms = { |
| 563 | static_cast<hwc_transform_t>(0), |
| 564 | }; |
| 565 | |
| 566 | const std::vector<hwc_transform_t> Hwc2TestTransform::mBasicTransforms = { |
| 567 | static_cast<hwc_transform_t>(0), |
| 568 | HWC_TRANSFORM_FLIP_H, |
| 569 | HWC_TRANSFORM_FLIP_V, |
| 570 | HWC_TRANSFORM_ROT_90, |
| 571 | }; |
| 572 | |
| 573 | const std::vector<hwc_transform_t> Hwc2TestTransform::mCompleteTransforms = { |
| 574 | static_cast<hwc_transform_t>(0), |
| 575 | HWC_TRANSFORM_FLIP_H, |
| 576 | HWC_TRANSFORM_FLIP_V, |
| 577 | HWC_TRANSFORM_ROT_90, |
| 578 | HWC_TRANSFORM_ROT_180, |
| 579 | HWC_TRANSFORM_ROT_270, |
| 580 | HWC_TRANSFORM_FLIP_H_ROT_90, |
| 581 | HWC_TRANSFORM_FLIP_V_ROT_90, |
| 582 | }; |