| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2019 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 | */ | 
| Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 16 |  | 
|  | 17 | #pragma once | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 18 |  | 
| Marin Shalamanov | 30b0b3c | 2020-10-13 19:15:06 +0200 | [diff] [blame] | 19 | // TODO(b/129481165): remove the #pragma below and fix conversion issues | 
|  | 20 | #pragma clang diagnostic push | 
|  | 21 | #pragma clang diagnostic ignored "-Wconversion" | 
| Marin Shalamanov | bed7fd3 | 2020-12-21 20:02:20 +0100 | [diff] [blame] | 22 | #pragma clang diagnostic ignored "-Wextra" | 
| Marin Shalamanov | 30b0b3c | 2020-10-13 19:15:06 +0200 | [diff] [blame] | 23 |  | 
| Galia Peycheva | 561d05c | 2021-03-08 15:14:05 +0100 | [diff] [blame] | 24 | #include <cutils/properties.h> | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 25 | #include <gtest/gtest.h> | 
| Huihong Luo | 3bdef86 | 2022-03-03 11:57:19 -0800 | [diff] [blame] | 26 | #include <gui/AidlStatusUtil.h> | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 27 | #include <gui/ISurfaceComposer.h> | 
|  | 28 | #include <gui/SurfaceComposerClient.h> | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 29 | #include <private/gui/ComposerService.h> | 
| Huihong Luo | 05539a1 | 2022-02-23 10:29:40 -0800 | [diff] [blame] | 30 | #include <private/gui/ComposerServiceAIDL.h> | 
| Marin Shalamanov | a7fe304 | 2021-01-29 21:02:08 +0100 | [diff] [blame] | 31 | #include <ui/DisplayMode.h> | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 32 |  | 
|  | 33 | #include "BufferGenerator.h" | 
|  | 34 | #include "utils/ScreenshotUtils.h" | 
|  | 35 | #include "utils/TransactionUtils.h" | 
|  | 36 |  | 
|  | 37 | namespace android { | 
|  | 38 |  | 
|  | 39 | using android::hardware::graphics::common::V1_1::BufferUsage; | 
|  | 40 |  | 
|  | 41 | class LayerTransactionTest : public ::testing::Test { | 
|  | 42 | protected: | 
|  | 43 | void SetUp() override { | 
|  | 44 | mClient = new SurfaceComposerClient; | 
|  | 45 | ASSERT_EQ(NO_ERROR, mClient->initCheck()) << "failed to create SurfaceComposerClient"; | 
|  | 46 |  | 
|  | 47 | ASSERT_NO_FATAL_FAILURE(SetUpDisplay()); | 
|  | 48 |  | 
| Huihong Luo | 05539a1 | 2022-02-23 10:29:40 -0800 | [diff] [blame] | 49 | sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService()); | 
|  | 50 | binder::Status status = sf->getColorManagement(&mColorManagementUsed); | 
| Huihong Luo | 3bdef86 | 2022-03-03 11:57:19 -0800 | [diff] [blame] | 51 | ASSERT_NO_FATAL_FAILURE(gui::aidl_utils::statusTFromBinderStatus(status)); | 
| chaviw | d243289 | 2020-07-24 17:42:39 -0700 | [diff] [blame] | 52 |  | 
|  | 53 | mCaptureArgs.displayToken = mDisplay; | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 54 | } | 
|  | 55 |  | 
|  | 56 | virtual void TearDown() { | 
|  | 57 | mBlackBgSurface = 0; | 
|  | 58 | mClient->dispose(); | 
|  | 59 | mClient = 0; | 
|  | 60 | } | 
|  | 61 |  | 
|  | 62 | virtual sp<SurfaceControl> createLayer(const sp<SurfaceComposerClient>& client, | 
|  | 63 | const char* name, uint32_t width, uint32_t height, | 
| Valerie Hau | 1acd696 | 2019-10-28 16:35:48 -0700 | [diff] [blame] | 64 | uint32_t flags = 0, SurfaceControl* parent = nullptr, | 
| chaviw | debadb8 | 2020-03-26 14:57:24 -0700 | [diff] [blame] | 65 | uint32_t* outTransformHint = nullptr, | 
|  | 66 | PixelFormat format = PIXEL_FORMAT_RGBA_8888) { | 
|  | 67 | auto layer = | 
|  | 68 | createSurface(client, name, width, height, format, flags, parent, outTransformHint); | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 69 |  | 
|  | 70 | Transaction t; | 
|  | 71 | t.setLayerStack(layer, mDisplayLayerStack).setLayer(layer, mLayerZBase); | 
|  | 72 |  | 
|  | 73 | status_t error = t.apply(); | 
|  | 74 | if (error != NO_ERROR) { | 
|  | 75 | ADD_FAILURE() << "failed to initialize SurfaceControl"; | 
|  | 76 | layer.clear(); | 
|  | 77 | } | 
|  | 78 |  | 
|  | 79 | return layer; | 
|  | 80 | } | 
|  | 81 |  | 
|  | 82 | virtual sp<SurfaceControl> createSurface(const sp<SurfaceComposerClient>& client, | 
|  | 83 | const char* name, uint32_t width, uint32_t height, | 
|  | 84 | PixelFormat format, uint32_t flags, | 
| Valerie Hau | 1acd696 | 2019-10-28 16:35:48 -0700 | [diff] [blame] | 85 | SurfaceControl* parent = nullptr, | 
|  | 86 | uint32_t* outTransformHint = nullptr) { | 
| Vishnu Nair | 992496b | 2020-10-22 17:27:21 -0700 | [diff] [blame] | 87 | sp<IBinder> parentHandle = (parent) ? parent->getHandle() : nullptr; | 
|  | 88 | auto layer = client->createSurface(String8(name), width, height, format, flags, | 
|  | 89 | parentHandle, LayerMetadata(), outTransformHint); | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 90 | EXPECT_NE(nullptr, layer.get()) << "failed to create SurfaceControl"; | 
|  | 91 | return layer; | 
|  | 92 | } | 
|  | 93 |  | 
|  | 94 | virtual sp<SurfaceControl> createLayer(const char* name, uint32_t width, uint32_t height, | 
| Valerie Hau | 1acd696 | 2019-10-28 16:35:48 -0700 | [diff] [blame] | 95 | uint32_t flags = 0, SurfaceControl* parent = nullptr, | 
| chaviw | debadb8 | 2020-03-26 14:57:24 -0700 | [diff] [blame] | 96 | uint32_t* outTransformHint = nullptr, | 
|  | 97 | PixelFormat format = PIXEL_FORMAT_RGBA_8888) { | 
|  | 98 | return createLayer(mClient, name, width, height, flags, parent, outTransformHint, format); | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 99 | } | 
|  | 100 |  | 
|  | 101 | sp<SurfaceControl> createColorLayer(const char* name, const Color& color, | 
|  | 102 | SurfaceControl* parent = nullptr) { | 
|  | 103 | auto colorLayer = createSurface(mClient, name, 0 /* buffer width */, 0 /* buffer height */, | 
|  | 104 | PIXEL_FORMAT_RGBA_8888, | 
| Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 105 | ISurfaceComposerClient::eFXSurfaceEffect, parent); | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 106 | asTransaction([&](Transaction& t) { | 
|  | 107 | t.setColor(colorLayer, half3{color.r / 255.0f, color.g / 255.0f, color.b / 255.0f}); | 
|  | 108 | t.setAlpha(colorLayer, color.a / 255.0f); | 
|  | 109 | }); | 
|  | 110 | return colorLayer; | 
|  | 111 | } | 
|  | 112 |  | 
|  | 113 | ANativeWindow_Buffer getBufferQueueLayerBuffer(const sp<SurfaceControl>& layer) { | 
|  | 114 | // wait for previous transactions (such as setSize) to complete | 
|  | 115 | Transaction().apply(true); | 
|  | 116 |  | 
|  | 117 | ANativeWindow_Buffer buffer = {}; | 
|  | 118 | EXPECT_EQ(NO_ERROR, layer->getSurface()->lock(&buffer, nullptr)); | 
|  | 119 |  | 
|  | 120 | return buffer; | 
|  | 121 | } | 
|  | 122 |  | 
|  | 123 | void postBufferQueueLayerBuffer(const sp<SurfaceControl>& layer) { | 
|  | 124 | ASSERT_EQ(NO_ERROR, layer->getSurface()->unlockAndPost()); | 
|  | 125 |  | 
|  | 126 | // wait for the newly posted buffer to be latched | 
|  | 127 | waitForLayerBuffers(); | 
|  | 128 | } | 
|  | 129 |  | 
|  | 130 | virtual void fillBufferQueueLayerColor(const sp<SurfaceControl>& layer, const Color& color, | 
| Marin Shalamanov | 4608442 | 2020-10-13 12:33:42 +0200 | [diff] [blame] | 131 | uint32_t bufferWidth, uint32_t bufferHeight) { | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 132 | ANativeWindow_Buffer buffer; | 
|  | 133 | ASSERT_NO_FATAL_FAILURE(buffer = getBufferQueueLayerBuffer(layer)); | 
|  | 134 | TransactionUtils::fillANativeWindowBufferColor(buffer, | 
|  | 135 | Rect(0, 0, bufferWidth, bufferHeight), | 
|  | 136 | color); | 
|  | 137 | postBufferQueueLayerBuffer(layer); | 
|  | 138 | } | 
|  | 139 |  | 
|  | 140 | virtual void fillBufferStateLayerColor(const sp<SurfaceControl>& layer, const Color& color, | 
|  | 141 | int32_t bufferWidth, int32_t bufferHeight) { | 
|  | 142 | sp<GraphicBuffer> buffer = | 
|  | 143 | new GraphicBuffer(bufferWidth, bufferHeight, PIXEL_FORMAT_RGBA_8888, 1, | 
|  | 144 | BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN | | 
| Ady Abraham | 193426d | 2021-02-18 14:01:53 -0800 | [diff] [blame] | 145 | BufferUsage::COMPOSER_OVERLAY | BufferUsage::GPU_TEXTURE, | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 146 | "test"); | 
|  | 147 | TransactionUtils::fillGraphicBufferColor(buffer, Rect(0, 0, bufferWidth, bufferHeight), | 
|  | 148 | color); | 
|  | 149 | Transaction().setBuffer(layer, buffer).apply(); | 
|  | 150 | } | 
|  | 151 |  | 
|  | 152 | void fillLayerColor(uint32_t mLayerType, const sp<SurfaceControl>& layer, const Color& color, | 
| Marin Shalamanov | 4608442 | 2020-10-13 12:33:42 +0200 | [diff] [blame] | 153 | uint32_t bufferWidth, uint32_t bufferHeight) { | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 154 | switch (mLayerType) { | 
|  | 155 | case ISurfaceComposerClient::eFXSurfaceBufferQueue: | 
|  | 156 | fillBufferQueueLayerColor(layer, color, bufferWidth, bufferHeight); | 
|  | 157 | break; | 
|  | 158 | case ISurfaceComposerClient::eFXSurfaceBufferState: | 
|  | 159 | fillBufferStateLayerColor(layer, color, bufferWidth, bufferHeight); | 
|  | 160 | break; | 
|  | 161 | default: | 
|  | 162 | ASSERT_TRUE(false) << "unsupported layer type: " << mLayerType; | 
|  | 163 | } | 
|  | 164 | } | 
|  | 165 |  | 
|  | 166 | void fillLayerQuadrant(uint32_t mLayerType, const sp<SurfaceControl>& layer, | 
|  | 167 | int32_t bufferWidth, int32_t bufferHeight, const Color& topLeft, | 
|  | 168 | const Color& topRight, const Color& bottomLeft, | 
|  | 169 | const Color& bottomRight) { | 
|  | 170 | switch (mLayerType) { | 
|  | 171 | case ISurfaceComposerClient::eFXSurfaceBufferQueue: | 
|  | 172 | fillBufferQueueLayerQuadrant(layer, bufferWidth, bufferHeight, topLeft, topRight, | 
|  | 173 | bottomLeft, bottomRight); | 
|  | 174 | break; | 
|  | 175 | case ISurfaceComposerClient::eFXSurfaceBufferState: | 
|  | 176 | fillBufferStateLayerQuadrant(layer, bufferWidth, bufferHeight, topLeft, topRight, | 
|  | 177 | bottomLeft, bottomRight); | 
|  | 178 | break; | 
|  | 179 | default: | 
|  | 180 | ASSERT_TRUE(false) << "unsupported layer type: " << mLayerType; | 
|  | 181 | } | 
|  | 182 | } | 
|  | 183 |  | 
|  | 184 | virtual void fillBufferQueueLayerQuadrant(const sp<SurfaceControl>& layer, int32_t bufferWidth, | 
|  | 185 | int32_t bufferHeight, const Color& topLeft, | 
|  | 186 | const Color& topRight, const Color& bottomLeft, | 
|  | 187 | const Color& bottomRight) { | 
|  | 188 | ANativeWindow_Buffer buffer; | 
|  | 189 | ASSERT_NO_FATAL_FAILURE(buffer = getBufferQueueLayerBuffer(layer)); | 
|  | 190 | ASSERT_TRUE(bufferWidth % 2 == 0 && bufferHeight % 2 == 0); | 
|  | 191 |  | 
|  | 192 | const int32_t halfW = bufferWidth / 2; | 
|  | 193 | const int32_t halfH = bufferHeight / 2; | 
|  | 194 | TransactionUtils::fillANativeWindowBufferColor(buffer, Rect(0, 0, halfW, halfH), topLeft); | 
|  | 195 | TransactionUtils::fillANativeWindowBufferColor(buffer, Rect(halfW, 0, bufferWidth, halfH), | 
|  | 196 | topRight); | 
|  | 197 | TransactionUtils::fillANativeWindowBufferColor(buffer, Rect(0, halfH, halfW, bufferHeight), | 
|  | 198 | bottomLeft); | 
|  | 199 | TransactionUtils::fillANativeWindowBufferColor(buffer, | 
|  | 200 | Rect(halfW, halfH, bufferWidth, | 
|  | 201 | bufferHeight), | 
|  | 202 | bottomRight); | 
|  | 203 |  | 
|  | 204 | postBufferQueueLayerBuffer(layer); | 
|  | 205 | } | 
|  | 206 |  | 
|  | 207 | virtual void fillBufferStateLayerQuadrant(const sp<SurfaceControl>& layer, int32_t bufferWidth, | 
|  | 208 | int32_t bufferHeight, const Color& topLeft, | 
|  | 209 | const Color& topRight, const Color& bottomLeft, | 
|  | 210 | const Color& bottomRight) { | 
|  | 211 | sp<GraphicBuffer> buffer = | 
|  | 212 | new GraphicBuffer(bufferWidth, bufferHeight, PIXEL_FORMAT_RGBA_8888, 1, | 
|  | 213 | BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN | | 
| Ady Abraham | 193426d | 2021-02-18 14:01:53 -0800 | [diff] [blame] | 214 | BufferUsage::COMPOSER_OVERLAY | BufferUsage::GPU_TEXTURE, | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 215 | "test"); | 
|  | 216 |  | 
|  | 217 | ASSERT_TRUE(bufferWidth % 2 == 0 && bufferHeight % 2 == 0); | 
|  | 218 |  | 
|  | 219 | const int32_t halfW = bufferWidth / 2; | 
|  | 220 | const int32_t halfH = bufferHeight / 2; | 
|  | 221 | TransactionUtils::fillGraphicBufferColor(buffer, Rect(0, 0, halfW, halfH), topLeft); | 
|  | 222 | TransactionUtils::fillGraphicBufferColor(buffer, Rect(halfW, 0, bufferWidth, halfH), | 
|  | 223 | topRight); | 
|  | 224 | TransactionUtils::fillGraphicBufferColor(buffer, Rect(0, halfH, halfW, bufferHeight), | 
|  | 225 | bottomLeft); | 
|  | 226 | TransactionUtils::fillGraphicBufferColor(buffer, | 
|  | 227 | Rect(halfW, halfH, bufferWidth, bufferHeight), | 
|  | 228 | bottomRight); | 
|  | 229 |  | 
|  | 230 | Transaction().setBuffer(layer, buffer).setSize(layer, bufferWidth, bufferHeight).apply(); | 
|  | 231 | } | 
|  | 232 |  | 
|  | 233 | std::unique_ptr<ScreenCapture> screenshot() { | 
|  | 234 | std::unique_ptr<ScreenCapture> screenshot; | 
|  | 235 | ScreenCapture::captureScreen(&screenshot); | 
|  | 236 | return screenshot; | 
|  | 237 | } | 
|  | 238 |  | 
|  | 239 | void asTransaction(const std::function<void(Transaction&)>& exec) { | 
|  | 240 | Transaction t; | 
|  | 241 | exec(t); | 
|  | 242 | t.apply(true); | 
|  | 243 | } | 
|  | 244 |  | 
|  | 245 | static status_t getBuffer(sp<GraphicBuffer>* outBuffer, sp<Fence>* outFence) { | 
|  | 246 | static BufferGenerator bufferGenerator; | 
|  | 247 | return bufferGenerator.get(outBuffer, outFence); | 
|  | 248 | } | 
|  | 249 |  | 
| Chavi Weingarten | a5aedbd | 2021-04-09 13:37:33 +0000 | [diff] [blame] | 250 | static ui::Size getBufferSize() { | 
|  | 251 | static BufferGenerator bufferGenerator; | 
|  | 252 | return bufferGenerator.getSize(); | 
|  | 253 | } | 
|  | 254 |  | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 255 | sp<SurfaceComposerClient> mClient; | 
|  | 256 |  | 
| Galia Peycheva | 561d05c | 2021-03-08 15:14:05 +0100 | [diff] [blame] | 257 | bool deviceSupportsBlurs() { | 
|  | 258 | char value[PROPERTY_VALUE_MAX]; | 
|  | 259 | property_get("ro.surface_flinger.supports_background_blur", value, "0"); | 
|  | 260 | return atoi(value); | 
|  | 261 | } | 
|  | 262 |  | 
|  | 263 | bool deviceUsesSkiaRenderEngine() { | 
|  | 264 | char value[PROPERTY_VALUE_MAX]; | 
|  | 265 | property_get("debug.renderengine.backend", value, "default"); | 
|  | 266 | return strstr(value, "skia") != nullptr; | 
|  | 267 | } | 
|  | 268 |  | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 269 | sp<IBinder> mDisplay; | 
|  | 270 | uint32_t mDisplayWidth; | 
|  | 271 | uint32_t mDisplayHeight; | 
| Dominik Laskowski | 29fa146 | 2021-04-27 15:51:50 -0700 | [diff] [blame] | 272 | ui::LayerStack mDisplayLayerStack = ui::DEFAULT_LAYER_STACK; | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 273 | Rect mDisplayRect = Rect::INVALID_RECT; | 
|  | 274 |  | 
|  | 275 | // leave room for ~256 layers | 
|  | 276 | const int32_t mLayerZBase = std::numeric_limits<int32_t>::max() - 256; | 
|  | 277 |  | 
|  | 278 | sp<SurfaceControl> mBlackBgSurface; | 
|  | 279 | bool mColorManagementUsed; | 
|  | 280 |  | 
| chaviw | d243289 | 2020-07-24 17:42:39 -0700 | [diff] [blame] | 281 | DisplayCaptureArgs mCaptureArgs; | 
|  | 282 | ScreenCaptureResults mCaptureResults; | 
|  | 283 |  | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 284 | private: | 
|  | 285 | void SetUpDisplay() { | 
|  | 286 | mDisplay = mClient->getInternalDisplayToken(); | 
|  | 287 | ASSERT_FALSE(mDisplay == nullptr) << "failed to get display"; | 
|  | 288 |  | 
| Marin Shalamanov | a7fe304 | 2021-01-29 21:02:08 +0100 | [diff] [blame] | 289 | ui::DisplayMode mode; | 
|  | 290 | ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(mDisplay, &mode)); | 
|  | 291 | mDisplayRect = Rect(mode.resolution); | 
| Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 292 | mDisplayWidth = mDisplayRect.getWidth(); | 
|  | 293 | mDisplayHeight = mDisplayRect.getHeight(); | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 294 |  | 
|  | 295 | // After a new buffer is queued, SurfaceFlinger is notified and will | 
|  | 296 | // latch the new buffer on next vsync.  Let's heuristically wait for 3 | 
|  | 297 | // vsyncs. | 
| Marin Shalamanov | a7fe304 | 2021-01-29 21:02:08 +0100 | [diff] [blame] | 298 | mBufferPostDelay = static_cast<int32_t>(1e6 / mode.refreshRate) * 3; | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 299 |  | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 300 | mBlackBgSurface = | 
|  | 301 | createSurface(mClient, "BaseSurface", 0 /* buffer width */, 0 /* buffer height */, | 
| Vishnu Nair | fa247b1 | 2020-02-11 08:58:26 -0800 | [diff] [blame] | 302 | PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eFXSurfaceEffect); | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 303 |  | 
|  | 304 | // set layer stack (b/68888219) | 
|  | 305 | Transaction t; | 
|  | 306 | t.setDisplayLayerStack(mDisplay, mDisplayLayerStack); | 
| chaviw | 2571450 | 2021-02-11 10:01:08 -0800 | [diff] [blame] | 307 | t.setCrop(mBlackBgSurface, Rect(0, 0, mDisplayWidth, mDisplayHeight)); | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 308 | t.setLayerStack(mBlackBgSurface, mDisplayLayerStack); | 
|  | 309 | t.setColor(mBlackBgSurface, half3{0, 0, 0}); | 
|  | 310 | t.setLayer(mBlackBgSurface, mLayerZBase); | 
|  | 311 | t.apply(); | 
|  | 312 | } | 
|  | 313 |  | 
|  | 314 | void waitForLayerBuffers() { | 
|  | 315 | // Request an empty transaction to get applied synchronously to ensure the buffer is | 
|  | 316 | // latched. | 
|  | 317 | Transaction().apply(true); | 
|  | 318 | usleep(mBufferPostDelay); | 
|  | 319 | } | 
|  | 320 |  | 
|  | 321 | int32_t mBufferPostDelay; | 
|  | 322 |  | 
|  | 323 | friend class LayerRenderPathTestHarness; | 
|  | 324 | }; | 
| Valerie Hau | 9cfc6d8 | 2019-09-23 13:54:07 -0700 | [diff] [blame] | 325 |  | 
| Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 326 | } // namespace android | 
| Marin Shalamanov | 30b0b3c | 2020-10-13 19:15:06 +0200 | [diff] [blame] | 327 |  | 
|  | 328 | // TODO(b/129481165): remove the #pragma below and fix conversion issues | 
| Galia Peycheva | 561d05c | 2021-03-08 15:14:05 +0100 | [diff] [blame] | 329 | #pragma clang diagnostic pop // ignored "-Wconversion -Wextra" |