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

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

Merge "Fix layer transform matrix for TextureView"

parents 34e83d28 a73b0be1
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;