Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c5cf722

Browse files
Restore old SurfaceTextureExternal drawing code (#44979)
The simpler version I committed last week doesn't work correctly when the texture has been transformed. This CL restores the old painting code that properly handles this case. Fixes internal b/296916021
1 parent 56b1c6d commit c5cf722

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

shell/platform/android/surface_texture_external_texture.cc

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,27 @@ void SurfaceTextureExternalTexture::Paint(PaintContext& context,
5656
FML_CHECK(state_ == AttachmentState::kAttached);
5757

5858
if (dl_image_) {
59-
context.canvas->DrawImageRect(
60-
dl_image_, // image
61-
SkRect::Make(dl_image_->bounds()), // source rect
62-
bounds, // destination rect
63-
sampling, // sampling
64-
context.paint, // paint
65-
flutter::DlCanvas::SrcRectConstraint::kStrict // enforce edges
66-
);
59+
DlAutoCanvasRestore autoRestore(context.canvas, true);
60+
61+
// The incoming texture is vertically flipped, so we flip it
62+
// back. OpenGL's coordinate system has Positive Y equivalent to up, while
63+
// Skia's coordinate system has Negative Y equvalent to up.
64+
context.canvas->Translate(bounds.x(), bounds.y() + bounds.height());
65+
context.canvas->Scale(bounds.width(), -bounds.height());
66+
67+
if (!transform_.isIdentity()) {
68+
DlImageColorSource source(dl_image_, DlTileMode::kRepeat,
69+
DlTileMode::kRepeat, sampling, &transform_);
70+
71+
DlPaint paintWithShader;
72+
if (context.paint) {
73+
paintWithShader = *context.paint;
74+
}
75+
paintWithShader.setColorSource(&source);
76+
context.canvas->DrawRect(SkRect::MakeWH(1, 1), paintWithShader);
77+
} else {
78+
context.canvas->DrawImage(dl_image_, {0, 0}, sampling, context.paint);
79+
}
6780
} else {
6881
FML_LOG(WARNING)
6982
<< "No DlImage available for SurfaceTextureExternalTexture to paint.";

0 commit comments

Comments
 (0)