From: Hermet Park Date: Fri, 18 Sep 2020 15:34:46 +0000 (+0900) Subject: examples: move tests to src/examples X-Git-Tag: accepted/tizen/6.0/unified/20201030.120901~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a000a1441da3d01a32c6c06663452963b45175b4;p=platform%2Fcore%2Fgraphics%2Ftizenvg.git examples: move tests to src/examples tests is now officially placed in src/examples, default is turned off, only necessaries turn it on. ex) meson . build -Dexamples=true + this examples are required efl 'elementary' package. Change-Id: I60be4a45d520eab138e25212fbc4de3691bf1127 --- diff --git a/meson.build b/meson.build index 981e753..8cff0aa 100644 --- a/meson.build +++ b/meson.build @@ -6,6 +6,8 @@ project('thorvg', config_h = configuration_data() +add_project_arguments('-DEXAMPLE_DIR="@0@/src/examples/svgs"'.format(meson.current_source_dir()), language : 'cpp') + if get_option('engines').contains('sw') == true config_h.set10('THORVG_SW_RASTER_SUPPORT', true) endif diff --git a/meson_options.txt b/meson_options.txt index 14a31ed..d784bb2 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -26,4 +26,9 @@ option('tools', type: 'array', choices: ['', 'svg2png'], value: [''], - description: 'Enable building ThorVG Tools') + description: 'Enable building thorvg tools') + +option('examples', + type: 'boolean', + value: false, + description: 'Enable building examples') diff --git a/src/bin/meson.build b/src/bin/meson.build index fa68f84..9ee39e9 100644 --- a/src/bin/meson.build +++ b/src/bin/meson.build @@ -1,4 +1,5 @@ if get_option('tools').contains('svg2png') == true + message('Enable Tools: svg2png') subdir('svg2png') endif diff --git a/src/examples/main.cpp b/src/examples/main.cpp deleted file mode 100644 index 8bd265a..0000000 --- a/src/examples/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -using namespace std; - -int -main(int argc, char *argv[]) -{ - cout << "test thorvg!" << endl; - - return 0; -} diff --git a/src/examples/meson.build b/src/examples/meson.build index 4ba6e9b..4c40890 100644 --- a/src/examples/meson.build +++ b/src/examples/meson.build @@ -1 +1,36 @@ -executable('thorvg_sample', 'main.cpp') +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', + 'testStroke.cpp', + 'testStrokeLine.cpp', + 'testSvg2.cpp', + 'testSvg.cpp', + 'testTransform.cpp', + 'testUpdate.cpp', +] + +foreach current_file : source_file + name = current_file.split('.')[0] + executable(name, current_file, + include_directories : headers, + link_with : thorvg_lib, + dependencies : examples_dep) +endforeach diff --git a/test/svgs/batman1.svg b/src/examples/svgs/batman1.svg similarity index 100% rename from test/svgs/batman1.svg rename to src/examples/svgs/batman1.svg diff --git a/test/svgs/bojo.svg b/src/examples/svgs/bojo.svg similarity index 100% rename from test/svgs/bojo.svg rename to src/examples/svgs/bojo.svg diff --git a/test/svgs/bzrfeed.svg b/src/examples/svgs/bzrfeed.svg similarity index 100% rename from test/svgs/bzrfeed.svg rename to src/examples/svgs/bzrfeed.svg diff --git a/test/svgs/cartman.svg b/src/examples/svgs/cartman.svg similarity index 100% rename from test/svgs/cartman.svg rename to src/examples/svgs/cartman.svg diff --git a/test/svgs/dst.svg b/src/examples/svgs/dst.svg similarity index 100% rename from test/svgs/dst.svg rename to src/examples/svgs/dst.svg diff --git a/test/svgs/duke.svg b/src/examples/svgs/duke.svg similarity index 100% rename from test/svgs/duke.svg rename to src/examples/svgs/duke.svg diff --git a/test/svgs/eee.svg b/src/examples/svgs/eee.svg similarity index 100% rename from test/svgs/eee.svg rename to src/examples/svgs/eee.svg diff --git a/test/svgs/favorite_on.svg b/src/examples/svgs/favorite_on.svg similarity index 100% rename from test/svgs/favorite_on.svg rename to src/examples/svgs/favorite_on.svg diff --git a/test/svgs/google.svg b/src/examples/svgs/google.svg similarity index 100% rename from test/svgs/google.svg rename to src/examples/svgs/google.svg diff --git a/test/svgs/ibm.svg b/src/examples/svgs/ibm.svg similarity index 100% rename from test/svgs/ibm.svg rename to src/examples/svgs/ibm.svg diff --git a/test/svgs/lineargrad1.svg b/src/examples/svgs/lineargrad1.svg similarity index 100% rename from test/svgs/lineargrad1.svg rename to src/examples/svgs/lineargrad1.svg diff --git a/test/svgs/radialgrad1.svg b/src/examples/svgs/radialgrad1.svg similarity index 100% rename from test/svgs/radialgrad1.svg rename to src/examples/svgs/radialgrad1.svg diff --git a/test/svgs/scion.svg b/src/examples/svgs/scion.svg similarity index 100% rename from test/svgs/scion.svg rename to src/examples/svgs/scion.svg diff --git a/test/svgs/tiger.svg b/src/examples/svgs/tiger.svg similarity index 100% rename from test/svgs/tiger.svg rename to src/examples/svgs/tiger.svg diff --git a/test/svgs/yadis.svg b/src/examples/svgs/yadis.svg similarity index 100% rename from test/svgs/yadis.svg rename to src/examples/svgs/yadis.svg diff --git a/test/svgs/yinyang.svg b/src/examples/svgs/yinyang.svg similarity index 100% rename from test/svgs/yinyang.svg rename to src/examples/svgs/yinyang.svg diff --git a/test/testArc.cpp b/src/examples/testArc.cpp similarity index 100% rename from test/testArc.cpp rename to src/examples/testArc.cpp diff --git a/test/testAsync.cpp b/src/examples/testAsync.cpp similarity index 100% rename from test/testAsync.cpp rename to src/examples/testAsync.cpp diff --git a/test/testBlending.cpp b/src/examples/testBlending.cpp similarity index 100% rename from test/testBlending.cpp rename to src/examples/testBlending.cpp diff --git a/test/testBoundary.cpp b/src/examples/testBoundary.cpp similarity index 100% rename from test/testBoundary.cpp rename to src/examples/testBoundary.cpp diff --git a/test/testCapi.c b/src/examples/testCapi.cpp similarity index 95% rename from test/testCapi.c rename to src/examples/testCapi.cpp index 82df1f5..bdcc349 100644 --- a/test/testCapi.c +++ b/src/examples/testCapi.cpp @@ -126,13 +126,13 @@ void testCapi() tvg_shape_get_path_commands(shape, &cmds, &cmdCnt); printf("---- First Shape Commands(%u) ----\n", cmdCnt); - for(int i=0; i < cmdCnt; ++i) { + for(uint32_t i = 0; i < cmdCnt; ++i) { printf("%d\n", cmds[i]); } tvg_shape_get_path_coords(shape, &pts, &ptsCnt); printf("---- First Shape Points(%u) ----\n", ptsCnt); - for(int i=0; i < ptsCnt; ++i) { + for(uint32_t i = 0; i < ptsCnt; ++i) { printf("(%.2lf, %.2lf)\n", pts[i].x, pts[i].y); } diff --git a/test/testCommon.h b/src/examples/testCommon.h similarity index 100% rename from test/testCommon.h rename to src/examples/testCommon.h diff --git a/test/testCustomTransform.cpp b/src/examples/testCustomTransform.cpp similarity index 100% rename from test/testCustomTransform.cpp rename to src/examples/testCustomTransform.cpp diff --git a/test/testDirectUpdate.cpp b/src/examples/testDirectUpdate.cpp similarity index 100% rename from test/testDirectUpdate.cpp rename to src/examples/testDirectUpdate.cpp diff --git a/test/testDuplicate.cpp b/src/examples/testDuplicate.cpp similarity index 100% rename from test/testDuplicate.cpp rename to src/examples/testDuplicate.cpp diff --git a/test/testGradientTransform.cpp b/src/examples/testGradientTransform.cpp similarity index 100% rename from test/testGradientTransform.cpp rename to src/examples/testGradientTransform.cpp diff --git a/test/testLinearGradient.cpp b/src/examples/testLinearGradient.cpp similarity index 100% rename from test/testLinearGradient.cpp rename to src/examples/testLinearGradient.cpp diff --git a/test/testMultiCanvas.cpp b/src/examples/testMultiCanvas.cpp similarity index 97% rename from test/testMultiCanvas.cpp rename to src/examples/testMultiCanvas.cpp index d39898c..e8739af 100644 --- a/test/testMultiCanvas.cpp +++ b/src/examples/testMultiCanvas.cpp @@ -216,9 +216,9 @@ int main(int argc, char **argv) evas_object_smart_callback_add(win, "delete,request", win_del, 0); if (tvgEngine == tvg::CanvasEngine::Sw) { - eina_file_dir_list("./svgs", EINA_TRUE, tvgSwTest, win); + eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, tvgSwTest, win); } else { - eina_file_dir_list("./svgs", EINA_TRUE, tvgGlTest, win); + eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, tvgGlTest, win); } evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT); @@ -234,4 +234,4 @@ int main(int argc, char **argv) cout << "engine is not supported" << endl; } return 0; -} \ No newline at end of file +} diff --git a/test/testMultiShapes.cpp b/src/examples/testMultiShapes.cpp similarity index 100% rename from test/testMultiShapes.cpp rename to src/examples/testMultiShapes.cpp diff --git a/test/testPath.cpp b/src/examples/testPath.cpp similarity index 100% rename from test/testPath.cpp rename to src/examples/testPath.cpp diff --git a/test/testPathCopy.cpp b/src/examples/testPathCopy.cpp similarity index 100% rename from test/testPathCopy.cpp rename to src/examples/testPathCopy.cpp diff --git a/test/testRadialGradient.cpp b/src/examples/testRadialGradient.cpp similarity index 100% rename from test/testRadialGradient.cpp rename to src/examples/testRadialGradient.cpp diff --git a/test/testScene.cpp b/src/examples/testScene.cpp similarity index 100% rename from test/testScene.cpp rename to src/examples/testScene.cpp diff --git a/test/testSceneTransform.cpp b/src/examples/testSceneTransform.cpp similarity index 100% rename from test/testSceneTransform.cpp rename to src/examples/testSceneTransform.cpp diff --git a/test/testShape.cpp b/src/examples/testShape.cpp similarity index 100% rename from test/testShape.cpp rename to src/examples/testShape.cpp diff --git a/test/testStroke.cpp b/src/examples/testStroke.cpp similarity index 100% rename from test/testStroke.cpp rename to src/examples/testStroke.cpp diff --git a/test/testStrokeLine.cpp b/src/examples/testStrokeLine.cpp similarity index 100% rename from test/testStrokeLine.cpp rename to src/examples/testStrokeLine.cpp diff --git a/test/testSvg.cpp b/src/examples/testSvg.cpp similarity index 96% rename from test/testSvg.cpp rename to src/examples/testSvg.cpp index 7e3d775..7086127 100644 --- a/test/testSvg.cpp +++ b/src/examples/testSvg.cpp @@ -14,12 +14,10 @@ static std::vector> pictures; void svgDirCallback(const char* name, const char* path, void* data) { - tvg::Canvas* canvas = static_cast(data); - auto picture = tvg::Picture::gen(); char buf[PATH_MAX]; - sprintf(buf,"%s/%s", path, name); + sprintf(buf, "/%s/%s", path, name); if (picture->load(buf) != tvg::Result::Success) return; @@ -61,7 +59,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) if (canvas->push(move(shape)) != tvg::Result::Success) return; - eina_file_dir_list("./svgs", EINA_TRUE, svgDirCallback, canvas); + eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, svgDirCallback, canvas); /* This showcase shows you asynchrounous loading of svg. For this, pushing pictures at a certian sync time. diff --git a/test/testSvg2.cpp b/src/examples/testSvg2.cpp similarity index 100% rename from test/testSvg2.cpp rename to src/examples/testSvg2.cpp diff --git a/test/testTransform.cpp b/src/examples/testTransform.cpp similarity index 100% rename from test/testTransform.cpp rename to src/examples/testTransform.cpp diff --git a/test/testUpdate.cpp b/src/examples/testUpdate.cpp similarity index 100% rename from test/testUpdate.cpp rename to src/examples/testUpdate.cpp diff --git a/src/meson.build b/src/meson.build index c32a993..8741ef2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -29,8 +29,6 @@ thorvg_lib = library( gnu_symbol_visibility : 'hidden', ) -subdir('bin') - thorvg_dep = declare_dependency( include_directories: headers, link_with : thorvg_lib @@ -45,3 +43,10 @@ pkg_mod.generate( filebase : 'thorvg', description : 'A Thor library for rendering vector graphics' ) + +subdir('bin') + +if get_option('examples') == true + message('Enable Examples') + subdir('examples') +endif diff --git a/test/makefile b/test/makefile deleted file mode 100644 index b5028b1..0000000 --- a/test/makefile +++ /dev/null @@ -1,25 +0,0 @@ -all: - gcc -o testShape testShape.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testMultiShapes testMultiShapes.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testBoundary testBoundary.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testPath testPath.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testPathCopy testPathCopy.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testBlending testBlending.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testUpdate testUpdate.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testDirectUpdate testDirectUpdate.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testScene testScene.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testTransform testTransform.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testCustomTransform testCustomTransform.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testSceneTransform testSceneTransform.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testStroke testStroke.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testStrokeLine testStrokeLine.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testLinearGradient testLinearGradient.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testRadialGradient testRadialGradient.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testGradientTransform testGradientTransform.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testSvg testSvg.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testSvg2 testSvg2.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testAsync testAsync.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testArc testArc.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testMultiCanvas testMultiCanvas.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testDuplicate testDuplicate.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg` - gcc -o testCapi testCapi.c -g `pkg-config --cflags --libs elementary thorvg`