This initializer will take over the global environments of tvg engines.
Change-Id: I7b99973dafaea57ddd3134800bd442ef4dc319ae
enum class TVG_EXPORT StrokeCap { Square = 0, Round, Butt };
enum class TVG_EXPORT StrokeJoin { Bevel = 0, Round, Miter };
enum class TVG_EXPORT FillSpread { Pad = 0, Reflect, Repeat };
-
+enum class TVG_EXPORT CanvasEngine { Sw = 0, Gl };
struct Point
{
/**
+ * @class Canvas
+ *
+ * @ingroup TizenVG
+ *
+ * @brief description...
+ *
+ */
+class TVG_EXPORT Canvas
+{
+public:
+ Canvas(RenderMethod*);
+ virtual ~Canvas();
+
+ Result reserve(uint32_t n) noexcept;
+ virtual Result push(std::unique_ptr<Paint> paint) noexcept;
+ virtual Result clear() noexcept;
+ virtual Result update() noexcept;
+ virtual Result update(Paint* paint) noexcept;
+ virtual Result draw(bool async = true) noexcept;
+ virtual Result sync() = 0;
+
+ _TVG_DECLARE_ACCESSOR(Scene);
+ _TVG_DECLARE_PRIVATE(Canvas);
+};
+
+
+
+/**
* @class LinearGradient
*
* @ingroup TizenVG
};
-/**
- * @class Canvas
- *
- * @ingroup TizenVG
- *
- * @brief description...
- *
- */
-class TVG_EXPORT Canvas
-{
-public:
- Canvas(RenderMethod*);
- virtual ~Canvas();
-
- Result reserve(uint32_t n) noexcept;
- virtual Result push(std::unique_ptr<Paint> paint) noexcept;
- virtual Result clear() noexcept;
- virtual Result update() noexcept;
- virtual Result update(Paint* paint) noexcept;
- virtual Result draw(bool async = true) noexcept;
- virtual Result sync() = 0;
-
- _TVG_DECLARE_ACCESSOR(Scene);
- _TVG_DECLARE_PRIVATE(Canvas);
-};
-
/**
* @class Shape
public:
~Scene();
- Result push(std::unique_ptr<Paint> shape) noexcept;
+ Result push(std::unique_ptr<Paint> paint) noexcept;
Result reserve(uint32_t size) noexcept;
Result rotate(float degree) noexcept override;
* @brief description...
*
*/
-class TVG_EXPORT Engine final
+class TVG_EXPORT Initializer final
{
public:
+
/**
* @brief ...
*
*
* @see ...
*/
- static Result init() noexcept;
- static Result term() noexcept;
+ static Result init(CanvasEngine engine) noexcept;
+ static Result term(CanvasEngine engine) noexcept;
- _TVG_DISABLE_CTOR(Engine);
+ _TVG_DISABLE_CTOR(Initializer);
};
} //namespace
'tvgShapePath.h',
'tvgShapeImpl.h',
'tvgCanvas.cpp',
- 'tvgEngine.cpp',
'tvgFill.cpp',
'tvgGlCanvas.cpp',
+ 'tvgInitializer.cpp',
'tvgLinearGradient.cpp',
'tvgRadialGradient.cpp',
'tvgScene.cpp',
* limitations under the License.
*
*/
-#ifndef _TVG_ENGINE_CPP_
-#define _TVG_ENGINE_CPP_
+#ifndef _TVG_INITIALIZER_CPP_
+#define _TVG_INITIALIZER_CPP_
#include "tvgCommon.h"
#include "tvgSwRenderer.h"
/************************************************************************/
/* Internal Class Implementation */
/************************************************************************/
-static bool initialized = false;
-
-
/************************************************************************/
/* External Class Implementation */
/************************************************************************/
-Result Engine::init() noexcept
+Result Initializer::init(CanvasEngine engine) noexcept
{
- if (initialized) return Result::InsufficientCondition;
+ if (engine == CanvasEngine::Sw) {
+ if (!SwRenderer::init()) return Result::InsufficientCondition;
+ } else if (engine == CanvasEngine::Gl) {
+ if (!GlRenderer::init()) return Result::InsufficientCondition;
+ } else {
+ return Result::InvalidArguments;
+ }
- //TODO: Initialize Raster engines by configuration.
- SwRenderer::init();
- GlRenderer::init();
-
- initialized = true;
+ //TODO: check modules then enable them
+ //1. TVG
+ //2. SVG
return Result::Success;
}
-Result Engine::term() noexcept
+Result Initializer::term(CanvasEngine engine) noexcept
{
- if (!initialized) return Result::InsufficientCondition;
-
- //TODO: Terminate only allowed engines.
- SwRenderer::term();
- GlRenderer::term();
+ //TODO: deinitialize modules
- initialized = false;
+ if (engine == CanvasEngine::Sw) {
+ if (!SwRenderer::term()) return Result::InsufficientCondition;
+ } else if (engine == CanvasEngine::Gl) {
+ if (!GlRenderer::term()) return Result::InsufficientCondition;
+ } else {
+ return Result::InvalidArguments;
+ }
return Result::Success;
}
-#endif /* _TVG_ENGINE_CPP_ */
+#endif /* _TVG_INITIALIZER_CPP_ */
uint32_t refCnt = 0;
bool initialized = false;
- static int init(RenderInitializer& renderInit, RenderMethod* engine)
+ static bool init(RenderInitializer& renderInit, RenderMethod* engine)
{
assert(engine);
- if (renderInit.pInst || renderInit.refCnt > 0) return -1;
+ if (renderInit.pInst || renderInit.refCnt > 0) return false;
renderInit.pInst = engine;
renderInit.refCnt = 0;
renderInit.initialized = true;
- return 0;
+ return true;
}
- static int term(RenderInitializer& renderInit)
+ static bool term(RenderInitializer& renderInit)
{
- if (!renderInit.pInst || !renderInit.initialized) return -1;
+ if (!renderInit.pInst || !renderInit.initialized) return false;
renderInit.initialized = false;
//Still it's refered....
- if (renderInit.refCnt > 0) return 0;
+ if (renderInit.refCnt > 0) return true;
delete(renderInit.pInst);
renderInit.pInst = nullptr;
- return 0;
+ return true;
}
static uint32_t unref(RenderInitializer& renderInit)
void tvgtest()
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen();
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void
void tvgtest()
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen();
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void
int main(int argc, char **argv)
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Composition Source Canvas
auto canvas1 = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT);
canvas2->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
int main(int argc, char **argv)
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
tvgtest();
elm_shutdown();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
int main(int argc, char **argv)
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT);
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
int main(int argc, char **argv)
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
tvgtest();
elm_shutdown();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void tvgtest()
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen();
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void
void tvgtest()
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen();
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void
void tvgtest()
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen();
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void
void tvgtest()
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen();
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void
void tvgtest()
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen();
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void
void tvgtest()
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen();
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void
int main(int argc, char **argv)
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
tvgtest();
elm_shutdown();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void tvgtest()
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen();
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void
void tvgtest()
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen();
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void
void tvgtest()
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
//Create a Canvas
auto canvas = tvg::SwCanvas::gen();
canvas->sync();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
void
int main(int argc, char **argv)
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
tvgtest();
elm_shutdown();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}
int main(int argc, char **argv)
{
//Initialize TizenVG Engine
- tvg::Engine::init();
+ tvg::Initializer::init(tvg::CanvasEngine::Sw);
tvgtest();
elm_shutdown();
//Terminate TizenVG Engine
- tvg::Engine::term();
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
}