Loading services/surfaceflinger/BufferStateLayer.cpp +27 −0 Original line number Diff line number Diff line Loading @@ -742,6 +742,33 @@ sp<Layer> BufferStateLayer::createClone() { layer->setInitialValuesForClone(this); return layer; } Layer::RoundedCornerState BufferStateLayer::getRoundedCornerState() const { const auto& p = mDrawingParent.promote(); if (p != nullptr) { RoundedCornerState parentState = p->getRoundedCornerState(); if (parentState.radius > 0) { ui::Transform t = getActiveTransform(getDrawingState()); t = t.inverse(); parentState.cropRect = t.transform(parentState.cropRect); // The rounded corners shader only accepts 1 corner radius for performance reasons, // but a transform matrix can define horizontal and vertical scales. // Let's take the average between both of them and pass into the shader, practically we // never do this type of transformation on windows anyway. parentState.radius *= (t[0][0] + t[1][1]) / 2.0f; return parentState; } } const float radius = getDrawingState().cornerRadius; const State& s(getDrawingState()); if (radius <= 0 || (getActiveWidth(s) == UINT32_MAX && getActiveHeight(s) == UINT32_MAX)) return RoundedCornerState(); return RoundedCornerState(FloatRect(static_cast<float>(s.active.transform.tx()), static_cast<float>(s.active.transform.ty()), static_cast<float>(s.active.transform.tx() + s.active.w), static_cast<float>(s.active.transform.ty() + s.active.h)), radius); } } // namespace android // TODO(b/129481165): remove the #pragma below and fix conversion issues Loading services/surfaceflinger/BufferStateLayer.h +1 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ public: Rect getBufferSize(const State& s) const override; FloatRect computeSourceBounds(const FloatRect& parentBounds) const override; Layer::RoundedCornerState getRoundedCornerState() const override; // ----------------------------------------------------------------------- Loading services/surfaceflinger/Layer.h +1 −1 Original line number Diff line number Diff line Loading @@ -710,7 +710,7 @@ public: // corner definition and converting it into current layer's coordinates. // As of now, only 1 corner radius per display list is supported. Subsequent ones will be // ignored. RoundedCornerState getRoundedCornerState() const; virtual RoundedCornerState getRoundedCornerState() const; renderengine::ShadowSettings getShadowSettings(const Rect& viewport) const; Loading services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp +26 −10 Original line number Diff line number Diff line Loading @@ -199,10 +199,17 @@ 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(); } { const uint8_t bottom = size - 1; const uint8_t right = size - 1; Loading @@ -226,12 +233,21 @@ 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(); } { const uint8_t bottom = size - 1; const uint8_t right = size - 1; Loading Loading
services/surfaceflinger/BufferStateLayer.cpp +27 −0 Original line number Diff line number Diff line Loading @@ -742,6 +742,33 @@ sp<Layer> BufferStateLayer::createClone() { layer->setInitialValuesForClone(this); return layer; } Layer::RoundedCornerState BufferStateLayer::getRoundedCornerState() const { const auto& p = mDrawingParent.promote(); if (p != nullptr) { RoundedCornerState parentState = p->getRoundedCornerState(); if (parentState.radius > 0) { ui::Transform t = getActiveTransform(getDrawingState()); t = t.inverse(); parentState.cropRect = t.transform(parentState.cropRect); // The rounded corners shader only accepts 1 corner radius for performance reasons, // but a transform matrix can define horizontal and vertical scales. // Let's take the average between both of them and pass into the shader, practically we // never do this type of transformation on windows anyway. parentState.radius *= (t[0][0] + t[1][1]) / 2.0f; return parentState; } } const float radius = getDrawingState().cornerRadius; const State& s(getDrawingState()); if (radius <= 0 || (getActiveWidth(s) == UINT32_MAX && getActiveHeight(s) == UINT32_MAX)) return RoundedCornerState(); return RoundedCornerState(FloatRect(static_cast<float>(s.active.transform.tx()), static_cast<float>(s.active.transform.ty()), static_cast<float>(s.active.transform.tx() + s.active.w), static_cast<float>(s.active.transform.ty() + s.active.h)), radius); } } // namespace android // TODO(b/129481165): remove the #pragma below and fix conversion issues Loading
services/surfaceflinger/BufferStateLayer.h +1 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ public: Rect getBufferSize(const State& s) const override; FloatRect computeSourceBounds(const FloatRect& parentBounds) const override; Layer::RoundedCornerState getRoundedCornerState() const override; // ----------------------------------------------------------------------- Loading
services/surfaceflinger/Layer.h +1 −1 Original line number Diff line number Diff line Loading @@ -710,7 +710,7 @@ public: // corner definition and converting it into current layer's coordinates. // As of now, only 1 corner radius per display list is supported. Subsequent ones will be // ignored. RoundedCornerState getRoundedCornerState() const; virtual RoundedCornerState getRoundedCornerState() const; renderengine::ShadowSettings getShadowSettings(const Rect& viewport) const; Loading
services/surfaceflinger/tests/LayerTypeAndRenderTypeTransaction_test.cpp +26 −10 Original line number Diff line number Diff line Loading @@ -199,10 +199,17 @@ 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(); } { const uint8_t bottom = size - 1; const uint8_t right = size - 1; Loading @@ -226,12 +233,21 @@ 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(); } { const uint8_t bottom = size - 1; const uint8_t right = size - 1; Loading