examples: removed test prefix

This commit is contained in:
Hermet Park 2020-10-07 13:57:10 +09:00
parent 4204030bbe
commit 433746f2bd
28 changed files with 49 additions and 422 deletions

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,5 +1,5 @@
#include <vector>
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,5 +1,5 @@
#include <vector>
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

@ -1,4 +1,4 @@
#include "testCommon.h"
#include "Common.h"
/************************************************************************/
/* Drawing Commands */

View file

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

View file

@ -1,237 +0,0 @@
#include <iostream>
#include <thread>
#include <vector>
#include <Elementary.h>
#include <thorvg.h>
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<unique_ptr<tvg::Canvas>> 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<size_t>(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<void*>(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<ObjData*>(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<ObjData*>(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<void*>(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;
}

View file

@ -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<tvg::SwCanvas> 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<tvg::GlCanvas> 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;
}