From: Hermet Park Date: Fri, 24 Jul 2020 02:03:20 +0000 (+0900) Subject: sw_engine: revise stroke scaling logic. X-Git-Tag: accepted/tizen/unified/20200806.062539~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5fdc1f7fc86b9a9667741491c63d060ecfb15dd6;p=platform%2Fcore%2Fgraphics%2Ftizenvg.git sw_engine: revise stroke scaling logic. previous fast track logic is useless, it actually doesn't helpful for performance, just increase the code complexity. Change-Id: Ib6ad204edfb241d74c41413dfec7ab42fb02af81 --- diff --git a/src/lib/sw_engine/tvgSwCommon.h b/src/lib/sw_engine/tvgSwCommon.h index bad159b..5f7ec46 100644 --- a/src/lib/sw_engine/tvgSwCommon.h +++ b/src/lib/sw_engine/tvgSwCommon.h @@ -153,13 +153,11 @@ struct SwStroke SwStrokeBorder borders[2]; - float sx; - float sy; + float sx, sy; bool firstPt; bool openSubPath; bool handleWideStrokes; - bool postScale; }; struct SwDashStroke diff --git a/src/lib/sw_engine/tvgSwStroke.cpp b/src/lib/sw_engine/tvgSwStroke.cpp index 53fae90..15cbf02 100644 --- a/src/lib/sw_engine/tvgSwStroke.cpp +++ b/src/lib/sw_engine/tvgSwStroke.cpp @@ -36,10 +36,8 @@ static inline SwFixed SIDE_TO_ROTATE(const int32_t s) static inline void SCALE(SwStroke& stroke, SwPoint& pt) { - if (stroke.postScale) { - pt.x = pt.x * stroke.sx; - pt.y = pt.y * stroke.sy; - } + pt.x *= stroke.sx; + pt.y *= stroke.sy; } @@ -548,7 +546,6 @@ static void _cubicTo(SwStroke& stroke, const SwPoint& ctrl1, const SwPoint& ctrl SwPoint delta = {alen, 0}; mathRotate(delta, beta); - SCALE(stroke, delta); delta += _start; //circumnavigate the negative sector backwards @@ -848,26 +845,14 @@ void strokeReset(SwStroke& stroke, const Shape* sdata, const Matrix* transform) { assert(sdata); - auto scale = 1.0f; - if (transform) { - //Fast Track: if x/y scale factor is identical, we can scale width size simply. - auto sx = sqrt(pow(transform->e11, 2) + pow(transform->e21, 2)); - auto sy = sqrt(pow(transform->e12, 2) + pow(transform->e22, 2)); - if (fabsf(sx - sy) < FLT_EPSILON) { - scale = sx; - stroke.postScale = false; - //Try scaling stroke with normal approach. - } else { - stroke.postScale = true; - stroke.sx = sx; - stroke.sy = sy; - } + stroke.sx = sqrt(pow(transform->e11, 2) + pow(transform->e21, 2)); + stroke.sy = sqrt(pow(transform->e12, 2) + pow(transform->e22, 2)); } else { - stroke.postScale = false; + stroke.sx = stroke.sy = 1.0f; } - stroke.width = TO_SWCOORD(sdata->strokeWidth() * 0.5 * scale); + stroke.width = TO_SWCOORD(sdata->strokeWidth() * 0.5); stroke.cap = sdata->strokeCap(); //Save line join: it can be temporarily changed when stroking curves...