Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | |
Chia-I Wu | 718daf8 | 2017-10-20 11:57:17 -0700 | [diff] [blame] | 17 | #include <algorithm> |
| 18 | #include <functional> |
| 19 | #include <limits> |
| 20 | #include <ostream> |
| 21 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 22 | #include <gtest/gtest.h> |
| 23 | |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 24 | #include <android/native_window.h> |
| 25 | |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 26 | #include <gui/ISurfaceComposer.h> |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 27 | #include <gui/LayerState.h> |
| 28 | |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 29 | #include <gui/Surface.h> |
| 30 | #include <gui/SurfaceComposerClient.h> |
| 31 | #include <private/gui/ComposerService.h> |
| 32 | |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 33 | #include <ui/DisplayInfo.h> |
Chia-I Wu | 718daf8 | 2017-10-20 11:57:17 -0700 | [diff] [blame] | 34 | #include <ui/Rect.h> |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 35 | #include <utils/String8.h> |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 36 | |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 37 | #include <math.h> |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 38 | #include <math/vec3.h> |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 39 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 40 | namespace android { |
| 41 | |
Chia-I Wu | 718daf8 | 2017-10-20 11:57:17 -0700 | [diff] [blame] | 42 | namespace { |
| 43 | |
| 44 | struct Color { |
| 45 | uint8_t r; |
| 46 | uint8_t g; |
| 47 | uint8_t b; |
| 48 | uint8_t a; |
| 49 | |
| 50 | static const Color RED; |
Chia-I Wu | 0ea0f82 | 2017-10-31 10:14:40 -0700 | [diff] [blame^] | 51 | static const Color GREEN; |
Chia-I Wu | 718daf8 | 2017-10-20 11:57:17 -0700 | [diff] [blame] | 52 | static const Color BLACK; |
| 53 | }; |
| 54 | |
| 55 | const Color Color::RED{255, 0, 0, 255}; |
Chia-I Wu | 0ea0f82 | 2017-10-31 10:14:40 -0700 | [diff] [blame^] | 56 | const Color Color::GREEN{0, 255, 0, 255}; |
Chia-I Wu | 718daf8 | 2017-10-20 11:57:17 -0700 | [diff] [blame] | 57 | const Color Color::BLACK{0, 0, 0, 255}; |
| 58 | |
| 59 | std::ostream& operator<<(std::ostream& os, const Color& color) { |
| 60 | os << int(color.r) << ", " << int(color.g) << ", " << int(color.b) << ", " << int(color.a); |
| 61 | return os; |
| 62 | } |
| 63 | |
| 64 | // Fill a region with the specified color. |
| 65 | void fillBufferColor(const ANativeWindow_Buffer& buffer, const Rect& rect, const Color& color) { |
| 66 | int32_t x = rect.left; |
| 67 | int32_t y = rect.top; |
| 68 | int32_t width = rect.right - rect.left; |
| 69 | int32_t height = rect.bottom - rect.top; |
| 70 | |
| 71 | if (x < 0) { |
| 72 | width += x; |
| 73 | x = 0; |
| 74 | } |
| 75 | if (y < 0) { |
| 76 | height += y; |
| 77 | y = 0; |
| 78 | } |
| 79 | if (x + width > buffer.width) { |
| 80 | x = std::min(x, buffer.width); |
| 81 | width = buffer.width - x; |
| 82 | } |
| 83 | if (y + height > buffer.height) { |
| 84 | y = std::min(y, buffer.height); |
| 85 | height = buffer.height - y; |
| 86 | } |
| 87 | |
| 88 | for (int32_t j = 0; j < height; j++) { |
| 89 | uint8_t* dst = static_cast<uint8_t*>(buffer.bits) + (buffer.stride * (y + j) + x) * 4; |
| 90 | for (int32_t i = 0; i < width; i++) { |
| 91 | dst[0] = color.r; |
| 92 | dst[1] = color.g; |
| 93 | dst[2] = color.b; |
| 94 | dst[3] = color.a; |
| 95 | dst += 4; |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // Check if a region has the specified color. |
| 101 | void expectBufferColor(const CpuConsumer::LockedBuffer& buffer, const Rect& rect, |
| 102 | const Color& color, uint8_t tolerance) { |
| 103 | int32_t x = rect.left; |
| 104 | int32_t y = rect.top; |
| 105 | int32_t width = rect.right - rect.left; |
| 106 | int32_t height = rect.bottom - rect.top; |
| 107 | |
| 108 | if (x + width > int32_t(buffer.width)) { |
| 109 | x = std::min(x, int32_t(buffer.width)); |
| 110 | width = buffer.width - x; |
| 111 | } |
| 112 | if (y + height > int32_t(buffer.height)) { |
| 113 | y = std::min(y, int32_t(buffer.height)); |
| 114 | height = buffer.height - y; |
| 115 | } |
| 116 | |
| 117 | auto colorCompare = [tolerance](uint8_t a, uint8_t b) { |
| 118 | uint8_t tmp = a >= b ? a - b : b - a; |
| 119 | return tmp <= tolerance; |
| 120 | }; |
| 121 | for (int32_t j = 0; j < height; j++) { |
| 122 | const uint8_t* src = |
| 123 | static_cast<const uint8_t*>(buffer.data) + (buffer.stride * (y + j) + x) * 4; |
| 124 | for (int32_t i = 0; i < width; i++) { |
| 125 | const uint8_t expected[4] = {color.r, color.g, color.b, color.a}; |
| 126 | EXPECT_TRUE(std::equal(src, src + 4, expected, colorCompare)) |
| 127 | << "pixel @ (" << x + i << ", " << y + j << "): " |
| 128 | << "expected (" << color << "), " |
| 129 | << "got (" << Color{src[0], src[1], src[2], src[3]} << ")"; |
| 130 | src += 4; |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | } // anonymous namespace |
| 136 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 137 | using Transaction = SurfaceComposerClient::Transaction; |
| 138 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 139 | // Fill an RGBA_8888 formatted surface with a single color. |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 140 | static void fillSurfaceRGBA8(const sp<SurfaceControl>& sc, uint8_t r, uint8_t g, uint8_t b, |
| 141 | bool unlock = true) { |
Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 142 | ANativeWindow_Buffer outBuffer; |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 143 | sp<Surface> s = sc->getSurface(); |
| 144 | ASSERT_TRUE(s != NULL); |
Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 145 | ASSERT_EQ(NO_ERROR, s->lock(&outBuffer, NULL)); |
| 146 | uint8_t* img = reinterpret_cast<uint8_t*>(outBuffer.bits); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 147 | for (int y = 0; y < outBuffer.height; y++) { |
| 148 | for (int x = 0; x < outBuffer.width; x++) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 149 | uint8_t* pixel = img + (4 * (y * outBuffer.stride + x)); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 150 | pixel[0] = r; |
| 151 | pixel[1] = g; |
| 152 | pixel[2] = b; |
| 153 | pixel[3] = 255; |
| 154 | } |
| 155 | } |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 156 | if (unlock) { |
| 157 | ASSERT_EQ(NO_ERROR, s->unlockAndPost()); |
| 158 | } |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | // A ScreenCapture is a screenshot from SurfaceFlinger that can be used to check |
| 162 | // individual pixel values for testing purposes. |
| 163 | class ScreenCapture : public RefBase { |
| 164 | public: |
Chia-I Wu | 718daf8 | 2017-10-20 11:57:17 -0700 | [diff] [blame] | 165 | static void captureScreen(sp<ScreenCapture>* sc, int32_t minLayerZ = 0, |
| 166 | int32_t maxLayerZ = std::numeric_limits<int32_t>::max()) { |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 167 | sp<IGraphicBufferProducer> producer; |
| 168 | sp<IGraphicBufferConsumer> consumer; |
| 169 | BufferQueue::createBufferQueue(&producer, &consumer); |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 170 | sp<CpuConsumer> cpuConsumer = new CpuConsumer(consumer, 1); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 171 | sp<ISurfaceComposer> sf(ComposerService::getComposerService()); |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 172 | sp<IBinder> display(sf->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain)); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 173 | SurfaceComposerClient::Transaction().apply(true); |
| 174 | |
Chia-I Wu | 718daf8 | 2017-10-20 11:57:17 -0700 | [diff] [blame] | 175 | ASSERT_EQ(NO_ERROR, |
| 176 | sf->captureScreen(display, producer, Rect(), 0, 0, minLayerZ, maxLayerZ, false)); |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 177 | *sc = new ScreenCapture(cpuConsumer); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 178 | } |
| 179 | |
Chia-I Wu | 718daf8 | 2017-10-20 11:57:17 -0700 | [diff] [blame] | 180 | void expectColor(const Rect& rect, const Color& color, uint8_t tolerance = 0) { |
| 181 | ASSERT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, mBuf.format); |
| 182 | expectBufferColor(mBuf, rect, color, tolerance); |
| 183 | } |
| 184 | |
| 185 | void expectBorder(const Rect& rect, const Color& color, uint8_t tolerance = 0) { |
| 186 | ASSERT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, mBuf.format); |
| 187 | const bool leftBorder = rect.left > 0; |
| 188 | const bool topBorder = rect.top > 0; |
| 189 | const bool rightBorder = rect.right < int32_t(mBuf.width); |
| 190 | const bool bottomBorder = rect.bottom < int32_t(mBuf.height); |
| 191 | |
| 192 | if (topBorder) { |
| 193 | Rect top(rect.left, rect.top - 1, rect.right, rect.top); |
| 194 | if (leftBorder) { |
| 195 | top.left -= 1; |
| 196 | } |
| 197 | if (rightBorder) { |
| 198 | top.right += 1; |
| 199 | } |
| 200 | expectColor(top, color, tolerance); |
| 201 | } |
| 202 | if (leftBorder) { |
| 203 | Rect left(rect.left - 1, rect.top, rect.left, rect.bottom); |
| 204 | expectColor(left, color, tolerance); |
| 205 | } |
| 206 | if (rightBorder) { |
| 207 | Rect right(rect.right, rect.top, rect.right + 1, rect.bottom); |
| 208 | expectColor(right, color, tolerance); |
| 209 | } |
| 210 | if (bottomBorder) { |
| 211 | Rect bottom(rect.left, rect.bottom, rect.right, rect.bottom + 1); |
| 212 | if (leftBorder) { |
| 213 | bottom.left -= 1; |
| 214 | } |
| 215 | if (rightBorder) { |
| 216 | bottom.right += 1; |
| 217 | } |
| 218 | expectColor(bottom, color, tolerance); |
| 219 | } |
| 220 | } |
| 221 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 222 | void checkPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b) { |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 223 | ASSERT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, mBuf.format); |
| 224 | const uint8_t* img = static_cast<const uint8_t*>(mBuf.data); |
| 225 | const uint8_t* pixel = img + (4 * (y * mBuf.stride + x)); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 226 | if (r != pixel[0] || g != pixel[1] || b != pixel[2]) { |
| 227 | String8 err(String8::format("pixel @ (%3d, %3d): " |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 228 | "expected [%3d, %3d, %3d], got [%3d, %3d, %3d]", |
| 229 | x, y, r, g, b, pixel[0], pixel[1], pixel[2])); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 230 | EXPECT_EQ(String8(), err) << err.string(); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 234 | void expectFGColor(uint32_t x, uint32_t y) { checkPixel(x, y, 195, 63, 63); } |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 235 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 236 | void expectBGColor(uint32_t x, uint32_t y) { checkPixel(x, y, 63, 63, 195); } |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 237 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 238 | void expectChildColor(uint32_t x, uint32_t y) { checkPixel(x, y, 200, 200, 200); } |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 239 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 240 | private: |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 241 | ScreenCapture(const sp<CpuConsumer>& cc) : mCC(cc) { |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 242 | EXPECT_EQ(NO_ERROR, mCC->lockNextBuffer(&mBuf)); |
| 243 | } |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 244 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 245 | ~ScreenCapture() { mCC->unlockBuffer(mBuf); } |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 246 | |
| 247 | sp<CpuConsumer> mCC; |
| 248 | CpuConsumer::LockedBuffer mBuf; |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 249 | }; |
| 250 | |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 251 | class CaptureLayer { |
| 252 | public: |
| 253 | static void captureScreen(std::unique_ptr<CaptureLayer>* sc, sp<IBinder>& parentHandle) { |
| 254 | sp<IGraphicBufferProducer> producer; |
| 255 | sp<IGraphicBufferConsumer> consumer; |
| 256 | BufferQueue::createBufferQueue(&producer, &consumer); |
| 257 | sp<CpuConsumer> cpuConsumer = new CpuConsumer(consumer, 1); |
| 258 | sp<ISurfaceComposer> sf(ComposerService::getComposerService()); |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 259 | sp<IBinder> display(sf->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain)); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 260 | SurfaceComposerClient::Transaction().apply(true); |
| 261 | ASSERT_EQ(NO_ERROR, sf->captureLayers(parentHandle, producer)); |
| 262 | *sc = std::make_unique<CaptureLayer>(cpuConsumer); |
| 263 | } |
| 264 | |
| 265 | void checkPixel(uint32_t x, uint32_t y, uint8_t r, uint8_t g, uint8_t b) { |
| 266 | ASSERT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, mBuffer.format); |
| 267 | const uint8_t* img = static_cast<const uint8_t*>(mBuffer.data); |
| 268 | const uint8_t* pixel = img + (4 * (y * mBuffer.stride + x)); |
| 269 | if (r != pixel[0] || g != pixel[1] || b != pixel[2]) { |
| 270 | String8 err(String8::format("pixel @ (%3d, %3d): " |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 271 | "expected [%3d, %3d, %3d], got [%3d, %3d, %3d]", |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 272 | x, y, r, g, b, pixel[0], pixel[1], pixel[2])); |
| 273 | EXPECT_EQ(String8(), err) << err.string(); |
| 274 | } |
| 275 | } |
| 276 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 277 | void expectFGColor(uint32_t x, uint32_t y) { checkPixel(x, y, 195, 63, 63); } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 278 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 279 | void expectBGColor(uint32_t x, uint32_t y) { checkPixel(x, y, 63, 63, 195); } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 280 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 281 | void expectChildColor(uint32_t x, uint32_t y) { checkPixel(x, y, 200, 200, 200); } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 282 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 283 | CaptureLayer(const sp<CpuConsumer>& cc) : mCC(cc) { |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 284 | EXPECT_EQ(NO_ERROR, mCC->lockNextBuffer(&mBuffer)); |
| 285 | } |
| 286 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 287 | ~CaptureLayer() { mCC->unlockBuffer(mBuffer); } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 288 | |
| 289 | private: |
| 290 | sp<CpuConsumer> mCC; |
| 291 | CpuConsumer::LockedBuffer mBuffer; |
| 292 | }; |
| 293 | |
Chia-I Wu | 718daf8 | 2017-10-20 11:57:17 -0700 | [diff] [blame] | 294 | class LayerTransactionTest : public ::testing::Test { |
| 295 | protected: |
| 296 | void SetUp() override { |
| 297 | mClient = new SurfaceComposerClient; |
| 298 | ASSERT_EQ(NO_ERROR, mClient->initCheck()) << "failed to create SurfaceComposerClient"; |
| 299 | |
| 300 | ASSERT_NO_FATAL_FAILURE(SetUpDisplay()); |
| 301 | } |
| 302 | |
| 303 | sp<SurfaceControl> createLayer(const char* name, uint32_t width, uint32_t height, |
| 304 | uint32_t flags = 0) { |
| 305 | auto layer = |
| 306 | mClient->createSurface(String8(name), width, height, PIXEL_FORMAT_RGBA_8888, flags); |
| 307 | EXPECT_NE(nullptr, layer.get()) << "failed to create SurfaceControl"; |
| 308 | |
| 309 | status_t error = Transaction() |
| 310 | .setLayerStack(layer, mDisplayLayerStack) |
| 311 | .setLayer(layer, mLayerZBase) |
| 312 | .apply(); |
| 313 | if (error != NO_ERROR) { |
| 314 | ADD_FAILURE() << "failed to initialize SurfaceControl"; |
| 315 | layer.clear(); |
| 316 | } |
| 317 | |
| 318 | return layer; |
| 319 | } |
| 320 | |
| 321 | ANativeWindow_Buffer getLayerBuffer(const sp<SurfaceControl>& layer) { |
| 322 | // wait for previous transactions (such as setSize) to complete |
| 323 | Transaction().apply(true); |
| 324 | |
| 325 | ANativeWindow_Buffer buffer = {}; |
| 326 | EXPECT_EQ(NO_ERROR, layer->getSurface()->lock(&buffer, nullptr)); |
| 327 | |
| 328 | return buffer; |
| 329 | } |
| 330 | |
| 331 | void postLayerBuffer(const sp<SurfaceControl>& layer) { |
| 332 | ASSERT_EQ(NO_ERROR, layer->getSurface()->unlockAndPost()); |
| 333 | |
| 334 | // wait for the newly posted buffer to be latched |
| 335 | waitForLayerBuffers(); |
| 336 | } |
| 337 | |
| 338 | void fillLayerColor(const sp<SurfaceControl>& layer, const Color& color) { |
| 339 | ANativeWindow_Buffer buffer; |
| 340 | ASSERT_NO_FATAL_FAILURE(buffer = getLayerBuffer(layer)); |
| 341 | fillBufferColor(buffer, Rect(0, 0, buffer.width, buffer.height), color); |
| 342 | postLayerBuffer(layer); |
| 343 | } |
| 344 | |
| 345 | sp<ScreenCapture> screenshot() { |
| 346 | sp<ScreenCapture> screenshot; |
| 347 | ScreenCapture::captureScreen(&screenshot, mLayerZBase); |
| 348 | return screenshot; |
| 349 | } |
| 350 | |
| 351 | sp<SurfaceComposerClient> mClient; |
| 352 | |
| 353 | sp<IBinder> mDisplay; |
| 354 | uint32_t mDisplayWidth; |
| 355 | uint32_t mDisplayHeight; |
| 356 | uint32_t mDisplayLayerStack; |
| 357 | |
| 358 | // leave room for ~256 layers |
| 359 | const int32_t mLayerZBase = std::numeric_limits<int32_t>::max() - 256; |
| 360 | |
| 361 | private: |
| 362 | void SetUpDisplay() { |
| 363 | mDisplay = mClient->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain); |
| 364 | ASSERT_NE(nullptr, mDisplay.get()) << "failed to get built-in display"; |
| 365 | |
| 366 | // get display width/height |
| 367 | DisplayInfo info; |
| 368 | SurfaceComposerClient::getDisplayInfo(mDisplay, &info); |
| 369 | mDisplayWidth = info.w; |
| 370 | mDisplayHeight = info.h; |
| 371 | |
| 372 | // After a new buffer is queued, SurfaceFlinger is notified and will |
| 373 | // latch the new buffer on next vsync. Let's heuristically wait for 3 |
| 374 | // vsyncs. |
| 375 | mBufferPostDelay = int32_t(1e6 / info.fps) * 3; |
| 376 | |
| 377 | mDisplayLayerStack = 0; |
| 378 | // set layer stack (b/68888219) |
| 379 | Transaction t; |
| 380 | t.setDisplayLayerStack(mDisplay, mDisplayLayerStack); |
| 381 | t.apply(); |
| 382 | } |
| 383 | |
| 384 | void waitForLayerBuffers() { usleep(mBufferPostDelay); } |
| 385 | |
| 386 | int32_t mBufferPostDelay; |
| 387 | }; |
| 388 | |
| 389 | TEST_F(LayerTransactionTest, SetPositionBasic) { |
| 390 | sp<SurfaceControl> layer; |
| 391 | ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32)); |
| 392 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 393 | |
| 394 | { |
| 395 | SCOPED_TRACE("default position"); |
| 396 | auto shot = screenshot(); |
| 397 | shot->expectColor(Rect(0, 0, 32, 32), Color::RED); |
| 398 | shot->expectBorder(Rect(0, 0, 32, 32), Color::BLACK); |
| 399 | } |
| 400 | |
| 401 | Transaction().setPosition(layer, 5, 10).apply(); |
| 402 | { |
| 403 | SCOPED_TRACE("new position"); |
| 404 | auto shot = screenshot(); |
| 405 | shot->expectColor(Rect(5, 10, 37, 42), Color::RED); |
| 406 | shot->expectBorder(Rect(5, 10, 37, 42), Color::BLACK); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | TEST_F(LayerTransactionTest, SetPositionRounding) { |
| 411 | sp<SurfaceControl> layer; |
| 412 | ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32)); |
| 413 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 414 | |
| 415 | // GLES requires only 4 bits of subpixel precision during rasterization |
| 416 | // XXX GLES composition does not match HWC composition due to precision |
| 417 | // loss (b/69315223) |
| 418 | const float epsilon = 1.0f / 16.0f; |
| 419 | Transaction().setPosition(layer, 0.5f - epsilon, 0.5f - epsilon).apply(); |
| 420 | { |
| 421 | SCOPED_TRACE("rounding down"); |
| 422 | screenshot()->expectColor(Rect(0, 0, 32, 32), Color::RED); |
| 423 | } |
| 424 | |
| 425 | Transaction().setPosition(layer, 0.5f + epsilon, 0.5f + epsilon).apply(); |
| 426 | { |
| 427 | SCOPED_TRACE("rounding up"); |
| 428 | screenshot()->expectColor(Rect(1, 1, 33, 33), Color::RED); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | TEST_F(LayerTransactionTest, SetPositionOutOfBounds) { |
| 433 | sp<SurfaceControl> layer; |
| 434 | ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32)); |
| 435 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 436 | |
| 437 | Transaction().setPosition(layer, -32, -32).apply(); |
| 438 | { |
| 439 | SCOPED_TRACE("negative coordinates"); |
| 440 | screenshot()->expectColor(Rect(0, 0, mDisplayWidth, mDisplayHeight), Color::BLACK); |
| 441 | } |
| 442 | |
| 443 | Transaction().setPosition(layer, mDisplayWidth, mDisplayHeight).apply(); |
| 444 | { |
| 445 | SCOPED_TRACE("positive coordinates"); |
| 446 | screenshot()->expectColor(Rect(0, 0, mDisplayWidth, mDisplayHeight), Color::BLACK); |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | TEST_F(LayerTransactionTest, SetPositionPartiallyOutOfBounds) { |
| 451 | sp<SurfaceControl> layer; |
| 452 | ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32)); |
| 453 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 454 | |
| 455 | // partially out of bounds |
| 456 | Transaction().setPosition(layer, -30, -30).apply(); |
| 457 | { |
| 458 | SCOPED_TRACE("negative coordinates"); |
| 459 | screenshot()->expectColor(Rect(0, 0, 2, 2), Color::RED); |
| 460 | } |
| 461 | |
| 462 | Transaction().setPosition(layer, mDisplayWidth - 2, mDisplayHeight - 2).apply(); |
| 463 | { |
| 464 | SCOPED_TRACE("positive coordinates"); |
| 465 | screenshot()->expectColor(Rect(mDisplayWidth - 2, mDisplayHeight - 2, mDisplayWidth, |
| 466 | mDisplayHeight), |
| 467 | Color::RED); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | TEST_F(LayerTransactionTest, SetPositionWithResize) { |
| 472 | sp<SurfaceControl> layer; |
| 473 | ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32)); |
| 474 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 475 | |
| 476 | // setPosition is applied immediately by default, with or without resize |
| 477 | // pending |
| 478 | Transaction().setPosition(layer, 5, 10).setSize(layer, 64, 64).apply(); |
| 479 | { |
| 480 | SCOPED_TRACE("resize pending"); |
| 481 | auto shot = screenshot(); |
| 482 | shot->expectColor(Rect(5, 10, 37, 42), Color::RED); |
| 483 | shot->expectBorder(Rect(5, 10, 37, 42), Color::BLACK); |
| 484 | } |
| 485 | |
| 486 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 487 | { |
| 488 | SCOPED_TRACE("resize applied"); |
| 489 | screenshot()->expectColor(Rect(5, 10, 69, 74), Color::RED); |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | TEST_F(LayerTransactionTest, SetPositionWithNextResize) { |
| 494 | sp<SurfaceControl> layer; |
| 495 | ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32)); |
| 496 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 497 | |
| 498 | // request setPosition to be applied with the next resize |
| 499 | Transaction().setPosition(layer, 5, 10).setGeometryAppliesWithResize(layer).apply(); |
| 500 | { |
| 501 | SCOPED_TRACE("new position pending"); |
| 502 | screenshot()->expectColor(Rect(0, 0, 32, 32), Color::RED); |
| 503 | } |
| 504 | |
| 505 | Transaction().setPosition(layer, 15, 20).apply(); |
| 506 | { |
| 507 | SCOPED_TRACE("pending new position modified"); |
| 508 | screenshot()->expectColor(Rect(0, 0, 32, 32), Color::RED); |
| 509 | } |
| 510 | |
| 511 | Transaction().setSize(layer, 64, 64).apply(); |
| 512 | { |
| 513 | SCOPED_TRACE("resize pending"); |
| 514 | screenshot()->expectColor(Rect(0, 0, 32, 32), Color::RED); |
| 515 | } |
| 516 | |
| 517 | // finally resize and latch the buffer |
| 518 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 519 | { |
| 520 | SCOPED_TRACE("new position applied"); |
| 521 | screenshot()->expectColor(Rect(15, 20, 79, 84), Color::RED); |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | TEST_F(LayerTransactionTest, SetPositionWithNextResizeScaleToWindow) { |
| 526 | sp<SurfaceControl> layer; |
| 527 | ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32)); |
| 528 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 529 | |
| 530 | // setPosition is not immediate even with SCALE_TO_WINDOW override |
| 531 | Transaction() |
| 532 | .setPosition(layer, 5, 10) |
| 533 | .setSize(layer, 64, 64) |
| 534 | .setOverrideScalingMode(layer, NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW) |
| 535 | .setGeometryAppliesWithResize(layer) |
| 536 | .apply(); |
| 537 | { |
| 538 | SCOPED_TRACE("new position pending"); |
| 539 | screenshot()->expectColor(Rect(0, 0, 64, 64), Color::RED); |
| 540 | } |
| 541 | |
| 542 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 543 | { |
| 544 | SCOPED_TRACE("new position applied"); |
| 545 | screenshot()->expectColor(Rect(5, 10, 69, 74), Color::RED); |
| 546 | } |
| 547 | } |
| 548 | |
Chia-I Wu | 0eaea31 | 2017-10-31 10:14:40 -0700 | [diff] [blame] | 549 | TEST_F(LayerTransactionTest, SetSizeBasic) { |
| 550 | sp<SurfaceControl> layer; |
| 551 | ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32)); |
| 552 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 553 | |
| 554 | Transaction().setSize(layer, 64, 64).apply(); |
| 555 | { |
| 556 | SCOPED_TRACE("resize pending"); |
| 557 | auto shot = screenshot(); |
| 558 | shot->expectColor(Rect(0, 0, 32, 32), Color::RED); |
| 559 | shot->expectBorder(Rect(0, 0, 32, 32), Color::BLACK); |
| 560 | } |
| 561 | |
| 562 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 563 | { |
| 564 | SCOPED_TRACE("resize applied"); |
| 565 | auto shot = screenshot(); |
| 566 | shot->expectColor(Rect(0, 0, 64, 64), Color::RED); |
| 567 | shot->expectBorder(Rect(0, 0, 64, 64), Color::BLACK); |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | TEST_F(LayerTransactionTest, SetSizeInvalid) { |
| 572 | // cannot test robustness against invalid sizes (zero or really huge) |
| 573 | } |
| 574 | |
| 575 | TEST_F(LayerTransactionTest, SetSizeWithScaleToWindow) { |
| 576 | sp<SurfaceControl> layer; |
| 577 | ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", 32, 32)); |
| 578 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED)); |
| 579 | |
| 580 | // setSize is immediate with SCALE_TO_WINDOW, unlike setPosition |
| 581 | Transaction() |
| 582 | .setSize(layer, 64, 64) |
| 583 | .setOverrideScalingMode(layer, NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW) |
| 584 | .apply(); |
| 585 | screenshot()->expectColor(Rect(0, 0, 64, 64), Color::RED); |
| 586 | } |
| 587 | |
Chia-I Wu | 0ea0f82 | 2017-10-31 10:14:40 -0700 | [diff] [blame^] | 588 | TEST_F(LayerTransactionTest, SetZBasic) { |
| 589 | sp<SurfaceControl> layerR; |
| 590 | sp<SurfaceControl> layerG; |
| 591 | ASSERT_NO_FATAL_FAILURE(layerR = createLayer("test R", 32, 32)); |
| 592 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layerR, Color::RED)); |
| 593 | ASSERT_NO_FATAL_FAILURE(layerG = createLayer("test G", 32, 32)); |
| 594 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layerG, Color::GREEN)); |
| 595 | |
| 596 | Transaction().setLayer(layerR, mLayerZBase + 1).apply(); |
| 597 | { |
| 598 | SCOPED_TRACE("layerR"); |
| 599 | screenshot()->expectColor(Rect(0, 0, 32, 32), Color::RED); |
| 600 | } |
| 601 | |
| 602 | Transaction().setLayer(layerG, mLayerZBase + 2).apply(); |
| 603 | { |
| 604 | SCOPED_TRACE("layerG"); |
| 605 | screenshot()->expectColor(Rect(0, 0, 32, 32), Color::GREEN); |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | TEST_F(LayerTransactionTest, SetZNegative) { |
| 610 | sp<SurfaceControl> layerR; |
| 611 | sp<SurfaceControl> layerG; |
| 612 | ASSERT_NO_FATAL_FAILURE(layerR = createLayer("test R", 32, 32)); |
| 613 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layerR, Color::RED)); |
| 614 | ASSERT_NO_FATAL_FAILURE(layerG = createLayer("test G", 32, 32)); |
| 615 | ASSERT_NO_FATAL_FAILURE(fillLayerColor(layerG, Color::GREEN)); |
| 616 | |
| 617 | Transaction().setLayer(layerR, -1).setLayer(layerG, -2).apply(); |
| 618 | { |
| 619 | SCOPED_TRACE("layerR"); |
| 620 | sp<ScreenCapture> screenshot; |
| 621 | ScreenCapture::captureScreen(&screenshot, -2, -1); |
| 622 | screenshot->expectColor(Rect(0, 0, 32, 32), Color::RED); |
| 623 | } |
| 624 | |
| 625 | Transaction().setLayer(layerR, -3).apply(); |
| 626 | { |
| 627 | SCOPED_TRACE("layerG"); |
| 628 | sp<ScreenCapture> screenshot; |
| 629 | ScreenCapture::captureScreen(&screenshot, -3, -1); |
| 630 | screenshot->expectColor(Rect(0, 0, 32, 32), Color::GREEN); |
| 631 | } |
| 632 | } |
| 633 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 634 | class LayerUpdateTest : public ::testing::Test { |
| 635 | protected: |
| 636 | virtual void SetUp() { |
| 637 | mComposerClient = new SurfaceComposerClient; |
| 638 | ASSERT_EQ(NO_ERROR, mComposerClient->initCheck()); |
| 639 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 640 | sp<IBinder> display( |
| 641 | SurfaceComposerClient::getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain)); |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 642 | DisplayInfo info; |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 643 | SurfaceComposerClient::getDisplayInfo(display, &info); |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 644 | |
| 645 | ssize_t displayWidth = info.w; |
| 646 | ssize_t displayHeight = info.h; |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 647 | |
| 648 | // Background surface |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 649 | mBGSurfaceControl = |
| 650 | mComposerClient->createSurface(String8("BG Test Surface"), displayWidth, |
| 651 | displayHeight, PIXEL_FORMAT_RGBA_8888, 0); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 652 | ASSERT_TRUE(mBGSurfaceControl != NULL); |
| 653 | ASSERT_TRUE(mBGSurfaceControl->isValid()); |
| 654 | fillSurfaceRGBA8(mBGSurfaceControl, 63, 63, 195); |
| 655 | |
| 656 | // Foreground surface |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 657 | mFGSurfaceControl = mComposerClient->createSurface(String8("FG Test Surface"), 64, 64, |
| 658 | PIXEL_FORMAT_RGBA_8888, 0); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 659 | ASSERT_TRUE(mFGSurfaceControl != NULL); |
| 660 | ASSERT_TRUE(mFGSurfaceControl->isValid()); |
| 661 | |
| 662 | fillSurfaceRGBA8(mFGSurfaceControl, 195, 63, 63); |
| 663 | |
| 664 | // Synchronization surface |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 665 | mSyncSurfaceControl = mComposerClient->createSurface(String8("Sync Test Surface"), 1, 1, |
| 666 | PIXEL_FORMAT_RGBA_8888, 0); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 667 | ASSERT_TRUE(mSyncSurfaceControl != NULL); |
| 668 | ASSERT_TRUE(mSyncSurfaceControl->isValid()); |
| 669 | |
| 670 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 671 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 672 | asTransaction([&](Transaction& t) { |
| 673 | t.setDisplayLayerStack(display, 0); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 674 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 675 | t.setLayer(mBGSurfaceControl, INT32_MAX - 2).show(mBGSurfaceControl); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 676 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 677 | t.setLayer(mFGSurfaceControl, INT32_MAX - 1) |
| 678 | .setPosition(mFGSurfaceControl, 64, 64) |
| 679 | .show(mFGSurfaceControl); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 680 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 681 | t.setLayer(mSyncSurfaceControl, INT32_MAX - 1) |
| 682 | .setPosition(mSyncSurfaceControl, displayWidth - 2, displayHeight - 2) |
| 683 | .show(mSyncSurfaceControl); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 684 | }); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 685 | } |
| 686 | |
| 687 | virtual void TearDown() { |
| 688 | mComposerClient->dispose(); |
| 689 | mBGSurfaceControl = 0; |
| 690 | mFGSurfaceControl = 0; |
| 691 | mSyncSurfaceControl = 0; |
| 692 | mComposerClient = 0; |
| 693 | } |
| 694 | |
| 695 | void waitForPostedBuffers() { |
| 696 | // Since the sync surface is in synchronous mode (i.e. double buffered) |
| 697 | // posting three buffers to it should ensure that at least two |
| 698 | // SurfaceFlinger::handlePageFlip calls have been made, which should |
| 699 | // guaranteed that a buffer posted to another Surface has been retired. |
| 700 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 701 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 702 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 703 | } |
| 704 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 705 | void asTransaction(const std::function<void(Transaction&)>& exec) { |
| 706 | Transaction t; |
| 707 | exec(t); |
| 708 | t.apply(true); |
| 709 | } |
| 710 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 711 | sp<SurfaceComposerClient> mComposerClient; |
| 712 | sp<SurfaceControl> mBGSurfaceControl; |
| 713 | sp<SurfaceControl> mFGSurfaceControl; |
| 714 | |
| 715 | // This surface is used to ensure that the buffers posted to |
| 716 | // mFGSurfaceControl have been picked up by SurfaceFlinger. |
| 717 | sp<SurfaceControl> mSyncSurfaceControl; |
| 718 | }; |
| 719 | |
Robert Carr | 7f619b2 | 2017-11-06 12:56:35 -0800 | [diff] [blame] | 720 | TEST_F(LayerUpdateTest, RelativesAreNotDetached) { |
| 721 | sp<ScreenCapture> sc; |
| 722 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 723 | sp<SurfaceControl> relative = mComposerClient->createSurface(String8("relativeTestSurface"), 10, |
| 724 | 10, PIXEL_FORMAT_RGBA_8888, 0); |
Robert Carr | 7f619b2 | 2017-11-06 12:56:35 -0800 | [diff] [blame] | 725 | fillSurfaceRGBA8(relative, 10, 10, 10); |
| 726 | waitForPostedBuffers(); |
| 727 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 728 | Transaction{} |
| 729 | .setRelativeLayer(relative, mFGSurfaceControl->getHandle(), 1) |
Robert Carr | 7f619b2 | 2017-11-06 12:56:35 -0800 | [diff] [blame] | 730 | .setPosition(relative, 64, 64) |
| 731 | .apply(); |
| 732 | |
| 733 | { |
| 734 | // The relative should be on top of the FG control. |
| 735 | ScreenCapture::captureScreen(&sc); |
| 736 | sc->checkPixel(64, 64, 10, 10, 10); |
| 737 | } |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 738 | Transaction{}.detachChildren(mFGSurfaceControl).apply(); |
Robert Carr | 7f619b2 | 2017-11-06 12:56:35 -0800 | [diff] [blame] | 739 | |
| 740 | { |
| 741 | // Nothing should change at this point. |
| 742 | ScreenCapture::captureScreen(&sc); |
| 743 | sc->checkPixel(64, 64, 10, 10, 10); |
| 744 | } |
| 745 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 746 | Transaction{}.hide(relative).apply(); |
Robert Carr | 7f619b2 | 2017-11-06 12:56:35 -0800 | [diff] [blame] | 747 | |
| 748 | { |
| 749 | // Ensure that the relative was actually hidden, rather than |
| 750 | // being left in the detached but visible state. |
| 751 | ScreenCapture::captureScreen(&sc); |
| 752 | sc->expectFGColor(64, 64); |
| 753 | } |
| 754 | } |
| 755 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 756 | TEST_F(LayerUpdateTest, LayerMoveWorks) { |
| 757 | sp<ScreenCapture> sc; |
| 758 | { |
| 759 | SCOPED_TRACE("before move"); |
| 760 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 761 | sc->expectBGColor(0, 12); |
| 762 | sc->expectFGColor(75, 75); |
| 763 | sc->expectBGColor(145, 145); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 764 | } |
| 765 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 766 | asTransaction([&](Transaction& t) { t.setPosition(mFGSurfaceControl, 128, 128); }); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 767 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 768 | { |
| 769 | // This should reflect the new position, but not the new color. |
| 770 | SCOPED_TRACE("after move, before redraw"); |
| 771 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 772 | sc->expectBGColor(24, 24); |
| 773 | sc->expectBGColor(75, 75); |
| 774 | sc->expectFGColor(145, 145); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | fillSurfaceRGBA8(mFGSurfaceControl, 63, 195, 63); |
| 778 | waitForPostedBuffers(); |
| 779 | { |
| 780 | // This should reflect the new position and the new color. |
| 781 | SCOPED_TRACE("after redraw"); |
| 782 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 783 | sc->expectBGColor(24, 24); |
| 784 | sc->expectBGColor(75, 75); |
| 785 | sc->checkPixel(145, 145, 63, 195, 63); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 786 | } |
| 787 | } |
| 788 | |
| 789 | TEST_F(LayerUpdateTest, LayerResizeWorks) { |
| 790 | sp<ScreenCapture> sc; |
| 791 | { |
| 792 | SCOPED_TRACE("before resize"); |
| 793 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 794 | sc->expectBGColor(0, 12); |
| 795 | sc->expectFGColor(75, 75); |
| 796 | sc->expectBGColor(145, 145); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 797 | } |
| 798 | |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 799 | ALOGD("resizing"); |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 800 | asTransaction([&](Transaction& t) { t.setSize(mFGSurfaceControl, 128, 128); }); |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 801 | ALOGD("resized"); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 802 | { |
| 803 | // This should not reflect the new size or color because SurfaceFlinger |
| 804 | // has not yet received a buffer of the correct size. |
| 805 | SCOPED_TRACE("after resize, before redraw"); |
| 806 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 807 | sc->expectBGColor(0, 12); |
| 808 | sc->expectFGColor(75, 75); |
| 809 | sc->expectBGColor(145, 145); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 810 | } |
| 811 | |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 812 | ALOGD("drawing"); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 813 | fillSurfaceRGBA8(mFGSurfaceControl, 63, 195, 63); |
| 814 | waitForPostedBuffers(); |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 815 | ALOGD("drawn"); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 816 | { |
| 817 | // This should reflect the new size and the new color. |
| 818 | SCOPED_TRACE("after redraw"); |
| 819 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 820 | sc->expectBGColor(24, 24); |
| 821 | sc->checkPixel(75, 75, 63, 195, 63); |
| 822 | sc->checkPixel(145, 145, 63, 195, 63); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 823 | } |
| 824 | } |
| 825 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 826 | TEST_F(LayerUpdateTest, LayerCropWorks) { |
| 827 | sp<ScreenCapture> sc; |
| 828 | { |
| 829 | SCOPED_TRACE("before crop"); |
| 830 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 831 | sc->expectBGColor(24, 24); |
| 832 | sc->expectFGColor(75, 75); |
| 833 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 834 | } |
| 835 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 836 | asTransaction([&](Transaction& t) { |
| 837 | Rect cropRect(16, 16, 32, 32); |
| 838 | t.setCrop(mFGSurfaceControl, cropRect); |
| 839 | }); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 840 | { |
| 841 | // This should crop the foreground surface. |
| 842 | SCOPED_TRACE("after crop"); |
| 843 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 844 | sc->expectBGColor(24, 24); |
| 845 | sc->expectBGColor(75, 75); |
| 846 | sc->expectFGColor(95, 80); |
| 847 | sc->expectFGColor(80, 95); |
| 848 | sc->expectBGColor(96, 96); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 849 | } |
| 850 | } |
| 851 | |
Pablo Ceballos | acbe678 | 2016-03-04 17:54:21 +0000 | [diff] [blame] | 852 | TEST_F(LayerUpdateTest, LayerFinalCropWorks) { |
| 853 | sp<ScreenCapture> sc; |
| 854 | { |
| 855 | SCOPED_TRACE("before crop"); |
| 856 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 857 | sc->expectBGColor(24, 24); |
| 858 | sc->expectFGColor(75, 75); |
| 859 | sc->expectBGColor(145, 145); |
Pablo Ceballos | acbe678 | 2016-03-04 17:54:21 +0000 | [diff] [blame] | 860 | } |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 861 | asTransaction([&](Transaction& t) { |
| 862 | Rect cropRect(16, 16, 32, 32); |
| 863 | t.setFinalCrop(mFGSurfaceControl, cropRect); |
| 864 | }); |
Pablo Ceballos | acbe678 | 2016-03-04 17:54:21 +0000 | [diff] [blame] | 865 | { |
| 866 | // This should crop the foreground surface. |
| 867 | SCOPED_TRACE("after crop"); |
| 868 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 869 | sc->expectBGColor(24, 24); |
| 870 | sc->expectBGColor(75, 75); |
| 871 | sc->expectBGColor(95, 80); |
| 872 | sc->expectBGColor(80, 95); |
| 873 | sc->expectBGColor(96, 96); |
Pablo Ceballos | acbe678 | 2016-03-04 17:54:21 +0000 | [diff] [blame] | 874 | } |
| 875 | } |
| 876 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 877 | TEST_F(LayerUpdateTest, LayerSetLayerWorks) { |
| 878 | sp<ScreenCapture> sc; |
| 879 | { |
| 880 | SCOPED_TRACE("before setLayer"); |
| 881 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 882 | sc->expectBGColor(24, 24); |
| 883 | sc->expectFGColor(75, 75); |
| 884 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 885 | } |
| 886 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 887 | asTransaction([&](Transaction& t) { t.setLayer(mFGSurfaceControl, INT_MAX - 3); }); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 888 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 889 | { |
| 890 | // This should hide the foreground surface beneath the background. |
| 891 | SCOPED_TRACE("after setLayer"); |
| 892 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 893 | sc->expectBGColor(24, 24); |
| 894 | sc->expectBGColor(75, 75); |
| 895 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 896 | } |
| 897 | } |
| 898 | |
| 899 | TEST_F(LayerUpdateTest, LayerShowHideWorks) { |
| 900 | sp<ScreenCapture> sc; |
| 901 | { |
| 902 | SCOPED_TRACE("before hide"); |
| 903 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 904 | sc->expectBGColor(24, 24); |
| 905 | sc->expectFGColor(75, 75); |
| 906 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 907 | } |
| 908 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 909 | asTransaction([&](Transaction& t) { t.hide(mFGSurfaceControl); }); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 910 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 911 | { |
| 912 | // This should hide the foreground surface. |
| 913 | SCOPED_TRACE("after hide, before show"); |
| 914 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 915 | sc->expectBGColor(24, 24); |
| 916 | sc->expectBGColor(75, 75); |
| 917 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 918 | } |
| 919 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 920 | asTransaction([&](Transaction& t) { t.show(mFGSurfaceControl); }); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 921 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 922 | { |
| 923 | // This should show the foreground surface. |
| 924 | SCOPED_TRACE("after show"); |
| 925 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 926 | sc->expectBGColor(24, 24); |
| 927 | sc->expectFGColor(75, 75); |
| 928 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 929 | } |
| 930 | } |
| 931 | |
| 932 | TEST_F(LayerUpdateTest, LayerSetAlphaWorks) { |
| 933 | sp<ScreenCapture> sc; |
| 934 | { |
| 935 | SCOPED_TRACE("before setAlpha"); |
| 936 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 937 | sc->expectBGColor(24, 24); |
| 938 | sc->expectFGColor(75, 75); |
| 939 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 940 | } |
| 941 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 942 | asTransaction([&](Transaction& t) { t.setAlpha(mFGSurfaceControl, 0.75f); }); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 943 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 944 | { |
| 945 | // This should set foreground to be 75% opaque. |
| 946 | SCOPED_TRACE("after setAlpha"); |
| 947 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 948 | sc->expectBGColor(24, 24); |
| 949 | sc->checkPixel(75, 75, 162, 63, 96); |
| 950 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 951 | } |
| 952 | } |
| 953 | |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 954 | TEST_F(LayerUpdateTest, LayerSetLayerStackWorks) { |
| 955 | sp<ScreenCapture> sc; |
| 956 | { |
| 957 | SCOPED_TRACE("before setLayerStack"); |
| 958 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 959 | sc->expectBGColor(24, 24); |
| 960 | sc->expectFGColor(75, 75); |
| 961 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 962 | } |
| 963 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 964 | asTransaction([&](Transaction& t) { t.setLayerStack(mFGSurfaceControl, 1); }); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 965 | { |
| 966 | // This should hide the foreground surface since it goes to a different |
| 967 | // layer stack. |
| 968 | SCOPED_TRACE("after setLayerStack"); |
| 969 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 970 | sc->expectBGColor(24, 24); |
| 971 | sc->expectBGColor(75, 75); |
| 972 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 973 | } |
| 974 | } |
| 975 | |
| 976 | TEST_F(LayerUpdateTest, LayerSetFlagsWorks) { |
| 977 | sp<ScreenCapture> sc; |
| 978 | { |
| 979 | SCOPED_TRACE("before setFlags"); |
| 980 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 981 | sc->expectBGColor(24, 24); |
| 982 | sc->expectFGColor(75, 75); |
| 983 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 984 | } |
| 985 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 986 | asTransaction([&](Transaction& t) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 987 | t.setFlags(mFGSurfaceControl, layer_state_t::eLayerHidden, layer_state_t::eLayerHidden); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 988 | }); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 989 | { |
| 990 | // This should hide the foreground surface |
| 991 | SCOPED_TRACE("after setFlags"); |
| 992 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 993 | sc->expectBGColor(24, 24); |
| 994 | sc->expectBGColor(75, 75); |
| 995 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 996 | } |
| 997 | } |
| 998 | |
| 999 | TEST_F(LayerUpdateTest, LayerSetMatrixWorks) { |
| 1000 | sp<ScreenCapture> sc; |
| 1001 | { |
| 1002 | SCOPED_TRACE("before setMatrix"); |
| 1003 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 1004 | sc->expectBGColor(24, 24); |
| 1005 | sc->expectFGColor(91, 96); |
| 1006 | sc->expectFGColor(96, 101); |
| 1007 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1010 | asTransaction([&](Transaction& t) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1011 | t.setMatrix(mFGSurfaceControl, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2, M_SQRT1_2); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1012 | }); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 1013 | { |
| 1014 | SCOPED_TRACE("after setMatrix"); |
| 1015 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 1016 | sc->expectBGColor(24, 24); |
| 1017 | sc->expectFGColor(91, 96); |
| 1018 | sc->expectBGColor(96, 91); |
| 1019 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 1020 | } |
| 1021 | } |
| 1022 | |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 1023 | class GeometryLatchingTest : public LayerUpdateTest { |
| 1024 | protected: |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1025 | void EXPECT_INITIAL_STATE(const char* trace) { |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 1026 | SCOPED_TRACE(trace); |
| 1027 | ScreenCapture::captureScreen(&sc); |
| 1028 | // We find the leading edge of the FG surface. |
| 1029 | sc->expectFGColor(127, 127); |
| 1030 | sc->expectBGColor(128, 128); |
| 1031 | } |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 1032 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1033 | void lockAndFillFGBuffer() { fillSurfaceRGBA8(mFGSurfaceControl, 195, 63, 63, false); } |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 1034 | |
| 1035 | void unlockFGBuffer() { |
| 1036 | sp<Surface> s = mFGSurfaceControl->getSurface(); |
| 1037 | ASSERT_EQ(NO_ERROR, s->unlockAndPost()); |
| 1038 | waitForPostedBuffers(); |
| 1039 | } |
| 1040 | |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 1041 | void completeFGResize() { |
| 1042 | fillSurfaceRGBA8(mFGSurfaceControl, 195, 63, 63); |
| 1043 | waitForPostedBuffers(); |
| 1044 | } |
| 1045 | void restoreInitialState() { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1046 | asTransaction([&](Transaction& t) { |
| 1047 | t.setSize(mFGSurfaceControl, 64, 64); |
| 1048 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1049 | t.setCrop(mFGSurfaceControl, Rect(0, 0, 64, 64)); |
| 1050 | t.setFinalCrop(mFGSurfaceControl, Rect(0, 0, -1, -1)); |
| 1051 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 1052 | |
| 1053 | EXPECT_INITIAL_STATE("After restoring initial state"); |
| 1054 | } |
| 1055 | sp<ScreenCapture> sc; |
| 1056 | }; |
| 1057 | |
| 1058 | TEST_F(GeometryLatchingTest, SurfacePositionLatching) { |
| 1059 | EXPECT_INITIAL_STATE("before anything"); |
| 1060 | |
| 1061 | // By default position can be updated even while |
| 1062 | // a resize is pending. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1063 | asTransaction([&](Transaction& t) { |
| 1064 | t.setSize(mFGSurfaceControl, 32, 32); |
| 1065 | t.setPosition(mFGSurfaceControl, 100, 100); |
| 1066 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 1067 | |
| 1068 | { |
| 1069 | SCOPED_TRACE("After moving surface"); |
| 1070 | ScreenCapture::captureScreen(&sc); |
| 1071 | // If we moved, the FG Surface should cover up what was previously BG |
| 1072 | // however if we didn't move the FG wouldn't be large enough now. |
| 1073 | sc->expectFGColor(163, 163); |
| 1074 | } |
| 1075 | |
| 1076 | restoreInitialState(); |
| 1077 | |
| 1078 | // Now we repeat with setGeometryAppliesWithResize |
| 1079 | // and verify the position DOESN'T latch. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1080 | asTransaction([&](Transaction& t) { |
| 1081 | t.setGeometryAppliesWithResize(mFGSurfaceControl); |
| 1082 | t.setSize(mFGSurfaceControl, 32, 32); |
| 1083 | t.setPosition(mFGSurfaceControl, 100, 100); |
| 1084 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 1085 | |
| 1086 | { |
| 1087 | SCOPED_TRACE("While resize is pending"); |
| 1088 | ScreenCapture::captureScreen(&sc); |
| 1089 | // This time we shouldn't have moved, so the BG color |
| 1090 | // should still be visible. |
| 1091 | sc->expectBGColor(128, 128); |
| 1092 | } |
| 1093 | |
| 1094 | completeFGResize(); |
| 1095 | |
| 1096 | { |
| 1097 | SCOPED_TRACE("After the resize"); |
| 1098 | ScreenCapture::captureScreen(&sc); |
| 1099 | // But after the resize completes, we should move |
| 1100 | // and the FG should be visible here. |
| 1101 | sc->expectFGColor(128, 128); |
| 1102 | } |
| 1103 | } |
| 1104 | |
| 1105 | class CropLatchingTest : public GeometryLatchingTest { |
| 1106 | protected: |
| 1107 | void EXPECT_CROPPED_STATE(const char* trace) { |
| 1108 | SCOPED_TRACE(trace); |
| 1109 | ScreenCapture::captureScreen(&sc); |
| 1110 | // The edge should be moved back one pixel by our crop. |
| 1111 | sc->expectFGColor(126, 126); |
| 1112 | sc->expectBGColor(127, 127); |
| 1113 | sc->expectBGColor(128, 128); |
| 1114 | } |
chaviw | 59f5c56 | 2017-06-28 16:39:06 -0700 | [diff] [blame] | 1115 | |
| 1116 | void EXPECT_RESIZE_STATE(const char* trace) { |
| 1117 | SCOPED_TRACE(trace); |
| 1118 | ScreenCapture::captureScreen(&sc); |
| 1119 | // The FG is now resized too 128,128 at 64,64 |
| 1120 | sc->expectFGColor(64, 64); |
| 1121 | sc->expectFGColor(191, 191); |
| 1122 | sc->expectBGColor(192, 192); |
| 1123 | } |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 1124 | }; |
| 1125 | |
| 1126 | TEST_F(CropLatchingTest, CropLatching) { |
| 1127 | EXPECT_INITIAL_STATE("before anything"); |
| 1128 | // Normally the crop applies immediately even while a resize is pending. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1129 | asTransaction([&](Transaction& t) { |
| 1130 | t.setSize(mFGSurfaceControl, 128, 128); |
| 1131 | t.setCrop(mFGSurfaceControl, Rect(0, 0, 63, 63)); |
| 1132 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 1133 | |
| 1134 | EXPECT_CROPPED_STATE("after setting crop (without geometryAppliesWithResize)"); |
| 1135 | |
| 1136 | restoreInitialState(); |
| 1137 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1138 | asTransaction([&](Transaction& t) { |
| 1139 | t.setSize(mFGSurfaceControl, 128, 128); |
| 1140 | t.setGeometryAppliesWithResize(mFGSurfaceControl); |
| 1141 | t.setCrop(mFGSurfaceControl, Rect(0, 0, 63, 63)); |
| 1142 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 1143 | |
| 1144 | EXPECT_INITIAL_STATE("after setting crop (with geometryAppliesWithResize)"); |
| 1145 | |
| 1146 | completeFGResize(); |
| 1147 | |
| 1148 | EXPECT_CROPPED_STATE("after the resize finishes"); |
| 1149 | } |
| 1150 | |
| 1151 | TEST_F(CropLatchingTest, FinalCropLatching) { |
| 1152 | EXPECT_INITIAL_STATE("before anything"); |
| 1153 | // Normally the crop applies immediately even while a resize is pending. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1154 | asTransaction([&](Transaction& t) { |
| 1155 | t.setSize(mFGSurfaceControl, 128, 128); |
| 1156 | t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127)); |
| 1157 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 1158 | |
| 1159 | EXPECT_CROPPED_STATE("after setting crop (without geometryAppliesWithResize)"); |
| 1160 | |
| 1161 | restoreInitialState(); |
| 1162 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1163 | asTransaction([&](Transaction& t) { |
| 1164 | t.setSize(mFGSurfaceControl, 128, 128); |
| 1165 | t.setGeometryAppliesWithResize(mFGSurfaceControl); |
| 1166 | t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127)); |
| 1167 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 1168 | |
| 1169 | EXPECT_INITIAL_STATE("after setting crop (with geometryAppliesWithResize)"); |
| 1170 | |
| 1171 | completeFGResize(); |
| 1172 | |
| 1173 | EXPECT_CROPPED_STATE("after the resize finishes"); |
| 1174 | } |
| 1175 | |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 1176 | // In this test we ensure that setGeometryAppliesWithResize actually demands |
| 1177 | // a buffer of the new size, and not just any size. |
| 1178 | TEST_F(CropLatchingTest, FinalCropLatchingBufferOldSize) { |
| 1179 | EXPECT_INITIAL_STATE("before anything"); |
| 1180 | // Normally the crop applies immediately even while a resize is pending. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1181 | asTransaction([&](Transaction& t) { |
| 1182 | t.setSize(mFGSurfaceControl, 128, 128); |
| 1183 | t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127)); |
| 1184 | }); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 1185 | |
| 1186 | EXPECT_CROPPED_STATE("after setting crop (without geometryAppliesWithResize)"); |
| 1187 | |
| 1188 | restoreInitialState(); |
| 1189 | |
| 1190 | // In order to prepare to submit a buffer at the wrong size, we acquire it prior to |
| 1191 | // initiating the resize. |
| 1192 | lockAndFillFGBuffer(); |
| 1193 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1194 | asTransaction([&](Transaction& t) { |
| 1195 | t.setSize(mFGSurfaceControl, 128, 128); |
| 1196 | t.setGeometryAppliesWithResize(mFGSurfaceControl); |
| 1197 | t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127)); |
| 1198 | }); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 1199 | |
| 1200 | EXPECT_INITIAL_STATE("after setting crop (with geometryAppliesWithResize)"); |
| 1201 | |
| 1202 | // We now submit our old buffer, at the old size, and ensure it doesn't |
| 1203 | // trigger geometry latching. |
| 1204 | unlockFGBuffer(); |
| 1205 | |
| 1206 | EXPECT_INITIAL_STATE("after unlocking FG buffer (with geometryAppliesWithResize)"); |
| 1207 | |
| 1208 | completeFGResize(); |
| 1209 | |
| 1210 | EXPECT_CROPPED_STATE("after the resize finishes"); |
| 1211 | } |
| 1212 | |
| 1213 | TEST_F(CropLatchingTest, FinalCropLatchingRegressionForb37531386) { |
| 1214 | EXPECT_INITIAL_STATE("before anything"); |
| 1215 | // In this scenario, we attempt to set the final crop a second time while the resize |
| 1216 | // is still pending, and ensure we are successful. Success meaning the second crop |
| 1217 | // is the one which eventually latches and not the first. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1218 | asTransaction([&](Transaction& t) { |
| 1219 | t.setSize(mFGSurfaceControl, 128, 128); |
| 1220 | t.setGeometryAppliesWithResize(mFGSurfaceControl); |
| 1221 | t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127)); |
| 1222 | }); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 1223 | |
chaviw | 59f5c56 | 2017-06-28 16:39:06 -0700 | [diff] [blame] | 1224 | EXPECT_INITIAL_STATE("after setting crops with geometryAppliesWithResize"); |
| 1225 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1226 | asTransaction([&](Transaction& t) { t.setFinalCrop(mFGSurfaceControl, Rect(0, 0, -1, -1)); }); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 1227 | |
chaviw | 59f5c56 | 2017-06-28 16:39:06 -0700 | [diff] [blame] | 1228 | EXPECT_INITIAL_STATE("after setting another crop"); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 1229 | |
| 1230 | completeFGResize(); |
| 1231 | |
chaviw | 59f5c56 | 2017-06-28 16:39:06 -0700 | [diff] [blame] | 1232 | EXPECT_RESIZE_STATE("after the resize finishes"); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 1233 | } |
| 1234 | |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 1235 | TEST_F(LayerUpdateTest, DeferredTransactionTest) { |
| 1236 | sp<ScreenCapture> sc; |
| 1237 | { |
| 1238 | SCOPED_TRACE("before anything"); |
| 1239 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 1240 | sc->expectBGColor(32, 32); |
| 1241 | sc->expectFGColor(96, 96); |
| 1242 | sc->expectBGColor(160, 160); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 1243 | } |
| 1244 | |
| 1245 | // set up two deferred transactions on different frames |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1246 | asTransaction([&](Transaction& t) { |
| 1247 | t.setAlpha(mFGSurfaceControl, 0.75); |
| 1248 | t.deferTransactionUntil(mFGSurfaceControl, mSyncSurfaceControl->getHandle(), |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1249 | mSyncSurfaceControl->getSurface()->getNextFrameNumber()); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1250 | }); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 1251 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1252 | asTransaction([&](Transaction& t) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1253 | t.setPosition(mFGSurfaceControl, 128, 128); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1254 | t.deferTransactionUntil(mFGSurfaceControl, mSyncSurfaceControl->getHandle(), |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1255 | mSyncSurfaceControl->getSurface()->getNextFrameNumber() + 1); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1256 | }); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 1257 | |
| 1258 | { |
| 1259 | SCOPED_TRACE("before any trigger"); |
| 1260 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 1261 | sc->expectBGColor(32, 32); |
| 1262 | sc->expectFGColor(96, 96); |
| 1263 | sc->expectBGColor(160, 160); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 1264 | } |
| 1265 | |
| 1266 | // should trigger the first deferred transaction, but not the second one |
| 1267 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 1268 | { |
| 1269 | SCOPED_TRACE("after first trigger"); |
| 1270 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 1271 | sc->expectBGColor(32, 32); |
| 1272 | sc->checkPixel(96, 96, 162, 63, 96); |
| 1273 | sc->expectBGColor(160, 160); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 1274 | } |
| 1275 | |
| 1276 | // should show up immediately since it's not deferred |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1277 | asTransaction([&](Transaction& t) { t.setAlpha(mFGSurfaceControl, 1.0); }); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 1278 | |
| 1279 | // trigger the second deferred transaction |
| 1280 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 1281 | { |
| 1282 | SCOPED_TRACE("after second trigger"); |
| 1283 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 1284 | sc->expectBGColor(32, 32); |
| 1285 | sc->expectBGColor(96, 96); |
| 1286 | sc->expectFGColor(160, 160); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 1287 | } |
| 1288 | } |
| 1289 | |
Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 1290 | TEST_F(LayerUpdateTest, LayerSetRelativeLayerWorks) { |
| 1291 | sp<ScreenCapture> sc; |
| 1292 | { |
| 1293 | SCOPED_TRACE("before adding relative surface"); |
| 1294 | ScreenCapture::captureScreen(&sc); |
| 1295 | sc->expectBGColor(24, 24); |
| 1296 | sc->expectFGColor(75, 75); |
| 1297 | sc->expectBGColor(145, 145); |
| 1298 | } |
| 1299 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1300 | auto relativeSurfaceControl = mComposerClient->createSurface(String8("Test Surface"), 64, 64, |
| 1301 | PIXEL_FORMAT_RGBA_8888, 0); |
Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 1302 | fillSurfaceRGBA8(relativeSurfaceControl, 255, 177, 177); |
| 1303 | waitForPostedBuffers(); |
| 1304 | |
| 1305 | // Now we stack the surface above the foreground surface and make sure it is visible. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1306 | asTransaction([&](Transaction& t) { |
| 1307 | t.setPosition(relativeSurfaceControl, 64, 64); |
| 1308 | t.show(relativeSurfaceControl); |
| 1309 | t.setRelativeLayer(relativeSurfaceControl, mFGSurfaceControl->getHandle(), 1); |
| 1310 | }); |
Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 1311 | |
| 1312 | { |
| 1313 | SCOPED_TRACE("after adding relative surface"); |
| 1314 | ScreenCapture::captureScreen(&sc); |
| 1315 | // our relative surface should be visible now. |
| 1316 | sc->checkPixel(75, 75, 255, 177, 177); |
| 1317 | } |
| 1318 | |
| 1319 | // A call to setLayer will override a call to setRelativeLayer |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1320 | asTransaction([&](Transaction& t) { t.setLayer(relativeSurfaceControl, 0); }); |
Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 1321 | |
| 1322 | { |
| 1323 | SCOPED_TRACE("after set layer"); |
| 1324 | ScreenCapture::captureScreen(&sc); |
| 1325 | // now the FG surface should be visible again. |
| 1326 | sc->expectFGColor(75, 75); |
| 1327 | } |
| 1328 | } |
| 1329 | |
Robert Carr | e392b55 | 2017-09-19 12:16:05 -0700 | [diff] [blame] | 1330 | TEST_F(LayerUpdateTest, LayerWithNoBuffersResizesImmediately) { |
| 1331 | sp<ScreenCapture> sc; |
| 1332 | |
| 1333 | sp<SurfaceControl> childNoBuffer = |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1334 | mComposerClient->createSurface(String8("Bufferless child"), 10, 10, |
| 1335 | PIXEL_FORMAT_RGBA_8888, 0, mFGSurfaceControl.get()); |
| 1336 | sp<SurfaceControl> childBuffer = |
| 1337 | mComposerClient->createSurface(String8("Buffered child"), 20, 20, |
| 1338 | PIXEL_FORMAT_RGBA_8888, 0, childNoBuffer.get()); |
Robert Carr | e392b55 | 2017-09-19 12:16:05 -0700 | [diff] [blame] | 1339 | fillSurfaceRGBA8(childBuffer, 200, 200, 200); |
| 1340 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1341 | SurfaceComposerClient::Transaction{}.show(childNoBuffer).show(childBuffer).apply(true); |
Robert Carr | e392b55 | 2017-09-19 12:16:05 -0700 | [diff] [blame] | 1342 | |
| 1343 | { |
| 1344 | ScreenCapture::captureScreen(&sc); |
| 1345 | sc->expectChildColor(73, 73); |
| 1346 | sc->expectFGColor(74, 74); |
| 1347 | } |
| 1348 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1349 | SurfaceComposerClient::Transaction{}.setSize(childNoBuffer, 20, 20).apply(true); |
Robert Carr | e392b55 | 2017-09-19 12:16:05 -0700 | [diff] [blame] | 1350 | |
| 1351 | { |
| 1352 | ScreenCapture::captureScreen(&sc); |
| 1353 | sc->expectChildColor(73, 73); |
| 1354 | sc->expectChildColor(74, 74); |
| 1355 | } |
| 1356 | } |
| 1357 | |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 1358 | TEST_F(LayerUpdateTest, MergingTransactions) { |
| 1359 | sp<ScreenCapture> sc; |
| 1360 | { |
| 1361 | SCOPED_TRACE("before move"); |
| 1362 | ScreenCapture::captureScreen(&sc); |
| 1363 | sc->expectBGColor(0, 12); |
| 1364 | sc->expectFGColor(75, 75); |
| 1365 | sc->expectBGColor(145, 145); |
| 1366 | } |
| 1367 | |
| 1368 | Transaction t1, t2; |
| 1369 | t1.setPosition(mFGSurfaceControl, 128, 128); |
| 1370 | t2.setPosition(mFGSurfaceControl, 0, 0); |
| 1371 | // We expect that the position update from t2 now |
| 1372 | // overwrites the position update from t1. |
| 1373 | t1.merge(std::move(t2)); |
| 1374 | t1.apply(); |
| 1375 | |
| 1376 | { |
| 1377 | ScreenCapture::captureScreen(&sc); |
| 1378 | sc->expectFGColor(1, 1); |
| 1379 | } |
| 1380 | } |
| 1381 | |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 1382 | class ChildLayerTest : public LayerUpdateTest { |
| 1383 | protected: |
| 1384 | void SetUp() override { |
| 1385 | LayerUpdateTest::SetUp(); |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1386 | mChild = mComposerClient->createSurface(String8("Child surface"), 10, 10, |
| 1387 | PIXEL_FORMAT_RGBA_8888, 0, mFGSurfaceControl.get()); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 1388 | fillSurfaceRGBA8(mChild, 200, 200, 200); |
| 1389 | |
| 1390 | { |
| 1391 | SCOPED_TRACE("before anything"); |
| 1392 | ScreenCapture::captureScreen(&mCapture); |
| 1393 | mCapture->expectChildColor(64, 64); |
| 1394 | } |
| 1395 | } |
| 1396 | void TearDown() override { |
| 1397 | LayerUpdateTest::TearDown(); |
| 1398 | mChild = 0; |
| 1399 | } |
| 1400 | |
| 1401 | sp<SurfaceControl> mChild; |
| 1402 | sp<ScreenCapture> mCapture; |
| 1403 | }; |
| 1404 | |
| 1405 | TEST_F(ChildLayerTest, ChildLayerPositioning) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1406 | asTransaction([&](Transaction& t) { |
| 1407 | t.show(mChild); |
| 1408 | t.setPosition(mChild, 10, 10); |
| 1409 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1410 | }); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 1411 | |
| 1412 | { |
| 1413 | ScreenCapture::captureScreen(&mCapture); |
| 1414 | // Top left of foreground must now be visible |
| 1415 | mCapture->expectFGColor(64, 64); |
| 1416 | // But 10 pixels in we should see the child surface |
| 1417 | mCapture->expectChildColor(74, 74); |
| 1418 | // And 10 more pixels we should be back to the foreground surface |
| 1419 | mCapture->expectFGColor(84, 84); |
| 1420 | } |
| 1421 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1422 | asTransaction([&](Transaction& t) { t.setPosition(mFGSurfaceControl, 0, 0); }); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 1423 | |
| 1424 | { |
| 1425 | ScreenCapture::captureScreen(&mCapture); |
| 1426 | // Top left of foreground should now be at 0, 0 |
| 1427 | mCapture->expectFGColor(0, 0); |
| 1428 | // But 10 pixels in we should see the child surface |
| 1429 | mCapture->expectChildColor(10, 10); |
| 1430 | // And 10 more pixels we should be back to the foreground surface |
| 1431 | mCapture->expectFGColor(20, 20); |
| 1432 | } |
| 1433 | } |
| 1434 | |
Robert Carr | 41b08b5 | 2017-06-01 16:11:34 -0700 | [diff] [blame] | 1435 | TEST_F(ChildLayerTest, ChildLayerCropping) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1436 | asTransaction([&](Transaction& t) { |
| 1437 | t.show(mChild); |
| 1438 | t.setPosition(mChild, 0, 0); |
| 1439 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 1440 | t.setCrop(mFGSurfaceControl, Rect(0, 0, 5, 5)); |
| 1441 | }); |
Robert Carr | 41b08b5 | 2017-06-01 16:11:34 -0700 | [diff] [blame] | 1442 | |
| 1443 | { |
| 1444 | ScreenCapture::captureScreen(&mCapture); |
| 1445 | mCapture->expectChildColor(0, 0); |
| 1446 | mCapture->expectChildColor(4, 4); |
| 1447 | mCapture->expectBGColor(5, 5); |
| 1448 | } |
| 1449 | } |
| 1450 | |
| 1451 | TEST_F(ChildLayerTest, ChildLayerFinalCropping) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1452 | asTransaction([&](Transaction& t) { |
| 1453 | t.show(mChild); |
| 1454 | t.setPosition(mChild, 0, 0); |
| 1455 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 1456 | t.setFinalCrop(mFGSurfaceControl, Rect(0, 0, 5, 5)); |
| 1457 | }); |
Robert Carr | 41b08b5 | 2017-06-01 16:11:34 -0700 | [diff] [blame] | 1458 | |
| 1459 | { |
| 1460 | ScreenCapture::captureScreen(&mCapture); |
| 1461 | mCapture->expectChildColor(0, 0); |
| 1462 | mCapture->expectChildColor(4, 4); |
| 1463 | mCapture->expectBGColor(5, 5); |
| 1464 | } |
| 1465 | } |
| 1466 | |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 1467 | TEST_F(ChildLayerTest, ChildLayerConstraints) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1468 | asTransaction([&](Transaction& t) { |
| 1469 | t.show(mChild); |
| 1470 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 1471 | t.setPosition(mChild, 63, 63); |
| 1472 | }); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 1473 | |
| 1474 | { |
| 1475 | ScreenCapture::captureScreen(&mCapture); |
| 1476 | mCapture->expectFGColor(0, 0); |
| 1477 | // Last pixel in foreground should now be the child. |
| 1478 | mCapture->expectChildColor(63, 63); |
| 1479 | // But the child should be constrained and the next pixel |
| 1480 | // must be the background |
| 1481 | mCapture->expectBGColor(64, 64); |
| 1482 | } |
| 1483 | } |
| 1484 | |
| 1485 | TEST_F(ChildLayerTest, ChildLayerScaling) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1486 | asTransaction([&](Transaction& t) { t.setPosition(mFGSurfaceControl, 0, 0); }); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 1487 | |
| 1488 | // Find the boundary between the parent and child |
| 1489 | { |
| 1490 | ScreenCapture::captureScreen(&mCapture); |
| 1491 | mCapture->expectChildColor(9, 9); |
| 1492 | mCapture->expectFGColor(10, 10); |
| 1493 | } |
| 1494 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1495 | asTransaction([&](Transaction& t) { t.setMatrix(mFGSurfaceControl, 2.0, 0, 0, 2.0); }); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 1496 | |
| 1497 | // The boundary should be twice as far from the origin now. |
| 1498 | // The pixels from the last test should all be child now |
| 1499 | { |
| 1500 | ScreenCapture::captureScreen(&mCapture); |
| 1501 | mCapture->expectChildColor(9, 9); |
| 1502 | mCapture->expectChildColor(10, 10); |
| 1503 | mCapture->expectChildColor(19, 19); |
| 1504 | mCapture->expectFGColor(20, 20); |
| 1505 | } |
| 1506 | } |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1507 | |
Robert Carr | 6452f12 | 2017-03-21 10:41:29 -0700 | [diff] [blame] | 1508 | TEST_F(ChildLayerTest, ChildLayerAlpha) { |
| 1509 | fillSurfaceRGBA8(mBGSurfaceControl, 0, 0, 254); |
| 1510 | fillSurfaceRGBA8(mFGSurfaceControl, 254, 0, 0); |
| 1511 | fillSurfaceRGBA8(mChild, 0, 254, 0); |
| 1512 | waitForPostedBuffers(); |
| 1513 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1514 | asTransaction([&](Transaction& t) { |
| 1515 | t.show(mChild); |
| 1516 | t.setPosition(mChild, 0, 0); |
| 1517 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 1518 | }); |
Robert Carr | 6452f12 | 2017-03-21 10:41:29 -0700 | [diff] [blame] | 1519 | |
| 1520 | { |
| 1521 | ScreenCapture::captureScreen(&mCapture); |
| 1522 | // Unblended child color |
| 1523 | mCapture->checkPixel(0, 0, 0, 254, 0); |
| 1524 | } |
| 1525 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1526 | asTransaction([&](Transaction& t) { t.setAlpha(mChild, 0.5); }); |
Robert Carr | 6452f12 | 2017-03-21 10:41:29 -0700 | [diff] [blame] | 1527 | |
| 1528 | { |
| 1529 | ScreenCapture::captureScreen(&mCapture); |
| 1530 | // Child and BG blended. |
| 1531 | mCapture->checkPixel(0, 0, 127, 127, 0); |
| 1532 | } |
| 1533 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1534 | asTransaction([&](Transaction& t) { t.setAlpha(mFGSurfaceControl, 0.5); }); |
Robert Carr | 6452f12 | 2017-03-21 10:41:29 -0700 | [diff] [blame] | 1535 | |
| 1536 | { |
| 1537 | ScreenCapture::captureScreen(&mCapture); |
| 1538 | // Child and BG blended. |
| 1539 | mCapture->checkPixel(0, 0, 95, 64, 95); |
| 1540 | } |
| 1541 | } |
| 1542 | |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1543 | TEST_F(ChildLayerTest, ReparentChildren) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1544 | asTransaction([&](Transaction& t) { |
| 1545 | t.show(mChild); |
| 1546 | t.setPosition(mChild, 10, 10); |
| 1547 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1548 | }); |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1549 | |
| 1550 | { |
| 1551 | ScreenCapture::captureScreen(&mCapture); |
| 1552 | // Top left of foreground must now be visible |
| 1553 | mCapture->expectFGColor(64, 64); |
| 1554 | // But 10 pixels in we should see the child surface |
| 1555 | mCapture->expectChildColor(74, 74); |
| 1556 | // And 10 more pixels we should be back to the foreground surface |
| 1557 | mCapture->expectFGColor(84, 84); |
| 1558 | } |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1559 | |
| 1560 | asTransaction([&](Transaction& t) { |
| 1561 | t.reparentChildren(mFGSurfaceControl, mBGSurfaceControl->getHandle()); |
| 1562 | }); |
| 1563 | |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1564 | { |
| 1565 | ScreenCapture::captureScreen(&mCapture); |
| 1566 | mCapture->expectFGColor(64, 64); |
| 1567 | // In reparenting we should have exposed the entire foreground surface. |
| 1568 | mCapture->expectFGColor(74, 74); |
| 1569 | // And the child layer should now begin at 10, 10 (since the BG |
| 1570 | // layer is at (0, 0)). |
| 1571 | mCapture->expectBGColor(9, 9); |
| 1572 | mCapture->expectChildColor(10, 10); |
| 1573 | } |
| 1574 | } |
| 1575 | |
chaviw | 161410b0 | 2017-07-27 10:46:08 -0700 | [diff] [blame] | 1576 | TEST_F(ChildLayerTest, DetachChildrenSameClient) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1577 | asTransaction([&](Transaction& t) { |
| 1578 | t.show(mChild); |
| 1579 | t.setPosition(mChild, 10, 10); |
| 1580 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1581 | }); |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1582 | |
| 1583 | { |
| 1584 | ScreenCapture::captureScreen(&mCapture); |
| 1585 | // Top left of foreground must now be visible |
| 1586 | mCapture->expectFGColor(64, 64); |
| 1587 | // But 10 pixels in we should see the child surface |
| 1588 | mCapture->expectChildColor(74, 74); |
| 1589 | // And 10 more pixels we should be back to the foreground surface |
| 1590 | mCapture->expectFGColor(84, 84); |
| 1591 | } |
| 1592 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1593 | asTransaction([&](Transaction& t) { t.detachChildren(mFGSurfaceControl); }); |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1594 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1595 | asTransaction([&](Transaction& t) { t.hide(mChild); }); |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1596 | |
chaviw | 161410b0 | 2017-07-27 10:46:08 -0700 | [diff] [blame] | 1597 | // Since the child has the same client as the parent, it will not get |
| 1598 | // detached and will be hidden. |
| 1599 | { |
| 1600 | ScreenCapture::captureScreen(&mCapture); |
| 1601 | mCapture->expectFGColor(64, 64); |
| 1602 | mCapture->expectFGColor(74, 74); |
| 1603 | mCapture->expectFGColor(84, 84); |
| 1604 | } |
| 1605 | } |
| 1606 | |
| 1607 | TEST_F(ChildLayerTest, DetachChildrenDifferentClient) { |
| 1608 | sp<SurfaceComposerClient> mNewComposerClient = new SurfaceComposerClient; |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1609 | sp<SurfaceControl> mChildNewClient = |
| 1610 | mNewComposerClient->createSurface(String8("New Child Test Surface"), 10, 10, |
| 1611 | PIXEL_FORMAT_RGBA_8888, 0, mFGSurfaceControl.get()); |
chaviw | 161410b0 | 2017-07-27 10:46:08 -0700 | [diff] [blame] | 1612 | |
| 1613 | ASSERT_TRUE(mChildNewClient != NULL); |
| 1614 | ASSERT_TRUE(mChildNewClient->isValid()); |
| 1615 | |
| 1616 | fillSurfaceRGBA8(mChildNewClient, 200, 200, 200); |
| 1617 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1618 | asTransaction([&](Transaction& t) { |
| 1619 | t.hide(mChild); |
| 1620 | t.show(mChildNewClient); |
| 1621 | t.setPosition(mChildNewClient, 10, 10); |
| 1622 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1623 | }); |
chaviw | 161410b0 | 2017-07-27 10:46:08 -0700 | [diff] [blame] | 1624 | |
| 1625 | { |
| 1626 | ScreenCapture::captureScreen(&mCapture); |
| 1627 | // Top left of foreground must now be visible |
| 1628 | mCapture->expectFGColor(64, 64); |
| 1629 | // But 10 pixels in we should see the child surface |
| 1630 | mCapture->expectChildColor(74, 74); |
| 1631 | // And 10 more pixels we should be back to the foreground surface |
| 1632 | mCapture->expectFGColor(84, 84); |
| 1633 | } |
| 1634 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1635 | asTransaction([&](Transaction& t) { t.detachChildren(mFGSurfaceControl); }); |
chaviw | 161410b0 | 2017-07-27 10:46:08 -0700 | [diff] [blame] | 1636 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1637 | asTransaction([&](Transaction& t) { t.hide(mChildNewClient); }); |
chaviw | 161410b0 | 2017-07-27 10:46:08 -0700 | [diff] [blame] | 1638 | |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1639 | // Nothing should have changed. |
| 1640 | { |
| 1641 | ScreenCapture::captureScreen(&mCapture); |
| 1642 | mCapture->expectFGColor(64, 64); |
| 1643 | mCapture->expectChildColor(74, 74); |
| 1644 | mCapture->expectFGColor(84, 84); |
| 1645 | } |
| 1646 | } |
| 1647 | |
Robert Carr | 9b429f4 | 2017-04-17 14:56:57 -0700 | [diff] [blame] | 1648 | TEST_F(ChildLayerTest, ChildrenInheritNonTransformScalingFromParent) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1649 | asTransaction([&](Transaction& t) { |
| 1650 | t.show(mChild); |
| 1651 | t.setPosition(mChild, 0, 0); |
| 1652 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 1653 | }); |
Robert Carr | 9b429f4 | 2017-04-17 14:56:57 -0700 | [diff] [blame] | 1654 | |
| 1655 | { |
| 1656 | ScreenCapture::captureScreen(&mCapture); |
| 1657 | // We've positioned the child in the top left. |
| 1658 | mCapture->expectChildColor(0, 0); |
| 1659 | // But it's only 10x10. |
| 1660 | mCapture->expectFGColor(10, 10); |
| 1661 | } |
| 1662 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1663 | asTransaction([&](Transaction& t) { |
| 1664 | t.setOverrideScalingMode(mFGSurfaceControl, NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW); |
| 1665 | // We cause scaling by 2. |
| 1666 | t.setSize(mFGSurfaceControl, 128, 128); |
| 1667 | }); |
Robert Carr | 9b429f4 | 2017-04-17 14:56:57 -0700 | [diff] [blame] | 1668 | |
| 1669 | { |
| 1670 | ScreenCapture::captureScreen(&mCapture); |
| 1671 | // We've positioned the child in the top left. |
| 1672 | mCapture->expectChildColor(0, 0); |
| 1673 | mCapture->expectChildColor(10, 10); |
| 1674 | mCapture->expectChildColor(19, 19); |
| 1675 | // And now it should be scaled all the way to 20x20 |
| 1676 | mCapture->expectFGColor(20, 20); |
| 1677 | } |
| 1678 | } |
| 1679 | |
Robert Carr | 1725eee | 2017-04-26 18:32:15 -0700 | [diff] [blame] | 1680 | // Regression test for b/37673612 |
| 1681 | TEST_F(ChildLayerTest, ChildrenWithParentBufferTransform) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1682 | asTransaction([&](Transaction& t) { |
| 1683 | t.show(mChild); |
| 1684 | t.setPosition(mChild, 0, 0); |
| 1685 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 1686 | }); |
Robert Carr | 1725eee | 2017-04-26 18:32:15 -0700 | [diff] [blame] | 1687 | |
| 1688 | { |
| 1689 | ScreenCapture::captureScreen(&mCapture); |
| 1690 | // We've positioned the child in the top left. |
| 1691 | mCapture->expectChildColor(0, 0); |
| 1692 | // But it's only 10x10. |
| 1693 | mCapture->expectFGColor(10, 10); |
| 1694 | } |
Robert Carr | 1725eee | 2017-04-26 18:32:15 -0700 | [diff] [blame] | 1695 | // We set things up as in b/37673612 so that there is a mismatch between the buffer size and |
| 1696 | // the WM specified state size. |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1697 | asTransaction([&](Transaction& t) { t.setSize(mFGSurfaceControl, 128, 64); }); |
Robert Carr | 1725eee | 2017-04-26 18:32:15 -0700 | [diff] [blame] | 1698 | sp<Surface> s = mFGSurfaceControl->getSurface(); |
| 1699 | auto anw = static_cast<ANativeWindow*>(s.get()); |
| 1700 | native_window_set_buffers_transform(anw, NATIVE_WINDOW_TRANSFORM_ROT_90); |
| 1701 | native_window_set_buffers_dimensions(anw, 64, 128); |
| 1702 | fillSurfaceRGBA8(mFGSurfaceControl, 195, 63, 63); |
| 1703 | waitForPostedBuffers(); |
| 1704 | |
| 1705 | { |
| 1706 | // The child should still be in the same place and not have any strange scaling as in |
| 1707 | // b/37673612. |
| 1708 | ScreenCapture::captureScreen(&mCapture); |
| 1709 | mCapture->expectChildColor(0, 0); |
| 1710 | mCapture->expectFGColor(10, 10); |
| 1711 | } |
| 1712 | } |
| 1713 | |
Dan Stoza | 412903f | 2017-04-27 13:42:17 -0700 | [diff] [blame] | 1714 | TEST_F(ChildLayerTest, Bug36858924) { |
| 1715 | // Destroy the child layer |
| 1716 | mChild.clear(); |
| 1717 | |
| 1718 | // Now recreate it as hidden |
| 1719 | mChild = mComposerClient->createSurface(String8("Child surface"), 10, 10, |
| 1720 | PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eHidden, |
| 1721 | mFGSurfaceControl.get()); |
| 1722 | |
| 1723 | // Show the child layer in a deferred transaction |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1724 | asTransaction([&](Transaction& t) { |
| 1725 | t.deferTransactionUntil(mChild, mFGSurfaceControl->getHandle(), |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1726 | mFGSurfaceControl->getSurface()->getNextFrameNumber()); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1727 | t.show(mChild); |
| 1728 | }); |
Dan Stoza | 412903f | 2017-04-27 13:42:17 -0700 | [diff] [blame] | 1729 | |
| 1730 | // Render the foreground surface a few times |
| 1731 | // |
| 1732 | // Prior to the bugfix for b/36858924, this would usually hang while trying to fill the third |
| 1733 | // frame because SurfaceFlinger would never process the deferred transaction and would therefore |
| 1734 | // never acquire/release the first buffer |
| 1735 | ALOGI("Filling 1"); |
| 1736 | fillSurfaceRGBA8(mFGSurfaceControl, 0, 255, 0); |
| 1737 | ALOGI("Filling 2"); |
| 1738 | fillSurfaceRGBA8(mFGSurfaceControl, 0, 0, 255); |
| 1739 | ALOGI("Filling 3"); |
| 1740 | fillSurfaceRGBA8(mFGSurfaceControl, 255, 0, 0); |
| 1741 | ALOGI("Filling 4"); |
| 1742 | fillSurfaceRGBA8(mFGSurfaceControl, 0, 255, 0); |
| 1743 | } |
| 1744 | |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1745 | TEST_F(ChildLayerTest, Reparent) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1746 | asTransaction([&](Transaction& t) { |
| 1747 | t.show(mChild); |
| 1748 | t.setPosition(mChild, 10, 10); |
| 1749 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1750 | }); |
chaviw | 0617894 | 2017-07-27 10:25:59 -0700 | [diff] [blame] | 1751 | |
| 1752 | { |
| 1753 | ScreenCapture::captureScreen(&mCapture); |
| 1754 | // Top left of foreground must now be visible |
| 1755 | mCapture->expectFGColor(64, 64); |
| 1756 | // But 10 pixels in we should see the child surface |
| 1757 | mCapture->expectChildColor(74, 74); |
| 1758 | // And 10 more pixels we should be back to the foreground surface |
| 1759 | mCapture->expectFGColor(84, 84); |
| 1760 | } |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1761 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1762 | asTransaction([&](Transaction& t) { t.reparent(mChild, mBGSurfaceControl->getHandle()); }); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1763 | |
chaviw | 0617894 | 2017-07-27 10:25:59 -0700 | [diff] [blame] | 1764 | { |
| 1765 | ScreenCapture::captureScreen(&mCapture); |
| 1766 | mCapture->expectFGColor(64, 64); |
| 1767 | // In reparenting we should have exposed the entire foreground surface. |
| 1768 | mCapture->expectFGColor(74, 74); |
| 1769 | // And the child layer should now begin at 10, 10 (since the BG |
| 1770 | // layer is at (0, 0)). |
| 1771 | mCapture->expectBGColor(9, 9); |
| 1772 | mCapture->expectChildColor(10, 10); |
| 1773 | } |
| 1774 | } |
| 1775 | |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1776 | TEST_F(ChildLayerTest, ReparentToNoParent) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1777 | asTransaction([&](Transaction& t) { |
| 1778 | t.show(mChild); |
| 1779 | t.setPosition(mChild, 10, 10); |
| 1780 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1781 | }); |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1782 | |
| 1783 | { |
| 1784 | ScreenCapture::captureScreen(&mCapture); |
| 1785 | // Top left of foreground must now be visible |
| 1786 | mCapture->expectFGColor(64, 64); |
| 1787 | // But 10 pixels in we should see the child surface |
| 1788 | mCapture->expectChildColor(74, 74); |
| 1789 | // And 10 more pixels we should be back to the foreground surface |
| 1790 | mCapture->expectFGColor(84, 84); |
| 1791 | } |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1792 | asTransaction([&](Transaction& t) { t.reparent(mChild, nullptr); }); |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1793 | { |
| 1794 | ScreenCapture::captureScreen(&mCapture); |
| 1795 | // Nothing should have changed. |
| 1796 | mCapture->expectFGColor(64, 64); |
| 1797 | mCapture->expectChildColor(74, 74); |
| 1798 | mCapture->expectFGColor(84, 84); |
| 1799 | } |
| 1800 | } |
| 1801 | |
| 1802 | TEST_F(ChildLayerTest, ReparentFromNoParent) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1803 | sp<SurfaceControl> newSurface = mComposerClient->createSurface(String8("New Surface"), 10, 10, |
| 1804 | PIXEL_FORMAT_RGBA_8888, 0); |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1805 | ASSERT_TRUE(newSurface != NULL); |
| 1806 | ASSERT_TRUE(newSurface->isValid()); |
| 1807 | |
| 1808 | fillSurfaceRGBA8(newSurface, 63, 195, 63); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1809 | asTransaction([&](Transaction& t) { |
| 1810 | t.hide(mChild); |
| 1811 | t.show(newSurface); |
| 1812 | t.setPosition(newSurface, 10, 10); |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1813 | t.setLayer(newSurface, INT32_MAX - 2); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1814 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1815 | }); |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1816 | |
| 1817 | { |
| 1818 | ScreenCapture::captureScreen(&mCapture); |
| 1819 | // Top left of foreground must now be visible |
| 1820 | mCapture->expectFGColor(64, 64); |
| 1821 | // At 10, 10 we should see the new surface |
| 1822 | mCapture->checkPixel(10, 10, 63, 195, 63); |
| 1823 | } |
| 1824 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1825 | asTransaction([&](Transaction& t) { t.reparent(newSurface, mFGSurfaceControl->getHandle()); }); |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1826 | |
| 1827 | { |
| 1828 | ScreenCapture::captureScreen(&mCapture); |
| 1829 | // newSurface will now be a child of mFGSurface so it will be 10, 10 offset from |
| 1830 | // mFGSurface, putting it at 74, 74. |
| 1831 | mCapture->expectFGColor(64, 64); |
| 1832 | mCapture->checkPixel(74, 74, 63, 195, 63); |
| 1833 | mCapture->expectFGColor(84, 84); |
| 1834 | } |
| 1835 | } |
| 1836 | |
chaviw | c967433 | 2017-08-28 12:32:18 -0700 | [diff] [blame] | 1837 | TEST_F(ChildLayerTest, NestedChildren) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1838 | sp<SurfaceControl> grandchild = |
| 1839 | mComposerClient->createSurface(String8("Grandchild surface"), 10, 10, |
| 1840 | PIXEL_FORMAT_RGBA_8888, 0, mChild.get()); |
chaviw | c967433 | 2017-08-28 12:32:18 -0700 | [diff] [blame] | 1841 | fillSurfaceRGBA8(grandchild, 50, 50, 50); |
| 1842 | |
| 1843 | { |
| 1844 | ScreenCapture::captureScreen(&mCapture); |
| 1845 | // Expect the grandchild to begin at 64, 64 because it's a child of mChild layer |
| 1846 | // which begins at 64, 64 |
| 1847 | mCapture->checkPixel(64, 64, 50, 50, 50); |
| 1848 | } |
| 1849 | } |
| 1850 | |
Robert Carr | 503c704 | 2017-09-27 15:06:08 -0700 | [diff] [blame] | 1851 | TEST_F(ChildLayerTest, ChildLayerRelativeLayer) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1852 | sp<SurfaceControl> relative = mComposerClient->createSurface(String8("Relative surface"), 128, |
| 1853 | 128, PIXEL_FORMAT_RGBA_8888, 0); |
Robert Carr | 503c704 | 2017-09-27 15:06:08 -0700 | [diff] [blame] | 1854 | fillSurfaceRGBA8(relative, 255, 255, 255); |
| 1855 | |
| 1856 | Transaction t; |
| 1857 | t.setLayer(relative, INT32_MAX) |
| 1858 | .setRelativeLayer(mChild, relative->getHandle(), 1) |
| 1859 | .setPosition(mFGSurfaceControl, 0, 0) |
| 1860 | .apply(true); |
| 1861 | |
| 1862 | // We expect that the child should have been elevated above our |
| 1863 | // INT_MAX layer even though it's not a child of it. |
| 1864 | { |
| 1865 | ScreenCapture::captureScreen(&mCapture); |
| 1866 | mCapture->expectChildColor(0, 0); |
| 1867 | mCapture->expectChildColor(9, 9); |
| 1868 | mCapture->checkPixel(10, 10, 255, 255, 255); |
| 1869 | } |
| 1870 | } |
| 1871 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1872 | class LayerColorTest : public LayerUpdateTest { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1873 | protected: |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1874 | void SetUp() override { |
| 1875 | LayerUpdateTest::SetUp(); |
| 1876 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1877 | mLayerColorControl = |
| 1878 | mComposerClient->createSurface(String8("Layer color surface"), 128, 128, |
| 1879 | PIXEL_FORMAT_RGBA_8888, |
| 1880 | ISurfaceComposerClient::eFXSurfaceColor); |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1881 | |
| 1882 | ASSERT_TRUE(mLayerColorControl != NULL); |
| 1883 | ASSERT_TRUE(mLayerColorControl->isValid()); |
| 1884 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1885 | asTransaction([&](Transaction& t) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1886 | t.setLayer(mLayerColorControl, INT32_MAX - 1); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1887 | t.setPosition(mLayerColorControl, 140, 140); |
| 1888 | t.hide(mLayerColorControl); |
| 1889 | t.hide(mFGSurfaceControl); |
| 1890 | }); |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1891 | } |
| 1892 | |
| 1893 | void TearDown() override { |
| 1894 | LayerUpdateTest::TearDown(); |
| 1895 | mLayerColorControl = 0; |
| 1896 | } |
| 1897 | |
| 1898 | sp<SurfaceControl> mLayerColorControl; |
| 1899 | }; |
| 1900 | |
| 1901 | TEST_F(LayerColorTest, ColorLayerNoAlpha) { |
| 1902 | sp<ScreenCapture> sc; |
| 1903 | |
| 1904 | { |
| 1905 | SCOPED_TRACE("before setColor"); |
| 1906 | ScreenCapture::captureScreen(&sc); |
| 1907 | sc->expectBGColor(145, 145); |
| 1908 | } |
| 1909 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1910 | asTransaction([&](Transaction& t) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1911 | half3 color(43.0f / 255.0f, 207.0f / 255.0f, 131.0f / 255.0f); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1912 | t.setColor(mLayerColorControl, color); |
| 1913 | t.show(mLayerColorControl); |
| 1914 | }); |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1915 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1916 | { |
| 1917 | // There should now be a color |
| 1918 | SCOPED_TRACE("after setColor"); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1919 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1920 | ScreenCapture::captureScreen(&sc); |
| 1921 | sc->checkPixel(145, 145, 43, 207, 131); |
| 1922 | } |
| 1923 | } |
| 1924 | |
| 1925 | TEST_F(LayerColorTest, ColorLayerWithAlpha) { |
| 1926 | sp<ScreenCapture> sc; |
| 1927 | { |
| 1928 | SCOPED_TRACE("before setColor"); |
| 1929 | ScreenCapture::captureScreen(&sc); |
| 1930 | sc->expectBGColor(145, 145); |
| 1931 | } |
| 1932 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1933 | asTransaction([&](Transaction& t) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1934 | half3 color(43.0f / 255.0f, 207.0f / 255.0f, 131.0f / 255.0f); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1935 | t.setColor(mLayerColorControl, color); |
| 1936 | t.setAlpha(mLayerColorControl, .75f); |
| 1937 | t.show(mLayerColorControl); |
| 1938 | }); |
| 1939 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1940 | { |
| 1941 | // There should now be a color with .75 alpha |
| 1942 | SCOPED_TRACE("after setColor"); |
| 1943 | ScreenCapture::captureScreen(&sc); |
| 1944 | sc->checkPixel(145, 145, 48, 171, 147); |
| 1945 | } |
| 1946 | } |
| 1947 | |
| 1948 | TEST_F(LayerColorTest, ColorLayerWithNoColor) { |
| 1949 | sp<ScreenCapture> sc; |
| 1950 | { |
| 1951 | SCOPED_TRACE("before setColor"); |
| 1952 | ScreenCapture::captureScreen(&sc); |
| 1953 | sc->expectBGColor(145, 145); |
| 1954 | } |
| 1955 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1956 | asTransaction([&](Transaction& t) { t.show(mLayerColorControl); }); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 1957 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1958 | { |
| 1959 | // There should now be set to 0,0,0 (black) as default. |
| 1960 | SCOPED_TRACE("after setColor"); |
| 1961 | ScreenCapture::captureScreen(&sc); |
| 1962 | sc->checkPixel(145, 145, 0, 0, 0); |
| 1963 | } |
| 1964 | } |
| 1965 | |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1966 | class ScreenCaptureTest : public LayerUpdateTest { |
| 1967 | protected: |
| 1968 | std::unique_ptr<CaptureLayer> mCapture; |
| 1969 | }; |
| 1970 | |
| 1971 | TEST_F(ScreenCaptureTest, CaptureSingleLayer) { |
| 1972 | auto bgHandle = mBGSurfaceControl->getHandle(); |
| 1973 | CaptureLayer::captureScreen(&mCapture, bgHandle); |
| 1974 | mCapture->expectBGColor(0, 0); |
| 1975 | // Doesn't capture FG layer which is at 64, 64 |
| 1976 | mCapture->expectBGColor(64, 64); |
| 1977 | } |
| 1978 | |
| 1979 | TEST_F(ScreenCaptureTest, CaptureLayerWithChild) { |
| 1980 | auto fgHandle = mFGSurfaceControl->getHandle(); |
| 1981 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1982 | sp<SurfaceControl> child = |
| 1983 | mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888, |
| 1984 | 0, mFGSurfaceControl.get()); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1985 | fillSurfaceRGBA8(child, 200, 200, 200); |
| 1986 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1987 | SurfaceComposerClient::Transaction().show(child).apply(true); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1988 | |
| 1989 | // Captures mFGSurfaceControl layer and its child. |
| 1990 | CaptureLayer::captureScreen(&mCapture, fgHandle); |
| 1991 | mCapture->expectFGColor(10, 10); |
| 1992 | mCapture->expectChildColor(0, 0); |
| 1993 | } |
| 1994 | |
| 1995 | TEST_F(ScreenCaptureTest, CaptureLayerWithGrandchild) { |
| 1996 | auto fgHandle = mFGSurfaceControl->getHandle(); |
| 1997 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 1998 | sp<SurfaceControl> child = |
| 1999 | mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888, |
| 2000 | 0, mFGSurfaceControl.get()); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 2001 | fillSurfaceRGBA8(child, 200, 200, 200); |
| 2002 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 2003 | sp<SurfaceControl> grandchild = |
| 2004 | mComposerClient->createSurface(String8("Grandchild surface"), 5, 5, |
| 2005 | PIXEL_FORMAT_RGBA_8888, 0, child.get()); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 2006 | |
| 2007 | fillSurfaceRGBA8(grandchild, 50, 50, 50); |
| 2008 | SurfaceComposerClient::Transaction() |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 2009 | .show(child) |
| 2010 | .setPosition(grandchild, 5, 5) |
| 2011 | .show(grandchild) |
| 2012 | .apply(true); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 2013 | |
| 2014 | // Captures mFGSurfaceControl, its child, and the grandchild. |
| 2015 | CaptureLayer::captureScreen(&mCapture, fgHandle); |
| 2016 | mCapture->expectFGColor(10, 10); |
| 2017 | mCapture->expectChildColor(0, 0); |
| 2018 | mCapture->checkPixel(5, 5, 50, 50, 50); |
| 2019 | } |
| 2020 | |
| 2021 | TEST_F(ScreenCaptureTest, CaptureChildOnly) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 2022 | sp<SurfaceControl> child = |
| 2023 | mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888, |
| 2024 | 0, mFGSurfaceControl.get()); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 2025 | fillSurfaceRGBA8(child, 200, 200, 200); |
| 2026 | auto childHandle = child->getHandle(); |
| 2027 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 2028 | SurfaceComposerClient::Transaction().setPosition(child, 5, 5).show(child).apply(true); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 2029 | |
| 2030 | // Captures only the child layer, and not the parent. |
| 2031 | CaptureLayer::captureScreen(&mCapture, childHandle); |
| 2032 | mCapture->expectChildColor(0, 0); |
| 2033 | mCapture->expectChildColor(9, 9); |
| 2034 | } |
| 2035 | |
| 2036 | TEST_F(ScreenCaptureTest, CaptureGrandchildOnly) { |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 2037 | sp<SurfaceControl> child = |
| 2038 | mComposerClient->createSurface(String8("Child surface"), 10, 10, PIXEL_FORMAT_RGBA_8888, |
| 2039 | 0, mFGSurfaceControl.get()); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 2040 | fillSurfaceRGBA8(child, 200, 200, 200); |
| 2041 | auto childHandle = child->getHandle(); |
| 2042 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 2043 | sp<SurfaceControl> grandchild = |
| 2044 | mComposerClient->createSurface(String8("Grandchild surface"), 5, 5, |
| 2045 | PIXEL_FORMAT_RGBA_8888, 0, child.get()); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 2046 | fillSurfaceRGBA8(grandchild, 50, 50, 50); |
| 2047 | |
| 2048 | SurfaceComposerClient::Transaction() |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 2049 | .show(child) |
| 2050 | .setPosition(grandchild, 5, 5) |
| 2051 | .show(grandchild) |
| 2052 | .apply(true); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 2053 | |
| 2054 | auto grandchildHandle = grandchild->getHandle(); |
| 2055 | |
| 2056 | // Captures only the grandchild. |
| 2057 | CaptureLayer::captureScreen(&mCapture, grandchildHandle); |
| 2058 | mCapture->checkPixel(0, 0, 50, 50, 50); |
| 2059 | mCapture->checkPixel(4, 4, 50, 50, 50); |
| 2060 | } |
| 2061 | |
Chia-I Wu | 1078bbb | 2017-10-20 11:29:02 -0700 | [diff] [blame] | 2062 | } // namespace android |