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

Commit a73b0be1 authored by Stan Iliev's avatar Stan Iliev
Browse files

Fix layer transform matrix for TextureView

Fix order of matrix multipication and use drawImage instead of
shader.

Test: Ran camera app, message app and smart face lock app.
Bug: 67405584
Change-Id: I3df161d58218e1b1845f1c1ca2db2b12c51b3532
parent 0e329691
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -72,15 +72,23 @@ bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer
            textureMatrixInv = textureMatrix;
        }

        SkMatrix matrix = SkMatrix::Concat(textureMatrixInv, layerTransform);
        SkMatrix matrix = SkMatrix::Concat(layerTransform, textureMatrixInv);

        SkPaint paint;
        paint.setAlpha(layer->getAlpha());
        paint.setBlendMode(layer->getMode());
        paint.setColorFilter(sk_ref_sp(layer->getColorFilter()));
        // draw image with a shader to avoid save/restore of the matrix
        paint.setShader(layerImage->makeShader(&matrix));
        canvas->drawRect(SkRect::MakeWH(layerWidth, layerHeight), paint);

        const bool nonIdentityMatrix = !matrix.isIdentity();
        if (nonIdentityMatrix) {
            canvas->save();
            canvas->concat(matrix);
        }
        canvas->drawImage(layerImage.get(), 0, 0, &paint);
        // restore the original matrix
        if (nonIdentityMatrix) {
            canvas->restore();
        }
    }

    return layerImage;