this patch adds the showcase how to handle exceptional cases.
Change-Id: Ic8e3c740bbf613f4dccace511b6c8d93b987a10c
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();
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();
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;
//Terminate ThorVG Engine
tvg::Initializer::term(tvgEngine);
-}
\ No newline at end of file
+}
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();
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;
}
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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();
+ }
}
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;
}
/************************************************************************/
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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();
+ }
}
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)
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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)
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)
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);
+ }
}
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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)
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();
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();
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)
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;
}
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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)
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();
fill2->colorStops(colorStops2, 3);
shape2->fill(move(fill2));
- canvas->push(move(shape2));
+ if (canvas->push(move(shape2)) != tvg::Result::Success) return;
//Prepare Ellipse
fill3->colorStops(colorStops3, 4);
shape3->fill(move(fill3));
- canvas->push(move(shape3));
+ if (canvas->push(move(shape3)) != tvg::Result::Success) return;
}
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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();
+ }
}
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;
}
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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();
+ }
}
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();
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;
+
}
/************************************************************************/
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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();
+ }
}
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;
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;
+
}
/************************************************************************/
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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();
+ }
}
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();
fill2->colorStops(colorStops2, 3);
shape2->fill(move(fill2));
- canvas->push(move(shape2));
+ if (canvas->push(move(shape2)) != tvg::Result::Success) return;
//Prepare Ellipse
fill3->colorStops(colorStops3, 4);
shape3->fill(move(fill3));
- canvas->push(move(shape3));
+ if (canvas->push(move(shape3)) != tvg::Result::Success) return;
}
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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 drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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 drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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)
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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();
+ }
}
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();
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();
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();
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();
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();
shape6->stroke(255, 255, 255, 255);
shape6->stroke(4);
- canvas->push(move(shape6));
+ if (canvas->push(move(shape6)) != tvg::Result::Success) return;
}
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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();
+ }
}
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
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);
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);
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();
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);
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);
float dashPattern3[2] = {10, 10};
shape6->stroke(dashPattern3, 2);
- canvas->push(move(shape6));
+ if (canvas->push(move(shape6)) != tvg::Result::Success) return;
}
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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();
+ }
}
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));
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);
}
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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();
+ }
}
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();
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();
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)
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;
}
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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)
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();
void drawSwView(void* data, Eo* obj)
{
- swCanvas->draw();
- swCanvas->sync();
+ if (swCanvas->draw() == tvg::Result::Success) {
+ swCanvas->sync();
+ }
}
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)