[Impeller] fix scaling of trampoline import of GLES textures into Vulkan. (#161331)

Not sure if this just needs the dpr transform or the entire canvas
transform.

Fixes https://github.com/flutter/flutter/issues/159688

## Before


![flutter_04](https://github.com/user-attachments/assets/be60b1d0-4e94-491c-b1da-a03d66897f12)


## After


![flutter_03](https://github.com/user-attachments/assets/64cca8b7-3ae7-4f40-af26-ae61d9ec6290)
This commit is contained in:
Jonah Williams
2025-01-09 12:39:29 -08:00
committed by GitHub
parent a38abc864c
commit 96dffbeda5
5 changed files with 211 additions and 5 deletions

View File

@@ -122,15 +122,17 @@ void SurfaceTextureExternalTextureVKImpeller::ProcessFrame(
VALIDATION_LOG << "Invalid external texture.";
return;
}
SkMatrix matrix = context.canvas->GetTransform();
SkRect mapped_bounds = matrix.mapRect(bounds);
const auto& surface_context =
SurfaceContextVK::Cast(*context.aiks_context->GetContext());
const auto& context_vk = ContextVK::Cast(*surface_context.GetParent());
auto dst_texture =
GetCachedTextureSource(surface_context.GetParent(), //
ISize::MakeWH(bounds.width(), bounds.height()) //
);
auto dst_texture = GetCachedTextureSource(
surface_context.GetParent(), //
ISize::MakeWH(mapped_bounds.width(), mapped_bounds.height()) //
);
if (!dst_texture || !dst_texture->IsValid()) {
VALIDATION_LOG << "Could not fetch trampoline texture target.";
return;
@@ -224,7 +226,10 @@ void SurfaceTextureExternalTextureVKImpeller::DrawFrame(
PaintContext& context,
const SkRect& bounds,
const DlImageSampling sampling) const {
context.canvas->DrawImage(dl_image_, SkPoint{0, 0}, sampling, context.paint);
context.canvas->DrawImageRect(
dl_image_,
SkRect::MakeSize(SkSize::Make(dl_image_->width(), dl_image_->height())),
bounds, sampling, context.paint);
}
} // namespace flutter