test: revise sample. 91/237391/3
authorHermet Park <chuneon.park@samsung.com>
Tue, 30 Jun 2020 04:08:09 +0000 (13:08 +0900)
committerHermet Park <chuneon.park@samsung.com>
Tue, 30 Jun 2020 04:31:28 +0000 (13:31 +0900)
this patch adds the showcase how to handle exceptional cases.

Change-Id: Ic8e3c740bbf613f4dccace511b6c8d93b987a10c

19 files changed:
test/testAsync.cpp
test/testBlending.cpp
test/testBoundary.cpp
test/testCustomTransform.cpp
test/testDirectUpdate.cpp
test/testGradientTransform.cpp
test/testLinearGradient.cpp
test/testMultiShapes.cpp
test/testPath.cpp
test/testPathCopy.cpp
test/testRadialGradient.cpp
test/testScene.cpp
test/testSceneTransform.cpp
test/testShape.cpp
test/testStroke.cpp
test/testStrokeLine.cpp
test/testSvg.cpp
test/testTransform.cpp
test/testUpdate.cpp

index a8ac2b0..666e7bb 100644 (file)
@@ -13,11 +13,10 @@ bool tvgUpdateCmds(tvg::Canvas* canvas)
     auto t = ecore_time_get();
 
     //Explicitly clear all retained paint nodes.
-    if (canvas->clear() != tvg::Result::Success)
-      {
-         //Logically wrong! Probably, you missed to call sync() before.
-         return false;
-      }
+    if (canvas->clear() != tvg::Result::Success) {
+        //Logically wrong! Probably, you missed to call sync() before.
+        return false;
+    }
 
     t1 = t;
     t2 = ecore_time_get();
@@ -45,7 +44,10 @@ bool tvgUpdateCmds(tvg::Canvas* canvas)
         fill->colorStops(colorStops, 3);
         shape->fill(move(fill));
 
-        canvas->push(move(shape));
+        if (canvas->push(move(shape)) != tvg::Result::Success) {
+            //Did you call clear()? Make it sure if canvas is on rendering
+            break;
+        }
     }
 
     t3 = ecore_time_get();
@@ -72,7 +74,7 @@ Eina_Bool animSwCb(void* data)
     if (!tvgUpdateCmds(swCanvas.get())) return ECORE_CALLBACK_RENEW;
 
     //Drawing task can be performed asynchronously.
-    swCanvas->draw();
+    if (swCanvas->draw() != tvg::Result::Success) return false;
 
     //Update Efl Canvas
     Eo* img = (Eo*) data;
@@ -174,4 +176,4 @@ int main(int argc, char **argv)
 
     //Terminate ThorVG Engine
     tvg::Initializer::term(tvgEngine);
-}
\ No newline at end of file
+}
index 7794689..733e60b 100644 (file)
@@ -12,19 +12,19 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     auto shape1 = tvg::Shape::gen();
     shape1->appendRect(0, 0, 400, 400, 50);      //x, y, w, h, cornerRadius
     shape1->fill(0, 255, 0, 255);                //r, g, b, a
-    canvas->push(move(shape1));
+    if (canvas->push(move(shape1)) != tvg::Result::Success) return;
 
     //Prepare Circle
     auto shape2 = tvg::Shape::gen();
     shape2->appendCircle(400, 400, 200, 200);    //cx, cy, radiusW, radiusH
     shape2->fill(170, 170, 0, 170);              //r, g, b, a
-    canvas->push(move(shape2));
+    if (canvas->push(move(shape2)) != tvg::Result::Success) return;
 
     //Prepare Ellipse
     auto shape3 = tvg::Shape::gen();
     shape3->appendCircle(400, 400, 250, 100);    //cx, cy, radiusW, radiusH
     shape3->fill(100, 100, 100, 100);            //r, g, b, a
-    canvas->push(move(shape3));
+    if (canvas->push(move(shape3)) != tvg::Result::Success) return;
 
     //Prepare Star
     auto shape4 = tvg::Shape::gen();
@@ -40,13 +40,13 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape4->lineTo(146, 343);
     shape4->close();
     shape4->fill(200, 0, 200, 200);
-    canvas->push(move(shape4));
+    if (canvas->push(move(shape4)) != tvg::Result::Success) return;
 
     //Prepare Opaque Ellipse
     auto shape5 = tvg::Shape::gen();
     shape5->appendCircle(600, 650, 200, 150);
     shape5->fill(0, 0, 255, 255);
-    canvas->push(move(shape5));
+    if (canvas->push(move(shape5)) != tvg::Result::Success) return;
 }
 
 
@@ -71,8 +71,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -109,8 +110,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index e74ac5e..fcfcd68 100644 (file)
@@ -12,31 +12,31 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     auto shape1 = tvg::Shape::gen();
     shape1->appendRect(-100, -100, 1000, 1000, 50);
     shape1->fill(255, 255, 255, 255);
-    canvas->push(move(shape1));
+    if (canvas->push(move(shape1)) != tvg::Result::Success) return;
 
     //Prepare Shape2
     auto shape2 = tvg::Shape::gen();
     shape2->appendRect(-100, -100, 250, 250, 50);
     shape2->fill(0, 0, 255, 255);
-    canvas->push(move(shape2));
+    if (canvas->push(move(shape2)) != tvg::Result::Success) return;
 
     //Prepare Shape3
     auto shape3 = tvg::Shape::gen();
     shape3->appendRect(500, 500, 550, 550, 0);
     shape3->fill(0, 255, 255, 255);
-    canvas->push(move(shape3));
+    if (canvas->push(move(shape3)) != tvg::Result::Success) return;
 
     //Prepare Shape4
     auto shape4 = tvg::Shape::gen();
     shape4->appendCircle(800, 100, 200, 200);
     shape4->fill(255, 255, 0, 255);
-    canvas->push(move(shape4));
+    if (canvas->push(move(shape4)) != tvg::Result::Success) return;
 
     //Prepare Shape5
     auto shape5 = tvg::Shape::gen();
     shape5->appendCircle(200, 650, 250, 200);
     shape5->fill(0, 0, 0, 255);
-    canvas->push(move(shape5));
+    if (canvas->push(move(shape5)) != tvg::Result::Success) return;
 }
 
 /************************************************************************/
@@ -60,8 +60,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -98,8 +99,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index 1109a21..d87b481 100644 (file)
@@ -26,7 +26,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape->lineTo(-53, -5.5);
     shape->close();
     shape->fill(0, 0, 255, 255);
-    canvas->push(move(shape));
+    if (canvas->push(move(shape)) != tvg::Result::Success) return;
 }
 
 void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
@@ -107,8 +107,9 @@ void transitSwCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progre
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -145,8 +146,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 void transitGlCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
index 93b2dfb..529e067 100644 (file)
@@ -21,7 +21,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape->stroke(0, 0, 255, 255);
     shape->stroke(1);
 
-    canvas->push(move(shape));
+    if (canvas->push(move(shape)) != tvg::Result::Success) return;
 }
 
 void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
@@ -30,13 +30,14 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
        You can update only necessary properties of this shape,
        while retaining other properties. */
 
-    pShape->reset();    //reset path
+    //Reset Shape
+    if (pShape->reset() == tvg::Result::Success) {
+        pShape->appendRect(-100 + (800 * progress), -100 + (800 * progress), 200, 200, (100 * progress));
+        pShape->stroke(30 * progress);
 
-    pShape->appendRect(-100 + (800 * progress), -100 + (800 * progress), 200, 200, (100 * progress));
-    pShape->stroke(30 * progress);
-
-    //Update shape for drawing (this may work asynchronously)
-    canvas->update(pShape);
+        //Update shape for drawing (this may work asynchronously)
+        canvas->update(pShape);
+    }
 }
 
 
@@ -71,8 +72,9 @@ void transitSwCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progre
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -109,8 +111,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 void transitGlCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
index b77062b..3edb5d8 100644 (file)
@@ -34,7 +34,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     fill->colorStops(colorStops, 3);
     shape->fill(move(fill));
     shape->translate(385, 400);
-    canvas->push(move(shape));
+    if (canvas->push(move(shape)) != tvg::Result::Success) return;
 
     //Shape2
     auto shape2 = tvg::Shape::gen();
@@ -53,7 +53,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
 
     fill2->colorStops(colorStops2, 2);
     shape2->fill(move(fill2));
-    canvas->push(move(shape2));
+    if (canvas->push(move(shape2)) != tvg::Result::Success) return;
 
     //Shape3
     auto shape3 = tvg::Shape::gen();
@@ -78,7 +78,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
 
     shape3->fill(move(fill3));
     shape3->translate(400, 400);
-    canvas->push(move(shape3));
+    if (canvas->push(move(shape3)) != tvg::Result::Success) return;
 }
 
 void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
@@ -92,17 +92,17 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
     pShape->rotate(360 * progress);
 
     //Update shape for drawing (this may work asynchronously)
-    canvas->update(pShape);
+    if (canvas->update(pShape) != tvg::Result::Success) return;
 
     //Update Shape2
     pShape2->rotate(360 * progress);
     pShape2->translate(400 + progress * 300, 400);
-    canvas->update(pShape2);
+    if (canvas->update(pShape2) != tvg::Result::Success) return;
 
     //Update Shape3
     pShape3->rotate(-360 * progress);
     pShape3->scale(0.5 + progress);
-    canvas->update(pShape3);
+    if (canvas->update(pShape3) != tvg::Result::Success) return;
 }
 
 
@@ -137,8 +137,9 @@ void transitSwCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progre
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -175,8 +176,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 void transitGlCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
index 36251f5..63e690a 100644 (file)
@@ -24,7 +24,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     fill->colorStops(colorStops, 2);
 
     shape1->fill(move(fill));
-    canvas->push(move(shape1));
+    if (canvas->push(move(shape1)) != tvg::Result::Success) return;
 
     //Prepare Circle
     auto shape2 = tvg::Shape::gen();
@@ -43,7 +43,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     fill2->colorStops(colorStops2, 3);
 
     shape2->fill(move(fill2));
-    canvas->push(move(shape2));
+    if (canvas->push(move(shape2)) != tvg::Result::Success) return;
 
 
     //Prepare Ellipse
@@ -64,7 +64,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     fill3->colorStops(colorStops3, 4);
 
     shape3->fill(move(fill3));
-    canvas->push(move(shape3));
+    if (canvas->push(move(shape3)) != tvg::Result::Success) return;
 }
 
 
@@ -89,8 +89,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -127,8 +128,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index 195547d..73992b6 100644 (file)
@@ -12,19 +12,19 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     auto shape1 = tvg::Shape::gen();
     shape1->appendRect(0, 0, 400, 400, 50);      //x, y, w, h, cornerRadius
     shape1->fill(0, 255, 0, 255);                //r, g, b, a
-    canvas->push(move(shape1));
+    if (canvas->push(move(shape1)) != tvg::Result::Success) return;
 
     //Prepare Circle
     auto shape2 = tvg::Shape::gen();
     shape2->appendCircle(400, 400, 200, 200);    //cx, cy, radiusW, radiusH
     shape2->fill(255, 255, 0, 255);              //r, g, b, a
-    canvas->push(move(shape2));
+    if (canvas->push(move(shape2)) != tvg::Result::Success) return;
 
     //Prepare Ellipse
     auto shape3 = tvg::Shape::gen();
     shape3->appendCircle(600, 600, 150, 100);    //cx, cy, radiusW, radiusH
     shape3->fill(0, 255, 255, 255);              //r, g, b, a
-    canvas->push(move(shape3));
+    if (canvas->push(move(shape3)) != tvg::Result::Success) return;
 }
 
 
@@ -49,8 +49,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -87,8 +88,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index 49bd738..3fbb834 100644 (file)
@@ -22,7 +22,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape1->lineTo(146, 143);
     shape1->close();
     shape1->fill(0, 0, 255, 255);
-    canvas->push(move(shape1));
+    if (canvas->push(move(shape1)) != tvg::Result::Success) return;
+
 
     //Circle
     auto shape2 = tvg::Shape::gen();
@@ -39,7 +40,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape2->cubicTo(cx - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy);
     shape2->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius);
     shape2->fill(255, 0, 0, 255);
-    canvas->push(move(shape2));
+    if (canvas->push(move(shape2)) != tvg::Result::Success) return;
+
 }
 
 /************************************************************************/
@@ -63,8 +65,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -101,8 +104,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index b619f78..3407f92 100644 (file)
@@ -38,8 +38,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     auto shape1 = tvg::Shape::gen();
     shape1->appendPath(cmds, 11, pts, 10);     //copy path data
     shape1->fill(0, 255, 0, 255);
-    canvas->push(move(shape1));
-
+    if (canvas->push(move(shape1)) != tvg::Result::Success) return;
 
     /* Circle */
     auto cx = 550.0f;
@@ -79,7 +78,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     auto shape2 = tvg::Shape::gen();
     shape2->appendPath(cmds2, 6, pts2, 13);     //copy path data
     shape2->fill(255, 255, 0, 255);
-    canvas->push(move(shape2));
+    if (canvas->push(move(shape2)) != tvg::Result::Success) return;
+
 }
 
 /************************************************************************/
@@ -103,8 +103,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -141,8 +142,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index f12777c..ffec5fa 100644 (file)
@@ -24,7 +24,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     fill->colorStops(colorStops, 2);
 
     shape1->fill(move(fill));
-    canvas->push(move(shape1));
+    if (canvas->push(move(shape1)) != tvg::Result::Success) return;
 
     //Prepare Circle
     auto shape2 = tvg::Shape::gen();
@@ -43,7 +43,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     fill2->colorStops(colorStops2, 3);
 
     shape2->fill(move(fill2));
-    canvas->push(move(shape2));
+    if (canvas->push(move(shape2)) != tvg::Result::Success) return;
 
 
     //Prepare Ellipse
@@ -64,7 +64,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     fill3->colorStops(colorStops3, 4);
 
     shape3->fill(move(fill3));
-    canvas->push(move(shape3));
+    if (canvas->push(move(shape3)) != tvg::Result::Success) return;
 }
 
 
@@ -89,8 +89,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -127,8 +128,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index e16772a..5a6b25f 100644 (file)
@@ -96,8 +96,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -134,8 +135,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index 7bd8b41..8c0898f 100644 (file)
@@ -132,8 +132,9 @@ void transitSwCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progre
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -170,8 +171,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 void transitGlCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
index 9aa284d..406b369 100644 (file)
@@ -39,8 +39,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -77,8 +78,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index 493bbde..c7f95df 100644 (file)
@@ -14,7 +14,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape1->stroke(tvg::StrokeJoin::Bevel);   //default is Bevel
     shape1->stroke(10);                       //width: 10px
 
-    canvas->push(move(shape1));
+    if (canvas->push(move(shape1)) != tvg::Result::Success) return;
 
     //Shape 2
     auto shape2 = tvg::Shape::gen();
@@ -24,7 +24,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape2->stroke(tvg::StrokeJoin::Round);
     shape2->stroke(10);
 
-    canvas->push(move(shape2));
+    if (canvas->push(move(shape2)) != tvg::Result::Success) return;
 
     //Shape 3
     auto shape3 = tvg::Shape::gen();
@@ -34,7 +34,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape3->stroke(tvg::StrokeJoin::Miter);
     shape3->stroke(10);
 
-    canvas->push(move(shape3));
+    if (canvas->push(move(shape3)) != tvg::Result::Success) return;
 
     //Shape 4
     auto shape4 = tvg::Shape::gen();
@@ -43,7 +43,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape4->stroke(255, 255, 255, 255);
     shape4->stroke(1);
 
-    canvas->push(move(shape4));
+    if (canvas->push(move(shape4)) != tvg::Result::Success) return;
 
     //Shape 5
     auto shape5 = tvg::Shape::gen();
@@ -52,7 +52,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape5->stroke(255, 255, 255, 255);
     shape5->stroke(2);
 
-    canvas->push(move(shape5));
+    if (canvas->push(move(shape5)) != tvg::Result::Success) return;
 
     //Shape 6
     auto shape6 = tvg::Shape::gen();
@@ -61,7 +61,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape6->stroke(255, 255, 255, 255);
     shape6->stroke(4);
 
-    canvas->push(move(shape6));
+    if (canvas->push(move(shape6)) != tvg::Result::Success) return;
 }
 
 
@@ -86,8 +86,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -124,8 +125,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index d57bf1f..31e670e 100644 (file)
@@ -14,7 +14,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
         shape->stroke(255, 255, 255, 255);       //color: r, g, b, a
         shape->stroke(i + 1);                    //stroke width
         shape->stroke(tvg::StrokeCap::Round);    //default is Square
-        canvas->push(move(shape));
+        if (canvas->push(move(shape)) != tvg::Result::Success) return;
     }
 
     //Test for StrokeJoin & StrokeCap
@@ -28,7 +28,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape1->stroke(10);
     shape1->stroke(tvg::StrokeJoin::Round);
     shape1->stroke(tvg::StrokeCap::Round);
-    canvas->push(move(shape1));
+    if (canvas->push(move(shape1)) != tvg::Result::Success) return;
 
     auto shape2 = tvg::Shape::gen();
     shape2->moveTo(270, 350);
@@ -40,7 +40,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape2->stroke(10);
     shape2->stroke(tvg::StrokeJoin::Bevel);
     shape2->stroke(tvg::StrokeCap::Square);
-    canvas->push(move(shape2));
+    if (canvas->push(move(shape2)) != tvg::Result::Success) return;
 
     auto shape3 = tvg::Shape::gen();
     shape3->moveTo(520, 350);
@@ -52,7 +52,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape3->stroke(10);
     shape3->stroke(tvg::StrokeJoin::Miter);
     shape3->stroke(tvg::StrokeCap::Butt);
-    canvas->push(move(shape3));
+    if (canvas->push(move(shape3)) != tvg::Result::Success) return;
 
     //Test for Stroke Dash
     auto shape4 = tvg::Shape::gen();
@@ -68,7 +68,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
 
     float dashPattern1[2] = {10, 10};
     shape4->stroke(dashPattern1, 2);
-    canvas->push(move(shape4));
+    if (canvas->push(move(shape4)) != tvg::Result::Success) return;
 
     auto shape5 = tvg::Shape::gen();
     shape5->moveTo(270, 600);
@@ -83,7 +83,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
 
     float dashPattern2[4] = {10, 10};
     shape5->stroke(dashPattern2, 4);
-    canvas->push(move(shape5));
+    if (canvas->push(move(shape5)) != tvg::Result::Success) return;
 
     auto shape6 = tvg::Shape::gen();
     shape6->moveTo(520, 600);
@@ -98,7 +98,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
 
     float dashPattern3[2] = {10, 10};
     shape6->stroke(dashPattern3, 2);
-    canvas->push(move(shape6));
+    if (canvas->push(move(shape6)) != tvg::Result::Success) return;
 }
 
 
@@ -123,8 +123,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -161,8 +162,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index 4da0349..13f3e4c 100644 (file)
@@ -16,10 +16,11 @@ void svgDirCallback(const char* name, const char* path, void* data)
 
     auto scene = tvg::Scene::gen();
 
-    char buf[255];
+    char buf[PATH_MAX];
     sprintf(buf,"%s/%s", path, name);
 
-    scene->load(buf);
+    if (scene->load(buf) != tvg::Result::Success) return;
+
     scene->translate(((WIDTH - (x * 2)) / NUM_PER_LINE) * (count % NUM_PER_LINE) + x, ((HEIGHT - (y * 2))/ NUM_PER_LINE) * (int)((float)count / (float)NUM_PER_LINE) + y);
     canvas->push(move(scene));
 
@@ -30,11 +31,12 @@ void svgDirCallback(const char* name, const char* path, void* data)
 
 void tvgDrawCmds(tvg::Canvas* canvas)
 {
-    auto shape1 = tvg::Shape::gen();
-    shape1->appendRect(0, 0, WIDTH, HEIGHT, 0);       //x, y, w, h, cornerRadius
-    shape1->fill(255, 255, 255, 255);                 //r, g, b, a
+    //Background
+    auto shape = tvg::Shape::gen();
+    shape->appendRect(0, 0, WIDTH, HEIGHT, 0);       //x, y, w, h, cornerRadius
+    shape->fill(255, 255, 255, 255);                 //r, g, b, a
 
-    canvas->push(move(shape1));
+    if (canvas->push(move(shape)) != tvg::Result::Success) return;
 
     eina_file_dir_list("./svgs", EINA_TRUE, svgDirCallback, canvas);
 }
@@ -61,8 +63,9 @@ void tvgSwTest(uint32_t* buffer)
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -99,8 +102,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 
index c017f24..7376f97 100644 (file)
@@ -22,7 +22,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape->appendCircle(115, 200, 170, 100);
     shape->fill(255, 255, 255, 255);
     shape->translate(385, 400);
-    canvas->push(move(shape));
+    if (canvas->push(move(shape)) != tvg::Result::Success) return;
 
     //Shape2
     auto shape2 = tvg::Shape::gen();
@@ -30,7 +30,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape2->appendRect(-50, -50, 100, 100, 0);
     shape2->fill(0, 255, 255, 255);
     shape2->translate(400, 400);
-    canvas->push(move(shape2));
+    if (canvas->push(move(shape2)) != tvg::Result::Success) return;
 
     //Shape3
     auto shape3 = tvg::Shape::gen();
@@ -41,7 +41,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
     shape3->appendRect(100, 100, 150, 50, 20);
     shape3->fill(255, 0, 255, 255);
     shape3->translate(400, 400);
-    canvas->push(move(shape3));
+    if (canvas->push(move(shape3)) != tvg::Result::Success) return;
 }
 
 void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
@@ -55,17 +55,17 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
     pShape->rotate(360 * progress);
 
     //Update shape for drawing (this may work asynchronously)
-    canvas->update(pShape);
+    if (canvas->update(pShape) != tvg::Result::Success) return;
 
     //Update Shape2
     pShape2->rotate(360 * progress);
     pShape2->translate(400 + progress * 300, 400);
-    canvas->update(pShape2);
+    if (canvas->update(pShape2) != tvg::Result::Success) return;
 
     //Update Shape3
     pShape3->rotate(-360 * progress);
     pShape3->scale(0.5 + progress);
-    canvas->update(pShape3);
+    if (canvas->update(pShape3) != tvg::Result::Success) return;
 }
 
 
@@ -100,8 +100,9 @@ void transitSwCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progre
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -138,8 +139,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 void transitGlCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
index d28207a..e1b0212 100644 (file)
@@ -16,7 +16,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
 void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
 {
     //Explicitly clear all retained paint nodes.
-    canvas->clear();
+    if (canvas->clear() != tvg::Result::Success) return;
 
     //Shape
     auto shape = tvg::Shape::gen();
@@ -61,8 +61,9 @@ void transitSwCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progre
 
 void drawSwView(void* data, Eo* obj)
 {
-    swCanvas->draw();
-    swCanvas->sync();
+    if (swCanvas->draw() == tvg::Result::Success) {
+        swCanvas->sync();
+    }
 }
 
 
@@ -99,8 +100,9 @@ void drawGLview(Evas_Object *obj)
     gl->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
     gl->glEnable(GL_BLEND);
 
-    glCanvas->draw();
-    glCanvas->sync();
+    if (glCanvas->draw() == tvg::Result::Success) {
+        glCanvas->sync();
+    }
 }
 
 void transitGlCb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)