From 8fd9148970d0ff597078e2a735f1e6b7e6b08da1 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 9 Jun 2021 21:07:13 +0900 Subject: [PATCH] examples stacking: ++ scene stacking. Change-Id: I368bddde7f058a1752ba55227205ff4dc30cb687 --- src/examples/Stacking.cpp | 62 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/src/examples/Stacking.cpp b/src/examples/Stacking.cpp index afae969..fe826b8 100644 --- a/src/examples/Stacking.cpp +++ b/src/examples/Stacking.cpp @@ -26,14 +26,14 @@ /* Drawing Commands */ /************************************************************************/ -static tvg::Shape* paints[3]; +static tvg::Paint* paints[4]; static int order = 0; void tvgDrawCmds(tvg::Canvas* canvas) { if (!canvas) return; - canvas->reserve(3); //reserve 3 shape nodes (optional) + canvas->reserve(4); //reserve 3 shape nodes (optional) //Prepare Round Rectangle auto shape1 = tvg::Shape::gen(); @@ -42,19 +42,39 @@ void tvgDrawCmds(tvg::Canvas* canvas) shape1->fill(0, 255, 0, 255); //r, g, b, a if (canvas->push(move(shape1)) != tvg::Result::Success) return; - //Prepare Circle + //Prepare Round Rectangle2 auto shape2 = tvg::Shape::gen(); paints[1] = shape2.get(); shape2->appendRect(100, 100, 400, 400, 50, 50); //x, y, w, h, rx, ry shape2->fill(255, 255, 0, 255); //r, g, b, a if (canvas->push(move(shape2)) != tvg::Result::Success) return; - //Prepare Ellipse + //Prepare Round Rectangle3 auto shape3 = tvg::Shape::gen(); paints[2] = shape3.get(); shape3->appendRect(200, 200, 400, 400, 50, 50); //x, y, w, h, rx, ry shape3->fill(0, 255, 255, 255); //r, g, b, a if (canvas->push(move(shape3)) != tvg::Result::Success) return; + + //Prepare Scene + auto scene = tvg::Scene::gen(); + paints[3] = scene.get(); + + auto shape4 = tvg::Shape::gen(); + shape4->appendCircle(400, 400, 100, 100); + shape4->fill(255, 0, 0, 255); + shape4->stroke(5); + shape4->stroke(255, 255, 255, 255); + scene->push(move(shape4)); + + auto shape5 = tvg::Shape::gen(); + shape5->appendCircle(550, 550, 150, 150); + shape5->fill(255, 0, 255, 255); + shape5->stroke(5); + shape5->stroke(255, 255, 255, 255); + scene->push(move(shape5)); + + if (canvas->push(move(scene)) != tvg::Result::Success) return; } @@ -67,25 +87,35 @@ void tvgUpdateCmds(tvg::Canvas* canvas) switch (order) { case 0: - canvas->push(unique_ptr(paints[0])); - canvas->push(unique_ptr(paints[1])); - canvas->push(unique_ptr(paints[2])); + canvas->push(unique_ptr((tvg::Shape*)paints[0])); + canvas->push(unique_ptr((tvg::Shape*)paints[1])); + canvas->push(unique_ptr((tvg::Shape*)paints[2])); + canvas->push(unique_ptr((tvg::Scene*)paints[3])); break; case 1: - canvas->push(unique_ptr(paints[1])); - canvas->push(unique_ptr(paints[2])); - canvas->push(unique_ptr(paints[0])); + canvas->push(unique_ptr((tvg::Shape*)paints[1])); + canvas->push(unique_ptr((tvg::Shape*)paints[2])); + canvas->push(unique_ptr((tvg::Scene*)paints[3])); + canvas->push(unique_ptr((tvg::Shape*)paints[0])); break; case 2: - canvas->push(unique_ptr(paints[2])); - canvas->push(unique_ptr(paints[0])); - canvas->push(unique_ptr(paints[1])); + canvas->push(unique_ptr((tvg::Shape*)paints[2])); + canvas->push(unique_ptr((tvg::Scene*)paints[3])); + canvas->push(unique_ptr((tvg::Shape*)paints[0])); + canvas->push(unique_ptr((tvg::Shape*)paints[1])); + break; + case 3: + canvas->push(unique_ptr((tvg::Scene*)paints[3])); + canvas->push(unique_ptr((tvg::Shape*)paints[0])); + canvas->push(unique_ptr((tvg::Shape*)paints[1])); + canvas->push(unique_ptr((tvg::Shape*)paints[2])); break; + } ++order; - if (order > 2) order = 0; + if (order > 3) order = 0; } @@ -199,10 +229,10 @@ int main(int argc, char **argv) if (tvgEngine == tvg::CanvasEngine::Sw) { auto view = createSwView(); - ecore_timer_add(0.5, timerSwCb, view); + ecore_timer_add(0.33, timerSwCb, view); } else { auto view = createGlView(); - ecore_timer_add(0.5, timerGlCb, view); + ecore_timer_add(0.33, timerGlCb, view); } elm_run(); -- 2.7.4