lottie/render: don't redraw stroke/dash if there is no change 91/185891/2
authorYoungbok Shin <youngb.shin@samsung.com>
Fri, 3 Aug 2018 08:46:02 +0000 (17:46 +0900)
committerSubhransu Mohanty <sub.mohanty@samsung.com>
Fri, 3 Aug 2018 08:55:34 +0000 (08:55 +0000)
It will improve performance.

Change-Id: I3764d126d7eae19d009d72998247789e620205a1

example/resource/static_dynamic_dash.json [new file with mode: 0644]
src/vector/vdrawable.cpp

diff --git a/example/resource/static_dynamic_dash.json b/example/resource/static_dynamic_dash.json
new file mode 100644 (file)
index 0000000..9ebce59
--- /dev/null
@@ -0,0 +1 @@
+{"v":"5.1.17","fr":29.9700012207031,"ip":0,"op":150.000006109625,"w":300,"h":300,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[150,150.5,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"rc","d":1,"s":{"a":1,"k":[{"i":{"x":[0.833,0.833],"y":[0.833,0.833]},"o":{"x":[0.167,0.167],"y":[0.167,0.167]},"n":["0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167"],"t":20,"s":[135,135],"e":[116,116]},{"t":137.000005580124}],"ix":2},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":20,"s":[24,25],"e":[57,52],"to":[5.5,4.5],"ti":[-5.5,-4.5]},{"t":129.000005254278}],"ix":3},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0],"e":[54]},{"t":149.000006068894}],"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"st","c":{"a":0,"k":[0.402888119221,0.437488675117,0.552941203117,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":7,"ix":5},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0,0,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"d":1,"ty":"el","s":{"a":1,"k":[{"i":{"x":[0.833,0.833],"y":[0.833,0.833]},"o":{"x":[0.167,0.167],"y":[0.167,0.167]},"n":["0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167"],"t":0,"s":[100,100],"e":[50,50]},{"t":40.0000016292334}],"ix":2},"p":{"a":0,"k":[-26,-37],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0.145327582955,0.057777773589,0.866666674614,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 2","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"sr","sy":1,"d":1,"pt":{"a":0,"k":5,"ix":3},"p":{"a":0,"k":[26,-54],"ix":4},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":110,"s":[0],"e":[184]},{"t":149.000006068894}],"ix":5},"ir":{"a":0,"k":30,"ix":6},"is":{"a":0,"k":27,"ix":8},"or":{"a":0,"k":59,"ix":7},"os":{"a":0,"k":73,"ix":9},"ix":6,"nm":"Polystar Path 1","mn":"ADBE Vector Shape - Star","hd":false},{"ty":"fl","c":{"a":0,"k":[0.07993286103,0.716212213039,0.766274511814,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 3","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":15,"ix":5},"lc":2,"lj":1,"ml":4,"d":[{"n":"d","nm":"dash","v":{"a":0,"k":25,"ix":1}},{"n":"o","nm":"offset","v":{"a":0,"k":0,"ix":7}}],"nm":"Stroke 2","mn":"ADBE Vector Graphic - Stroke","hd":false}],"ip":0,"op":150.000006109625,"st":0,"bm":0}],"markers":[]}
\ No newline at end of file
index 93e7da1..470f0e1 100644 (file)
@@ -31,6 +31,10 @@ VRle VDrawable::rle()
 void VDrawable::setStrokeInfo(CapStyle cap, JoinStyle join, float meterLimit,
                               float strokeWidth)
 {
+    if ((mStroke.cap == cap) && (mStroke.join == join) &&
+       vCompare(mStroke.meterLimit, meterLimit) && vCompare(mStroke.width, strokeWidth))
+        return;
+
     mStroke.enable = true;
     mStroke.cap = cap;
     mStroke.join = join;
@@ -41,6 +45,21 @@ void VDrawable::setStrokeInfo(CapStyle cap, JoinStyle join, float meterLimit,
 
 void VDrawable::setDashInfo(float *array, int size)
 {
+    bool hasChanged = false;
+
+    if (mStroke.dashArraySize == size) {
+        for (int i = 0; i < size; i++) {
+            if (!vCompare(mStroke.dashArray[i], array[i])) {
+                hasChanged = true;
+                break;
+            }
+        }
+    } else {
+        hasChanged = true;
+    }
+
+    if (!hasChanged) return;
+
     mStroke.dashArray = array;
     mStroke.dashArraySize = size;
     mFlag |= DirtyState::Path;