From 654299d0ab6b3eeb0a5c21aafba036b93f1e995e Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Mon, 29 Jun 2020 19:30:29 +0900 Subject: [PATCH] test: Improve svg test Displays svg files located in "./svgs" dir. Change-Id: I4b9a281dc31fefb28c969780fa28adb74a5f5c02 --- test/svgs/bojo.svg | 15 ++++++++++++++ test/svgs/bzrfeed.svg | 23 +++++++++++++++++++++ test/svgs/cartman.svg | 11 ++++++++++ test/svgs/dst.svg | 15 ++++++++++++++ test/svgs/shape.svg | 18 ++++++++++++++++ test/testSvg.cpp | 57 +++++++++++++++++++++++++++++++++++---------------- 6 files changed, 121 insertions(+), 18 deletions(-) create mode 100644 test/svgs/bojo.svg create mode 100644 test/svgs/bzrfeed.svg create mode 100644 test/svgs/cartman.svg create mode 100644 test/svgs/dst.svg create mode 100644 test/svgs/shape.svg diff --git a/test/svgs/bojo.svg b/test/svgs/bojo.svg new file mode 100644 index 0000000..fe62615 --- /dev/null +++ b/test/svgs/bojo.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/test/svgs/bzrfeed.svg b/test/svgs/bzrfeed.svg new file mode 100644 index 0000000..e5d210f --- /dev/null +++ b/test/svgs/bzrfeed.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/svgs/cartman.svg b/test/svgs/cartman.svg new file mode 100644 index 0000000..d4b2740 --- /dev/null +++ b/test/svgs/cartman.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/test/svgs/dst.svg b/test/svgs/dst.svg new file mode 100644 index 0000000..bce75d8 --- /dev/null +++ b/test/svgs/dst.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/test/svgs/shape.svg b/test/svgs/shape.svg new file mode 100644 index 0000000..a0b3677 --- /dev/null +++ b/test/svgs/shape.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/test/testSvg.cpp b/test/testSvg.cpp index b7671b8..1ae4fe0 100644 --- a/test/testSvg.cpp +++ b/test/testSvg.cpp @@ -8,36 +8,54 @@ using namespace std; static uint32_t buffer[WIDTH * HEIGHT]; -void tvgtest() -{ - //Initialize ThorVG Engine - tvg::Initializer::init(tvg::CanvasEngine::Sw); +unique_ptr canvas = nullptr; +int count = 0; +static const int numberPerLine = 3; + +static int x = 30; +static int y = 30; - //Create a Canvas - auto canvas = tvg::SwCanvas::gen(); - canvas->target(buffer, WIDTH, WIDTH, HEIGHT); - // Create a SVG scene, request the original size, +void svgDirCallback(const char* name, const char* path, void* data) +{ auto scene = tvg::Scene::gen(); - scene->load("sample.svg"); + char buf[255]; + sprintf(buf,"%s/%s", path, name); + scene->load(buf); + printf("SVG Load : %s\n", buf); + scene->translate(((WIDTH - (x * 2)) / numberPerLine) * (count % numberPerLine) + x, ((HEIGHT - (y * 2))/ numberPerLine) * (int)((float)count / (float)numberPerLine) + y); canvas->push(move(scene)); - - canvas->draw(); - canvas->sync(); - - //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + count++; } -void win_del(void *data, Evas_Object *o, void *ev) + +void win_del(void* data, Evas_Object* o, void* ev) { elm_exit(); } -int main(int argc, char **argv) +int main(int argc, char** argv) { - tvgtest(); + //Initialize ThorVG Engine + tvg::Initializer::init(tvg::CanvasEngine::Sw); + + //Create a Canvas + canvas = tvg::SwCanvas::gen(); + canvas->target(buffer, WIDTH, WIDTH, HEIGHT); + + //Draw white background + auto scene = tvg::Scene::gen(); + auto shape1 = tvg::Shape::gen(); + shape1->appendRect(0, 0, WIDTH, HEIGHT, 0); + shape1->fill(255, 255, 255, 255); + scene->push(move(shape1)); + canvas->push(move(scene)); + + eina_file_dir_list("./svgs", EINA_TRUE, svgDirCallback, NULL); + + canvas->draw(); + canvas->sync(); //Show the result using EFL... elm_init(argc, argv); @@ -57,4 +75,7 @@ int main(int argc, char **argv) elm_run(); elm_shutdown(); + + //Terminate ThorVG Engine + tvg::Initializer::term(tvg::CanvasEngine::Sw); } -- 2.7.4