Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 505dbf0f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Id150f78d,Iec948124 into pi-dev

* changes:
  SurfaceFlinger: Regression test for b/74220420
  SurfaceFlinger: Fix GL composition of ColorLayers
parents 3836d4c3 b7a96508
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -44,13 +44,13 @@ ColorLayer::ColorLayer(SurfaceFlinger* flinger, const sp<Client>& client, const

void ColorLayer::onDraw(const RenderArea& renderArea, const Region& /* clip */,
                        bool useIdentityTransform) const {
    const State& s(getDrawingState());
    if (s.color.a > 0) {
    half4 color = getColor();
    if (color.a > 0) {
        Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2);
        computeGeometry(renderArea, mesh, useIdentityTransform);
        auto& engine(mFlinger->getRenderEngine());
        engine.setupLayerBlending(getPremultipledAlpha(), false /* opaque */,
                                  true /* disableTexture */, s.color);
                                  true /* disableTexture */, color);
        engine.drawMesh(mesh);
        engine.disableBlending();
    }
+26 −0
Original line number Diff line number Diff line
@@ -1008,6 +1008,32 @@ TEST_F(LayerTransactionTest, SetColorWithAlpha) {
                              tolerance);
}

TEST_F(LayerTransactionTest, SetColorWithParentAlpha_Bug74220420) {
    sp<SurfaceControl> bufferLayer;
    sp<SurfaceControl> parentLayer;
    sp<SurfaceControl> colorLayer;
    ASSERT_NO_FATAL_FAILURE(bufferLayer = createLayer("test bg", 32, 32));
    ASSERT_NO_FATAL_FAILURE(parentLayer = createLayer("parentWithAlpha", 32, 32));
    ASSERT_NO_FATAL_FAILURE(fillLayerColor(bufferLayer, Color::RED));
    ASSERT_NO_FATAL_FAILURE(colorLayer = createLayer(
            "childWithColor", 32, 32, ISurfaceComposerClient::eFXSurfaceColor));

    const half3 color(15.0f / 255.0f, 51.0f / 255.0f, 85.0f / 255.0f);
    const float alpha = 0.25f;
    const ubyte3 expected((vec3(color) * alpha + vec3(1.0f, 0.0f, 0.0f) * (1.0f - alpha)) * 255.0f);
    // this is handwavy, but the precision loss scaled by 255 (8-bit per
    // channel) should be less than one
    const uint8_t tolerance = 1;
    Transaction()
            .reparent(colorLayer, parentLayer->getHandle())
            .setColor(colorLayer, color)
            .setAlpha(parentLayer, alpha)
            .setLayer(parentLayer, mLayerZBase + 1)
            .apply();
    screenshot()->expectColor(Rect(0, 0, 32, 32), {expected.r, expected.g, expected.b, 255},
                              tolerance);
}

TEST_F(LayerTransactionTest, SetColorWithBuffer) {
    sp<SurfaceControl> bufferLayer;
    ASSERT_NO_FATAL_FAILURE(bufferLayer = createLayer("test", 32, 32));