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