mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
common loader: build up loader infrastructure.
Change-Id: I62aaed43015301ec39e414833f37d6c5485d8043
This commit is contained in:
parent
0e25879d12
commit
01e52c7c7a
20 changed files with 279 additions and 103 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -18,5 +18,4 @@ testLinearGradient
|
||||||
testRadialGradient
|
testRadialGradient
|
||||||
testGradientTransform
|
testGradientTransform
|
||||||
testSvg
|
testSvg
|
||||||
testSvg2
|
|
||||||
testGlShape
|
testGlShape
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Scene;
|
||||||
class Canvas;
|
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 PathCommand { Close = 0, MoveTo, LineTo, CubicTo };
|
||||||
enum class TVG_EXPORT StrokeCap { Square = 0, Round, Butt };
|
enum class TVG_EXPORT StrokeCap { Square = 0, Round, Butt };
|
||||||
enum class TVG_EXPORT StrokeJoin { Bevel = 0, Round, Miter };
|
enum class TVG_EXPORT StrokeJoin { Bevel = 0, Round, Miter };
|
||||||
|
@ -283,8 +283,7 @@ public:
|
||||||
Result push(std::unique_ptr<Paint> paint) noexcept;
|
Result push(std::unique_ptr<Paint> paint) noexcept;
|
||||||
Result reserve(uint32_t size) noexcept;
|
Result reserve(uint32_t size) noexcept;
|
||||||
|
|
||||||
Result load(const std::string& path, float w, float h, bool lazy = false) noexcept;
|
Result load(const std::string& path) noexcept;
|
||||||
Result save(const std::string& path) noexcept;
|
|
||||||
|
|
||||||
Result rotate(float degree) noexcept override;
|
Result rotate(float degree) noexcept override;
|
||||||
Result scale(float factor) noexcept override;
|
Result scale(float factor) noexcept override;
|
||||||
|
|
|
@ -14,7 +14,7 @@ source_file = [
|
||||||
'tvgGlShaderSrc.cpp',
|
'tvgGlShaderSrc.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
glraster_dep = declare_dependency(
|
glengine_dep = declare_dependency(
|
||||||
include_directories : include_directories('.'),
|
include_directories : include_directories('.'),
|
||||||
sources : source_file
|
sources : source_file
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,6 +4,8 @@ subdir('gl_engine')
|
||||||
source_file = [
|
source_file = [
|
||||||
'tvgCanvasImpl.h',
|
'tvgCanvasImpl.h',
|
||||||
'tvgCommon.h',
|
'tvgCommon.h',
|
||||||
|
'tvgLoader.h',
|
||||||
|
'tvgLoaderMgr.h',
|
||||||
'tvgRenderCommon.h',
|
'tvgRenderCommon.h',
|
||||||
'tvgSceneImpl.h',
|
'tvgSceneImpl.h',
|
||||||
'tvgShapePath.h',
|
'tvgShapePath.h',
|
||||||
|
@ -13,6 +15,7 @@ source_file = [
|
||||||
'tvgGlCanvas.cpp',
|
'tvgGlCanvas.cpp',
|
||||||
'tvgInitializer.cpp',
|
'tvgInitializer.cpp',
|
||||||
'tvgLinearGradient.cpp',
|
'tvgLinearGradient.cpp',
|
||||||
|
'tvgLoaderMgr.cpp',
|
||||||
'tvgRadialGradient.cpp',
|
'tvgRadialGradient.cpp',
|
||||||
'tvgScene.cpp',
|
'tvgScene.cpp',
|
||||||
'tvgShape.cpp',
|
'tvgShape.cpp',
|
||||||
|
|
|
@ -10,7 +10,7 @@ source_file = [
|
||||||
'tvgSwStroke.cpp',
|
'tvgSwStroke.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
swraster_dep = declare_dependency(
|
swengine_dep = declare_dependency(
|
||||||
include_directories : include_directories('.'),
|
include_directories : include_directories('.'),
|
||||||
sources : source_file
|
sources : source_file
|
||||||
)
|
)
|
||||||
|
|
|
@ -37,6 +37,8 @@ using namespace tvg;
|
||||||
#define FILL_ID_LINEAR 0
|
#define FILL_ID_LINEAR 0
|
||||||
#define FILL_ID_RADIAL 1
|
#define FILL_ID_RADIAL 1
|
||||||
|
|
||||||
|
#include "tvgLoader.h"
|
||||||
|
#include "tvgLoaderMgr.h"
|
||||||
#include "tvgRenderCommon.h"
|
#include "tvgRenderCommon.h"
|
||||||
#include "tvgShapePath.h"
|
#include "tvgShapePath.h"
|
||||||
#include "tvgShapeImpl.h"
|
#include "tvgShapeImpl.h"
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "tvgCommon.h"
|
#include "tvgCommon.h"
|
||||||
#include "tvgSwRenderer.h"
|
#include "tvgSwRenderer.h"
|
||||||
#include "tvgGlRenderer.h"
|
#include "tvgGlRenderer.h"
|
||||||
|
#include "tvgLoaderMgr.h"
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Internal Class Implementation */
|
/* Internal Class Implementation */
|
||||||
|
@ -39,9 +40,7 @@ Result Initializer::init(CanvasEngine engine) noexcept
|
||||||
return Result::InvalidArguments;
|
return Result::InvalidArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: check modules then enable them
|
if (!LoaderMgr::init()) return Result::Unknown;
|
||||||
//1. TVG
|
|
||||||
//2. SVG
|
|
||||||
|
|
||||||
return Result::Success;
|
return Result::Success;
|
||||||
}
|
}
|
||||||
|
@ -59,6 +58,8 @@ Result Initializer::term(CanvasEngine engine) noexcept
|
||||||
return Result::InvalidArguments;
|
return Result::InvalidArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!LoaderMgr::term()) return Result::Unknown;
|
||||||
|
|
||||||
return Result::Success;
|
return Result::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
src/lib/tvgLoader.h
Normal file
36
src/lib/tvgLoader.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* 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_
|
52
src/lib/tvgLoaderMgr.cpp
Normal file
52
src/lib/tvgLoaderMgr.cpp
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* 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_
|
27
src/lib/tvgLoaderMgr.h
Normal file
27
src/lib/tvgLoaderMgr.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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_
|
|
@ -108,26 +108,14 @@ Result Scene::bounds(float* x, float* y, float* w, float* h) const noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
if (path.empty()) return Result::InvalidArguments;
|
||||||
|
|
||||||
auto impl = pImpl.get();
|
auto impl = pImpl.get();
|
||||||
if (!impl) return Result::MemoryCorruption;
|
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_ */
|
#endif /* _TVG_SCENE_CPP_ */
|
|
@ -28,6 +28,7 @@ struct Scene::Impl
|
||||||
vector<Paint*> paints;
|
vector<Paint*> paints;
|
||||||
RenderTransform *transform = nullptr;
|
RenderTransform *transform = nullptr;
|
||||||
uint32_t flag = RenderUpdateFlag::None;
|
uint32_t flag = RenderUpdateFlag::None;
|
||||||
|
unique_ptr<Loader> loader = nullptr;
|
||||||
|
|
||||||
~Impl()
|
~Impl()
|
||||||
{
|
{
|
||||||
|
@ -71,6 +72,15 @@ struct Scene::Impl
|
||||||
|
|
||||||
bool update(RenderMethod &renderer, const RenderTransform* pTransform = nullptr, uint32_t pFlag = 0)
|
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 (flag & RenderUpdateFlag::Transform) {
|
||||||
if (!transform) return false;
|
if (!transform) return false;
|
||||||
if (!transform->update()) {
|
if (!transform->update()) {
|
||||||
|
@ -192,13 +202,12 @@ struct Scene::Impl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result load(const string& path, float w, float h, bool lazy)
|
Result load(const string& path)
|
||||||
{
|
|
||||||
return Result::Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result save(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;
|
return Result::Success;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
1
src/loaders/meson.build
Normal file
1
src/loaders/meson.build
Normal file
|
@ -0,0 +1 @@
|
||||||
|
subdir('svg_loader')
|
9
src/loaders/svg_loader/meson.build
Normal file
9
src/loaders/svg_loader/meson.build
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
source_file = [
|
||||||
|
'tvgSvgLoader.h',
|
||||||
|
'tvgSvgLoader.cpp',
|
||||||
|
]
|
||||||
|
|
||||||
|
svgloader_dep = declare_dependency(
|
||||||
|
include_directories : include_directories('.'),
|
||||||
|
sources : source_file
|
||||||
|
)
|
80
src/loaders/svg_loader/tvgSvgLoader.cpp
Normal file
80
src/loaders/svg_loader/tvgSvgLoader.cpp
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* 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_
|
38
src/loaders/svg_loader/tvgSvgLoader.h
Normal file
38
src/loaders/svg_loader/tvgSvgLoader.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* 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_
|
|
@ -1,12 +1,14 @@
|
||||||
compiler_flags = ['-DTVG_BUILD']
|
compiler_flags = ['-DTVG_BUILD']
|
||||||
|
|
||||||
subdir('lib')
|
subdir('lib')
|
||||||
|
subdir('loaders')
|
||||||
subdir('examples')
|
subdir('examples')
|
||||||
|
|
||||||
m_dep = meson.get_compiler('cpp').find_library('m')
|
m_dep = meson.get_compiler('cpp').find_library('m')
|
||||||
egl_dep = meson.get_compiler('cpp').find_library('EGL')
|
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(
|
tizenvg_lib = library(
|
||||||
|
|
|
@ -15,6 +15,5 @@ all:
|
||||||
gcc -o testLinearGradient testLinearGradient.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
|
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 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 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 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 testGlShape testGlShape.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
|
gcc -o testGlShape testGlShape.cpp -g -lstdc++ `pkg-config --cflags --libs elementary tizenvg`
|
||||||
|
|
|
@ -17,9 +17,7 @@ void tvgtest()
|
||||||
auto canvas = tvg::SwCanvas::gen();
|
auto canvas = tvg::SwCanvas::gen();
|
||||||
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
|
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
|
||||||
|
|
||||||
/* Create a SVG scene, keep original size,
|
// Create a SVG scene, request the 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();
|
auto scene = tvg::Scene::gen();
|
||||||
scene->load("sample.svg");
|
scene->load("sample.svg");
|
||||||
canvas->push(move(scene));
|
canvas->push(move(scene));
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
#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();
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue