these interfaces will perform for vector resources such as svg/tvg/etc ...
see testSvg examples
Change-Id: Icec0a4682301a13646868bd7c3bfc1771ae7db2c
testLinearGradient
testRadialGradient
testGradientTransform
+testSvg
+testSvg2
enum class TVG_EXPORT FillSpread { Pad = 0, Reflect, Repeat };
enum class TVG_EXPORT CanvasEngine { Sw = 0, Gl };
+
struct Point
{
float x, y;
Result push(std::unique_ptr<Paint> paint) noexcept;
Result reserve(uint32_t size) noexcept;
+ Result load(const std::string& path, float w, float h, bool lazy = false) noexcept;
+ Result save(const std::string& path) noexcept;
+
Result rotate(float degree) noexcept override;
Result scale(float factor) noexcept override;
Result translate(float x, float y) noexcept override;
return Result::Success;
}
+
+Result Scene::load(const std::string& path, float w, float h, bool lazy) noexcept
+{
+ if (path.empty()) return Result::InvalidArguments;
+
+ auto impl = pImpl.get();
+ if (!impl) return Result::MemoryCorruption;
+
+ return impl->load(path, w, h, lazy);
+}
+
+
+Result Scene::save(const std::string& path) noexcept
+{
+ if (path.empty()) return Result::InvalidArguments;
+
+ auto impl = pImpl.get();
+ if (!impl) return Result::MemoryCorruption;
+
+ return impl->save(path);
+}
+
+
#endif /* _TVG_SCENE_CPP_ */
\ No newline at end of file
return true;
}
+
+ Result load(const string& path, float w, float h, bool lazy)
+ {
+ return Result::Success;
+ }
+
+ Result save(const string& path)
+ {
+ return Result::Success;
+ }
};
#endif //_TVG_SCENE_IMPL_H_
\ No newline at end of file
gcc -o testLinearGradient testLinearGradient.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
gcc -o testRadialGradient testRadialGradient.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
gcc -o testGradientTransform testGradientTransform.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
+ gcc -o testSvg testSvg.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
+ gcc -o testSvg2 testSvg2.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
--- /dev/null
+#include <tizenvg.h>
+#include <Elementary.h>
+
+using namespace std;
+
+#define WIDTH 800
+#define HEIGHT 800
+
+static uint32_t buffer[WIDTH * HEIGHT];
+
+void tvgtest()
+{
+ //Initialize TizenVG Engine
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
+
+ //Create a Canvas
+ auto canvas = tvg::SwCanvas::gen();
+ canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
+
+ /* Create a SVG scene, keep original size,
+ You can pass 0 x 0 size for lazying loading in this case.
+ scene->load("sample.svg", 0, 0, true); */
+ auto scene = tvg::Scene::gen();
+ scene->load("sample.svg");
+ canvas->push(move(scene));
+
+ canvas->draw();
+ canvas->sync();
+
+ //Terminate TizenVG Engine
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
+}
+
+void
+win_del(void *data, Evas_Object *o, void *ev)
+{
+ elm_exit();
+}
+
+
+int main(int argc, char **argv)
+{
+ tvgtest();
+
+ //Show the result using EFL...
+ elm_init(argc, argv);
+
+ Eo* win = elm_win_util_standard_add(NULL, "TizenVG Test");
+ evas_object_smart_callback_add(win, "delete,request", win_del, 0);
+
+ Eo* img = evas_object_image_filled_add(evas_object_evas_get(win));
+ evas_object_image_size_set(img, WIDTH, HEIGHT);
+ evas_object_image_data_set(img, buffer);
+ evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(img);
+
+ elm_win_resize_object_add(win, img);
+ evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
+ evas_object_show(win);
+
+ elm_run();
+ elm_shutdown();
+}
--- /dev/null
+#include <tizenvg.h>
+#include <Elementary.h>
+
+using namespace std;
+
+#define WIDTH 800
+#define HEIGHT 800
+
+static uint32_t buffer[WIDTH * HEIGHT];
+
+void tvgtest()
+{
+ //Initialize TizenVG Engine
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
+
+ //Create a Canvas
+ auto canvas = tvg::SwCanvas::gen();
+ canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
+
+ //Create a SVG scene, keep aspect ratio to width/2 with lazy loading
+ auto scene = tvg::Scene::gen();
+ scene->load("sample.svg", WIDTH/2, 0, true);
+ canvas->push(move(scene));
+
+ //Create a SVG scene, keep aspect ratio to height/2 with lazy loading
+ auto scene2 = tvg::Scene::gen();
+ scene2->load("sample.svg", 0, HEIGHT/2, true);
+ scene2->translate(WIDTH/2, HEIGHT/2);
+ canvas->push(move(scene2));
+
+ canvas->draw();
+ canvas->sync();
+
+ //Terminate TizenVG Engine
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
+}
+
+void
+win_del(void *data, Evas_Object *o, void *ev)
+{
+ elm_exit();
+}
+
+
+int main(int argc, char **argv)
+{
+ tvgtest();
+
+ //Show the result using EFL...
+ elm_init(argc, argv);
+
+ Eo* win = elm_win_util_standard_add(NULL, "TizenVG Test");
+ evas_object_smart_callback_add(win, "delete,request", win_del, 0);
+
+ Eo* img = evas_object_image_filled_add(evas_object_evas_get(win));
+ evas_object_image_size_set(img, WIDTH, HEIGHT);
+ evas_object_image_data_set(img, buffer);
+ evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(img);
+
+ elm_win_resize_object_add(win, img);
+ evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
+ evas_object_show(win);
+
+ elm_run();
+ elm_shutdown();
+}