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 | |
| 17 | #include <gtest/gtest.h> |
| 18 | |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 19 | #include <android/native_window.h> |
| 20 | |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 21 | #include <gui/ISurfaceComposer.h> |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 22 | #include <gui/LayerState.h> |
| 23 | |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 24 | #include <gui/Surface.h> |
| 25 | #include <gui/SurfaceComposerClient.h> |
| 26 | #include <private/gui/ComposerService.h> |
| 27 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 28 | #include <utils/String8.h> |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 29 | #include <ui/DisplayInfo.h> |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 30 | |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 31 | #include <math.h> |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 32 | #include <math/vec3.h> |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 33 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 34 | #include <functional> |
| 35 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 36 | namespace android { |
| 37 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 38 | using Transaction = SurfaceComposerClient::Transaction; |
| 39 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 40 | // Fill an RGBA_8888 formatted surface with a single color. |
| 41 | static void fillSurfaceRGBA8(const sp<SurfaceControl>& sc, |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 42 | uint8_t r, uint8_t g, uint8_t b, bool unlock=true) { |
Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 43 | ANativeWindow_Buffer outBuffer; |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 44 | sp<Surface> s = sc->getSurface(); |
| 45 | ASSERT_TRUE(s != NULL); |
Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 46 | ASSERT_EQ(NO_ERROR, s->lock(&outBuffer, NULL)); |
| 47 | uint8_t* img = reinterpret_cast<uint8_t*>(outBuffer.bits); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 48 | for (int y = 0; y < outBuffer.height; y++) { |
| 49 | for (int x = 0; x < outBuffer.width; x++) { |
Mathias Agopian | e3c697f | 2013-02-14 17:11:02 -0800 | [diff] [blame] | 50 | uint8_t* pixel = img + (4 * (y*outBuffer.stride + x)); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 51 | pixel[0] = r; |
| 52 | pixel[1] = g; |
| 53 | pixel[2] = b; |
| 54 | pixel[3] = 255; |
| 55 | } |
| 56 | } |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 57 | if (unlock) { |
| 58 | ASSERT_EQ(NO_ERROR, s->unlockAndPost()); |
| 59 | } |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | // A ScreenCapture is a screenshot from SurfaceFlinger that can be used to check |
| 63 | // individual pixel values for testing purposes. |
| 64 | class ScreenCapture : public RefBase { |
| 65 | public: |
| 66 | static void captureScreen(sp<ScreenCapture>* sc) { |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 67 | sp<IGraphicBufferProducer> producer; |
| 68 | sp<IGraphicBufferConsumer> consumer; |
| 69 | BufferQueue::createBufferQueue(&producer, &consumer); |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 70 | sp<CpuConsumer> cpuConsumer = new CpuConsumer(consumer, 1); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 71 | sp<ISurfaceComposer> sf(ComposerService::getComposerService()); |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 72 | sp<IBinder> display(sf->getBuiltInDisplay( |
| 73 | ISurfaceComposer::eDisplayIdMain)); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 74 | SurfaceComposerClient::Transaction().apply(true); |
| 75 | |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 76 | ASSERT_EQ(NO_ERROR, sf->captureScreen(display, producer, Rect(), 0, 0, |
| 77 | 0, INT_MAX, false)); |
| 78 | *sc = new ScreenCapture(cpuConsumer); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | 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] | 82 | ASSERT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, mBuf.format); |
| 83 | const uint8_t* img = static_cast<const uint8_t*>(mBuf.data); |
| 84 | const uint8_t* pixel = img + (4 * (y * mBuf.stride + x)); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 85 | if (r != pixel[0] || g != pixel[1] || b != pixel[2]) { |
| 86 | String8 err(String8::format("pixel @ (%3d, %3d): " |
| 87 | "expected [%3d, %3d, %3d], got [%3d, %3d, %3d]", |
| 88 | x, y, r, g, b, pixel[0], pixel[1], pixel[2])); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 89 | EXPECT_EQ(String8(), err) << err.string(); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 90 | } |
| 91 | } |
| 92 | |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 93 | void expectFGColor(uint32_t x, uint32_t y) { |
| 94 | checkPixel(x, y, 195, 63, 63); |
| 95 | } |
| 96 | |
| 97 | void expectBGColor(uint32_t x, uint32_t y) { |
| 98 | checkPixel(x, y, 63, 63, 195); |
| 99 | } |
| 100 | |
| 101 | void expectChildColor(uint32_t x, uint32_t y) { |
| 102 | checkPixel(x, y, 200, 200, 200); |
| 103 | } |
| 104 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 105 | private: |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 106 | ScreenCapture(const sp<CpuConsumer>& cc) : |
| 107 | mCC(cc) { |
| 108 | EXPECT_EQ(NO_ERROR, mCC->lockNextBuffer(&mBuf)); |
| 109 | } |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 110 | |
Michael Lentine | 5a16a62 | 2015-05-21 13:48:24 -0700 | [diff] [blame] | 111 | ~ScreenCapture() { |
| 112 | mCC->unlockBuffer(mBuf); |
| 113 | } |
| 114 | |
| 115 | sp<CpuConsumer> mCC; |
| 116 | CpuConsumer::LockedBuffer mBuf; |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | class LayerUpdateTest : public ::testing::Test { |
| 120 | protected: |
| 121 | virtual void SetUp() { |
| 122 | mComposerClient = new SurfaceComposerClient; |
| 123 | ASSERT_EQ(NO_ERROR, mComposerClient->initCheck()); |
| 124 | |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 125 | sp<IBinder> display(SurfaceComposerClient::getBuiltInDisplay( |
| 126 | ISurfaceComposer::eDisplayIdMain)); |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 127 | DisplayInfo info; |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 128 | SurfaceComposerClient::getDisplayInfo(display, &info); |
Mathias Agopian | c666cae | 2012-07-25 18:56:13 -0700 | [diff] [blame] | 129 | |
| 130 | ssize_t displayWidth = info.w; |
| 131 | ssize_t displayHeight = info.h; |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 132 | |
| 133 | // Background surface |
| 134 | mBGSurfaceControl = mComposerClient->createSurface( |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 135 | String8("BG Test Surface"), displayWidth, displayHeight, |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 136 | PIXEL_FORMAT_RGBA_8888, 0); |
| 137 | ASSERT_TRUE(mBGSurfaceControl != NULL); |
| 138 | ASSERT_TRUE(mBGSurfaceControl->isValid()); |
| 139 | fillSurfaceRGBA8(mBGSurfaceControl, 63, 63, 195); |
| 140 | |
| 141 | // Foreground surface |
| 142 | mFGSurfaceControl = mComposerClient->createSurface( |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 143 | String8("FG Test Surface"), 64, 64, PIXEL_FORMAT_RGBA_8888, 0); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 144 | ASSERT_TRUE(mFGSurfaceControl != NULL); |
| 145 | ASSERT_TRUE(mFGSurfaceControl->isValid()); |
| 146 | |
| 147 | fillSurfaceRGBA8(mFGSurfaceControl, 195, 63, 63); |
| 148 | |
| 149 | // Synchronization surface |
| 150 | mSyncSurfaceControl = mComposerClient->createSurface( |
Jeff Brown | 9d4e3d2 | 2012-08-24 20:00:51 -0700 | [diff] [blame] | 151 | String8("Sync Test Surface"), 1, 1, PIXEL_FORMAT_RGBA_8888, 0); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 152 | ASSERT_TRUE(mSyncSurfaceControl != NULL); |
| 153 | ASSERT_TRUE(mSyncSurfaceControl->isValid()); |
| 154 | |
| 155 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 156 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 157 | asTransaction([&](Transaction& t) { |
| 158 | t.setDisplayLayerStack(display, 0); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 159 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 160 | t.setLayer(mBGSurfaceControl, INT32_MAX-2) |
| 161 | .show(mBGSurfaceControl); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 162 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 163 | t.setLayer(mFGSurfaceControl, INT32_MAX-1) |
| 164 | .setPosition(mFGSurfaceControl, 64, 64) |
| 165 | .show(mFGSurfaceControl); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 166 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 167 | t.setLayer(mSyncSurfaceControl, INT32_MAX-1) |
| 168 | .setPosition(mSyncSurfaceControl, displayWidth-2, |
| 169 | displayHeight-2) |
| 170 | .show(mSyncSurfaceControl); |
| 171 | }); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | virtual void TearDown() { |
| 175 | mComposerClient->dispose(); |
| 176 | mBGSurfaceControl = 0; |
| 177 | mFGSurfaceControl = 0; |
| 178 | mSyncSurfaceControl = 0; |
| 179 | mComposerClient = 0; |
| 180 | } |
| 181 | |
| 182 | void waitForPostedBuffers() { |
| 183 | // Since the sync surface is in synchronous mode (i.e. double buffered) |
| 184 | // posting three buffers to it should ensure that at least two |
| 185 | // SurfaceFlinger::handlePageFlip calls have been made, which should |
| 186 | // guaranteed that a buffer posted to another Surface has been retired. |
| 187 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 188 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 189 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 190 | } |
| 191 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 192 | void asTransaction(const std::function<void(Transaction&)>& exec) { |
| 193 | Transaction t; |
| 194 | exec(t); |
| 195 | t.apply(true); |
| 196 | } |
| 197 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 198 | sp<SurfaceComposerClient> mComposerClient; |
| 199 | sp<SurfaceControl> mBGSurfaceControl; |
| 200 | sp<SurfaceControl> mFGSurfaceControl; |
| 201 | |
| 202 | // This surface is used to ensure that the buffers posted to |
| 203 | // mFGSurfaceControl have been picked up by SurfaceFlinger. |
| 204 | sp<SurfaceControl> mSyncSurfaceControl; |
| 205 | }; |
| 206 | |
| 207 | TEST_F(LayerUpdateTest, LayerMoveWorks) { |
| 208 | sp<ScreenCapture> sc; |
| 209 | { |
| 210 | SCOPED_TRACE("before move"); |
| 211 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 212 | sc->expectBGColor(0, 12); |
| 213 | sc->expectFGColor(75, 75); |
| 214 | sc->expectBGColor(145, 145); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 215 | } |
| 216 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 217 | asTransaction([&](Transaction& t) { |
| 218 | t.setPosition(mFGSurfaceControl, 128, 128); |
| 219 | }); |
| 220 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 221 | { |
| 222 | // This should reflect the new position, but not the new color. |
| 223 | SCOPED_TRACE("after move, before redraw"); |
| 224 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 225 | sc->expectBGColor(24, 24); |
| 226 | sc->expectBGColor(75, 75); |
| 227 | sc->expectFGColor(145, 145); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | fillSurfaceRGBA8(mFGSurfaceControl, 63, 195, 63); |
| 231 | waitForPostedBuffers(); |
| 232 | { |
| 233 | // This should reflect the new position and the new color. |
| 234 | SCOPED_TRACE("after redraw"); |
| 235 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 236 | sc->expectBGColor(24, 24); |
| 237 | sc->expectBGColor(75, 75); |
| 238 | sc->checkPixel(145, 145, 63, 195, 63); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 239 | } |
| 240 | } |
| 241 | |
| 242 | TEST_F(LayerUpdateTest, LayerResizeWorks) { |
| 243 | sp<ScreenCapture> sc; |
| 244 | { |
| 245 | SCOPED_TRACE("before resize"); |
| 246 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 247 | sc->expectBGColor(0, 12); |
| 248 | sc->expectFGColor(75, 75); |
| 249 | sc->expectBGColor(145, 145); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 250 | } |
| 251 | |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 252 | ALOGD("resizing"); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 253 | asTransaction([&](Transaction& t) { |
| 254 | t.setSize(mFGSurfaceControl, 128, 128); |
| 255 | }); |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 256 | ALOGD("resized"); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 257 | { |
| 258 | // This should not reflect the new size or color because SurfaceFlinger |
| 259 | // has not yet received a buffer of the correct size. |
| 260 | SCOPED_TRACE("after resize, before redraw"); |
| 261 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 262 | sc->expectBGColor(0, 12); |
| 263 | sc->expectFGColor(75, 75); |
| 264 | sc->expectBGColor(145, 145); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 267 | ALOGD("drawing"); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 268 | fillSurfaceRGBA8(mFGSurfaceControl, 63, 195, 63); |
| 269 | waitForPostedBuffers(); |
Steve Block | 9d45368 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 270 | ALOGD("drawn"); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 271 | { |
| 272 | // This should reflect the new size and the new color. |
| 273 | SCOPED_TRACE("after redraw"); |
| 274 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 275 | sc->expectBGColor(24, 24); |
| 276 | sc->checkPixel(75, 75, 63, 195, 63); |
| 277 | sc->checkPixel(145, 145, 63, 195, 63); |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 278 | } |
| 279 | } |
| 280 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 281 | TEST_F(LayerUpdateTest, LayerCropWorks) { |
| 282 | sp<ScreenCapture> sc; |
| 283 | { |
| 284 | SCOPED_TRACE("before crop"); |
| 285 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 286 | sc->expectBGColor(24, 24); |
| 287 | sc->expectFGColor(75, 75); |
| 288 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 289 | } |
| 290 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 291 | asTransaction([&](Transaction& t) { |
| 292 | Rect cropRect(16, 16, 32, 32); |
| 293 | t.setCrop(mFGSurfaceControl, cropRect); |
| 294 | }); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 295 | { |
| 296 | // This should crop the foreground surface. |
| 297 | SCOPED_TRACE("after crop"); |
| 298 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 299 | sc->expectBGColor(24, 24); |
| 300 | sc->expectBGColor(75, 75); |
| 301 | sc->expectFGColor(95, 80); |
| 302 | sc->expectFGColor(80, 95); |
| 303 | sc->expectBGColor(96, 96); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 304 | } |
| 305 | } |
| 306 | |
Pablo Ceballos | acbe678 | 2016-03-04 17:54:21 +0000 | [diff] [blame] | 307 | TEST_F(LayerUpdateTest, LayerFinalCropWorks) { |
| 308 | sp<ScreenCapture> sc; |
| 309 | { |
| 310 | SCOPED_TRACE("before crop"); |
| 311 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 312 | sc->expectBGColor(24, 24); |
| 313 | sc->expectFGColor(75, 75); |
| 314 | sc->expectBGColor(145, 145); |
Pablo Ceballos | acbe678 | 2016-03-04 17:54:21 +0000 | [diff] [blame] | 315 | } |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 316 | asTransaction([&](Transaction& t) { |
| 317 | Rect cropRect(16, 16, 32, 32); |
| 318 | t.setFinalCrop(mFGSurfaceControl, cropRect); |
| 319 | }); |
Pablo Ceballos | acbe678 | 2016-03-04 17:54:21 +0000 | [diff] [blame] | 320 | { |
| 321 | // This should crop the foreground surface. |
| 322 | SCOPED_TRACE("after crop"); |
| 323 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 324 | sc->expectBGColor(24, 24); |
| 325 | sc->expectBGColor(75, 75); |
| 326 | sc->expectBGColor(95, 80); |
| 327 | sc->expectBGColor(80, 95); |
| 328 | sc->expectBGColor(96, 96); |
Pablo Ceballos | acbe678 | 2016-03-04 17:54:21 +0000 | [diff] [blame] | 329 | } |
| 330 | } |
| 331 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 332 | TEST_F(LayerUpdateTest, LayerSetLayerWorks) { |
| 333 | sp<ScreenCapture> sc; |
| 334 | { |
| 335 | SCOPED_TRACE("before setLayer"); |
| 336 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 337 | sc->expectBGColor(24, 24); |
| 338 | sc->expectFGColor(75, 75); |
| 339 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 340 | } |
| 341 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 342 | asTransaction([&](Transaction& t) { |
| 343 | t.setLayer(mFGSurfaceControl, INT_MAX - 3); |
| 344 | }); |
| 345 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 346 | { |
| 347 | // This should hide the foreground surface beneath the background. |
| 348 | SCOPED_TRACE("after setLayer"); |
| 349 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 350 | sc->expectBGColor(24, 24); |
| 351 | sc->expectBGColor(75, 75); |
| 352 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 353 | } |
| 354 | } |
| 355 | |
| 356 | TEST_F(LayerUpdateTest, LayerShowHideWorks) { |
| 357 | sp<ScreenCapture> sc; |
| 358 | { |
| 359 | SCOPED_TRACE("before hide"); |
| 360 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 361 | sc->expectBGColor(24, 24); |
| 362 | sc->expectFGColor(75, 75); |
| 363 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 364 | } |
| 365 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 366 | asTransaction([&](Transaction& t) { |
| 367 | t.hide(mFGSurfaceControl); |
| 368 | }); |
| 369 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 370 | { |
| 371 | // This should hide the foreground surface. |
| 372 | SCOPED_TRACE("after hide, before show"); |
| 373 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 374 | sc->expectBGColor(24, 24); |
| 375 | sc->expectBGColor(75, 75); |
| 376 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 377 | } |
| 378 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 379 | asTransaction([&](Transaction& t) { |
| 380 | t.show(mFGSurfaceControl); |
| 381 | }); |
| 382 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 383 | { |
| 384 | // This should show the foreground surface. |
| 385 | SCOPED_TRACE("after show"); |
| 386 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 387 | sc->expectBGColor(24, 24); |
| 388 | sc->expectFGColor(75, 75); |
| 389 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 390 | } |
| 391 | } |
| 392 | |
| 393 | TEST_F(LayerUpdateTest, LayerSetAlphaWorks) { |
| 394 | sp<ScreenCapture> sc; |
| 395 | { |
| 396 | SCOPED_TRACE("before setAlpha"); |
| 397 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 398 | sc->expectBGColor(24, 24); |
| 399 | sc->expectFGColor(75, 75); |
| 400 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 401 | } |
| 402 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 403 | asTransaction([&](Transaction& t) { |
| 404 | t.setAlpha(mFGSurfaceControl, 0.75f); |
| 405 | }); |
| 406 | |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 407 | { |
| 408 | // This should set foreground to be 75% opaque. |
| 409 | SCOPED_TRACE("after setAlpha"); |
| 410 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 411 | sc->expectBGColor(24, 24); |
| 412 | sc->checkPixel(75, 75, 162, 63, 96); |
| 413 | sc->expectBGColor(145, 145); |
Haixia Shi | d575096 | 2015-07-27 16:50:49 -0700 | [diff] [blame] | 414 | } |
| 415 | } |
| 416 | |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 417 | TEST_F(LayerUpdateTest, LayerSetLayerStackWorks) { |
| 418 | sp<ScreenCapture> sc; |
| 419 | { |
| 420 | SCOPED_TRACE("before setLayerStack"); |
| 421 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 422 | sc->expectBGColor(24, 24); |
| 423 | sc->expectFGColor(75, 75); |
| 424 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 425 | } |
| 426 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 427 | asTransaction([&](Transaction& t) { |
| 428 | t.setLayerStack(mFGSurfaceControl, 1); |
| 429 | }); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 430 | { |
| 431 | // This should hide the foreground surface since it goes to a different |
| 432 | // layer stack. |
| 433 | SCOPED_TRACE("after setLayerStack"); |
| 434 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 435 | sc->expectBGColor(24, 24); |
| 436 | sc->expectBGColor(75, 75); |
| 437 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 438 | } |
| 439 | } |
| 440 | |
| 441 | TEST_F(LayerUpdateTest, LayerSetFlagsWorks) { |
| 442 | sp<ScreenCapture> sc; |
| 443 | { |
| 444 | SCOPED_TRACE("before setFlags"); |
| 445 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 446 | sc->expectBGColor(24, 24); |
| 447 | sc->expectFGColor(75, 75); |
| 448 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 449 | } |
| 450 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 451 | asTransaction([&](Transaction& t) { |
| 452 | t.setFlags(mFGSurfaceControl, |
| 453 | layer_state_t::eLayerHidden, layer_state_t::eLayerHidden); |
| 454 | }); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 455 | { |
| 456 | // This should hide the foreground surface |
| 457 | SCOPED_TRACE("after setFlags"); |
| 458 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 459 | sc->expectBGColor(24, 24); |
| 460 | sc->expectBGColor(75, 75); |
| 461 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 462 | } |
| 463 | } |
| 464 | |
| 465 | TEST_F(LayerUpdateTest, LayerSetMatrixWorks) { |
| 466 | sp<ScreenCapture> sc; |
| 467 | { |
| 468 | SCOPED_TRACE("before setMatrix"); |
| 469 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 470 | sc->expectBGColor(24, 24); |
| 471 | sc->expectFGColor(91, 96); |
| 472 | sc->expectFGColor(96, 101); |
| 473 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 474 | } |
| 475 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 476 | asTransaction([&](Transaction& t) { |
| 477 | t.setMatrix(mFGSurfaceControl, |
| 478 | M_SQRT1_2, M_SQRT1_2, |
| 479 | -M_SQRT1_2, M_SQRT1_2); |
| 480 | }); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 481 | { |
| 482 | SCOPED_TRACE("after setMatrix"); |
| 483 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 484 | sc->expectBGColor(24, 24); |
| 485 | sc->expectFGColor(91, 96); |
| 486 | sc->expectBGColor(96, 91); |
| 487 | sc->expectBGColor(145, 145); |
Pablo Ceballos | 5e4fcbe | 2015-09-02 09:53:16 -0700 | [diff] [blame] | 488 | } |
| 489 | } |
| 490 | |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 491 | class GeometryLatchingTest : public LayerUpdateTest { |
| 492 | protected: |
| 493 | void EXPECT_INITIAL_STATE(const char * trace) { |
| 494 | SCOPED_TRACE(trace); |
| 495 | ScreenCapture::captureScreen(&sc); |
| 496 | // We find the leading edge of the FG surface. |
| 497 | sc->expectFGColor(127, 127); |
| 498 | sc->expectBGColor(128, 128); |
| 499 | } |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 500 | |
| 501 | void lockAndFillFGBuffer() { |
| 502 | fillSurfaceRGBA8(mFGSurfaceControl, 195, 63, 63, false); |
| 503 | } |
| 504 | |
| 505 | void unlockFGBuffer() { |
| 506 | sp<Surface> s = mFGSurfaceControl->getSurface(); |
| 507 | ASSERT_EQ(NO_ERROR, s->unlockAndPost()); |
| 508 | waitForPostedBuffers(); |
| 509 | } |
| 510 | |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 511 | void completeFGResize() { |
| 512 | fillSurfaceRGBA8(mFGSurfaceControl, 195, 63, 63); |
| 513 | waitForPostedBuffers(); |
| 514 | } |
| 515 | void restoreInitialState() { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 516 | asTransaction([&](Transaction& t) { |
| 517 | t.setSize(mFGSurfaceControl, 64, 64); |
| 518 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 519 | t.setCrop(mFGSurfaceControl, Rect(0, 0, 64, 64)); |
| 520 | t.setFinalCrop(mFGSurfaceControl, Rect(0, 0, -1, -1)); |
| 521 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 522 | |
| 523 | EXPECT_INITIAL_STATE("After restoring initial state"); |
| 524 | } |
| 525 | sp<ScreenCapture> sc; |
| 526 | }; |
| 527 | |
| 528 | TEST_F(GeometryLatchingTest, SurfacePositionLatching) { |
| 529 | EXPECT_INITIAL_STATE("before anything"); |
| 530 | |
| 531 | // By default position can be updated even while |
| 532 | // a resize is pending. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 533 | asTransaction([&](Transaction& t) { |
| 534 | t.setSize(mFGSurfaceControl, 32, 32); |
| 535 | t.setPosition(mFGSurfaceControl, 100, 100); |
| 536 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 537 | |
| 538 | { |
| 539 | SCOPED_TRACE("After moving surface"); |
| 540 | ScreenCapture::captureScreen(&sc); |
| 541 | // If we moved, the FG Surface should cover up what was previously BG |
| 542 | // however if we didn't move the FG wouldn't be large enough now. |
| 543 | sc->expectFGColor(163, 163); |
| 544 | } |
| 545 | |
| 546 | restoreInitialState(); |
| 547 | |
| 548 | // Now we repeat with setGeometryAppliesWithResize |
| 549 | // and verify the position DOESN'T latch. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 550 | asTransaction([&](Transaction& t) { |
| 551 | t.setGeometryAppliesWithResize(mFGSurfaceControl); |
| 552 | t.setSize(mFGSurfaceControl, 32, 32); |
| 553 | t.setPosition(mFGSurfaceControl, 100, 100); |
| 554 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 555 | |
| 556 | { |
| 557 | SCOPED_TRACE("While resize is pending"); |
| 558 | ScreenCapture::captureScreen(&sc); |
| 559 | // This time we shouldn't have moved, so the BG color |
| 560 | // should still be visible. |
| 561 | sc->expectBGColor(128, 128); |
| 562 | } |
| 563 | |
| 564 | completeFGResize(); |
| 565 | |
| 566 | { |
| 567 | SCOPED_TRACE("After the resize"); |
| 568 | ScreenCapture::captureScreen(&sc); |
| 569 | // But after the resize completes, we should move |
| 570 | // and the FG should be visible here. |
| 571 | sc->expectFGColor(128, 128); |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | class CropLatchingTest : public GeometryLatchingTest { |
| 576 | protected: |
| 577 | void EXPECT_CROPPED_STATE(const char* trace) { |
| 578 | SCOPED_TRACE(trace); |
| 579 | ScreenCapture::captureScreen(&sc); |
| 580 | // The edge should be moved back one pixel by our crop. |
| 581 | sc->expectFGColor(126, 126); |
| 582 | sc->expectBGColor(127, 127); |
| 583 | sc->expectBGColor(128, 128); |
| 584 | } |
chaviw | 59f5c56 | 2017-06-28 16:39:06 -0700 | [diff] [blame] | 585 | |
| 586 | void EXPECT_RESIZE_STATE(const char* trace) { |
| 587 | SCOPED_TRACE(trace); |
| 588 | ScreenCapture::captureScreen(&sc); |
| 589 | // The FG is now resized too 128,128 at 64,64 |
| 590 | sc->expectFGColor(64, 64); |
| 591 | sc->expectFGColor(191, 191); |
| 592 | sc->expectBGColor(192, 192); |
| 593 | } |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 594 | }; |
| 595 | |
| 596 | TEST_F(CropLatchingTest, CropLatching) { |
| 597 | EXPECT_INITIAL_STATE("before anything"); |
| 598 | // Normally the crop applies immediately even while a resize is pending. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 599 | asTransaction([&](Transaction& t) { |
| 600 | t.setSize(mFGSurfaceControl, 128, 128); |
| 601 | t.setCrop(mFGSurfaceControl, Rect(0, 0, 63, 63)); |
| 602 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 603 | |
| 604 | EXPECT_CROPPED_STATE("after setting crop (without geometryAppliesWithResize)"); |
| 605 | |
| 606 | restoreInitialState(); |
| 607 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 608 | asTransaction([&](Transaction& t) { |
| 609 | t.setSize(mFGSurfaceControl, 128, 128); |
| 610 | t.setGeometryAppliesWithResize(mFGSurfaceControl); |
| 611 | t.setCrop(mFGSurfaceControl, Rect(0, 0, 63, 63)); |
| 612 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 613 | |
| 614 | EXPECT_INITIAL_STATE("after setting crop (with geometryAppliesWithResize)"); |
| 615 | |
| 616 | completeFGResize(); |
| 617 | |
| 618 | EXPECT_CROPPED_STATE("after the resize finishes"); |
| 619 | } |
| 620 | |
| 621 | TEST_F(CropLatchingTest, FinalCropLatching) { |
| 622 | EXPECT_INITIAL_STATE("before anything"); |
| 623 | // Normally the crop applies immediately even while a resize is pending. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 624 | asTransaction([&](Transaction& t) { |
| 625 | t.setSize(mFGSurfaceControl, 128, 128); |
| 626 | t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127)); |
| 627 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 628 | |
| 629 | EXPECT_CROPPED_STATE("after setting crop (without geometryAppliesWithResize)"); |
| 630 | |
| 631 | restoreInitialState(); |
| 632 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 633 | asTransaction([&](Transaction& t) { |
| 634 | t.setSize(mFGSurfaceControl, 128, 128); |
| 635 | t.setGeometryAppliesWithResize(mFGSurfaceControl); |
| 636 | t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127)); |
| 637 | }); |
Robert Carr | 8d5227b | 2017-03-16 15:41:03 -0700 | [diff] [blame] | 638 | |
| 639 | EXPECT_INITIAL_STATE("after setting crop (with geometryAppliesWithResize)"); |
| 640 | |
| 641 | completeFGResize(); |
| 642 | |
| 643 | EXPECT_CROPPED_STATE("after the resize finishes"); |
| 644 | } |
| 645 | |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 646 | // In this test we ensure that setGeometryAppliesWithResize actually demands |
| 647 | // a buffer of the new size, and not just any size. |
| 648 | TEST_F(CropLatchingTest, FinalCropLatchingBufferOldSize) { |
| 649 | EXPECT_INITIAL_STATE("before anything"); |
| 650 | // Normally the crop applies immediately even while a resize is pending. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 651 | asTransaction([&](Transaction& t) { |
| 652 | t.setSize(mFGSurfaceControl, 128, 128); |
| 653 | t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127)); |
| 654 | }); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 655 | |
| 656 | EXPECT_CROPPED_STATE("after setting crop (without geometryAppliesWithResize)"); |
| 657 | |
| 658 | restoreInitialState(); |
| 659 | |
| 660 | // In order to prepare to submit a buffer at the wrong size, we acquire it prior to |
| 661 | // initiating the resize. |
| 662 | lockAndFillFGBuffer(); |
| 663 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 664 | asTransaction([&](Transaction& t) { |
| 665 | t.setSize(mFGSurfaceControl, 128, 128); |
| 666 | t.setGeometryAppliesWithResize(mFGSurfaceControl); |
| 667 | t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127)); |
| 668 | }); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 669 | |
| 670 | EXPECT_INITIAL_STATE("after setting crop (with geometryAppliesWithResize)"); |
| 671 | |
| 672 | // We now submit our old buffer, at the old size, and ensure it doesn't |
| 673 | // trigger geometry latching. |
| 674 | unlockFGBuffer(); |
| 675 | |
| 676 | EXPECT_INITIAL_STATE("after unlocking FG buffer (with geometryAppliesWithResize)"); |
| 677 | |
| 678 | completeFGResize(); |
| 679 | |
| 680 | EXPECT_CROPPED_STATE("after the resize finishes"); |
| 681 | } |
| 682 | |
| 683 | TEST_F(CropLatchingTest, FinalCropLatchingRegressionForb37531386) { |
| 684 | EXPECT_INITIAL_STATE("before anything"); |
| 685 | // In this scenario, we attempt to set the final crop a second time while the resize |
| 686 | // is still pending, and ensure we are successful. Success meaning the second crop |
| 687 | // is the one which eventually latches and not the first. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 688 | asTransaction([&](Transaction& t) { |
| 689 | t.setSize(mFGSurfaceControl, 128, 128); |
| 690 | t.setGeometryAppliesWithResize(mFGSurfaceControl); |
| 691 | t.setFinalCrop(mFGSurfaceControl, Rect(64, 64, 127, 127)); |
| 692 | }); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 693 | |
chaviw | 59f5c56 | 2017-06-28 16:39:06 -0700 | [diff] [blame] | 694 | EXPECT_INITIAL_STATE("after setting crops with geometryAppliesWithResize"); |
| 695 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 696 | asTransaction([&](Transaction& t) { |
| 697 | t.setFinalCrop(mFGSurfaceControl, Rect(0, 0, -1, -1)); |
| 698 | }); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 699 | |
chaviw | 59f5c56 | 2017-06-28 16:39:06 -0700 | [diff] [blame] | 700 | EXPECT_INITIAL_STATE("after setting another crop"); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 701 | |
| 702 | completeFGResize(); |
| 703 | |
chaviw | 59f5c56 | 2017-06-28 16:39:06 -0700 | [diff] [blame] | 704 | EXPECT_RESIZE_STATE("after the resize finishes"); |
Robert Carr | 7bf247e | 2017-05-18 14:02:49 -0700 | [diff] [blame] | 705 | } |
| 706 | |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 707 | TEST_F(LayerUpdateTest, DeferredTransactionTest) { |
| 708 | sp<ScreenCapture> sc; |
| 709 | { |
| 710 | SCOPED_TRACE("before anything"); |
| 711 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 712 | sc->expectBGColor(32, 32); |
| 713 | sc->expectFGColor(96, 96); |
| 714 | sc->expectBGColor(160, 160); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 715 | } |
| 716 | |
| 717 | // set up two deferred transactions on different frames |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 718 | asTransaction([&](Transaction& t) { |
| 719 | t.setAlpha(mFGSurfaceControl, 0.75); |
| 720 | t.deferTransactionUntil(mFGSurfaceControl, mSyncSurfaceControl->getHandle(), |
| 721 | mSyncSurfaceControl->getSurface()->getNextFrameNumber()); |
| 722 | }); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 723 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 724 | asTransaction([&](Transaction& t) { |
| 725 | t.setPosition(mFGSurfaceControl, 128,128); |
| 726 | t.deferTransactionUntil(mFGSurfaceControl, mSyncSurfaceControl->getHandle(), |
| 727 | mSyncSurfaceControl->getSurface()->getNextFrameNumber() + 1); |
| 728 | }); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 729 | |
| 730 | { |
| 731 | SCOPED_TRACE("before any trigger"); |
| 732 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 733 | sc->expectBGColor(32, 32); |
| 734 | sc->expectFGColor(96, 96); |
| 735 | sc->expectBGColor(160, 160); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | // should trigger the first deferred transaction, but not the second one |
| 739 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 740 | { |
| 741 | SCOPED_TRACE("after first trigger"); |
| 742 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 743 | sc->expectBGColor(32, 32); |
| 744 | sc->checkPixel(96, 96, 162, 63, 96); |
| 745 | sc->expectBGColor(160, 160); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | // should show up immediately since it's not deferred |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 749 | asTransaction([&](Transaction& t) { |
| 750 | t.setAlpha(mFGSurfaceControl, 1.0); |
| 751 | }); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 752 | |
| 753 | // trigger the second deferred transaction |
| 754 | fillSurfaceRGBA8(mSyncSurfaceControl, 31, 31, 31); |
| 755 | { |
| 756 | SCOPED_TRACE("after second trigger"); |
| 757 | ScreenCapture::captureScreen(&sc); |
Robert Carr | 2b91c82 | 2017-02-21 19:41:24 -0800 | [diff] [blame] | 758 | sc->expectBGColor(32, 32); |
| 759 | sc->expectBGColor(96, 96); |
| 760 | sc->expectFGColor(160, 160); |
Pablo Ceballos | 05289c2 | 2016-04-14 15:49:55 -0700 | [diff] [blame] | 761 | } |
| 762 | } |
| 763 | |
Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 764 | TEST_F(LayerUpdateTest, LayerSetRelativeLayerWorks) { |
| 765 | sp<ScreenCapture> sc; |
| 766 | { |
| 767 | SCOPED_TRACE("before adding relative surface"); |
| 768 | ScreenCapture::captureScreen(&sc); |
| 769 | sc->expectBGColor(24, 24); |
| 770 | sc->expectFGColor(75, 75); |
| 771 | sc->expectBGColor(145, 145); |
| 772 | } |
| 773 | |
| 774 | auto relativeSurfaceControl = mComposerClient->createSurface( |
| 775 | String8("Test Surface"), 64, 64, PIXEL_FORMAT_RGBA_8888, 0); |
| 776 | fillSurfaceRGBA8(relativeSurfaceControl, 255, 177, 177); |
| 777 | waitForPostedBuffers(); |
| 778 | |
| 779 | // 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^] | 780 | asTransaction([&](Transaction& t) { |
| 781 | t.setPosition(relativeSurfaceControl, 64, 64); |
| 782 | t.show(relativeSurfaceControl); |
| 783 | t.setRelativeLayer(relativeSurfaceControl, mFGSurfaceControl->getHandle(), 1); |
| 784 | }); |
Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 785 | |
| 786 | { |
| 787 | SCOPED_TRACE("after adding relative surface"); |
| 788 | ScreenCapture::captureScreen(&sc); |
| 789 | // our relative surface should be visible now. |
| 790 | sc->checkPixel(75, 75, 255, 177, 177); |
| 791 | } |
| 792 | |
| 793 | // A call to setLayer will override a call to setRelativeLayer |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 794 | asTransaction([&](Transaction& t) { |
| 795 | t.setLayer(relativeSurfaceControl, 0); |
| 796 | }); |
Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 797 | |
| 798 | { |
| 799 | SCOPED_TRACE("after set layer"); |
| 800 | ScreenCapture::captureScreen(&sc); |
| 801 | // now the FG surface should be visible again. |
| 802 | sc->expectFGColor(75, 75); |
| 803 | } |
| 804 | } |
| 805 | |
Robert Carr | e392b55 | 2017-09-19 12:16:05 -0700 | [diff] [blame] | 806 | TEST_F(LayerUpdateTest, LayerWithNoBuffersResizesImmediately) { |
| 807 | sp<ScreenCapture> sc; |
| 808 | |
| 809 | sp<SurfaceControl> childNoBuffer = |
| 810 | mComposerClient->createSurface(String8("Bufferless child"), |
| 811 | 10, 10, PIXEL_FORMAT_RGBA_8888, |
| 812 | 0, mFGSurfaceControl.get()); |
| 813 | sp<SurfaceControl> childBuffer = mComposerClient->createSurface( |
| 814 | String8("Buffered child"), 20, 20, |
| 815 | PIXEL_FORMAT_RGBA_8888, 0, childNoBuffer.get()); |
| 816 | fillSurfaceRGBA8(childBuffer, 200, 200, 200); |
| 817 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 818 | SurfaceComposerClient::Transaction{} |
| 819 | .show(childNoBuffer) |
| 820 | .show(childBuffer) |
| 821 | .apply(true); |
Robert Carr | e392b55 | 2017-09-19 12:16:05 -0700 | [diff] [blame] | 822 | |
| 823 | { |
| 824 | ScreenCapture::captureScreen(&sc); |
| 825 | sc->expectChildColor(73, 73); |
| 826 | sc->expectFGColor(74, 74); |
| 827 | } |
| 828 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 829 | SurfaceComposerClient::Transaction{} |
| 830 | .setSize(childNoBuffer, 20, 20) |
| 831 | .apply(true); |
Robert Carr | e392b55 | 2017-09-19 12:16:05 -0700 | [diff] [blame] | 832 | |
| 833 | { |
| 834 | ScreenCapture::captureScreen(&sc); |
| 835 | sc->expectChildColor(73, 73); |
| 836 | sc->expectChildColor(74, 74); |
| 837 | } |
| 838 | } |
| 839 | |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 840 | class ChildLayerTest : public LayerUpdateTest { |
| 841 | protected: |
| 842 | void SetUp() override { |
| 843 | LayerUpdateTest::SetUp(); |
| 844 | mChild = mComposerClient->createSurface( |
| 845 | String8("Child surface"), |
| 846 | 10, 10, PIXEL_FORMAT_RGBA_8888, |
| 847 | 0, mFGSurfaceControl.get()); |
| 848 | fillSurfaceRGBA8(mChild, 200, 200, 200); |
| 849 | |
| 850 | { |
| 851 | SCOPED_TRACE("before anything"); |
| 852 | ScreenCapture::captureScreen(&mCapture); |
| 853 | mCapture->expectChildColor(64, 64); |
| 854 | } |
| 855 | } |
| 856 | void TearDown() override { |
| 857 | LayerUpdateTest::TearDown(); |
| 858 | mChild = 0; |
| 859 | } |
| 860 | |
| 861 | sp<SurfaceControl> mChild; |
| 862 | sp<ScreenCapture> mCapture; |
| 863 | }; |
| 864 | |
| 865 | TEST_F(ChildLayerTest, ChildLayerPositioning) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 866 | asTransaction([&](Transaction& t) { |
| 867 | t.show(mChild); |
| 868 | t.setPosition(mChild, 10, 10); |
| 869 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 870 | }); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 871 | |
| 872 | { |
| 873 | ScreenCapture::captureScreen(&mCapture); |
| 874 | // Top left of foreground must now be visible |
| 875 | mCapture->expectFGColor(64, 64); |
| 876 | // But 10 pixels in we should see the child surface |
| 877 | mCapture->expectChildColor(74, 74); |
| 878 | // And 10 more pixels we should be back to the foreground surface |
| 879 | mCapture->expectFGColor(84, 84); |
| 880 | } |
| 881 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 882 | asTransaction([&](Transaction& t) { |
| 883 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 884 | }); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 885 | |
| 886 | { |
| 887 | ScreenCapture::captureScreen(&mCapture); |
| 888 | // Top left of foreground should now be at 0, 0 |
| 889 | mCapture->expectFGColor(0, 0); |
| 890 | // But 10 pixels in we should see the child surface |
| 891 | mCapture->expectChildColor(10, 10); |
| 892 | // And 10 more pixels we should be back to the foreground surface |
| 893 | mCapture->expectFGColor(20, 20); |
| 894 | } |
| 895 | } |
| 896 | |
Robert Carr | 41b08b5 | 2017-06-01 16:11:34 -0700 | [diff] [blame] | 897 | TEST_F(ChildLayerTest, ChildLayerCropping) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 898 | asTransaction([&](Transaction& t) { |
| 899 | t.show(mChild); |
| 900 | t.setPosition(mChild, 0, 0); |
| 901 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 902 | t.setCrop(mFGSurfaceControl, Rect(0, 0, 5, 5)); |
| 903 | }); |
Robert Carr | 41b08b5 | 2017-06-01 16:11:34 -0700 | [diff] [blame] | 904 | |
| 905 | { |
| 906 | ScreenCapture::captureScreen(&mCapture); |
| 907 | mCapture->expectChildColor(0, 0); |
| 908 | mCapture->expectChildColor(4, 4); |
| 909 | mCapture->expectBGColor(5, 5); |
| 910 | } |
| 911 | } |
| 912 | |
| 913 | TEST_F(ChildLayerTest, ChildLayerFinalCropping) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 914 | asTransaction([&](Transaction& t) { |
| 915 | t.show(mChild); |
| 916 | t.setPosition(mChild, 0, 0); |
| 917 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 918 | t.setFinalCrop(mFGSurfaceControl, Rect(0, 0, 5, 5)); |
| 919 | }); |
Robert Carr | 41b08b5 | 2017-06-01 16:11:34 -0700 | [diff] [blame] | 920 | |
| 921 | { |
| 922 | ScreenCapture::captureScreen(&mCapture); |
| 923 | mCapture->expectChildColor(0, 0); |
| 924 | mCapture->expectChildColor(4, 4); |
| 925 | mCapture->expectBGColor(5, 5); |
| 926 | } |
| 927 | } |
| 928 | |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 929 | TEST_F(ChildLayerTest, ChildLayerConstraints) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 930 | asTransaction([&](Transaction& t) { |
| 931 | t.show(mChild); |
| 932 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 933 | t.setPosition(mChild, 63, 63); |
| 934 | }); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 935 | |
| 936 | { |
| 937 | ScreenCapture::captureScreen(&mCapture); |
| 938 | mCapture->expectFGColor(0, 0); |
| 939 | // Last pixel in foreground should now be the child. |
| 940 | mCapture->expectChildColor(63, 63); |
| 941 | // But the child should be constrained and the next pixel |
| 942 | // must be the background |
| 943 | mCapture->expectBGColor(64, 64); |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | TEST_F(ChildLayerTest, ChildLayerScaling) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 948 | asTransaction([&](Transaction& t) { |
| 949 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 950 | }); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 951 | |
| 952 | // Find the boundary between the parent and child |
| 953 | { |
| 954 | ScreenCapture::captureScreen(&mCapture); |
| 955 | mCapture->expectChildColor(9, 9); |
| 956 | mCapture->expectFGColor(10, 10); |
| 957 | } |
| 958 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 959 | asTransaction([&](Transaction& t) { |
| 960 | t.setMatrix(mFGSurfaceControl, 2.0, 0, 0, 2.0); |
| 961 | }); |
Robert Carr | 1f0a16a | 2016-10-24 16:27:39 -0700 | [diff] [blame] | 962 | |
| 963 | // The boundary should be twice as far from the origin now. |
| 964 | // The pixels from the last test should all be child now |
| 965 | { |
| 966 | ScreenCapture::captureScreen(&mCapture); |
| 967 | mCapture->expectChildColor(9, 9); |
| 968 | mCapture->expectChildColor(10, 10); |
| 969 | mCapture->expectChildColor(19, 19); |
| 970 | mCapture->expectFGColor(20, 20); |
| 971 | } |
| 972 | } |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 973 | |
Robert Carr | 6452f12 | 2017-03-21 10:41:29 -0700 | [diff] [blame] | 974 | TEST_F(ChildLayerTest, ChildLayerAlpha) { |
| 975 | fillSurfaceRGBA8(mBGSurfaceControl, 0, 0, 254); |
| 976 | fillSurfaceRGBA8(mFGSurfaceControl, 254, 0, 0); |
| 977 | fillSurfaceRGBA8(mChild, 0, 254, 0); |
| 978 | waitForPostedBuffers(); |
| 979 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 980 | asTransaction([&](Transaction& t) { |
| 981 | t.show(mChild); |
| 982 | t.setPosition(mChild, 0, 0); |
| 983 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 984 | }); |
Robert Carr | 6452f12 | 2017-03-21 10:41:29 -0700 | [diff] [blame] | 985 | |
| 986 | { |
| 987 | ScreenCapture::captureScreen(&mCapture); |
| 988 | // Unblended child color |
| 989 | mCapture->checkPixel(0, 0, 0, 254, 0); |
| 990 | } |
| 991 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 992 | asTransaction([&](Transaction& t) { |
| 993 | t.setAlpha(mChild, 0.5); |
| 994 | }); |
Robert Carr | 6452f12 | 2017-03-21 10:41:29 -0700 | [diff] [blame] | 995 | |
| 996 | { |
| 997 | ScreenCapture::captureScreen(&mCapture); |
| 998 | // Child and BG blended. |
| 999 | mCapture->checkPixel(0, 0, 127, 127, 0); |
| 1000 | } |
| 1001 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1002 | asTransaction([&](Transaction& t) { |
| 1003 | t.setAlpha(mFGSurfaceControl, 0.5); |
| 1004 | }); |
Robert Carr | 6452f12 | 2017-03-21 10:41:29 -0700 | [diff] [blame] | 1005 | |
| 1006 | { |
| 1007 | ScreenCapture::captureScreen(&mCapture); |
| 1008 | // Child and BG blended. |
| 1009 | mCapture->checkPixel(0, 0, 95, 64, 95); |
| 1010 | } |
| 1011 | } |
| 1012 | |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1013 | TEST_F(ChildLayerTest, ReparentChildren) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1014 | asTransaction([&](Transaction& t) { |
| 1015 | t.show(mChild); |
| 1016 | t.setPosition(mChild, 10, 10); |
| 1017 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1018 | }); |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1019 | |
| 1020 | { |
| 1021 | ScreenCapture::captureScreen(&mCapture); |
| 1022 | // Top left of foreground must now be visible |
| 1023 | mCapture->expectFGColor(64, 64); |
| 1024 | // But 10 pixels in we should see the child surface |
| 1025 | mCapture->expectChildColor(74, 74); |
| 1026 | // And 10 more pixels we should be back to the foreground surface |
| 1027 | mCapture->expectFGColor(84, 84); |
| 1028 | } |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1029 | |
| 1030 | asTransaction([&](Transaction& t) { |
| 1031 | t.reparentChildren(mFGSurfaceControl, mBGSurfaceControl->getHandle()); |
| 1032 | }); |
| 1033 | |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1034 | { |
| 1035 | ScreenCapture::captureScreen(&mCapture); |
| 1036 | mCapture->expectFGColor(64, 64); |
| 1037 | // In reparenting we should have exposed the entire foreground surface. |
| 1038 | mCapture->expectFGColor(74, 74); |
| 1039 | // And the child layer should now begin at 10, 10 (since the BG |
| 1040 | // layer is at (0, 0)). |
| 1041 | mCapture->expectBGColor(9, 9); |
| 1042 | mCapture->expectChildColor(10, 10); |
| 1043 | } |
| 1044 | } |
| 1045 | |
chaviw | 161410b0 | 2017-07-27 10:46:08 -0700 | [diff] [blame] | 1046 | TEST_F(ChildLayerTest, DetachChildrenSameClient) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1047 | asTransaction([&](Transaction& t) { |
| 1048 | t.show(mChild); |
| 1049 | t.setPosition(mChild, 10, 10); |
| 1050 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1051 | }); |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1052 | |
| 1053 | { |
| 1054 | ScreenCapture::captureScreen(&mCapture); |
| 1055 | // Top left of foreground must now be visible |
| 1056 | mCapture->expectFGColor(64, 64); |
| 1057 | // But 10 pixels in we should see the child surface |
| 1058 | mCapture->expectChildColor(74, 74); |
| 1059 | // And 10 more pixels we should be back to the foreground surface |
| 1060 | mCapture->expectFGColor(84, 84); |
| 1061 | } |
| 1062 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1063 | asTransaction([&](Transaction& t) { |
| 1064 | t.detachChildren(mFGSurfaceControl); |
| 1065 | }); |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1066 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1067 | asTransaction([&](Transaction& t) { |
| 1068 | t.hide(mChild); |
| 1069 | }); |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1070 | |
chaviw | 161410b0 | 2017-07-27 10:46:08 -0700 | [diff] [blame] | 1071 | // Since the child has the same client as the parent, it will not get |
| 1072 | // detached and will be hidden. |
| 1073 | { |
| 1074 | ScreenCapture::captureScreen(&mCapture); |
| 1075 | mCapture->expectFGColor(64, 64); |
| 1076 | mCapture->expectFGColor(74, 74); |
| 1077 | mCapture->expectFGColor(84, 84); |
| 1078 | } |
| 1079 | } |
| 1080 | |
| 1081 | TEST_F(ChildLayerTest, DetachChildrenDifferentClient) { |
| 1082 | sp<SurfaceComposerClient> mNewComposerClient = new SurfaceComposerClient; |
| 1083 | sp<SurfaceControl> mChildNewClient = mNewComposerClient->createSurface( |
| 1084 | String8("New Child Test Surface"), 10, 10, PIXEL_FORMAT_RGBA_8888, |
| 1085 | 0, mFGSurfaceControl.get()); |
| 1086 | |
| 1087 | ASSERT_TRUE(mChildNewClient != NULL); |
| 1088 | ASSERT_TRUE(mChildNewClient->isValid()); |
| 1089 | |
| 1090 | fillSurfaceRGBA8(mChildNewClient, 200, 200, 200); |
| 1091 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1092 | asTransaction([&](Transaction& t) { |
| 1093 | t.hide(mChild); |
| 1094 | t.show(mChildNewClient); |
| 1095 | t.setPosition(mChildNewClient, 10, 10); |
| 1096 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1097 | }); |
chaviw | 161410b0 | 2017-07-27 10:46:08 -0700 | [diff] [blame] | 1098 | |
| 1099 | { |
| 1100 | ScreenCapture::captureScreen(&mCapture); |
| 1101 | // Top left of foreground must now be visible |
| 1102 | mCapture->expectFGColor(64, 64); |
| 1103 | // But 10 pixels in we should see the child surface |
| 1104 | mCapture->expectChildColor(74, 74); |
| 1105 | // And 10 more pixels we should be back to the foreground surface |
| 1106 | mCapture->expectFGColor(84, 84); |
| 1107 | } |
| 1108 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1109 | asTransaction([&](Transaction& t) { |
| 1110 | t.detachChildren(mFGSurfaceControl); |
| 1111 | }); |
chaviw | 161410b0 | 2017-07-27 10:46:08 -0700 | [diff] [blame] | 1112 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1113 | asTransaction([&](Transaction& t) { |
| 1114 | t.hide(mChildNewClient); |
| 1115 | }); |
chaviw | 161410b0 | 2017-07-27 10:46:08 -0700 | [diff] [blame] | 1116 | |
Robert Carr | 9524cb3 | 2017-02-13 11:32:32 -0800 | [diff] [blame] | 1117 | // Nothing should have changed. |
| 1118 | { |
| 1119 | ScreenCapture::captureScreen(&mCapture); |
| 1120 | mCapture->expectFGColor(64, 64); |
| 1121 | mCapture->expectChildColor(74, 74); |
| 1122 | mCapture->expectFGColor(84, 84); |
| 1123 | } |
| 1124 | } |
| 1125 | |
Robert Carr | 9b429f4 | 2017-04-17 14:56:57 -0700 | [diff] [blame] | 1126 | TEST_F(ChildLayerTest, ChildrenInheritNonTransformScalingFromParent) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1127 | asTransaction([&](Transaction& t) { |
| 1128 | t.show(mChild); |
| 1129 | t.setPosition(mChild, 0, 0); |
| 1130 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 1131 | }); |
Robert Carr | 9b429f4 | 2017-04-17 14:56:57 -0700 | [diff] [blame] | 1132 | |
| 1133 | { |
| 1134 | ScreenCapture::captureScreen(&mCapture); |
| 1135 | // We've positioned the child in the top left. |
| 1136 | mCapture->expectChildColor(0, 0); |
| 1137 | // But it's only 10x10. |
| 1138 | mCapture->expectFGColor(10, 10); |
| 1139 | } |
| 1140 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1141 | asTransaction([&](Transaction& t) { |
| 1142 | t.setOverrideScalingMode(mFGSurfaceControl, NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW); |
| 1143 | // We cause scaling by 2. |
| 1144 | t.setSize(mFGSurfaceControl, 128, 128); |
| 1145 | }); |
Robert Carr | 9b429f4 | 2017-04-17 14:56:57 -0700 | [diff] [blame] | 1146 | |
| 1147 | { |
| 1148 | ScreenCapture::captureScreen(&mCapture); |
| 1149 | // We've positioned the child in the top left. |
| 1150 | mCapture->expectChildColor(0, 0); |
| 1151 | mCapture->expectChildColor(10, 10); |
| 1152 | mCapture->expectChildColor(19, 19); |
| 1153 | // And now it should be scaled all the way to 20x20 |
| 1154 | mCapture->expectFGColor(20, 20); |
| 1155 | } |
| 1156 | } |
| 1157 | |
Robert Carr | 1725eee | 2017-04-26 18:32:15 -0700 | [diff] [blame] | 1158 | // Regression test for b/37673612 |
| 1159 | TEST_F(ChildLayerTest, ChildrenWithParentBufferTransform) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1160 | asTransaction([&](Transaction& t) { |
| 1161 | t.show(mChild); |
| 1162 | t.setPosition(mChild, 0, 0); |
| 1163 | t.setPosition(mFGSurfaceControl, 0, 0); |
| 1164 | }); |
Robert Carr | 1725eee | 2017-04-26 18:32:15 -0700 | [diff] [blame] | 1165 | |
| 1166 | { |
| 1167 | ScreenCapture::captureScreen(&mCapture); |
| 1168 | // We've positioned the child in the top left. |
| 1169 | mCapture->expectChildColor(0, 0); |
| 1170 | // But it's only 10x10. |
| 1171 | mCapture->expectFGColor(10, 10); |
| 1172 | } |
Robert Carr | 1725eee | 2017-04-26 18:32:15 -0700 | [diff] [blame] | 1173 | // We set things up as in b/37673612 so that there is a mismatch between the buffer size and |
| 1174 | // the WM specified state size. |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1175 | asTransaction([&](Transaction& t) { |
| 1176 | t.setSize(mFGSurfaceControl, 128, 64); |
| 1177 | }); |
Robert Carr | 1725eee | 2017-04-26 18:32:15 -0700 | [diff] [blame] | 1178 | sp<Surface> s = mFGSurfaceControl->getSurface(); |
| 1179 | auto anw = static_cast<ANativeWindow*>(s.get()); |
| 1180 | native_window_set_buffers_transform(anw, NATIVE_WINDOW_TRANSFORM_ROT_90); |
| 1181 | native_window_set_buffers_dimensions(anw, 64, 128); |
| 1182 | fillSurfaceRGBA8(mFGSurfaceControl, 195, 63, 63); |
| 1183 | waitForPostedBuffers(); |
| 1184 | |
| 1185 | { |
| 1186 | // The child should still be in the same place and not have any strange scaling as in |
| 1187 | // b/37673612. |
| 1188 | ScreenCapture::captureScreen(&mCapture); |
| 1189 | mCapture->expectChildColor(0, 0); |
| 1190 | mCapture->expectFGColor(10, 10); |
| 1191 | } |
| 1192 | } |
| 1193 | |
Dan Stoza | 412903f | 2017-04-27 13:42:17 -0700 | [diff] [blame] | 1194 | TEST_F(ChildLayerTest, Bug36858924) { |
| 1195 | // Destroy the child layer |
| 1196 | mChild.clear(); |
| 1197 | |
| 1198 | // Now recreate it as hidden |
| 1199 | mChild = mComposerClient->createSurface(String8("Child surface"), 10, 10, |
| 1200 | PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eHidden, |
| 1201 | mFGSurfaceControl.get()); |
| 1202 | |
| 1203 | // Show the child layer in a deferred transaction |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1204 | asTransaction([&](Transaction& t) { |
| 1205 | t.deferTransactionUntil(mChild, mFGSurfaceControl->getHandle(), |
| 1206 | mFGSurfaceControl->getSurface()->getNextFrameNumber()); |
| 1207 | t.show(mChild); |
| 1208 | }); |
Dan Stoza | 412903f | 2017-04-27 13:42:17 -0700 | [diff] [blame] | 1209 | |
| 1210 | // Render the foreground surface a few times |
| 1211 | // |
| 1212 | // Prior to the bugfix for b/36858924, this would usually hang while trying to fill the third |
| 1213 | // frame because SurfaceFlinger would never process the deferred transaction and would therefore |
| 1214 | // never acquire/release the first buffer |
| 1215 | ALOGI("Filling 1"); |
| 1216 | fillSurfaceRGBA8(mFGSurfaceControl, 0, 255, 0); |
| 1217 | ALOGI("Filling 2"); |
| 1218 | fillSurfaceRGBA8(mFGSurfaceControl, 0, 0, 255); |
| 1219 | ALOGI("Filling 3"); |
| 1220 | fillSurfaceRGBA8(mFGSurfaceControl, 255, 0, 0); |
| 1221 | ALOGI("Filling 4"); |
| 1222 | fillSurfaceRGBA8(mFGSurfaceControl, 0, 255, 0); |
| 1223 | } |
| 1224 | |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1225 | TEST_F(ChildLayerTest, Reparent) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1226 | asTransaction([&](Transaction& t) { |
| 1227 | t.show(mChild); |
| 1228 | t.setPosition(mChild, 10, 10); |
| 1229 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1230 | }); |
chaviw | 0617894 | 2017-07-27 10:25:59 -0700 | [diff] [blame] | 1231 | |
| 1232 | { |
| 1233 | ScreenCapture::captureScreen(&mCapture); |
| 1234 | // Top left of foreground must now be visible |
| 1235 | mCapture->expectFGColor(64, 64); |
| 1236 | // But 10 pixels in we should see the child surface |
| 1237 | mCapture->expectChildColor(74, 74); |
| 1238 | // And 10 more pixels we should be back to the foreground surface |
| 1239 | mCapture->expectFGColor(84, 84); |
| 1240 | } |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1241 | |
| 1242 | asTransaction([&](Transaction& t) { |
| 1243 | t.reparent(mChild, mBGSurfaceControl->getHandle()); |
| 1244 | }); |
| 1245 | |
chaviw | 0617894 | 2017-07-27 10:25:59 -0700 | [diff] [blame] | 1246 | { |
| 1247 | ScreenCapture::captureScreen(&mCapture); |
| 1248 | mCapture->expectFGColor(64, 64); |
| 1249 | // In reparenting we should have exposed the entire foreground surface. |
| 1250 | mCapture->expectFGColor(74, 74); |
| 1251 | // And the child layer should now begin at 10, 10 (since the BG |
| 1252 | // layer is at (0, 0)). |
| 1253 | mCapture->expectBGColor(9, 9); |
| 1254 | mCapture->expectChildColor(10, 10); |
| 1255 | } |
| 1256 | } |
| 1257 | |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1258 | TEST_F(ChildLayerTest, ReparentToNoParent) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1259 | asTransaction([&](Transaction& t) { |
| 1260 | t.show(mChild); |
| 1261 | t.setPosition(mChild, 10, 10); |
| 1262 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1263 | }); |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1264 | |
| 1265 | { |
| 1266 | ScreenCapture::captureScreen(&mCapture); |
| 1267 | // Top left of foreground must now be visible |
| 1268 | mCapture->expectFGColor(64, 64); |
| 1269 | // But 10 pixels in we should see the child surface |
| 1270 | mCapture->expectChildColor(74, 74); |
| 1271 | // And 10 more pixels we should be back to the foreground surface |
| 1272 | mCapture->expectFGColor(84, 84); |
| 1273 | } |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1274 | asTransaction([&](Transaction& t) { |
| 1275 | t.reparent(mChild, nullptr); |
| 1276 | }); |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1277 | { |
| 1278 | ScreenCapture::captureScreen(&mCapture); |
| 1279 | // Nothing should have changed. |
| 1280 | mCapture->expectFGColor(64, 64); |
| 1281 | mCapture->expectChildColor(74, 74); |
| 1282 | mCapture->expectFGColor(84, 84); |
| 1283 | } |
| 1284 | } |
| 1285 | |
| 1286 | TEST_F(ChildLayerTest, ReparentFromNoParent) { |
| 1287 | sp<SurfaceControl> newSurface = mComposerClient->createSurface( |
| 1288 | String8("New Surface"), 10, 10, PIXEL_FORMAT_RGBA_8888, 0); |
| 1289 | ASSERT_TRUE(newSurface != NULL); |
| 1290 | ASSERT_TRUE(newSurface->isValid()); |
| 1291 | |
| 1292 | fillSurfaceRGBA8(newSurface, 63, 195, 63); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1293 | asTransaction([&](Transaction& t) { |
| 1294 | t.hide(mChild); |
| 1295 | t.show(newSurface); |
| 1296 | t.setPosition(newSurface, 10, 10); |
| 1297 | t.setLayer(newSurface, INT32_MAX-2); |
| 1298 | t.setPosition(mFGSurfaceControl, 64, 64); |
| 1299 | }); |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1300 | |
| 1301 | { |
| 1302 | ScreenCapture::captureScreen(&mCapture); |
| 1303 | // Top left of foreground must now be visible |
| 1304 | mCapture->expectFGColor(64, 64); |
| 1305 | // At 10, 10 we should see the new surface |
| 1306 | mCapture->checkPixel(10, 10, 63, 195, 63); |
| 1307 | } |
| 1308 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1309 | asTransaction([&](Transaction& t) { |
| 1310 | t.reparent(newSurface, mFGSurfaceControl->getHandle()); |
| 1311 | }); |
chaviw | f1961f7 | 2017-09-18 16:41:07 -0700 | [diff] [blame] | 1312 | |
| 1313 | { |
| 1314 | ScreenCapture::captureScreen(&mCapture); |
| 1315 | // newSurface will now be a child of mFGSurface so it will be 10, 10 offset from |
| 1316 | // mFGSurface, putting it at 74, 74. |
| 1317 | mCapture->expectFGColor(64, 64); |
| 1318 | mCapture->checkPixel(74, 74, 63, 195, 63); |
| 1319 | mCapture->expectFGColor(84, 84); |
| 1320 | } |
| 1321 | } |
| 1322 | |
chaviw | c967433 | 2017-08-28 12:32:18 -0700 | [diff] [blame] | 1323 | TEST_F(ChildLayerTest, NestedChildren) { |
| 1324 | sp<SurfaceControl> grandchild = mComposerClient->createSurface( |
| 1325 | String8("Grandchild surface"), |
| 1326 | 10, 10, PIXEL_FORMAT_RGBA_8888, |
| 1327 | 0, mChild.get()); |
| 1328 | fillSurfaceRGBA8(grandchild, 50, 50, 50); |
| 1329 | |
| 1330 | { |
| 1331 | ScreenCapture::captureScreen(&mCapture); |
| 1332 | // Expect the grandchild to begin at 64, 64 because it's a child of mChild layer |
| 1333 | // which begins at 64, 64 |
| 1334 | mCapture->checkPixel(64, 64, 50, 50, 50); |
| 1335 | } |
| 1336 | } |
| 1337 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1338 | class LayerColorTest : public LayerUpdateTest { |
| 1339 | protected: |
| 1340 | void SetUp() override { |
| 1341 | LayerUpdateTest::SetUp(); |
| 1342 | |
| 1343 | mLayerColorControl = mComposerClient->createSurface( |
| 1344 | String8("Layer color surface"), |
| 1345 | 128, 128, PIXEL_FORMAT_RGBA_8888, |
| 1346 | ISurfaceComposerClient::eFXSurfaceColor); |
| 1347 | |
| 1348 | ASSERT_TRUE(mLayerColorControl != NULL); |
| 1349 | ASSERT_TRUE(mLayerColorControl->isValid()); |
| 1350 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1351 | asTransaction([&](Transaction& t) { |
| 1352 | t.setLayer(mLayerColorControl, INT32_MAX-1); |
| 1353 | t.setPosition(mLayerColorControl, 140, 140); |
| 1354 | t.hide(mLayerColorControl); |
| 1355 | t.hide(mFGSurfaceControl); |
| 1356 | }); |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1357 | } |
| 1358 | |
| 1359 | void TearDown() override { |
| 1360 | LayerUpdateTest::TearDown(); |
| 1361 | mLayerColorControl = 0; |
| 1362 | } |
| 1363 | |
| 1364 | sp<SurfaceControl> mLayerColorControl; |
| 1365 | }; |
| 1366 | |
| 1367 | TEST_F(LayerColorTest, ColorLayerNoAlpha) { |
| 1368 | sp<ScreenCapture> sc; |
| 1369 | |
| 1370 | { |
| 1371 | SCOPED_TRACE("before setColor"); |
| 1372 | ScreenCapture::captureScreen(&sc); |
| 1373 | sc->expectBGColor(145, 145); |
| 1374 | } |
| 1375 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1376 | asTransaction([&](Transaction& t) { |
| 1377 | half3 color(43.0f/255.0f, 207.0f/255.0f, 131.0f/255.0f); |
| 1378 | t.setColor(mLayerColorControl, color); |
| 1379 | t.show(mLayerColorControl); |
| 1380 | }); |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1381 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1382 | { |
| 1383 | // There should now be a color |
| 1384 | SCOPED_TRACE("after setColor"); |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1385 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1386 | ScreenCapture::captureScreen(&sc); |
| 1387 | sc->checkPixel(145, 145, 43, 207, 131); |
| 1388 | } |
| 1389 | } |
| 1390 | |
| 1391 | TEST_F(LayerColorTest, ColorLayerWithAlpha) { |
| 1392 | sp<ScreenCapture> sc; |
| 1393 | { |
| 1394 | SCOPED_TRACE("before setColor"); |
| 1395 | ScreenCapture::captureScreen(&sc); |
| 1396 | sc->expectBGColor(145, 145); |
| 1397 | } |
| 1398 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1399 | asTransaction([&](Transaction& t) { |
| 1400 | half3 color(43.0f/255.0f, 207.0f/255.0f, 131.0f/255.0f); |
| 1401 | t.setColor(mLayerColorControl, color); |
| 1402 | t.setAlpha(mLayerColorControl, .75f); |
| 1403 | t.show(mLayerColorControl); |
| 1404 | }); |
| 1405 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1406 | { |
| 1407 | // There should now be a color with .75 alpha |
| 1408 | SCOPED_TRACE("after setColor"); |
| 1409 | ScreenCapture::captureScreen(&sc); |
| 1410 | sc->checkPixel(145, 145, 48, 171, 147); |
| 1411 | } |
| 1412 | } |
| 1413 | |
| 1414 | TEST_F(LayerColorTest, ColorLayerWithNoColor) { |
| 1415 | sp<ScreenCapture> sc; |
| 1416 | { |
| 1417 | SCOPED_TRACE("before setColor"); |
| 1418 | ScreenCapture::captureScreen(&sc); |
| 1419 | sc->expectBGColor(145, 145); |
| 1420 | } |
| 1421 | |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame^] | 1422 | asTransaction([&](Transaction& t) { |
| 1423 | t.show(mLayerColorControl); |
| 1424 | }); |
| 1425 | |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 1426 | { |
| 1427 | // There should now be set to 0,0,0 (black) as default. |
| 1428 | SCOPED_TRACE("after setColor"); |
| 1429 | ScreenCapture::captureScreen(&sc); |
| 1430 | sc->checkPixel(145, 145, 0, 0, 0); |
| 1431 | } |
| 1432 | } |
| 1433 | |
Jamie Gennis | 23c2c5d | 2011-10-11 19:22:19 -0700 | [diff] [blame] | 1434 | } |