diff --git a/rosen/modules/render_service/core/pipeline/rs_render_service_util.cpp b/rosen/modules/render_service/core/pipeline/rs_render_service_util.cpp index 26949d6e0f..9754ae974f 100644 --- a/rosen/modules/render_service/core/pipeline/rs_render_service_util.cpp +++ b/rosen/modules/render_service/core/pipeline/rs_render_service_util.cpp @@ -16,6 +16,7 @@ #include +#include "include/core/SkRect.h" #include "platform/common/rs_log.h" #include "property/rs_properties_painter.h" #include "render/rs_blur_filter.h" @@ -395,12 +396,14 @@ void FillDrawParameters(BufferDrawParameters& params, const sptrGetWidth(), buffer->GetHeight()); + params.dstRect = SkRect::MakeXYWH(0, 0, buffer->GetSurfaceBufferWidth(), buffer->GetSurfaceBufferHeight()); auto geoPtr = std::static_pointer_cast(property.GetBoundsGeometry()); if (geoPtr) { params.transform = geoPtr->GetAbsMatrix(); - params.widthScale = static_cast(geoPtr->GetAbsRect().width_ * 1.0 / buffer->GetWidth()); - params.heightScale = static_cast(geoPtr->GetAbsRect().height_ * 1.0 / buffer->GetHeight()); + params.dstLeft = geoPtr->GetAbsRect().left_; + params.dstTop = geoPtr->GetAbsRect().top_; + params.dstWidth = geoPtr->GetAbsRect().width_; + params.dstHeight = geoPtr->GetAbsRect().height_; } } } // namespace Detail @@ -479,8 +482,8 @@ void RsRenderServiceUtil::Draw(SkCanvas& canvas, BufferDrawParameters& params, R if (bitmap.installPixels(pixmap)) { canvas.save(); if (params.onDisplay) { + canvas.clipRect(SkRect::MakeXYWH(params.dstLeft, params.dstTop, params.dstWidth, params.dstHeight)); canvas.setMatrix(params.transform); - canvas.scale(params.widthScale, params.heightScale); DealAnimation(canvas, paint, node); const RSProperties& property = node.GetRenderProperties(); auto filter = std::static_pointer_cast(property.GetBackgroundFilter()); @@ -491,7 +494,8 @@ void RsRenderServiceUtil::Draw(SkCanvas& canvas, BufferDrawParameters& params, R RSPropertiesPainter::RestoreForFilter(canvas); } } - canvas.drawBitmapRect(bitmap, params.dstRect, &paint); + canvas.drawBitmapRect(bitmap, params.dstRect, SkRect::MakeXYWH(0, 0, params.dstWidth, params.dstHeight), + &paint); canvas.restore(); } } diff --git a/rosen/modules/render_service/core/pipeline/rs_render_service_util.h b/rosen/modules/render_service/core/pipeline/rs_render_service_util.h index d21ef4566d..1052fe1ccb 100644 --- a/rosen/modules/render_service/core/pipeline/rs_render_service_util.h +++ b/rosen/modules/render_service/core/pipeline/rs_render_service_util.h @@ -35,8 +35,10 @@ struct BufferDrawParameters { bool antiAlias = true; bool onDisplay = true; float alpha = 1.0f; - double widthScale = 1.0f; - double heightScale = 1.0f; + uint32_t dstLeft = 0; + uint32_t dstTop = 0; + uint32_t dstWidth = 0; + uint32_t dstHeight = 0; SkPixmap pixmap; SkBitmap bitmap; SkMatrix transform;