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.
This commit is contained in:
Hermet Park 2020-09-19 00:34:46 +09:00
parent 3e18b85f99
commit 729fee5a23
48 changed files with 59 additions and 49 deletions

View file

@ -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

View file

@ -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')

View file

@ -1,4 +1,5 @@
if get_option('tools').contains('svg2png') == true
message('Enable Tools: svg2png')
subdir('svg2png')
endif

View file

@ -1,11 +0,0 @@
#include <iostream>
using namespace std;
int
main(int argc, char *argv[])
{
cout << "test thorvg!" << endl;
return 0;
}

View file

@ -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

View file

Before

Width:  |  Height:  |  Size: 532 B

After

Width:  |  Height:  |  Size: 532 B

View file

Before

Width:  |  Height:  |  Size: 807 B

After

Width:  |  Height:  |  Size: 807 B

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 794 B

After

Width:  |  Height:  |  Size: 794 B

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

Before

Width:  |  Height:  |  Size: 919 B

After

Width:  |  Height:  |  Size: 919 B

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

View file

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 330 B

View file

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

Before

Width:  |  Height:  |  Size: 514 B

After

Width:  |  Height:  |  Size: 514 B

View file

Before

Width:  |  Height:  |  Size: 501 B

After

Width:  |  Height:  |  Size: 501 B

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

View file

Before

Width:  |  Height:  |  Size: 633 B

After

Width:  |  Height:  |  Size: 633 B

View file

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 282 B

View file

@ -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);
}

View file

@ -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);

View file

@ -14,12 +14,10 @@ static std::vector<unique_ptr<tvg::Picture>> pictures;
void svgDirCallback(const char* name, const char* path, void* data)
{
tvg::Canvas* canvas = static_cast<tvg::Canvas*>(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.

View file

@ -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

View file

@ -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`