sw_engine: fix a regression bug. 56/237056/3
authorHermet Park <chuneon.park@samsung.com>
Wed, 24 Jun 2020 12:00:43 +0000 (21:00 +0900)
committerHermet Park <chuneon.park@samsung.com>
Thu, 25 Jun 2020 04:31:45 +0000 (13:31 +0900)
this matrix data is volatile since it's coming from stack memory.
thus engine should record its own memory space for keeping it.

Change-Id: I664dd56412f4d236ad04c312220c67da226274e5

src/lib/sw_engine/tvgSwRenderer.cpp
src/lib/sw_engine/tvgSwShape.cpp

index 2458cdb..ac5464e 100644 (file)
@@ -32,7 +32,7 @@ namespace tvg {
         SwShape shape;
         const Shape* sdata;
         SwSize clip;
-        const Matrix* transform;
+        Matrix* transform;
         RenderUpdateFlag flags;
         future<void> progress;
     };
@@ -139,6 +139,7 @@ bool SwRenderer::dispose(const Shape& sdata, void *data)
     if (!task) return true;
     if (task->progress.valid()) task->progress.get();
     shapeFree(task->shape);
+    if (task->transform) free(task->transform);
     free(task);
     return true;
 }
@@ -158,8 +159,14 @@ void* SwRenderer::prepare(const Shape& sdata, void* data, const RenderTransform*
     task->sdata = &sdata;
     task->clip = {static_cast<SwCoord>(surface.w), static_cast<SwCoord>(surface.h)};
 
-    if (transform) task->transform = &transform->m;
-    else task->transform = nullptr;
+    if (transform) {
+        if (!task->transform) task->transform = static_cast<Matrix*>(malloc(sizeof(Matrix)));
+        assert(task->transform);
+        *task->transform = transform->m;
+    } else {
+        if (task->transform) free(task->transform);
+        task->transform = nullptr;
+    }
 
     task->flags = flags;
 
index 9a79c6e..29ecf27 100644 (file)
@@ -201,7 +201,6 @@ static bool _updateBBox(SwOutline* outline, SwBBox& bbox)
     ++pt;
 
     for(uint32_t i = 1; i < outline->ptsCnt; ++i, ++pt) {
-        assert(pt);
         if (xMin > pt->x) xMin = pt->x;
         if (xMax < pt->x) xMax = pt->x;
         if (yMin > pt->y) yMin = pt->y;
@@ -567,7 +566,6 @@ void shapeFree(SwShape& shape)
 {
     shapeDelOutline(shape);
     rleFree(shape.rle);
-
     shapeDelFill(shape);
 
     if (shape.stroke) {