sw_engine image: code refactoring
authorHermet Park <chuneon.park@samsung.com>
Mon, 15 Nov 2021 02:26:31 +0000 (11:26 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Tue, 16 Nov 2021 08:37:47 +0000 (17:37 +0900)
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
src/lib/sw_engine/tvgSwImage.cpp
src/lib/sw_engine/tvgSwRenderer.cpp

index 3dad781..365e9b4 100644 (file)
@@ -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);
index b19078e..5167067 100644 (file)
@@ -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<float>(image->w);
-        auto h = static_cast<float>(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<SwCoord>(xMin);
-        renderRegion.max.x = static_cast<SwCoord>(round(xMax));
-        renderRegion.min.y = static_cast<SwCoord>(yMin);
-        renderRegion.max.y = static_cast<SwCoord>(round(yMax));
-
-        return mathClipBBox(clipRegion, renderRegion);
-    }
+    if (!_genOutline(image, transform, mpool, tid)) return false;
+    return mathUpdateOutlineBBox(image->outline, clipRegion, renderRegion, false);
 }
 
 
index 8cc0b8e..bc63335 100644 (file)
@@ -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) {