testRadialGradient
testGradientTransform
testSvg
-testSvg2
testGlShape
class Canvas;
-enum class TVG_EXPORT Result { Success = 0, InvalidArguments, InsufficientCondition, FailedAllocation, MemoryCorruption, Unknown };
+enum class TVG_EXPORT Result { Success = 0, InvalidArguments, InsufficientCondition, FailedAllocation, MemoryCorruption, NonSupport, Unknown };
enum class TVG_EXPORT PathCommand { Close = 0, MoveTo, LineTo, CubicTo };
enum class TVG_EXPORT StrokeCap { Square = 0, Round, Butt };
enum class TVG_EXPORT StrokeJoin { Bevel = 0, Round, Miter };
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 load(const std::string& path) noexcept;
Result rotate(float degree) noexcept override;
Result scale(float factor) noexcept override;
'tvgGlShaderSrc.cpp',
]
-glraster_dep = declare_dependency(
+glengine_dep = declare_dependency(
include_directories : include_directories('.'),
sources : source_file
)
source_file = [
'tvgCanvasImpl.h',
'tvgCommon.h',
+ 'tvgLoader.h',
+ 'tvgLoaderMgr.h',
'tvgRenderCommon.h',
'tvgSceneImpl.h',
'tvgShapePath.h',
'tvgGlCanvas.cpp',
'tvgInitializer.cpp',
'tvgLinearGradient.cpp',
+ 'tvgLoaderMgr.cpp',
'tvgRadialGradient.cpp',
'tvgScene.cpp',
'tvgShape.cpp',
'tvgSwStroke.cpp',
]
-swraster_dep = declare_dependency(
+swengine_dep = declare_dependency(
include_directories : include_directories('.'),
sources : source_file
)
#define FILL_ID_LINEAR 0
#define FILL_ID_RADIAL 1
+#include "tvgLoader.h"
+#include "tvgLoaderMgr.h"
#include "tvgRenderCommon.h"
#include "tvgShapePath.h"
#include "tvgShapeImpl.h"
#include "tvgCommon.h"
#include "tvgSwRenderer.h"
#include "tvgGlRenderer.h"
+#include "tvgLoaderMgr.h"
/************************************************************************/
/* Internal Class Implementation */
return Result::InvalidArguments;
}
- //TODO: check modules then enable them
- //1. TVG
- //2. SVG
+ if (!LoaderMgr::init()) return Result::Unknown;
return Result::Success;
}
return Result::InvalidArguments;
}
+ if (!LoaderMgr::term()) return Result::Unknown;
+
return Result::Success;
}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef _TVG_LOADER_H_
+#define _TVG_LOADER_H_
+
+namespace tvg
+{
+
+class Loader
+{
+public:
+ virtual ~Loader() {}
+
+ virtual bool open(const char* path) = 0;
+ virtual bool read() = 0;
+ virtual bool close() = 0;
+ virtual unique_ptr<Scene> data() = 0;
+};
+
+}
+
+#endif //_TVG_LOADER_H_
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef _TVG_LOADER_MGR_CPP_
+#define _TVG_LOADER_MGR_CPP_
+
+#include "tvgCommon.h"
+#include "tvgSvgLoader.h"
+
+
+static int initCnt = 0;
+
+bool LoaderMgr::init()
+{
+ if (initCnt > 0) return true;
+ ++initCnt;
+
+ //TODO:
+
+ return true;
+}
+
+bool LoaderMgr::term()
+{
+ --initCnt;
+ if (initCnt > 0) return true;
+
+ //TODO:
+
+ return true;
+}
+
+unique_ptr<Loader> LoaderMgr::loader(const char* path)
+{
+ //TODO:
+ return unique_ptr<SvgLoader>(new SvgLoader);
+}
+
+#endif //_TVG_LOADER_MGR_CPP_
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef _TVG_LOADER_MGR_H_
+#define _TVG_LOADER_MGR_H_
+
+struct LoaderMgr
+{
+ static bool init();
+ static bool term();
+ static unique_ptr<Loader> loader(const char* path);
+};
+
+#endif //_TVG_LOADER_MGR_H_
\ No newline at end of file
}
-Result Scene::load(const std::string& path, float w, float h, bool lazy) noexcept
+Result Scene::load(const std::string& path) noexcept
{
if (path.empty()) return Result::InvalidArguments;
auto impl = pImpl.get();
if (!impl) return Result::MemoryCorruption;
- return impl->load(path, w, h, lazy);
+ return impl->load(path);
}
-
-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
vector<Paint*> paints;
RenderTransform *transform = nullptr;
uint32_t flag = RenderUpdateFlag::None;
+ unique_ptr<Loader> loader = nullptr;
~Impl()
{
bool update(RenderMethod &renderer, const RenderTransform* pTransform = nullptr, uint32_t pFlag = 0)
{
+ if (loader) {
+ auto scene = loader->data();
+ auto p = scene.release();
+ if (!p) return false;
+ paints.push_back(p);
+ loader->close();
+ loader.reset(nullptr);
+ }
+
if (flag & RenderUpdateFlag::Transform) {
if (!transform) return false;
if (!transform->update()) {
return true;
}
- Result load(const string& path, float w, float h, bool lazy)
- {
- return Result::Success;
- }
-
- Result save(const string& path)
+ Result load(const string& path)
{
+ if (loader) loader->close();
+ loader = LoaderMgr::loader(path.c_str());
+ if (!loader || !loader->open(path.c_str())) return Result::NonSupport;
+ if (!loader->read()) return Result::Unknown;
return Result::Success;
}
};
--- /dev/null
+subdir('svg_loader')
--- /dev/null
+source_file = [
+ 'tvgSvgLoader.h',
+ 'tvgSvgLoader.cpp',
+]
+
+svgloader_dep = declare_dependency(
+ include_directories : include_directories('.'),
+ sources : source_file
+)
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef _TVG_SVG_LOADER_CPP_
+#define _TVG_SVG_LOADER_CPP_
+
+#include "tvgSvgLoader.h"
+
+
+/************************************************************************/
+/* Internal Class Implementation */
+/************************************************************************/
+
+
+
+/************************************************************************/
+/* External Class Implementation */
+/************************************************************************/
+
+SvgLoader::SvgLoader()
+{
+ cout << "SvgLoader()" << endl;
+}
+
+
+SvgLoader::~SvgLoader()
+{
+ cout << "~SvgLoader()" << endl;
+}
+
+
+bool SvgLoader::open(const char* path)
+{
+ //TODO:
+ cout << "SvgLoader::open()" << endl;
+
+ return false;
+}
+
+
+bool SvgLoader::read()
+{
+ //TODO:
+ cout << "SvgLoader::read()" << endl;
+
+ return false;
+}
+
+
+bool SvgLoader::close()
+{
+ //TODO:
+ cout << "SvgLoader::close()" << endl;
+
+ return false;
+}
+
+
+unique_ptr<Scene> SvgLoader::data()
+{
+ //TODO:
+ cout << "SvgLoader::data()" << endl;
+
+ return nullptr;
+}
+
+#endif //_TVG_SVG_LOADER_CPP_
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef _TVG_SVG_LOADER_H_
+#define _TVG_SVG_LOADER_H_
+
+#include "tvgCommon.h"
+
+class SvgLoader : public Loader
+{
+private:
+ //TODO:
+
+public:
+ SvgLoader();
+ ~SvgLoader();
+
+ bool open(const char* path) override;
+ bool read() override;
+ bool close() override;
+ unique_ptr<Scene> data() override;
+};
+
+
+#endif //_TVG_SVG_LOADER_H_
\ No newline at end of file
compiler_flags = ['-DTVG_BUILD']
subdir('lib')
+subdir('loaders')
subdir('examples')
+
m_dep = meson.get_compiler('cpp').find_library('m')
egl_dep = meson.get_compiler('cpp').find_library('EGL')
-gl_dep = meson.get_compiler('cpp').find_library('GLESv2')
+gles_dep = meson.get_compiler('cpp').find_library('GLESv2')
-tizenvg_lib_dep = [ src_dep, swraster_dep, glraster_dep, m_dep, egl_dep, gl_dep]
+tizenvg_lib_dep = [ src_dep, swengine_dep, glengine_dep, m_dep, egl_dep, gles_dep, svgloader_dep]
tizenvg_lib = library(
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`
+ gcc -o testSvg testSvg.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
gcc -o testGlShape testGlShape.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
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); */
+ // Create a SVG scene, request the original size,
auto scene = tvg::Scene::gen();
scene->load("sample.svg");
canvas->push(move(scene));
+++ /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();
-}