From e609b202ed35b0c0bfc16d7dcfa95afb0c66100c Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sat, 22 Feb 2025 15:54:43 +0800 Subject: [PATCH] fix: draw canvas on canvas clip (#1003) --- skia-c/skia_c.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/skia-c/skia_c.cpp b/skia-c/skia_c.cpp index 994c1e04..f720e7d6 100644 --- a/skia-c/skia_c.cpp +++ b/skia-c/skia_c.cpp @@ -371,10 +371,11 @@ extern "C" CANVAS_CAST->save(); // Translate to the destination position CANVAS_CAST->translate(dx, dy); + CANVAS_CAST->clipRect(SkRect::MakeWH(d_width, d_height)); // Scale using the ratio of destination size to source surface size CANVAS_CAST->scale( - d_width / src_surface->width(), - d_height / src_surface->height() + d_width / s_width, + d_height / s_height ); // Draw the surface directly src_surface->draw(CANVAS_CAST, -sx, -sy, sampling, paint);