From ee60a04f2011f6d4d47f3a4b220d41b94d2d5c58 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 15 Nov 2021 11:26:31 +0900 Subject: [PATCH] sw_engine image: code refactoring revert d520da2db8966db19ae83897549a107c01c475c1 After considered the scneario seriously, this doesn't helpful for the performance at all... just increased code complexity. earlier bad decision... revert it. --- src/lib/sw_engine/tvgSwCommon.h | 2 +- src/lib/sw_engine/tvgSwImage.cpp | 34 +++-------------------------- src/lib/sw_engine/tvgSwRenderer.cpp | 6 ++--- 3 files changed, 6 insertions(+), 36 deletions(-) diff --git a/src/lib/sw_engine/tvgSwCommon.h b/src/lib/sw_engine/tvgSwCommon.h index 3dad781e..365e9b4e 100644 --- a/src/lib/sw_engine/tvgSwCommon.h +++ b/src/lib/sw_engine/tvgSwCommon.h @@ -323,7 +323,7 @@ bool strokeParseOutline(SwStroke* stroke, const SwOutline& outline); SwOutline* strokeExportOutline(SwStroke* stroke, SwMpool* mpool, unsigned tid); void strokeFree(SwStroke* stroke); -bool imagePrepare(SwImage* image, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid, bool outline); +bool imagePrepare(SwImage* image, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid); bool imageGenRle(SwImage* image, TVG_UNUSED const Picture* pdata, const SwBBox& renderRegion, bool antiAlias); void imageDelOutline(SwImage* image, SwMpool* mpool, uint32_t tid); void imageReset(SwImage* image); diff --git a/src/lib/sw_engine/tvgSwImage.cpp b/src/lib/sw_engine/tvgSwImage.cpp index b19078eb..5167067d 100644 --- a/src/lib/sw_engine/tvgSwImage.cpp +++ b/src/lib/sw_engine/tvgSwImage.cpp @@ -72,38 +72,10 @@ static bool _genOutline(SwImage* image, const Matrix* transform, SwMpool* mpool, /************************************************************************/ -bool imagePrepare(SwImage* image, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid, bool outline) +bool imagePrepare(SwImage* image, const Matrix* transform, const SwBBox& clipRegion, SwBBox& renderRegion, SwMpool* mpool, unsigned tid) { - if (outline || !mathRightAngle(transform)) { - if (!_genOutline(image, transform, mpool, tid)) return false; - return mathUpdateOutlineBBox(image->outline, clipRegion, renderRegion, false); - //Fast Track, don't need outlines. - } else { - auto w = static_cast(image->w); - auto h = static_cast(image->h); - - Point pt[4] = {{0 ,0}, {w, 0}, {w, h}, {0, h}}; - for (int i = 0; i < 4; i++) mathMultiply(&pt[i], transform); - - auto xMin = pt[0].x; - auto xMax = pt[0].x; - auto yMin = pt[0].y; - auto yMax = pt[0].y; - - for (uint32_t i = 1; i < 4; ++i) { - if (xMin > pt[i].x) xMin = pt[i].x; - if (xMax < pt[i].x) xMax = pt[i].x; - if (yMin > pt[i].y) yMin = pt[i].y; - if (yMax < pt[i].y) yMax = pt[i].y; - } - - renderRegion.min.x = static_cast(xMin); - renderRegion.max.x = static_cast(round(xMax)); - renderRegion.min.y = static_cast(yMin); - renderRegion.max.y = static_cast(round(yMax)); - - return mathClipBBox(clipRegion, renderRegion); - } + if (!_genOutline(image, transform, mpool, tid)) return false; + return mathUpdateOutlineBBox(image->outline, clipRegion, renderRegion, false); } diff --git a/src/lib/sw_engine/tvgSwRenderer.cpp b/src/lib/sw_engine/tvgSwRenderer.cpp index 8cc0b8e4..bc63335a 100644 --- a/src/lib/sw_engine/tvgSwRenderer.cpp +++ b/src/lib/sw_engine/tvgSwRenderer.cpp @@ -192,11 +192,9 @@ struct SwImageTask : SwTask if (!image.data || image.w == 0 || image.h == 0) goto end; image.stride = image.w; //same, pixel buffer size. - auto clipPath = (clips.count > 0) ? true : false; + if (!imagePrepare(&image, transform, clipRegion, bbox, mpool, tid)) goto end; - if (!imagePrepare(&image, transform, clipRegion, bbox, mpool, tid, clipPath)) goto end; - - if (clipPath) { + if (clips.count > 0) { if (!imageGenRle(&image, pdata, bbox, false)) goto end; if (image.rle) { for (auto clip = clips.data; clip < (clips.data + clips.count); ++clip) {