diff --git a/test/testAsync.cpp b/test/testAsync.cpp index a8ac2b01..666e7bbb 100644 --- a/test/testAsync.cpp +++ b/test/testAsync.cpp @@ -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 +} diff --git a/test/testBlending.cpp b/test/testBlending.cpp index 7794689a..733e60bb 100644 --- a/test/testBlending.cpp +++ b/test/testBlending.cpp @@ -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(); + } } diff --git a/test/testBoundary.cpp b/test/testBoundary.cpp index e74ac5e8..fcfcd683 100644 --- a/test/testBoundary.cpp +++ b/test/testBoundary.cpp @@ -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(); + } } diff --git a/test/testCustomTransform.cpp b/test/testCustomTransform.cpp index 1109a21b..d87b4815 100644 --- a/test/testCustomTransform.cpp +++ b/test/testCustomTransform.cpp @@ -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) diff --git a/test/testDirectUpdate.cpp b/test/testDirectUpdate.cpp index 93b2dfb3..529e067d 100644 --- a/test/testDirectUpdate.cpp +++ b/test/testDirectUpdate.cpp @@ -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) diff --git a/test/testGradientTransform.cpp b/test/testGradientTransform.cpp index b77062bf..3edb5d8a 100644 --- a/test/testGradientTransform.cpp +++ b/test/testGradientTransform.cpp @@ -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) diff --git a/test/testLinearGradient.cpp b/test/testLinearGradient.cpp index 36251f56..63e690a4 100644 --- a/test/testLinearGradient.cpp +++ b/test/testLinearGradient.cpp @@ -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(); + } } diff --git a/test/testMultiShapes.cpp b/test/testMultiShapes.cpp index 195547de..73992b66 100644 --- a/test/testMultiShapes.cpp +++ b/test/testMultiShapes.cpp @@ -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(); + } } diff --git a/test/testPath.cpp b/test/testPath.cpp index 49bd738b..3fbb8346 100644 --- a/test/testPath.cpp +++ b/test/testPath.cpp @@ -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(); + } } diff --git a/test/testPathCopy.cpp b/test/testPathCopy.cpp index b619f78d..3407f927 100644 --- a/test/testPathCopy.cpp +++ b/test/testPathCopy.cpp @@ -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(); + } } diff --git a/test/testRadialGradient.cpp b/test/testRadialGradient.cpp index f12777c0..ffec5faf 100644 --- a/test/testRadialGradient.cpp +++ b/test/testRadialGradient.cpp @@ -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(); + } } diff --git a/test/testScene.cpp b/test/testScene.cpp index e16772ad..5a6b25fc 100644 --- a/test/testScene.cpp +++ b/test/testScene.cpp @@ -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(); + } } diff --git a/test/testSceneTransform.cpp b/test/testSceneTransform.cpp index 7bd8b417..8c0898f6 100644 --- a/test/testSceneTransform.cpp +++ b/test/testSceneTransform.cpp @@ -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) diff --git a/test/testShape.cpp b/test/testShape.cpp index 9aa284da..406b369c 100644 --- a/test/testShape.cpp +++ b/test/testShape.cpp @@ -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(); + } } diff --git a/test/testStroke.cpp b/test/testStroke.cpp index 493bbde5..c7f95dfc 100644 --- a/test/testStroke.cpp +++ b/test/testStroke.cpp @@ -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(); + } } diff --git a/test/testStrokeLine.cpp b/test/testStrokeLine.cpp index d57bf1f7..31e670eb 100644 --- a/test/testStrokeLine.cpp +++ b/test/testStrokeLine.cpp @@ -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(); + } } diff --git a/test/testSvg.cpp b/test/testSvg.cpp index 4da0349c..13f3e4ce 100644 --- a/test/testSvg.cpp +++ b/test/testSvg.cpp @@ -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(); + } } diff --git a/test/testTransform.cpp b/test/testTransform.cpp index c017f243..7376f97b 100644 --- a/test/testTransform.cpp +++ b/test/testTransform.cpp @@ -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) diff --git a/test/testUpdate.cpp b/test/testUpdate.cpp index d28207af..e1b02128 100644 --- a/test/testUpdate.cpp +++ b/test/testUpdate.cpp @@ -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)