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