From 4a19e5b9f62ddce964e25b7e7c5a12ebed27cb24 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 26 Mar 2021 17:24:43 +0900 Subject: [PATCH] common: fix wrong viewport region. in the clip rect, viewport must be accumulated to the smaller one. this patch improves that corner-case. --- src/lib/sw_engine/tvgSwShape.cpp | 2 +- src/lib/tvgPaint.h | 1 + src/lib/tvgRender.h | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lib/sw_engine/tvgSwShape.cpp b/src/lib/sw_engine/tvgSwShape.cpp index 4dcb91c3..7756e7d4 100644 --- a/src/lib/sw_engine/tvgSwShape.cpp +++ b/src/lib/sw_engine/tvgSwShape.cpp @@ -401,7 +401,7 @@ bool shapeGenRle(SwShape* shape, TVG_UNUSED const Shape* sdata, bool antiAlias, //Case A: Fast Track Rectangle Drawing if (!hasComposite && (shape->rect = _fastTrack(shape->outline))) return true; //Case B: Normale Shape RLE Drawing - if ((shape->rle = rleRender(shape->rle, shape->outline, shape->bbox,antiAlias))) return true; + if ((shape->rle = rleRender(shape->rle, shape->outline, shape->bbox, antiAlias))) return true; return false; } diff --git a/src/lib/tvgPaint.h b/src/lib/tvgPaint.h index 7ba2d16b..adb7cfef 100644 --- a/src/lib/tvgPaint.h +++ b/src/lib/tvgPaint.h @@ -214,6 +214,7 @@ namespace tvg RenderRegion viewport2; if ((cmpFastTrack = _clipPathFastTrack(cmpTarget, pTransform, viewport2))) { viewport = renderer.viewport(); + viewport2.merge(viewport); renderer.viewport(viewport2); } } diff --git a/src/lib/tvgRender.h b/src/lib/tvgRender.h index 7b06fb7d..510420e5 100644 --- a/src/lib/tvgRender.h +++ b/src/lib/tvgRender.h @@ -48,6 +48,19 @@ struct Compositor { struct RenderRegion { uint32_t x, y, w, h; + + void merge(const RenderRegion& rhs) + { + auto x1 = x + w; + auto y1 = y + h; + auto x2 = rhs.x + rhs.w; + auto y2 = rhs.y + rhs.h; + + x = max(x, rhs.x); + y = max(y, rhs.y); + w = min(x1, x2) - x; + h = min(y1, y2) - y; + } }; struct RenderTransform