From 96e8cfd6de890e7f6d7b8edcea58c912bf2929dc Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 7 Oct 2020 13:57:10 +0900 Subject: [PATCH] examples: removed test prefix Change-Id: Ie7a897ebaac59701665a5340db31110599a63b8d --- src/examples/{testArc.cpp => Arc.cpp} | 2 +- src/examples/{testAsync.cpp => Async.cpp} | 2 +- src/examples/{testBlending.cpp => Blending.cpp} | 2 +- src/examples/{testBoundary.cpp => Boundary.cpp} | 2 +- src/examples/{testCapi.cpp => Capi.cpp} | 0 src/examples/{testClipPath.cpp => ClipPath.cpp} | 2 +- src/examples/{testCommon.h => Common.h} | 0 ...testCustomTransform.cpp => CustomTransform.cpp} | 2 +- .../{testDirectUpdate.cpp => DirectUpdate.cpp} | 2 +- src/examples/{testDuplicate.cpp => Duplicate.cpp} | 2 +- ...GradientTransform.cpp => GradientTransform.cpp} | 2 +- .../{testLinearGradient.cpp => LinearGradient.cpp} | 2 +- src/examples/{testPath.cpp => Path.cpp} | 2 +- src/examples/{testPathCopy.cpp => PathCopy.cpp} | 2 +- .../{testRadialGradient.cpp => RadialGradient.cpp} | 2 +- src/examples/{testScene.cpp => Scene.cpp} | 2 +- .../{testSceneTransform.cpp => SceneTransform.cpp} | 2 +- src/examples/{testShape.cpp => Shape.cpp} | 2 +- src/examples/{testStress.cpp => Stress.cpp} | 2 +- src/examples/{testStroke.cpp => Stroke.cpp} | 2 +- .../{testStrokeLine.cpp => StrokeLine.cpp} | 2 +- src/examples/{testSvg.cpp => Svg.cpp} | 2 +- src/examples/{testSvg2.cpp => Svg2.cpp} | 2 +- src/examples/{testTransform.cpp => Transform.cpp} | 2 +- src/examples/{testUpdate.cpp => Update.cpp} | 2 +- src/examples/meson.build | 52 ++--- src/examples/testMultiCanvas.cpp | 237 --------------------- src/examples/testMultiShapes.cpp | 136 ------------ 28 files changed, 49 insertions(+), 422 deletions(-) rename src/examples/{testArc.cpp => Arc.cpp} (99%) rename src/examples/{testAsync.cpp => Async.cpp} (99%) rename src/examples/{testBlending.cpp => Blending.cpp} (99%) rename src/examples/{testBoundary.cpp => Boundary.cpp} (99%) rename src/examples/{testCapi.cpp => Capi.cpp} (100%) rename src/examples/{testClipPath.cpp => ClipPath.cpp} (99%) rename src/examples/{testCommon.h => Common.h} (100%) rename src/examples/{testCustomTransform.cpp => CustomTransform.cpp} (99%) rename src/examples/{testDirectUpdate.cpp => DirectUpdate.cpp} (99%) rename src/examples/{testDuplicate.cpp => Duplicate.cpp} (99%) rename src/examples/{testGradientTransform.cpp => GradientTransform.cpp} (99%) rename src/examples/{testLinearGradient.cpp => LinearGradient.cpp} (99%) rename src/examples/{testPath.cpp => Path.cpp} (99%) rename src/examples/{testPathCopy.cpp => PathCopy.cpp} (99%) rename src/examples/{testRadialGradient.cpp => RadialGradient.cpp} (99%) rename src/examples/{testScene.cpp => Scene.cpp} (99%) rename src/examples/{testSceneTransform.cpp => SceneTransform.cpp} (99%) rename src/examples/{testShape.cpp => Shape.cpp} (99%) rename src/examples/{testStress.cpp => Stress.cpp} (99%) rename src/examples/{testStroke.cpp => Stroke.cpp} (99%) rename src/examples/{testStrokeLine.cpp => StrokeLine.cpp} (99%) rename src/examples/{testSvg.cpp => Svg.cpp} (99%) rename src/examples/{testSvg2.cpp => Svg2.cpp} (99%) rename src/examples/{testTransform.cpp => Transform.cpp} (99%) rename src/examples/{testUpdate.cpp => Update.cpp} (99%) delete mode 100644 src/examples/testMultiCanvas.cpp delete mode 100644 src/examples/testMultiShapes.cpp diff --git a/src/examples/testArc.cpp b/src/examples/Arc.cpp similarity index 99% rename from src/examples/testArc.cpp rename to src/examples/Arc.cpp index 9c307d4..ccd75fb 100644 --- a/src/examples/testArc.cpp +++ b/src/examples/Arc.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testAsync.cpp b/src/examples/Async.cpp similarity index 99% rename from src/examples/testAsync.cpp rename to src/examples/Async.cpp index ddb8271..f69300e 100644 --- a/src/examples/testAsync.cpp +++ b/src/examples/Async.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testBlending.cpp b/src/examples/Blending.cpp similarity index 99% rename from src/examples/testBlending.cpp rename to src/examples/Blending.cpp index 68623dc..81f3e01 100644 --- a/src/examples/testBlending.cpp +++ b/src/examples/Blending.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testBoundary.cpp b/src/examples/Boundary.cpp similarity index 99% rename from src/examples/testBoundary.cpp rename to src/examples/Boundary.cpp index e2ed1c0..e39e1cb 100644 --- a/src/examples/testBoundary.cpp +++ b/src/examples/Boundary.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testCapi.cpp b/src/examples/Capi.cpp similarity index 100% rename from src/examples/testCapi.cpp rename to src/examples/Capi.cpp diff --git a/src/examples/testClipPath.cpp b/src/examples/ClipPath.cpp similarity index 99% rename from src/examples/testClipPath.cpp rename to src/examples/ClipPath.cpp index 667abba..122016b 100644 --- a/src/examples/testClipPath.cpp +++ b/src/examples/ClipPath.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testCommon.h b/src/examples/Common.h similarity index 100% rename from src/examples/testCommon.h rename to src/examples/Common.h diff --git a/src/examples/testCustomTransform.cpp b/src/examples/CustomTransform.cpp similarity index 99% rename from src/examples/testCustomTransform.cpp rename to src/examples/CustomTransform.cpp index 50033f9..9cc188e 100644 --- a/src/examples/testCustomTransform.cpp +++ b/src/examples/CustomTransform.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testDirectUpdate.cpp b/src/examples/DirectUpdate.cpp similarity index 99% rename from src/examples/testDirectUpdate.cpp rename to src/examples/DirectUpdate.cpp index 96de6a6..6dea62e 100644 --- a/src/examples/testDirectUpdate.cpp +++ b/src/examples/DirectUpdate.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testDuplicate.cpp b/src/examples/Duplicate.cpp similarity index 99% rename from src/examples/testDuplicate.cpp rename to src/examples/Duplicate.cpp index 86fea2c..2c94642 100644 --- a/src/examples/testDuplicate.cpp +++ b/src/examples/Duplicate.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testGradientTransform.cpp b/src/examples/GradientTransform.cpp similarity index 99% rename from src/examples/testGradientTransform.cpp rename to src/examples/GradientTransform.cpp index 45431e3..fe06740 100644 --- a/src/examples/testGradientTransform.cpp +++ b/src/examples/GradientTransform.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testLinearGradient.cpp b/src/examples/LinearGradient.cpp similarity index 99% rename from src/examples/testLinearGradient.cpp rename to src/examples/LinearGradient.cpp index d1ed5fa..8d25543 100644 --- a/src/examples/testLinearGradient.cpp +++ b/src/examples/LinearGradient.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testPath.cpp b/src/examples/Path.cpp similarity index 99% rename from src/examples/testPath.cpp rename to src/examples/Path.cpp index a265d03..3b4241e 100644 --- a/src/examples/testPath.cpp +++ b/src/examples/Path.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testPathCopy.cpp b/src/examples/PathCopy.cpp similarity index 99% rename from src/examples/testPathCopy.cpp rename to src/examples/PathCopy.cpp index b5d97cf..fca78be 100644 --- a/src/examples/testPathCopy.cpp +++ b/src/examples/PathCopy.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testRadialGradient.cpp b/src/examples/RadialGradient.cpp similarity index 99% rename from src/examples/testRadialGradient.cpp rename to src/examples/RadialGradient.cpp index a64e47b..c33ba43 100644 --- a/src/examples/testRadialGradient.cpp +++ b/src/examples/RadialGradient.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testScene.cpp b/src/examples/Scene.cpp similarity index 99% rename from src/examples/testScene.cpp rename to src/examples/Scene.cpp index 8c46428..4760b94 100644 --- a/src/examples/testScene.cpp +++ b/src/examples/Scene.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testSceneTransform.cpp b/src/examples/SceneTransform.cpp similarity index 99% rename from src/examples/testSceneTransform.cpp rename to src/examples/SceneTransform.cpp index ef6c157..9b69679 100644 --- a/src/examples/testSceneTransform.cpp +++ b/src/examples/SceneTransform.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testShape.cpp b/src/examples/Shape.cpp similarity index 99% rename from src/examples/testShape.cpp rename to src/examples/Shape.cpp index 56acfd5..235e82e 100644 --- a/src/examples/testShape.cpp +++ b/src/examples/Shape.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testStress.cpp b/src/examples/Stress.cpp similarity index 99% rename from src/examples/testStress.cpp rename to src/examples/Stress.cpp index 2f95639..5d9eadf 100644 --- a/src/examples/testStress.cpp +++ b/src/examples/Stress.cpp @@ -1,5 +1,5 @@ #include -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testStroke.cpp b/src/examples/Stroke.cpp similarity index 99% rename from src/examples/testStroke.cpp rename to src/examples/Stroke.cpp index b50804f..a1beeee 100644 --- a/src/examples/testStroke.cpp +++ b/src/examples/Stroke.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testStrokeLine.cpp b/src/examples/StrokeLine.cpp similarity index 99% rename from src/examples/testStrokeLine.cpp rename to src/examples/StrokeLine.cpp index dbb2311..6c8cc7b 100644 --- a/src/examples/testStrokeLine.cpp +++ b/src/examples/StrokeLine.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testSvg.cpp b/src/examples/Svg.cpp similarity index 99% rename from src/examples/testSvg.cpp rename to src/examples/Svg.cpp index 7086127..d1ef9e7 100644 --- a/src/examples/testSvg.cpp +++ b/src/examples/Svg.cpp @@ -1,5 +1,5 @@ #include -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testSvg2.cpp b/src/examples/Svg2.cpp similarity index 99% rename from src/examples/testSvg2.cpp rename to src/examples/Svg2.cpp index c859b04..85cc291 100644 --- a/src/examples/testSvg2.cpp +++ b/src/examples/Svg2.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testTransform.cpp b/src/examples/Transform.cpp similarity index 99% rename from src/examples/testTransform.cpp rename to src/examples/Transform.cpp index 6cd9be6..8a9ac6f 100644 --- a/src/examples/testTransform.cpp +++ b/src/examples/Transform.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/testUpdate.cpp b/src/examples/Update.cpp similarity index 99% rename from src/examples/testUpdate.cpp rename to src/examples/Update.cpp index 6df8533..8ebe428 100644 --- a/src/examples/testUpdate.cpp +++ b/src/examples/Update.cpp @@ -1,4 +1,4 @@ -#include "testCommon.h" +#include "Common.h" /************************************************************************/ /* Drawing Commands */ diff --git a/src/examples/meson.build b/src/examples/meson.build index 24f2cbd..25c5a89 100644 --- a/src/examples/meson.build +++ b/src/examples/meson.build @@ -1,32 +1,32 @@ examples_dep = dependency('elementary', required : true) source_file = [ - 'testArc.cpp', - 'testAsync.cpp', - 'testBlending.cpp', - 'testBoundary.cpp', - 'testCapi.cpp', - 'testCustomTransform.cpp', - 'testDirectUpdate.cpp', - 'testDuplicate.cpp', - 'testGradientTransform.cpp', - 'testLinearGradient.cpp', - 'testMultiCanvas.cpp', - 'testMultiShapes.cpp', - 'testPathCopy.cpp', - 'testPath.cpp', - 'testRadialGradient.cpp', - 'testScene.cpp', - 'testSceneTransform.cpp', - 'testShape.cpp', - 'testStress.cpp', - 'testStroke.cpp', - 'testStrokeLine.cpp', - 'testSvg2.cpp', - 'testSvg.cpp', - 'testTransform.cpp', - 'testUpdate.cpp', - 'testClipPath.cpp', + 'Arc.cpp', + 'Async.cpp', + 'Blending.cpp', + 'Boundary.cpp', + 'Capi.cpp', + 'CustomTransform.cpp', + 'DirectUpdate.cpp', + 'Duplicate.cpp', + 'GradientTransform.cpp', + 'LinearGradient.cpp', + 'MultiCanvas.cpp', + 'MultiShapes.cpp', + 'PathCopy.cpp', + 'Path.cpp', + 'RadialGradient.cpp', + 'Scene.cpp', + 'SceneTransform.cpp', + 'Shape.cpp', + 'Stress.cpp', + 'Stroke.cpp', + 'StrokeLine.cpp', + 'Svg2.cpp', + 'Svg.cpp', + 'Transform.cpp', + 'Update.cpp', + 'ClipPath.cpp', ] foreach current_file : source_file diff --git a/src/examples/testMultiCanvas.cpp b/src/examples/testMultiCanvas.cpp deleted file mode 100644 index e8739af..0000000 --- a/src/examples/testMultiCanvas.cpp +++ /dev/null @@ -1,237 +0,0 @@ -#include -#include -#include -#include -#include - -using namespace std; - -/************************************************************************/ -/* Drawing Commands */ -/************************************************************************/ -#define WIDTH 800 -#define HEIGHT 800 -#define NUM_PER_LINE 4 -#define SIZE 200 - -static size_t count = 0; -static std::vector> canvases; - - -void win_del(void *data, Evas_Object *o, void* ev) -{ - elm_exit(); -} - - -void tvgDrawCmds(tvg::Canvas* canvas, const char* path, const char* name) -{ - auto picture = tvg::Picture::gen(); - - char buf[PATH_MAX]; - sprintf(buf,"%s/%s", path, name); - - if (picture->load(buf) != tvg::Result::Success) return; - - float x, y, w, h; - picture->viewbox(&x, &y, &w, &h); - - float rate = (SIZE/(w > h ? w : h)); - picture->scale(rate); - - x *= rate; - y *= rate; - w *= rate; - h *= rate; - - //Center Align ? - if (w > h) { - y -= (SIZE - h) * 0.5f; - } else { - x -= (SIZE - w) * 0.5f; - } - picture->translate(-x, -y); - - if (canvas->push(move(picture)) != tvg::Result::Success) return; - - cout << "SVG: " << buf << endl; - - count++; -} - - -/************************************************************************/ -/* Sw Engine Test Code */ -/************************************************************************/ - -void sw_del(void* data, Evas* evas, Eo* obj, void* ev) -{ - auto buffer = (uint32_t*) data; - free(buffer); -} - - -void drawSwView(void* data, Eo* obj) -{ - auto i = reinterpret_cast(data); - auto& canvas = canvases[i]; - - if (canvas->draw() == tvg::Result::Success) { - canvas->sync(); - } -} - - -void tvgSwTest(const char* name, const char* path, void* data) -{ - Eo* win = (Eo*) data; - - uint32_t* buffer = (uint32_t*) calloc(sizeof(uint32_t), SIZE * SIZE); - - Eo* view = evas_object_image_filled_add(evas_object_evas_get(win)); - evas_object_image_size_set(view, SIZE, SIZE); - evas_object_image_data_set(view, buffer); - evas_object_image_pixels_dirty_set(view, EINA_TRUE); - evas_object_image_data_update_add(view, 0, 0, SIZE, SIZE); - evas_object_image_alpha_set(view, EINA_TRUE); - evas_object_image_pixels_get_callback_set(view, drawSwView, reinterpret_cast(count)); - evas_object_event_callback_add(view, EVAS_CALLBACK_DEL, sw_del, buffer); - evas_object_resize(view, SIZE, SIZE); - evas_object_move(view, (count % NUM_PER_LINE) * SIZE, SIZE * (count / NUM_PER_LINE)); - evas_object_show(view); - - //Create a Canvas - auto canvas = tvg::SwCanvas::gen(); - canvas->target(buffer, SIZE, SIZE, SIZE, tvg::SwCanvas::ARGB8888); - - tvgDrawCmds(canvas.get(), path, name); - - canvases.push_back(move(canvas)); -} - - -/************************************************************************/ -/* GL Engine Test Code */ -/************************************************************************/ - -struct ObjData -{ - char* path; - char* name; - int idx; -}; - -void gl_del(void* data, Evas* evas, Eo* obj, void* ev) -{ - auto objData = (ObjData*) data; - delete(objData); -} - -void initGLview(Evas_Object *obj) -{ - auto objData = reinterpret_cast(evas_object_data_get(obj, "objdata")); - objData->idx = count; - - static constexpr auto BPP = 4; - - //Create a Canvas - auto canvas = tvg::GlCanvas::gen(); - canvas->target(nullptr, SIZE * BPP, SIZE, SIZE); - - /* Push the shape into the Canvas drawing list - When this shape is into the canvas list, the shape could update & prepare - internal data asynchronously for coming rendering. - Canvas keeps this shape node unless user call canvas->clear() */ - tvgDrawCmds(canvas.get(), objData->path, objData->name); - - canvases.push_back(move(canvas)); -} - - -void drawGLview(Evas_Object *obj) -{ - auto gl = elm_glview_gl_api_get(obj); - gl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - gl->glClear(GL_COLOR_BUFFER_BIT); - - auto objData = reinterpret_cast(evas_object_data_get(obj, "objdata")); - auto& canvas = canvases[objData->idx]; - - if (canvas->draw() == tvg::Result::Success) { - canvas->sync(); - } -} - - -void tvgGlTest(const char* name, const char* path, void* data) -{ - auto objData = new ObjData; - objData->name = strdup(name); - objData->path = strdup(path); - - Eo* win = (Eo*) data; - - Eo* view = elm_glview_add(win); - elm_glview_mode_set(view, ELM_GLVIEW_ALPHA); - elm_glview_resize_policy_set(view, ELM_GLVIEW_RESIZE_POLICY_RECREATE); - elm_glview_render_policy_set(view, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND); - elm_glview_init_func_set(view, initGLview); - elm_glview_render_func_set(view, drawGLview); - evas_object_data_set(view, "objdata", reinterpret_cast(objData)); - evas_object_event_callback_add(view, EVAS_CALLBACK_DEL, gl_del, objData); - evas_object_resize(view, SIZE, SIZE); - evas_object_move(view, (count % NUM_PER_LINE) * SIZE, SIZE * (count / NUM_PER_LINE)); - evas_object_show(view); -} - - -/************************************************************************/ -/* Main Code */ -/************************************************************************/ - -int main(int argc, char **argv) -{ - tvg::CanvasEngine tvgEngine = tvg::CanvasEngine::Sw; - - if (argc > 1) { - if (!strcmp(argv[1], "gl")) tvgEngine = tvg::CanvasEngine::Gl; - } - - //Initialize ThorVG Engine - if (tvgEngine == tvg::CanvasEngine::Sw) { - cout << "tvg engine: software" << endl; - } else { - cout << "tvg engine: opengl" << endl; - } - - //Threads Count - auto threads = std::thread::hardware_concurrency(); - - //Initialize ThorVG Engine - if (tvg::Initializer::init(tvgEngine, threads) == tvg::Result::Success) { - - elm_init(argc, argv); - - Eo* win = elm_win_util_standard_add(NULL, "ThorVG Test"); - evas_object_smart_callback_add(win, "delete,request", win_del, 0); - - if (tvgEngine == tvg::CanvasEngine::Sw) { - eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, tvgSwTest, win); - } else { - eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, tvgGlTest, win); - } - - evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT); - evas_object_show(win); - - elm_run(); - elm_shutdown(); - - //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); - - } else { - cout << "engine is not supported" << endl; - } - return 0; -} diff --git a/src/examples/testMultiShapes.cpp b/src/examples/testMultiShapes.cpp deleted file mode 100644 index 3db41b9..0000000 --- a/src/examples/testMultiShapes.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "testCommon.h" - -/************************************************************************/ -/* Drawing Commands */ -/************************************************************************/ - -void tvgDrawCmds(tvg::Canvas* canvas) -{ - if (!canvas) return; - - canvas->reserve(3); //reserve 3 shape nodes (optional) - - //Prepare Round Rectangle - auto shape1 = tvg::Shape::gen(); - shape1->appendRect(0, 0, 400, 400, 50, 50); //x, y, w, h, rx, ry - shape1->fill(0, 255, 0, 255); //r, g, b, a - 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 - 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 - if (canvas->push(move(shape3)) != tvg::Result::Success) return; -} - - -/************************************************************************/ -/* Sw Engine Test Code */ -/************************************************************************/ - -static unique_ptr swCanvas; - -void tvgSwTest(uint32_t* buffer) -{ - //Create a Canvas - swCanvas = tvg::SwCanvas::gen(); - swCanvas->target(buffer, WIDTH, WIDTH, HEIGHT, tvg::SwCanvas::ARGB8888); - - /* Push the shape into the Canvas drawing list - When this shape is into the canvas list, the shape could update & prepare - internal data asynchronously for coming rendering. - Canvas keeps this shape node unless user call canvas->clear() */ - tvgDrawCmds(swCanvas.get()); -} - -void drawSwView(void* data, Eo* obj) -{ - if (swCanvas->draw() == tvg::Result::Success) { - swCanvas->sync(); - } -} - - -/************************************************************************/ -/* GL Engine Test Code */ -/************************************************************************/ - -static unique_ptr glCanvas; - -void initGLview(Evas_Object *obj) -{ - static constexpr auto BPP = 4; - - //Create a Canvas - glCanvas = tvg::GlCanvas::gen(); - glCanvas->target(nullptr, WIDTH * BPP, WIDTH, HEIGHT); - - /* Push the shape into the Canvas drawing list - When this shape is into the canvas list, the shape could update & prepare - internal data asynchronously for coming rendering. - Canvas keeps this shape node unless user call canvas->clear() */ - tvgDrawCmds(glCanvas.get()); -} - -void drawGLview(Evas_Object *obj) -{ - auto gl = elm_glview_gl_api_get(obj); - gl->glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - gl->glClear(GL_COLOR_BUFFER_BIT); - - if (glCanvas->draw() == tvg::Result::Success) { - glCanvas->sync(); - } -} - - -/************************************************************************/ -/* Main Code */ -/************************************************************************/ - -int main(int argc, char **argv) -{ - tvg::CanvasEngine tvgEngine = tvg::CanvasEngine::Sw; - - if (argc > 1) { - if (!strcmp(argv[1], "gl")) tvgEngine = tvg::CanvasEngine::Gl; - } - - //Initialize ThorVG Engine - if (tvgEngine == tvg::CanvasEngine::Sw) { - cout << "tvg engine: software" << endl; - } else { - cout << "tvg engine: opengl" << endl; - } - - //Threads Count - auto threads = std::thread::hardware_concurrency(); - - //Initialize ThorVG Engine - if (tvg::Initializer::init(tvgEngine, threads) == tvg::Result::Success) { - - elm_init(argc, argv); - - if (tvgEngine == tvg::CanvasEngine::Sw) { - createSwView(); - } else { - createGlView(); - } - - elm_run(); - elm_shutdown(); - - //Terminate ThorVG Engine - tvg::Initializer::term(tvgEngine); - - } else { - cout << "engine is not supported" << endl; - } - return 0; -} -- 2.7.4