Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 <gtest/gtest.h> |
| 18 | |
| 19 | #include <renderengine/RenderEngine.h> |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 20 | #include <sync/sync.h> |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 21 | #include <ui/PixelFormat.h> |
| 22 | |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 23 | constexpr int DEFAULT_DISPLAY_WIDTH = 128; |
| 24 | constexpr int DEFAULT_DISPLAY_HEIGHT = 256; |
| 25 | constexpr int DEFAULT_DISPLAY_OFFSET = 64; |
| 26 | |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 27 | namespace android { |
| 28 | |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 29 | struct RenderEngineTest : public ::testing::Test { |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 30 | static sp<GraphicBuffer> allocateDefaultBuffer() { |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 31 | return new GraphicBuffer(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT, |
| 32 | HAL_PIXEL_FORMAT_RGBA_8888, 1, |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 33 | GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN | |
| 34 | GRALLOC_USAGE_HW_RENDER, |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 35 | "output"); |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 38 | // Allocates a 1x1 buffer to fill with a solid color |
| 39 | static sp<GraphicBuffer> allocateSourceBuffer(uint32_t width, uint32_t height) { |
| 40 | return new GraphicBuffer(width, height, HAL_PIXEL_FORMAT_RGBA_8888, 1, |
| 41 | GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN | |
| 42 | GRALLOC_USAGE_HW_TEXTURE, |
| 43 | "input"); |
| 44 | } |
| 45 | |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 46 | RenderEngineTest() { mBuffer = allocateDefaultBuffer(); } |
| 47 | |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 48 | ~RenderEngineTest() { |
| 49 | for (uint32_t texName : mTexNames) { |
| 50 | sRE->deleteTextures(1, &texName); |
| 51 | } |
| 52 | } |
| 53 | |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 54 | void expectBufferColor(const Rect& region, uint8_t r, uint8_t g, uint8_t b, uint8_t a, |
| 55 | uint8_t tolerance = 0) { |
| 56 | uint8_t* pixels; |
| 57 | mBuffer->lock(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN, |
| 58 | reinterpret_cast<void**>(&pixels)); |
| 59 | |
| 60 | auto colorCompare = [tolerance](uint8_t a, uint8_t b) { |
| 61 | uint8_t tmp = a >= b ? a - b : b - a; |
| 62 | return tmp <= tolerance; |
| 63 | }; |
| 64 | int32_t maxFails = 10; |
| 65 | int32_t fails = 0; |
| 66 | for (int32_t j = 0; j < region.getHeight(); j++) { |
| 67 | const uint8_t* src = |
| 68 | pixels + (mBuffer->getStride() * (region.top + j) + region.left) * 4; |
| 69 | for (int32_t i = 0; i < region.getWidth(); i++) { |
| 70 | const uint8_t expected[4] = {r, g, b, a}; |
| 71 | bool equal = std::equal(src, src + 4, expected, colorCompare); |
| 72 | EXPECT_TRUE(equal) |
| 73 | << "pixel @ (" << region.left + i << ", " << region.top + j << "): " |
| 74 | << "expected (" << static_cast<uint32_t>(r) << ", " |
| 75 | << static_cast<uint32_t>(g) << ", " << static_cast<uint32_t>(b) << ", " |
| 76 | << static_cast<uint32_t>(a) << "), " |
| 77 | << "got (" << static_cast<uint32_t>(src[0]) << ", " |
| 78 | << static_cast<uint32_t>(src[1]) << ", " << static_cast<uint32_t>(src[2]) |
| 79 | << ", " << static_cast<uint32_t>(src[3]) << ")"; |
| 80 | src += 4; |
| 81 | if (!equal && ++fails >= maxFails) { |
| 82 | break; |
| 83 | } |
| 84 | } |
| 85 | if (fails >= maxFails) { |
| 86 | break; |
| 87 | } |
| 88 | } |
| 89 | mBuffer->unlock(); |
| 90 | } |
| 91 | |
| 92 | static Rect fullscreenRect() { return Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT); } |
| 93 | |
| 94 | static Rect offsetRect() { |
| 95 | return Rect(DEFAULT_DISPLAY_OFFSET, DEFAULT_DISPLAY_OFFSET, DEFAULT_DISPLAY_WIDTH, |
| 96 | DEFAULT_DISPLAY_HEIGHT); |
| 97 | } |
| 98 | |
| 99 | static Rect offsetRectAtZero() { |
| 100 | return Rect(DEFAULT_DISPLAY_WIDTH - DEFAULT_DISPLAY_OFFSET, |
| 101 | DEFAULT_DISPLAY_HEIGHT - DEFAULT_DISPLAY_OFFSET); |
| 102 | } |
| 103 | |
| 104 | static void invokeDraw(renderengine::DisplaySettings settings, |
| 105 | std::vector<renderengine::LayerSettings> layers, |
| 106 | sp<GraphicBuffer> buffer) { |
| 107 | base::unique_fd fence; |
| 108 | status_t status = sRE->drawLayers(settings, layers, buffer->getNativeBuffer(), &fence); |
| 109 | |
| 110 | int fd = fence.release(); |
| 111 | if (fd >= 0) { |
| 112 | sync_wait(fd, -1); |
| 113 | close(fd); |
| 114 | } |
| 115 | |
| 116 | ASSERT_EQ(NO_ERROR, status); |
| 117 | } |
| 118 | |
| 119 | static void drawEmptyLayers() { |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 120 | renderengine::DisplaySettings settings; |
| 121 | std::vector<renderengine::LayerSettings> layers; |
| 122 | // Meaningless buffer since we don't do any drawing |
| 123 | sp<GraphicBuffer> buffer = new GraphicBuffer(); |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 124 | invokeDraw(settings, layers, buffer); |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 125 | } |
| 126 | |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 127 | template <typename SourceVariant> |
| 128 | void fillBuffer(half r, half g, half b, half a); |
| 129 | |
| 130 | template <typename SourceVariant> |
| 131 | void fillRedBuffer(); |
| 132 | |
| 133 | template <typename SourceVariant> |
| 134 | void fillGreenBuffer(); |
| 135 | |
| 136 | template <typename SourceVariant> |
| 137 | void fillBlueBuffer(); |
| 138 | |
| 139 | template <typename SourceVariant> |
| 140 | void fillRedTransparentBuffer(); |
| 141 | |
| 142 | template <typename SourceVariant> |
| 143 | void fillRedOffsetBuffer(); |
| 144 | |
| 145 | template <typename SourceVariant> |
| 146 | void fillBufferPhysicalOffset(); |
| 147 | |
| 148 | template <typename SourceVariant> |
| 149 | void fillBufferCheckers(mat4 transform); |
| 150 | |
| 151 | template <typename SourceVariant> |
| 152 | void fillBufferCheckersRotate0(); |
| 153 | |
| 154 | template <typename SourceVariant> |
| 155 | void fillBufferCheckersRotate90(); |
| 156 | |
| 157 | template <typename SourceVariant> |
| 158 | void fillBufferCheckersRotate180(); |
| 159 | |
| 160 | template <typename SourceVariant> |
| 161 | void fillBufferCheckersRotate270(); |
| 162 | |
| 163 | template <typename SourceVariant> |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 164 | void fillBufferWithLayerTransform(); |
| 165 | |
| 166 | template <typename SourceVariant> |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 167 | void fillBufferLayerTransform(); |
| 168 | |
| 169 | template <typename SourceVariant> |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 170 | void fillBufferWithColorTransform(); |
| 171 | |
| 172 | template <typename SourceVariant> |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 173 | void fillBufferColorTransform(); |
| 174 | |
Alec Mouri | 7c94edb | 2018-12-03 21:23:26 -0800 | [diff] [blame] | 175 | template <typename SourceVariant> |
| 176 | void fillRedBufferWithRoundedCorners(); |
| 177 | |
| 178 | template <typename SourceVariant> |
| 179 | void fillBufferWithRoundedCorners(); |
| 180 | |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame^] | 181 | template <typename SourceVariant> |
| 182 | void overlayCorners(); |
| 183 | |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 184 | void fillRedBufferTextureTransform(); |
| 185 | |
| 186 | void fillBufferTextureTransform(); |
| 187 | |
| 188 | void fillRedBufferWithPremultiplyAlpha(); |
| 189 | |
| 190 | void fillBufferWithPremultiplyAlpha(); |
| 191 | |
| 192 | void fillRedBufferWithoutPremultiplyAlpha(); |
| 193 | |
| 194 | void fillBufferWithoutPremultiplyAlpha(); |
| 195 | |
Alec Mouri | ac33553 | 2018-11-12 15:01:33 -0800 | [diff] [blame] | 196 | void fillGreenColorBufferThenClearRegion(); |
| 197 | |
| 198 | void clearLeftRegion(); |
| 199 | |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame^] | 200 | void clearRegion(); |
Alec Mouri | ac33553 | 2018-11-12 15:01:33 -0800 | [diff] [blame] | 201 | |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 202 | // Dumb hack to get aroud the fact that tear-down for renderengine isn't |
| 203 | // well defined right now, so we can't create multiple instances |
| 204 | static std::unique_ptr<renderengine::RenderEngine> sRE; |
| 205 | |
| 206 | sp<GraphicBuffer> mBuffer; |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 207 | |
| 208 | std::vector<uint32_t> mTexNames; |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 209 | }; |
| 210 | |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 211 | std::unique_ptr<renderengine::RenderEngine> RenderEngineTest::sRE = |
| 212 | renderengine::RenderEngine::create(static_cast<int32_t>(ui::PixelFormat::RGBA_8888), 0); |
| 213 | |
| 214 | struct ColorSourceVariant { |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 215 | static void fillColor(renderengine::LayerSettings& layer, half r, half g, half b, |
| 216 | RenderEngineTest* /*fixture*/) { |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 217 | layer.source.solidColor = half3(r, g, b); |
| 218 | } |
| 219 | }; |
| 220 | |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 221 | struct RelaxOpaqueBufferVariant { |
| 222 | static void setOpaqueBit(renderengine::LayerSettings& layer) { |
| 223 | layer.source.buffer.isOpaque = false; |
| 224 | } |
| 225 | |
| 226 | static uint8_t getAlphaChannel() { return 255; } |
| 227 | }; |
| 228 | |
| 229 | struct ForceOpaqueBufferVariant { |
| 230 | static void setOpaqueBit(renderengine::LayerSettings& layer) { |
| 231 | layer.source.buffer.isOpaque = true; |
| 232 | } |
| 233 | |
| 234 | static uint8_t getAlphaChannel() { |
| 235 | // The isOpaque bit will override the alpha channel, so this should be |
| 236 | // arbitrary. |
| 237 | return 10; |
| 238 | } |
| 239 | }; |
| 240 | |
| 241 | template <typename OpaquenessVariant> |
| 242 | struct BufferSourceVariant { |
| 243 | static void fillColor(renderengine::LayerSettings& layer, half r, half g, half b, |
| 244 | RenderEngineTest* fixture) { |
| 245 | sp<GraphicBuffer> buf = RenderEngineTest::allocateSourceBuffer(1, 1); |
| 246 | uint32_t texName; |
| 247 | RenderEngineTest::sRE->genTextures(1, &texName); |
| 248 | fixture->mTexNames.push_back(texName); |
| 249 | |
| 250 | uint8_t* pixels; |
| 251 | buf->lock(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN, |
| 252 | reinterpret_cast<void**>(&pixels)); |
| 253 | |
| 254 | for (int32_t j = 0; j < buf->getHeight(); j++) { |
| 255 | uint8_t* iter = pixels + (buf->getStride() * j) * 4; |
| 256 | for (int32_t i = 0; i < buf->getWidth(); i++) { |
| 257 | iter[0] = uint8_t(r * 255); |
| 258 | iter[1] = uint8_t(g * 255); |
| 259 | iter[2] = uint8_t(b * 255); |
| 260 | iter[3] = OpaquenessVariant::getAlphaChannel(); |
| 261 | iter += 4; |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | buf->unlock(); |
| 266 | |
| 267 | layer.source.buffer.buffer = buf; |
| 268 | layer.source.buffer.textureName = texName; |
| 269 | OpaquenessVariant::setOpaqueBit(layer); |
| 270 | } |
| 271 | }; |
| 272 | |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 273 | template <typename SourceVariant> |
| 274 | void RenderEngineTest::fillBuffer(half r, half g, half b, half a) { |
| 275 | renderengine::DisplaySettings settings; |
| 276 | settings.physicalDisplay = fullscreenRect(); |
| 277 | settings.clip = fullscreenRect(); |
| 278 | |
| 279 | std::vector<renderengine::LayerSettings> layers; |
| 280 | |
| 281 | renderengine::LayerSettings layer; |
| 282 | layer.geometry.boundaries = fullscreenRect().toFloatRect(); |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 283 | SourceVariant::fillColor(layer, r, g, b, this); |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 284 | layer.alpha = a; |
| 285 | |
| 286 | layers.push_back(layer); |
| 287 | |
| 288 | invokeDraw(settings, layers, mBuffer); |
| 289 | } |
| 290 | |
| 291 | template <typename SourceVariant> |
| 292 | void RenderEngineTest::fillRedBuffer() { |
| 293 | fillBuffer<SourceVariant>(1.0f, 0.0f, 0.0f, 1.0f); |
| 294 | expectBufferColor(fullscreenRect(), 255, 0, 0, 255); |
| 295 | } |
| 296 | |
| 297 | template <typename SourceVariant> |
| 298 | void RenderEngineTest::fillGreenBuffer() { |
| 299 | fillBuffer<SourceVariant>(0.0f, 1.0f, 0.0f, 1.0f); |
| 300 | expectBufferColor(fullscreenRect(), 0, 255, 0, 255); |
| 301 | } |
| 302 | |
| 303 | template <typename SourceVariant> |
| 304 | void RenderEngineTest::fillBlueBuffer() { |
| 305 | fillBuffer<SourceVariant>(0.0f, 0.0f, 1.0f, 1.0f); |
| 306 | expectBufferColor(fullscreenRect(), 0, 0, 255, 255); |
| 307 | } |
| 308 | |
| 309 | template <typename SourceVariant> |
| 310 | void RenderEngineTest::fillRedTransparentBuffer() { |
| 311 | fillBuffer<SourceVariant>(1.0f, 0.0f, 0.0f, .2f); |
| 312 | expectBufferColor(fullscreenRect(), 51, 0, 0, 51); |
| 313 | } |
| 314 | |
| 315 | template <typename SourceVariant> |
| 316 | void RenderEngineTest::fillRedOffsetBuffer() { |
| 317 | renderengine::DisplaySettings settings; |
| 318 | settings.physicalDisplay = offsetRect(); |
| 319 | settings.clip = offsetRectAtZero(); |
| 320 | |
| 321 | std::vector<renderengine::LayerSettings> layers; |
| 322 | |
| 323 | renderengine::LayerSettings layer; |
| 324 | layer.geometry.boundaries = offsetRectAtZero().toFloatRect(); |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 325 | SourceVariant::fillColor(layer, 1.0f, 0.0f, 0.0f, this); |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 326 | layer.alpha = 1.0f; |
| 327 | |
| 328 | layers.push_back(layer); |
| 329 | invokeDraw(settings, layers, mBuffer); |
| 330 | } |
| 331 | |
| 332 | template <typename SourceVariant> |
| 333 | void RenderEngineTest::fillBufferPhysicalOffset() { |
| 334 | fillRedOffsetBuffer<SourceVariant>(); |
| 335 | |
| 336 | expectBufferColor(Rect(DEFAULT_DISPLAY_OFFSET, DEFAULT_DISPLAY_OFFSET, DEFAULT_DISPLAY_WIDTH, |
| 337 | DEFAULT_DISPLAY_HEIGHT), |
| 338 | 255, 0, 0, 255); |
| 339 | Rect offsetRegionLeft(DEFAULT_DISPLAY_OFFSET, DEFAULT_DISPLAY_HEIGHT); |
| 340 | Rect offsetRegionTop(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_OFFSET); |
| 341 | |
| 342 | expectBufferColor(offsetRegionLeft, 0, 0, 0, 0); |
| 343 | expectBufferColor(offsetRegionTop, 0, 0, 0, 0); |
| 344 | } |
| 345 | |
| 346 | template <typename SourceVariant> |
| 347 | void RenderEngineTest::fillBufferCheckers(mat4 transform) { |
| 348 | renderengine::DisplaySettings settings; |
| 349 | settings.physicalDisplay = fullscreenRect(); |
| 350 | // Here logical space is 2x2 |
| 351 | settings.clip = Rect(2, 2); |
| 352 | settings.globalTransform = transform; |
| 353 | |
| 354 | std::vector<renderengine::LayerSettings> layers; |
| 355 | |
| 356 | renderengine::LayerSettings layerOne; |
| 357 | Rect rectOne(0, 0, 1, 1); |
| 358 | layerOne.geometry.boundaries = rectOne.toFloatRect(); |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 359 | SourceVariant::fillColor(layerOne, 1.0f, 0.0f, 0.0f, this); |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 360 | layerOne.alpha = 1.0f; |
| 361 | |
| 362 | renderengine::LayerSettings layerTwo; |
| 363 | Rect rectTwo(0, 1, 1, 2); |
| 364 | layerTwo.geometry.boundaries = rectTwo.toFloatRect(); |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 365 | SourceVariant::fillColor(layerTwo, 0.0f, 1.0f, 0.0f, this); |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 366 | layerTwo.alpha = 1.0f; |
| 367 | |
| 368 | renderengine::LayerSettings layerThree; |
| 369 | Rect rectThree(1, 0, 2, 1); |
| 370 | layerThree.geometry.boundaries = rectThree.toFloatRect(); |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 371 | SourceVariant::fillColor(layerThree, 0.0f, 0.0f, 1.0f, this); |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 372 | layerThree.alpha = 1.0f; |
| 373 | |
| 374 | layers.push_back(layerOne); |
| 375 | layers.push_back(layerTwo); |
| 376 | layers.push_back(layerThree); |
| 377 | |
| 378 | invokeDraw(settings, layers, mBuffer); |
| 379 | } |
| 380 | |
| 381 | template <typename SourceVariant> |
| 382 | void RenderEngineTest::fillBufferCheckersRotate0() { |
| 383 | fillBufferCheckers<SourceVariant>(mat4()); |
| 384 | expectBufferColor(Rect(0, 0, DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT / 2), 255, 0, 0, |
| 385 | 255); |
| 386 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, 0, DEFAULT_DISPLAY_WIDTH, |
| 387 | DEFAULT_DISPLAY_HEIGHT / 2), |
| 388 | 0, 0, 255, 255); |
| 389 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT / 2, |
| 390 | DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 391 | 0, 0, 0, 0); |
| 392 | expectBufferColor(Rect(0, DEFAULT_DISPLAY_HEIGHT / 2, DEFAULT_DISPLAY_WIDTH / 2, |
| 393 | DEFAULT_DISPLAY_HEIGHT), |
| 394 | 0, 255, 0, 255); |
| 395 | } |
| 396 | |
| 397 | template <typename SourceVariant> |
| 398 | void RenderEngineTest::fillBufferCheckersRotate90() { |
| 399 | mat4 matrix = mat4(0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 1); |
| 400 | fillBufferCheckers<SourceVariant>(matrix); |
| 401 | expectBufferColor(Rect(0, 0, DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT / 2), 0, 255, 0, |
| 402 | 255); |
| 403 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, 0, DEFAULT_DISPLAY_WIDTH, |
| 404 | DEFAULT_DISPLAY_HEIGHT / 2), |
| 405 | 255, 0, 0, 255); |
| 406 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT / 2, |
| 407 | DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 408 | 0, 0, 255, 255); |
| 409 | expectBufferColor(Rect(0, DEFAULT_DISPLAY_HEIGHT / 2, DEFAULT_DISPLAY_WIDTH / 2, |
| 410 | DEFAULT_DISPLAY_HEIGHT), |
| 411 | 0, 0, 0, 0); |
| 412 | } |
| 413 | |
| 414 | template <typename SourceVariant> |
| 415 | void RenderEngineTest::fillBufferCheckersRotate180() { |
| 416 | mat4 matrix = mat4(-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 2, 2, 0, 1); |
| 417 | fillBufferCheckers<SourceVariant>(matrix); |
| 418 | expectBufferColor(Rect(0, 0, DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT / 2), 0, 0, 0, |
| 419 | 0); |
| 420 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, 0, DEFAULT_DISPLAY_WIDTH, |
| 421 | DEFAULT_DISPLAY_HEIGHT / 2), |
| 422 | 0, 255, 0, 255); |
| 423 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT / 2, |
| 424 | DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 425 | 255, 0, 0, 255); |
| 426 | expectBufferColor(Rect(0, DEFAULT_DISPLAY_HEIGHT / 2, DEFAULT_DISPLAY_WIDTH / 2, |
| 427 | DEFAULT_DISPLAY_HEIGHT), |
| 428 | 0, 0, 255, 255); |
| 429 | } |
| 430 | |
| 431 | template <typename SourceVariant> |
| 432 | void RenderEngineTest::fillBufferCheckersRotate270() { |
| 433 | mat4 matrix = mat4(0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 1); |
| 434 | fillBufferCheckers<SourceVariant>(matrix); |
| 435 | expectBufferColor(Rect(0, 0, DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT / 2), 0, 0, 255, |
| 436 | 255); |
| 437 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, 0, DEFAULT_DISPLAY_WIDTH, |
| 438 | DEFAULT_DISPLAY_HEIGHT / 2), |
| 439 | 0, 0, 0, 0); |
| 440 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT / 2, |
| 441 | DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 442 | 0, 255, 0, 255); |
| 443 | expectBufferColor(Rect(0, DEFAULT_DISPLAY_HEIGHT / 2, DEFAULT_DISPLAY_WIDTH / 2, |
| 444 | DEFAULT_DISPLAY_HEIGHT), |
| 445 | 255, 0, 0, 255); |
| 446 | } |
| 447 | |
| 448 | template <typename SourceVariant> |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 449 | void RenderEngineTest::fillBufferWithLayerTransform() { |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 450 | renderengine::DisplaySettings settings; |
| 451 | settings.physicalDisplay = fullscreenRect(); |
| 452 | // Here logical space is 2x2 |
| 453 | settings.clip = Rect(2, 2); |
| 454 | |
| 455 | std::vector<renderengine::LayerSettings> layers; |
| 456 | |
| 457 | renderengine::LayerSettings layer; |
| 458 | layer.geometry.boundaries = Rect(1, 1).toFloatRect(); |
| 459 | // Translate one pixel diagonally |
| 460 | layer.geometry.positionTransform = mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1); |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 461 | SourceVariant::fillColor(layer, 1.0f, 0.0f, 0.0f, this); |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 462 | layer.source.solidColor = half3(1.0f, 0.0f, 0.0f); |
| 463 | layer.alpha = 1.0f; |
| 464 | |
| 465 | layers.push_back(layer); |
| 466 | |
| 467 | invokeDraw(settings, layers, mBuffer); |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 468 | } |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 469 | |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 470 | template <typename SourceVariant> |
| 471 | void RenderEngineTest::fillBufferLayerTransform() { |
| 472 | fillBufferWithLayerTransform<SourceVariant>(); |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 473 | expectBufferColor(Rect(0, 0, DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT / 2), 0, 0, 0, 0); |
| 474 | expectBufferColor(Rect(0, 0, DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT), 0, 0, 0, 0); |
| 475 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT / 2, |
| 476 | DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 477 | 255, 0, 0, 255); |
| 478 | } |
| 479 | |
| 480 | template <typename SourceVariant> |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 481 | void RenderEngineTest::fillBufferWithColorTransform() { |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 482 | renderengine::DisplaySettings settings; |
| 483 | settings.physicalDisplay = fullscreenRect(); |
| 484 | settings.clip = Rect(1, 1); |
| 485 | |
| 486 | std::vector<renderengine::LayerSettings> layers; |
| 487 | |
| 488 | renderengine::LayerSettings layer; |
| 489 | layer.geometry.boundaries = Rect(1, 1).toFloatRect(); |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 490 | SourceVariant::fillColor(layer, 0.5f, 0.25f, 0.125f, this); |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 491 | layer.alpha = 1.0f; |
| 492 | |
| 493 | // construct a fake color matrix |
| 494 | // annihilate green and blue channels |
| 495 | settings.colorTransform = mat4::scale(vec4(1, 0, 0, 1)); |
| 496 | // set red channel to red + green |
| 497 | layer.colorTransform = mat4(1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); |
| 498 | |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 499 | layer.alpha = 1.0f; |
| 500 | layer.geometry.boundaries = Rect(1, 1).toFloatRect(); |
| 501 | |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 502 | layers.push_back(layer); |
| 503 | |
| 504 | invokeDraw(settings, layers, mBuffer); |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 505 | } |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 506 | |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 507 | template <typename SourceVariant> |
| 508 | void RenderEngineTest::fillBufferColorTransform() { |
| 509 | fillBufferWithColorTransform<SourceVariant>(); |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 510 | expectBufferColor(fullscreenRect(), 191, 0, 0, 255); |
| 511 | } |
| 512 | |
Alec Mouri | 7c94edb | 2018-12-03 21:23:26 -0800 | [diff] [blame] | 513 | template <typename SourceVariant> |
| 514 | void RenderEngineTest::fillRedBufferWithRoundedCorners() { |
| 515 | renderengine::DisplaySettings settings; |
| 516 | settings.physicalDisplay = fullscreenRect(); |
| 517 | settings.clip = fullscreenRect(); |
| 518 | |
| 519 | std::vector<renderengine::LayerSettings> layers; |
| 520 | |
| 521 | renderengine::LayerSettings layer; |
| 522 | layer.geometry.boundaries = fullscreenRect().toFloatRect(); |
| 523 | layer.geometry.roundedCornersRadius = 5.0f; |
| 524 | layer.geometry.roundedCornersCrop = fullscreenRect().toFloatRect(); |
| 525 | SourceVariant::fillColor(layer, 1.0f, 0.0f, 0.0f, this); |
| 526 | layer.alpha = 1.0f; |
| 527 | |
| 528 | layers.push_back(layer); |
| 529 | |
| 530 | invokeDraw(settings, layers, mBuffer); |
| 531 | } |
| 532 | |
| 533 | template <typename SourceVariant> |
| 534 | void RenderEngineTest::fillBufferWithRoundedCorners() { |
| 535 | fillRedBufferWithRoundedCorners<SourceVariant>(); |
| 536 | // Corners should be ignored... |
| 537 | expectBufferColor(Rect(0, 0, 1, 1), 0, 0, 0, 0); |
| 538 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH - 1, 0, DEFAULT_DISPLAY_WIDTH, 1), 0, 0, 0, 0); |
| 539 | expectBufferColor(Rect(0, DEFAULT_DISPLAY_HEIGHT - 1, 1, DEFAULT_DISPLAY_HEIGHT), 0, 0, 0, 0); |
| 540 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH - 1, DEFAULT_DISPLAY_HEIGHT - 1, |
| 541 | DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 542 | 0, 0, 0, 0); |
| 543 | // ...And the non-rounded portion should be red. |
| 544 | // Other pixels may be anti-aliased, so let's not check those. |
| 545 | expectBufferColor(Rect(5, 5, DEFAULT_DISPLAY_WIDTH - 5, DEFAULT_DISPLAY_HEIGHT - 5), 255, 0, 0, |
| 546 | 255); |
| 547 | } |
| 548 | |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame^] | 549 | template <typename SourceVariant> |
| 550 | void RenderEngineTest::overlayCorners() { |
| 551 | renderengine::DisplaySettings settings; |
| 552 | settings.physicalDisplay = fullscreenRect(); |
| 553 | settings.clip = fullscreenRect(); |
| 554 | |
| 555 | std::vector<renderengine::LayerSettings> layersFirst; |
| 556 | |
| 557 | renderengine::LayerSettings layerOne; |
| 558 | layerOne.geometry.boundaries = |
| 559 | FloatRect(0, 0, DEFAULT_DISPLAY_WIDTH / 3.0, DEFAULT_DISPLAY_HEIGHT / 3.0); |
| 560 | SourceVariant::fillColor(layerOne, 1.0f, 0.0f, 0.0f, this); |
| 561 | layerOne.alpha = 0.2; |
| 562 | |
| 563 | layersFirst.push_back(layerOne); |
| 564 | invokeDraw(settings, layersFirst, mBuffer); |
| 565 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 3, DEFAULT_DISPLAY_HEIGHT / 3), 51, 0, 0, 51); |
| 566 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 3 + 1, DEFAULT_DISPLAY_HEIGHT / 3 + 1, |
| 567 | DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 568 | 0, 0, 0, 0); |
| 569 | |
| 570 | std::vector<renderengine::LayerSettings> layersSecond; |
| 571 | renderengine::LayerSettings layerTwo; |
| 572 | layerTwo.geometry.boundaries = |
| 573 | FloatRect(DEFAULT_DISPLAY_WIDTH / 3.0, DEFAULT_DISPLAY_HEIGHT / 3.0, |
| 574 | DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT); |
| 575 | SourceVariant::fillColor(layerTwo, 0.0f, 1.0f, 0.0f, this); |
| 576 | layerTwo.alpha = 1.0f; |
| 577 | |
| 578 | layersSecond.push_back(layerTwo); |
| 579 | invokeDraw(settings, layersSecond, mBuffer); |
| 580 | |
| 581 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 3, DEFAULT_DISPLAY_HEIGHT / 3), 0, 0, 0, 0); |
| 582 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 3 + 1, DEFAULT_DISPLAY_HEIGHT / 3 + 1, |
| 583 | DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT), |
| 584 | 0, 255, 0, 255); |
| 585 | } |
| 586 | |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 587 | void RenderEngineTest::fillRedBufferTextureTransform() { |
| 588 | renderengine::DisplaySettings settings; |
| 589 | settings.physicalDisplay = fullscreenRect(); |
| 590 | settings.clip = Rect(1, 1); |
| 591 | |
| 592 | std::vector<renderengine::LayerSettings> layers; |
| 593 | |
| 594 | renderengine::LayerSettings layer; |
| 595 | // Here will allocate a checker board texture, but transform texture |
| 596 | // coordinates so that only the upper left is applied. |
| 597 | sp<GraphicBuffer> buf = allocateSourceBuffer(2, 2); |
| 598 | uint32_t texName; |
| 599 | RenderEngineTest::sRE->genTextures(1, &texName); |
| 600 | this->mTexNames.push_back(texName); |
| 601 | |
| 602 | uint8_t* pixels; |
| 603 | buf->lock(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN, |
| 604 | reinterpret_cast<void**>(&pixels)); |
| 605 | // Red top left, Green top right, Blue bottom left, Black bottom right |
| 606 | pixels[0] = 255; |
| 607 | pixels[1] = 0; |
| 608 | pixels[2] = 0; |
| 609 | pixels[3] = 255; |
| 610 | pixels[4] = 0; |
| 611 | pixels[5] = 255; |
| 612 | pixels[6] = 0; |
| 613 | pixels[7] = 255; |
| 614 | pixels[8] = 0; |
| 615 | pixels[9] = 0; |
| 616 | pixels[10] = 255; |
| 617 | pixels[11] = 255; |
| 618 | buf->unlock(); |
| 619 | |
| 620 | layer.source.buffer.buffer = buf; |
| 621 | layer.source.buffer.textureName = texName; |
| 622 | // Transform coordinates to only be inside the red quadrant. |
| 623 | layer.source.buffer.textureTransform = mat4::scale(vec4(0.2, 0.2, 1, 1)); |
| 624 | layer.alpha = 1.0f; |
| 625 | layer.geometry.boundaries = Rect(1, 1).toFloatRect(); |
| 626 | |
| 627 | layers.push_back(layer); |
| 628 | |
| 629 | invokeDraw(settings, layers, mBuffer); |
| 630 | } |
| 631 | |
| 632 | void RenderEngineTest::fillBufferTextureTransform() { |
| 633 | fillRedBufferTextureTransform(); |
| 634 | expectBufferColor(fullscreenRect(), 255, 0, 0, 255); |
| 635 | } |
| 636 | |
| 637 | void RenderEngineTest::fillRedBufferWithPremultiplyAlpha() { |
| 638 | renderengine::DisplaySettings settings; |
| 639 | settings.physicalDisplay = fullscreenRect(); |
| 640 | // Here logical space is 1x1 |
| 641 | settings.clip = Rect(1, 1); |
| 642 | |
| 643 | std::vector<renderengine::LayerSettings> layers; |
| 644 | |
| 645 | renderengine::LayerSettings layer; |
| 646 | sp<GraphicBuffer> buf = allocateSourceBuffer(1, 1); |
| 647 | uint32_t texName; |
| 648 | RenderEngineTest::sRE->genTextures(1, &texName); |
| 649 | this->mTexNames.push_back(texName); |
| 650 | |
| 651 | uint8_t* pixels; |
| 652 | buf->lock(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN, |
| 653 | reinterpret_cast<void**>(&pixels)); |
| 654 | pixels[0] = 255; |
| 655 | pixels[1] = 0; |
| 656 | pixels[2] = 0; |
| 657 | pixels[3] = 255; |
| 658 | buf->unlock(); |
| 659 | |
| 660 | layer.source.buffer.buffer = buf; |
| 661 | layer.source.buffer.textureName = texName; |
| 662 | layer.source.buffer.usePremultipliedAlpha = true; |
| 663 | layer.alpha = 0.5f; |
| 664 | layer.geometry.boundaries = Rect(1, 1).toFloatRect(); |
| 665 | |
| 666 | layers.push_back(layer); |
| 667 | |
| 668 | invokeDraw(settings, layers, mBuffer); |
| 669 | } |
| 670 | |
| 671 | void RenderEngineTest::fillBufferWithPremultiplyAlpha() { |
| 672 | fillRedBufferWithPremultiplyAlpha(); |
| 673 | expectBufferColor(fullscreenRect(), 128, 0, 0, 128); |
| 674 | } |
| 675 | |
| 676 | void RenderEngineTest::fillRedBufferWithoutPremultiplyAlpha() { |
| 677 | renderengine::DisplaySettings settings; |
| 678 | settings.physicalDisplay = fullscreenRect(); |
| 679 | // Here logical space is 1x1 |
| 680 | settings.clip = Rect(1, 1); |
| 681 | |
| 682 | std::vector<renderengine::LayerSettings> layers; |
| 683 | |
| 684 | renderengine::LayerSettings layer; |
| 685 | sp<GraphicBuffer> buf = allocateSourceBuffer(1, 1); |
| 686 | uint32_t texName; |
| 687 | RenderEngineTest::sRE->genTextures(1, &texName); |
| 688 | this->mTexNames.push_back(texName); |
| 689 | |
| 690 | uint8_t* pixels; |
| 691 | buf->lock(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN, |
| 692 | reinterpret_cast<void**>(&pixels)); |
| 693 | pixels[0] = 255; |
| 694 | pixels[1] = 0; |
| 695 | pixels[2] = 0; |
| 696 | pixels[3] = 255; |
| 697 | buf->unlock(); |
| 698 | |
| 699 | layer.source.buffer.buffer = buf; |
| 700 | layer.source.buffer.textureName = texName; |
| 701 | layer.source.buffer.usePremultipliedAlpha = false; |
| 702 | layer.alpha = 0.5f; |
| 703 | layer.geometry.boundaries = Rect(1, 1).toFloatRect(); |
| 704 | |
| 705 | layers.push_back(layer); |
| 706 | |
| 707 | invokeDraw(settings, layers, mBuffer); |
| 708 | } |
| 709 | |
| 710 | void RenderEngineTest::fillBufferWithoutPremultiplyAlpha() { |
| 711 | fillRedBufferWithoutPremultiplyAlpha(); |
| 712 | expectBufferColor(fullscreenRect(), 128, 0, 0, 64, 1); |
| 713 | } |
| 714 | |
Alec Mouri | ac33553 | 2018-11-12 15:01:33 -0800 | [diff] [blame] | 715 | void RenderEngineTest::clearLeftRegion() { |
| 716 | renderengine::DisplaySettings settings; |
| 717 | settings.physicalDisplay = fullscreenRect(); |
| 718 | // Here logical space is 4x4 |
| 719 | settings.clip = Rect(4, 4); |
| 720 | settings.globalTransform = mat4::scale(vec4(2, 4, 0, 1)); |
| 721 | settings.clearRegion = Region(Rect(1, 1)); |
| 722 | std::vector<renderengine::LayerSettings> layers; |
| 723 | // dummy layer, without bounds should not render anything |
| 724 | renderengine::LayerSettings layer; |
| 725 | layers.push_back(layer); |
| 726 | invokeDraw(settings, layers, mBuffer); |
| 727 | } |
| 728 | |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame^] | 729 | void RenderEngineTest::clearRegion() { |
Alec Mouri | ac33553 | 2018-11-12 15:01:33 -0800 | [diff] [blame] | 730 | // Reuse mBuffer |
| 731 | clearLeftRegion(); |
| 732 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT), 0, 0, 0, 255); |
| 733 | expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, 0, DEFAULT_DISPLAY_WIDTH, |
| 734 | DEFAULT_DISPLAY_HEIGHT), |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame^] | 735 | 0, 0, 0, 0); |
Alec Mouri | ac33553 | 2018-11-12 15:01:33 -0800 | [diff] [blame] | 736 | } |
| 737 | |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 738 | TEST_F(RenderEngineTest, drawLayers_noLayersToDraw) { |
| 739 | drawEmptyLayers(); |
| 740 | } |
| 741 | |
| 742 | TEST_F(RenderEngineTest, drawLayers_fillRedBuffer_colorSource) { |
| 743 | fillRedBuffer<ColorSourceVariant>(); |
| 744 | } |
| 745 | |
| 746 | TEST_F(RenderEngineTest, drawLayers_fillGreenBuffer_colorSource) { |
| 747 | fillGreenBuffer<ColorSourceVariant>(); |
| 748 | } |
| 749 | |
| 750 | TEST_F(RenderEngineTest, drawLayers_fillBlueBuffer_colorSource) { |
| 751 | fillBlueBuffer<ColorSourceVariant>(); |
| 752 | } |
| 753 | |
| 754 | TEST_F(RenderEngineTest, drawLayers_fillRedTransparentBuffer_colorSource) { |
| 755 | fillRedTransparentBuffer<ColorSourceVariant>(); |
| 756 | } |
| 757 | |
| 758 | TEST_F(RenderEngineTest, drawLayers_fillBufferPhysicalOffset_colorSource) { |
| 759 | fillBufferPhysicalOffset<ColorSourceVariant>(); |
| 760 | } |
| 761 | |
| 762 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate0_colorSource) { |
| 763 | fillBufferCheckersRotate0<ColorSourceVariant>(); |
| 764 | } |
| 765 | |
| 766 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate90_colorSource) { |
| 767 | fillBufferCheckersRotate90<ColorSourceVariant>(); |
| 768 | } |
| 769 | |
| 770 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate180_colorSource) { |
| 771 | fillBufferCheckersRotate180<ColorSourceVariant>(); |
| 772 | } |
| 773 | |
| 774 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate270_colorSource) { |
| 775 | fillBufferCheckersRotate270<ColorSourceVariant>(); |
| 776 | } |
| 777 | |
| 778 | TEST_F(RenderEngineTest, drawLayers_fillBufferLayerTransform_colorSource) { |
| 779 | fillBufferLayerTransform<ColorSourceVariant>(); |
| 780 | } |
| 781 | |
| 782 | TEST_F(RenderEngineTest, drawLayers_fillBufferColorTransform_colorSource) { |
| 783 | fillBufferLayerTransform<ColorSourceVariant>(); |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 784 | } |
| 785 | |
Alec Mouri | 7c94edb | 2018-12-03 21:23:26 -0800 | [diff] [blame] | 786 | TEST_F(RenderEngineTest, drawLayers_fillBufferRoundedCorners_colorSource) { |
| 787 | fillBufferWithRoundedCorners<ColorSourceVariant>(); |
| 788 | } |
| 789 | |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame^] | 790 | TEST_F(RenderEngineTest, drawLayers_overlayCorners_colorSource) { |
| 791 | overlayCorners<ColorSourceVariant>(); |
| 792 | } |
| 793 | |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 794 | TEST_F(RenderEngineTest, drawLayers_fillRedBuffer_opaqueBufferSource) { |
| 795 | fillRedBuffer<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 796 | } |
| 797 | |
| 798 | TEST_F(RenderEngineTest, drawLayers_fillGreenBuffer_opaqueBufferSource) { |
| 799 | fillGreenBuffer<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 800 | } |
| 801 | |
| 802 | TEST_F(RenderEngineTest, drawLayers_fillBlueBuffer_opaqueBufferSource) { |
| 803 | fillBlueBuffer<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 804 | } |
| 805 | |
| 806 | TEST_F(RenderEngineTest, drawLayers_fillRedTransparentBuffer_opaqueBufferSource) { |
| 807 | fillRedTransparentBuffer<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 808 | } |
| 809 | |
| 810 | TEST_F(RenderEngineTest, drawLayers_fillBufferPhysicalOffset_opaqueBufferSource) { |
| 811 | fillBufferPhysicalOffset<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 812 | } |
| 813 | |
| 814 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate0_opaqueBufferSource) { |
| 815 | fillBufferCheckersRotate0<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 816 | } |
| 817 | |
| 818 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate90_opaqueBufferSource) { |
| 819 | fillBufferCheckersRotate90<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 820 | } |
| 821 | |
| 822 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate180_opaqueBufferSource) { |
| 823 | fillBufferCheckersRotate180<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 824 | } |
| 825 | |
| 826 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate270_opaqueBufferSource) { |
| 827 | fillBufferCheckersRotate270<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 828 | } |
| 829 | |
| 830 | TEST_F(RenderEngineTest, drawLayers_fillBufferLayerTransform_opaqueBufferSource) { |
| 831 | fillBufferLayerTransform<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 832 | } |
| 833 | |
| 834 | TEST_F(RenderEngineTest, drawLayers_fillBufferColorTransform_opaqueBufferSource) { |
| 835 | fillBufferLayerTransform<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 836 | } |
| 837 | |
Alec Mouri | 7c94edb | 2018-12-03 21:23:26 -0800 | [diff] [blame] | 838 | TEST_F(RenderEngineTest, drawLayers_fillBufferRoundedCorners_opaqueBufferSource) { |
| 839 | fillBufferWithRoundedCorners<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 840 | } |
| 841 | |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame^] | 842 | TEST_F(RenderEngineTest, drawLayers_overlayCorners_opaqueBufferSource) { |
| 843 | overlayCorners<BufferSourceVariant<ForceOpaqueBufferVariant>>(); |
| 844 | } |
| 845 | |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 846 | TEST_F(RenderEngineTest, drawLayers_fillRedBuffer_bufferSource) { |
| 847 | fillRedBuffer<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 848 | } |
| 849 | |
| 850 | TEST_F(RenderEngineTest, drawLayers_fillGreenBuffer_bufferSource) { |
| 851 | fillGreenBuffer<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 852 | } |
| 853 | |
| 854 | TEST_F(RenderEngineTest, drawLayers_fillBlueBuffer_bufferSource) { |
| 855 | fillBlueBuffer<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 856 | } |
| 857 | |
| 858 | TEST_F(RenderEngineTest, drawLayers_fillRedTransparentBuffer_bufferSource) { |
| 859 | fillRedTransparentBuffer<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 860 | } |
| 861 | |
| 862 | TEST_F(RenderEngineTest, drawLayers_fillBufferPhysicalOffset_bufferSource) { |
| 863 | fillBufferPhysicalOffset<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 864 | } |
| 865 | |
| 866 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate0_bufferSource) { |
| 867 | fillBufferCheckersRotate0<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 868 | } |
| 869 | |
| 870 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate90_bufferSource) { |
| 871 | fillBufferCheckersRotate90<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 872 | } |
| 873 | |
| 874 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate180_bufferSource) { |
| 875 | fillBufferCheckersRotate180<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 876 | } |
| 877 | |
| 878 | TEST_F(RenderEngineTest, drawLayers_fillBufferCheckersRotate270_bufferSource) { |
| 879 | fillBufferCheckersRotate270<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 880 | } |
| 881 | |
| 882 | TEST_F(RenderEngineTest, drawLayers_fillBufferLayerTransform_bufferSource) { |
| 883 | fillBufferLayerTransform<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 884 | } |
| 885 | |
| 886 | TEST_F(RenderEngineTest, drawLayers_fillBufferColorTransform_bufferSource) { |
| 887 | fillBufferLayerTransform<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 888 | } |
| 889 | |
Alec Mouri | 7c94edb | 2018-12-03 21:23:26 -0800 | [diff] [blame] | 890 | TEST_F(RenderEngineTest, drawLayers_fillBufferRoundedCorners_bufferSource) { |
| 891 | fillBufferWithRoundedCorners<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 892 | } |
| 893 | |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame^] | 894 | TEST_F(RenderEngineTest, drawLayers_overlayCorners_bufferSource) { |
| 895 | overlayCorners<BufferSourceVariant<RelaxOpaqueBufferVariant>>(); |
| 896 | } |
| 897 | |
Alec Mouri | 0d5e1eb | 2018-11-10 20:40:12 -0800 | [diff] [blame] | 898 | TEST_F(RenderEngineTest, drawLayers_fillBufferTextureTransform) { |
| 899 | fillBufferTextureTransform(); |
| 900 | } |
| 901 | |
| 902 | TEST_F(RenderEngineTest, drawLayers_fillBuffer_premultipliesAlpha) { |
| 903 | fillBufferWithPremultiplyAlpha(); |
| 904 | } |
| 905 | |
| 906 | TEST_F(RenderEngineTest, drawLayers_fillBuffer_withoutPremultiplyingAlpha) { |
| 907 | fillBufferWithoutPremultiplyAlpha(); |
| 908 | } |
| 909 | |
Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame^] | 910 | TEST_F(RenderEngineTest, drawLayers_clearRegion) { |
| 911 | clearRegion(); |
Alec Mouri | ac33553 | 2018-11-12 15:01:33 -0800 | [diff] [blame] | 912 | } |
| 913 | |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 914 | } // namespace android |