summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp')
-rw-r--r--services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp425
1 files changed, 332 insertions, 93 deletions
diff --git a/services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp b/services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp
index 7d4314f4df..43d957cf7a 100644
--- a/services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp
+++ b/services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp
@@ -18,7 +18,6 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
-#include <cutils/properties.h>
#include <gui/BufferItemConsumer.h>
#include "TransactionTestHarnesses.h"
@@ -40,6 +39,9 @@ public:
protected:
LayerRenderPathTestHarness mRenderPathHarness;
+
+ static constexpr int64_t kUsageFlags = BufferUsage::CPU_READ_OFTEN |
+ BufferUsage::CPU_WRITE_OFTEN | BufferUsage::COMPOSER_OVERLAY | BufferUsage::GPU_TEXTURE;
};
::testing::Environment* const binderEnv =
@@ -49,14 +51,9 @@ INSTANTIATE_TEST_CASE_P(
LayerTypeAndRenderTypeTransactionTests, LayerTypeAndRenderTypeTransactionTest,
::testing::Combine(
::testing::Values(
- static_cast<uint32_t>(ISurfaceComposerClient::eFXSurfaceBufferQueue),
static_cast<uint32_t>(ISurfaceComposerClient::eFXSurfaceBufferState)),
::testing::Values(RenderPath::VIRTUAL_DISPLAY, RenderPath::SCREENSHOT)));
-TEST_P(LayerTypeAndRenderTypeTransactionTest, SetSizeInvalid) {
- // cannot test robustness against invalid sizes (zero or really huge)
-}
-
TEST_P(LayerTypeAndRenderTypeTransactionTest, SetZBasic) {
sp<SurfaceControl> layerR;
sp<SurfaceControl> layerG;
@@ -87,10 +84,7 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetRelativeZBug64572777) {
ASSERT_NO_FATAL_FAILURE(layerG = createLayer("test G", 32, 32));
ASSERT_NO_FATAL_FAILURE(fillLayerColor(layerG, Color::GREEN, 32, 32));
- Transaction()
- .setPosition(layerG, 16, 16)
- .setRelativeLayer(layerG, layerR->getHandle(), 1)
- .apply();
+ Transaction().setPosition(layerG, 16, 16).setRelativeLayer(layerG, layerR, 1).apply();
Transaction().reparent(layerG, nullptr).apply();
@@ -146,7 +140,7 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetZNegative) {
sp<SurfaceControl> parent =
LayerTransactionTest::createLayer("Parent", 0 /* buffer width */, 0 /* buffer height */,
ISurfaceComposerClient::eFXSurfaceContainer);
- Transaction().setCrop_legacy(parent, Rect(0, 0, mDisplayWidth, mDisplayHeight)).apply();
+ Transaction().setCrop(parent, Rect(0, 0, mDisplayWidth, mDisplayHeight)).apply();
sp<SurfaceControl> layerR;
sp<SurfaceControl> layerG;
ASSERT_NO_FATAL_FAILURE(layerR = createLayer("test R", 32, 32));
@@ -154,10 +148,7 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetZNegative) {
ASSERT_NO_FATAL_FAILURE(layerG = createLayer("test G", 32, 32));
ASSERT_NO_FATAL_FAILURE(fillLayerColor(layerG, Color::GREEN, 32, 32));
- Transaction()
- .reparent(layerR, parent->getHandle())
- .reparent(layerG, parent->getHandle())
- .apply();
+ Transaction().reparent(layerR, parent).reparent(layerG, parent).apply();
Transaction().setLayer(layerR, -1).setLayer(layerG, -2).apply();
{
SCOPED_TRACE("layerR");
@@ -200,17 +191,7 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetCornerRadius) {
ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", size, size));
ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED, size, size));
- if (mLayerType == ISurfaceComposerClient::eFXSurfaceBufferQueue) {
- Transaction()
- .setCornerRadius(layer, cornerRadius)
- .setCrop_legacy(layer, Rect(0, 0, size, size))
- .apply();
- } else {
- Transaction()
- .setCornerRadius(layer, cornerRadius)
- .setFrame(layer, Rect(0, 0, size, size))
- .apply();
- }
+ Transaction().setCornerRadius(layer, cornerRadius).apply();
{
const uint8_t bottom = size - 1;
const uint8_t right = size - 1;
@@ -238,19 +219,13 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetCornerRadiusRotated) {
ASSERT_NO_FATAL_FAILURE(child = createLayer("child", size, size));
ASSERT_NO_FATAL_FAILURE(fillLayerColor(child, Color::GREEN, size, size));
- auto transaction = Transaction()
- .setCornerRadius(parent, cornerRadius)
- .setCrop_legacy(parent, Rect(0, 0, size, size))
- .reparent(child, parent->getHandle())
- .setPosition(child, 0, size)
- // Rotate by half PI
- .setMatrix(child, 0.0f, -1.0f, 1.0f, 0.0f);
- if (mLayerType == ISurfaceComposerClient::eFXSurfaceBufferQueue) {
- transaction.setCrop_legacy(parent, Rect(0, 0, size, size));
- } else {
- transaction.setFrame(parent, Rect(0, 0, size, size));
- }
- transaction.apply();
+ Transaction()
+ .setCornerRadius(parent, cornerRadius)
+ .reparent(child, parent)
+ .setPosition(child, 0, size)
+ // Rotate by half PI
+ .setMatrix(child, 0.0f, -1.0f, 1.0f, 0.0f)
+ .apply();
{
const uint8_t bottom = size - 1;
@@ -279,21 +254,12 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetCornerRadiusChildCrop) {
ASSERT_NO_FATAL_FAILURE(child = createLayer("child", size, size / 2));
ASSERT_NO_FATAL_FAILURE(fillLayerColor(child, Color::GREEN, size, size / 2));
- if (mLayerType == ISurfaceComposerClient::eFXSurfaceBufferQueue) {
- Transaction()
- .setCornerRadius(parent, cornerRadius)
- .setCrop_legacy(parent, Rect(0, 0, size, size))
- .reparent(child, parent->getHandle())
- .setPosition(child, 0, size / 2)
- .apply();
- } else {
- Transaction()
- .setCornerRadius(parent, cornerRadius)
- .setFrame(parent, Rect(0, 0, size, size))
- .reparent(child, parent->getHandle())
- .setFrame(child, Rect(0, size / 2, size, size))
- .apply();
- }
+ Transaction()
+ .setCornerRadius(parent, cornerRadius)
+ .reparent(child, parent)
+ .setPosition(child, 0, size / 2)
+ .apply();
+
{
const uint8_t bottom = size - 1;
const uint8_t right = size - 1;
@@ -307,47 +273,273 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetCornerRadiusChildCrop) {
}
}
-TEST_P(LayerTypeAndRenderTypeTransactionTest, SetBackgroundBlurRadius) {
- char value[PROPERTY_VALUE_MAX];
- property_get("ro.surface_flinger.supports_background_blur", value, "0");
- if (!atoi(value)) {
- // This device doesn't support blurs, no-op.
- return;
+TEST_P(LayerTypeAndRenderTypeTransactionTest, SetCornerRadiusBufferRotationTransform) {
+ sp<SurfaceControl> layer;
+ sp<SurfaceControl> parent;
+ ASSERT_NO_FATAL_FAILURE(
+ parent = LayerTransactionTest::createLayer("parent", 0, 0,
+ ISurfaceComposerClient::eFXSurfaceEffect));
+
+ const uint32_t bufferWidth = 1500;
+ const uint32_t bufferHeight = 300;
+
+ const uint32_t layerWidth = 300;
+ const uint32_t layerHeight = 1500;
+
+ const uint32_t testArea = 4;
+ const float cornerRadius = 120.0f;
+ ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", bufferWidth, bufferHeight));
+ ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::RED, bufferWidth, bufferHeight));
+
+ Transaction()
+ .reparent(layer, parent)
+ .setColor(parent, half3(0, 1, 0))
+ .setCrop(parent, Rect(0, 0, layerWidth, layerHeight))
+ .setCornerRadius(parent, cornerRadius)
+
+ .setTransform(layer, ui::Transform::ROT_90)
+ .setDestinationFrame(layer, Rect(0, 0, layerWidth, layerHeight))
+ .apply();
+ {
+ auto shot = getScreenCapture();
+ // Corners are transparent
+ // top-left
+ shot->expectColor(Rect(0, 0, testArea, testArea), Color::BLACK);
+ // top-right
+ shot->expectColor(Rect(layerWidth - testArea, 0, layerWidth, testArea), Color::BLACK);
+ // bottom-left
+ shot->expectColor(Rect(0, layerHeight - testArea, testArea, layerHeight), Color::BLACK);
+ // bottom-right
+ shot->expectColor(Rect(layerWidth - testArea, layerHeight - testArea, layerWidth,
+ layerHeight),
+ Color::BLACK);
+
+ // Area after corner radius is solid
+ // top-left to top-right under the corner
+ shot->expectColor(Rect(0, cornerRadius, layerWidth, cornerRadius + testArea), Color::RED);
+ // bottom-left to bottom-right above the corner
+ shot->expectColor(Rect(0, layerHeight - cornerRadius - testArea, layerWidth,
+ layerHeight - cornerRadius),
+ Color::RED);
+ // left side after the corner
+ shot->expectColor(Rect(cornerRadius, 0, cornerRadius + testArea, layerHeight), Color::RED);
+ // right side before the corner
+ shot->expectColor(Rect(layerWidth - cornerRadius - testArea, 0, layerWidth - cornerRadius,
+ layerHeight),
+ Color::RED);
}
+}
- auto size = 256;
- auto center = size / 2;
- auto blurRadius = 50;
+TEST_P(LayerTypeAndRenderTypeTransactionTest, SetCornerRadiusBufferCropTransform) {
+ sp<SurfaceControl> layer;
+ sp<SurfaceControl> parent;
+ ASSERT_NO_FATAL_FAILURE(
+ parent = LayerTransactionTest::createLayer("parent", 0, 0,
+ ISurfaceComposerClient::eFXSurfaceEffect));
- sp<SurfaceControl> backgroundLayer;
- ASSERT_NO_FATAL_FAILURE(backgroundLayer = createLayer("background", size, size));
- ASSERT_NO_FATAL_FAILURE(fillLayerColor(backgroundLayer, Color::GREEN, size, size));
+ const uint32_t bufferWidth = 150 * 2;
+ const uint32_t bufferHeight = 750 * 2;
- sp<SurfaceControl> leftLayer;
- ASSERT_NO_FATAL_FAILURE(leftLayer = createLayer("left", size / 2, size));
- ASSERT_NO_FATAL_FAILURE(fillLayerColor(leftLayer, Color::RED, size / 2, size));
+ const Rect bufferCrop(0, 0, 150, 750);
+
+ const uint32_t layerWidth = 300;
+ const uint32_t layerHeight = 1500;
+
+ const uint32_t testArea = 4;
+ const float cornerRadius = 120.0f;
+ ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", bufferWidth, bufferHeight));
+ ASSERT_NO_FATAL_FAILURE(fillLayerQuadrant(layer, bufferWidth, bufferHeight, Color::RED,
+ Color::BLACK, Color::GREEN, Color::BLUE));
+
+ Transaction()
+ .reparent(layer, parent)
+ .setColor(parent, half3(0, 1, 0))
+ .setCrop(parent, Rect(0, 0, layerWidth, layerHeight))
+ .setCornerRadius(parent, cornerRadius)
+
+ .setBufferCrop(layer, bufferCrop)
+ .setDestinationFrame(layer, Rect(0, 0, layerWidth, layerHeight))
+ .apply();
+ {
+ auto shot = getScreenCapture();
+ // Corners are transparent
+ // top-left
+ shot->expectColor(Rect(0, 0, testArea, testArea), Color::BLACK);
+ // top-right
+ shot->expectColor(Rect(layerWidth - testArea, 0, layerWidth, testArea), Color::BLACK);
+ // bottom-left
+ shot->expectColor(Rect(0, layerHeight - testArea, testArea, layerHeight), Color::BLACK);
+ // bottom-right
+ shot->expectColor(Rect(layerWidth - testArea, layerHeight - testArea, layerWidth,
+ layerHeight),
+ Color::BLACK);
+
+ // Area after corner radius is solid
+ // since the buffer is scaled, there will blending so adjust some of the bounds when
+ // checking.
+ float adjustedCornerRadius = cornerRadius + 15;
+ float adjustedLayerHeight = layerHeight - 15;
+ float adjustedLayerWidth = layerWidth - 15;
+
+ // top-left to top-right under the corner
+ shot->expectColor(Rect(15, adjustedCornerRadius, adjustedLayerWidth,
+ adjustedCornerRadius + testArea),
+ Color::RED);
+ // bottom-left to bottom-right above the corner
+ shot->expectColor(Rect(15, adjustedLayerHeight - adjustedCornerRadius - testArea,
+ adjustedLayerWidth, adjustedLayerHeight - adjustedCornerRadius),
+ Color::RED);
+ // left side after the corner
+ shot->expectColor(Rect(adjustedCornerRadius, 15, adjustedCornerRadius + testArea,
+ adjustedLayerHeight),
+ Color::RED);
+ // right side before the corner
+ shot->expectColor(Rect(adjustedLayerWidth - adjustedCornerRadius - testArea, 15,
+ adjustedLayerWidth - adjustedCornerRadius, adjustedLayerHeight),
+ Color::RED);
+ }
+}
+TEST_P(LayerTypeAndRenderTypeTransactionTest, SetCornerRadiusChildBufferRotationTransform) {
+ sp<SurfaceControl> layer;
+ sp<SurfaceControl> parent;
+ ASSERT_NO_FATAL_FAILURE(
+ parent = LayerTransactionTest::createLayer("parent", 0, 0,
+ ISurfaceComposerClient::eFXSurfaceEffect));
+
+ const uint32_t bufferWidth = 1500;
+ const uint32_t bufferHeight = 300;
+
+ const uint32_t layerWidth = 300;
+ const uint32_t layerHeight = 1500;
+
+ const uint32_t testArea = 4;
+ const float cornerRadius = 120.0f;
+ ASSERT_NO_FATAL_FAILURE(layer = createLayer("test", bufferWidth, bufferHeight));
+ ASSERT_NO_FATAL_FAILURE(fillLayerColor(layer, Color::BLUE, bufferWidth, bufferHeight));
+
+ sp<SurfaceControl> child;
+ ASSERT_NO_FATAL_FAILURE(child = createLayer("child", bufferWidth, bufferHeight));
+ ASSERT_NO_FATAL_FAILURE(fillLayerColor(child, Color::RED, bufferWidth, bufferHeight));
+
+ Transaction()
+ .reparent(layer, parent)
+ .reparent(child, layer)
+ .setColor(parent, half3(0, 1, 0))
+ .setCrop(parent, Rect(0, 0, layerWidth, layerHeight))
+ .setCornerRadius(parent, cornerRadius) /* */
+
+ .setTransform(layer, ui::Transform::ROT_90)
+ .setDestinationFrame(layer, Rect(0, 0, layerWidth, layerHeight))
+
+ .setTransform(child, ui::Transform::ROT_90)
+ .setDestinationFrame(child, Rect(0, 0, layerWidth, layerHeight))
+ .apply();
+ {
+ auto shot = getScreenCapture();
+ // Corners are transparent
+ // top-left
+ shot->expectColor(Rect(0, 0, testArea, testArea), Color::BLACK);
+ // top-right
+ shot->expectColor(Rect(layerWidth - testArea, 0, layerWidth, testArea), Color::BLACK);
+ // bottom-left
+ shot->expectColor(Rect(0, layerHeight - testArea, testArea, layerHeight), Color::BLACK);
+ // bottom-right
+ shot->expectColor(Rect(layerWidth - testArea, layerHeight - testArea, layerWidth,
+ layerHeight),
+ Color::BLACK);
+
+ // Area after corner radius is solid
+ // top-left to top-right under the corner
+ shot->expectColor(Rect(0, cornerRadius, layerWidth, cornerRadius + testArea), Color::RED);
+ // bottom-left to bottom-right above the corner
+ shot->expectColor(Rect(0, layerHeight - cornerRadius - testArea, layerWidth,
+ layerHeight - cornerRadius),
+ Color::RED);
+ // left side after the corner
+ shot->expectColor(Rect(cornerRadius, 0, cornerRadius + testArea, layerHeight), Color::RED);
+ // right side before the corner
+ shot->expectColor(Rect(layerWidth - cornerRadius - testArea, 0, layerWidth - cornerRadius,
+ layerHeight),
+ Color::RED);
+ }
+}
+
+TEST_P(LayerTypeAndRenderTypeTransactionTest, SetBackgroundBlurRadiusSimple) {
+ if (!deviceSupportsBlurs()) GTEST_SKIP();
+ if (!deviceUsesSkiaRenderEngine()) GTEST_SKIP();
+
+ const auto canvasSize = 256;
+
+ sp<SurfaceControl> leftLayer;
+ sp<SurfaceControl> rightLayer;
+ sp<SurfaceControl> greenLayer;
sp<SurfaceControl> blurLayer;
- ASSERT_NO_FATAL_FAILURE(blurLayer = createLayer("blur", size, size));
- ASSERT_NO_FATAL_FAILURE(fillLayerColor(blurLayer, Color::TRANSPARENT, size, size));
+ const auto leftRect = Rect(0, 0, canvasSize / 2, canvasSize);
+ const auto rightRect = Rect(canvasSize / 2, 0, canvasSize, canvasSize);
+ const auto blurRect = Rect(0, 0, canvasSize, canvasSize);
- Transaction().setBackgroundBlurRadius(blurLayer, blurRadius).apply();
+ ASSERT_NO_FATAL_FAILURE(leftLayer =
+ createLayer("Left", leftRect.getWidth(), leftRect.getHeight()));
+ ASSERT_NO_FATAL_FAILURE(
+ fillLayerColor(leftLayer, Color::BLUE, leftRect.getWidth(), leftRect.getHeight()));
+ ASSERT_NO_FATAL_FAILURE(greenLayer = createLayer("Green", canvasSize * 2, canvasSize * 2));
+ ASSERT_NO_FATAL_FAILURE(
+ fillLayerColor(greenLayer, Color::GREEN, canvasSize * 2, canvasSize * 2));
+ ASSERT_NO_FATAL_FAILURE(
+ rightLayer = createLayer("Right", rightRect.getWidth(), rightRect.getHeight()));
+ ASSERT_NO_FATAL_FAILURE(
+ fillLayerColor(rightLayer, Color::RED, rightRect.getWidth(), rightRect.getHeight()));
- auto shot = getScreenCapture();
- // Edges are mixed
- shot->expectColor(Rect(center - 1, center - 5, center, center + 5), Color{150, 150, 0, 255},
- 50 /* tolerance */);
- shot->expectColor(Rect(center, center - 5, center + 1, center + 5), Color{150, 150, 0, 255},
- 50 /* tolerance */);
+ Transaction()
+ .setLayer(greenLayer, mLayerZBase)
+ .setLayer(leftLayer, mLayerZBase + 1)
+ .setLayer(rightLayer, mLayerZBase + 2)
+ .setPosition(rightLayer, rightRect.left, rightRect.top)
+ .apply();
+
+ {
+ auto shot = getScreenCapture();
+ shot->expectColor(leftRect, Color::BLUE);
+ shot->expectColor(rightRect, Color::RED);
+ }
+
+ ASSERT_NO_FATAL_FAILURE(blurLayer = createColorLayer("BackgroundBlur", Color::TRANSPARENT));
+
+ const auto blurRadius = canvasSize / 2;
+ Transaction()
+ .setLayer(blurLayer, mLayerZBase + 3)
+ .setBackgroundBlurRadius(blurLayer, blurRadius)
+ .setCrop(blurLayer, blurRect)
+ .setAlpha(blurLayer, 0.0f)
+ .apply();
+
+ {
+ auto shot = getScreenCapture();
+
+ const auto stepSize = 1;
+ const auto blurAreaOffset = blurRadius * 0.7f;
+ const auto blurAreaStartX = canvasSize / 2 - blurRadius + blurAreaOffset;
+ const auto blurAreaEndX = canvasSize / 2 + blurRadius - blurAreaOffset;
+ Color previousColor;
+ Color currentColor;
+ for (int y = 0; y < canvasSize; y++) {
+ shot->checkPixel(0, y, /* r = */ 0, /* g = */ 0, /* b = */ 255);
+ previousColor = shot->getPixelColor(0, y);
+ for (int x = blurAreaStartX; x < blurAreaEndX; x += stepSize) {
+ currentColor = shot->getPixelColor(x, y);
+ ASSERT_GT(currentColor.r, previousColor.r);
+ ASSERT_LT(currentColor.b, previousColor.b);
+ ASSERT_EQ(0, currentColor.g);
+ }
+ shot->checkPixel(canvasSize - 1, y, 255, 0, 0);
+ }
+ }
}
TEST_P(LayerTypeAndRenderTypeTransactionTest, SetBackgroundBlurRadiusOnMultipleLayers) {
- char value[PROPERTY_VALUE_MAX];
- property_get("ro.surface_flinger.supports_background_blur", value, "0");
- if (!atoi(value)) {
- // This device doesn't support blurs, no-op.
- return;
- }
+ if (!deviceSupportsBlurs()) GTEST_SKIP();
+ if (!deviceUsesSkiaRenderEngine()) GTEST_SKIP();
auto size = 256;
auto center = size / 2;
@@ -383,6 +575,59 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetBackgroundBlurRadiusOnMultipleL
40 /* tolerance */);
}
+TEST_P(LayerTypeAndRenderTypeTransactionTest, SetBackgroundBlurAffectedByParentAlpha) {
+ if (!deviceSupportsBlurs()) GTEST_SKIP();
+ if (!deviceUsesSkiaRenderEngine()) GTEST_SKIP();
+
+ sp<SurfaceControl> left;
+ sp<SurfaceControl> right;
+ sp<SurfaceControl> blur;
+ sp<SurfaceControl> blurParent;
+
+ const auto size = 256;
+ ASSERT_NO_FATAL_FAILURE(left = createLayer("Left", size, size));
+ ASSERT_NO_FATAL_FAILURE(fillLayerColor(left, Color::BLUE, size, size));
+ ASSERT_NO_FATAL_FAILURE(right = createLayer("Right", size, size));
+ ASSERT_NO_FATAL_FAILURE(fillLayerColor(right, Color::RED, size, size));
+
+ Transaction()
+ .setLayer(left, mLayerZBase + 1)
+ .setLayer(right, mLayerZBase + 2)
+ .setPosition(right, size, 0)
+ .apply();
+
+ {
+ auto shot = getScreenCapture();
+ shot->expectColor(Rect(0, 0, size, size), Color::BLUE);
+ shot->expectColor(Rect(size, 0, size * 2, size), Color::RED);
+ }
+
+ ASSERT_NO_FATAL_FAILURE(blur = createLayer("BackgroundBlur", size * 2, size));
+ ASSERT_NO_FATAL_FAILURE(fillLayerColor(blur, Color::TRANSPARENT, size * 2, size));
+ ASSERT_NO_FATAL_FAILURE(blurParent = createLayer("BackgroundBlurParent", size * 2, size));
+ ASSERT_NO_FATAL_FAILURE(fillLayerColor(blurParent, Color::TRANSPARENT, size * 2, size));
+
+ Transaction()
+ .setLayer(blurParent, mLayerZBase + 3)
+ .setAlpha(blurParent, 0.5)
+ .setLayer(blur, mLayerZBase + 4)
+ .setBackgroundBlurRadius(blur, size) // set the blur radius to the size of one rect
+ .reparent(blur, blurParent)
+ .apply();
+
+ {
+ auto shot = getScreenCapture();
+ // assert that outer sides of the red and blue rects are not blended with the other color;
+ // if the blur didn't take into account parent alpha, the outer sides would have traces of
+ // the other color
+ shot->expectColor(Rect(0, 0, size / 2, size), Color::BLUE);
+ shot->expectColor(Rect(size + size / 2, 0, size * 2, size), Color::RED);
+ // assert that middle line has blended red and blur color; adding a tolerance of 10 to
+ // account for future blur algorithm changes
+ shot->expectColor(Rect(size, 0, size + 1, size), {136, 0, 119, 255}, 10);
+ }
+}
+
TEST_P(LayerTypeAndRenderTypeTransactionTest, SetColorWithBuffer) {
sp<SurfaceControl> bufferLayer;
ASSERT_NO_FATAL_FAILURE(bufferLayer = createLayer("test", 32, 32));
@@ -425,7 +670,7 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetBufferFormat) {
.setLayer(layer, INT32_MAX - 1)
.show(layer)
.setLayerStack(behindLayer, mDisplayLayerStack)
- .setCrop_legacy(behindLayer, crop)
+ .setCrop(behindLayer, crop)
.setLayer(behindLayer, INT32_MAX - 2)
.show(behindLayer)
.apply();
@@ -433,10 +678,7 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetBufferFormat) {
sp<Surface> surface = layer->getSurface();
sp<GraphicBuffer> buffer =
- new GraphicBuffer(width, height, PIXEL_FORMAT_RGBX_8888, 1,
- BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
- BufferUsage::COMPOSER_OVERLAY,
- "test");
+ new GraphicBuffer(width, height, PIXEL_FORMAT_RGBX_8888, 1, kUsageFlags, "test");
ASSERT_NO_FATAL_FAILURE(
TransactionUtils::fillGraphicBufferColor(buffer, crop, Color::TRANSPARENT));
@@ -452,10 +694,7 @@ TEST_P(LayerTypeAndRenderTypeTransactionTest, SetBufferFormat) {
shot->expectColor(crop, Color::BLACK);
}
- buffer = new GraphicBuffer(width, height, PIXEL_FORMAT_RGBA_8888, 1,
- BufferUsage::CPU_READ_OFTEN | BufferUsage::CPU_WRITE_OFTEN |
- BufferUsage::COMPOSER_OVERLAY,
- "test");
+ buffer = new GraphicBuffer(width, height, PIXEL_FORMAT_RGBA_8888, 1, kUsageFlags, "test");
ASSERT_NO_FATAL_FAILURE(
TransactionUtils::fillGraphicBufferColor(buffer, crop, Color::TRANSPARENT));