mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
common initializer: don't try initialize engine duplicatedly.
Change-Id: I58c715745b8db40fe759582545082f2e6e10626a
This commit is contained in:
parent
657e6daddb
commit
8efef7714c
2 changed files with 14 additions and 6 deletions
|
@ -56,7 +56,7 @@ 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 };
|
||||
enum class TVG_EXPORT FillSpread { Pad = 0, Reflect, Repeat };
|
||||
enum class TVG_EXPORT CanvasEngine { Sw = 0, Gl };
|
||||
enum class TVG_EXPORT CanvasEngine { Sw = (1 << 1), Gl = (1 << 2)};
|
||||
|
||||
|
||||
struct Point
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
/************************************************************************/
|
||||
/* Internal Class Implementation */
|
||||
/************************************************************************/
|
||||
|
||||
static bool initialized = false;
|
||||
|
||||
/************************************************************************/
|
||||
/* External Class Implementation */
|
||||
|
@ -42,14 +42,16 @@
|
|||
|
||||
Result Initializer::init(CanvasEngine engine, uint32_t threads) noexcept
|
||||
{
|
||||
if (initialized) return Result::InsufficientCondition;
|
||||
|
||||
auto nonSupport = true;
|
||||
|
||||
if (engine == CanvasEngine::Sw) {
|
||||
if (static_cast<uint32_t>(engine) & static_cast<uint32_t>(CanvasEngine::Sw)) {
|
||||
#ifdef THORVG_SW_RASTER_SUPPORT
|
||||
if (!SwRenderer::init()) return Result::InsufficientCondition;
|
||||
nonSupport = false;
|
||||
#endif
|
||||
} else if (engine == CanvasEngine::Gl) {
|
||||
} else if (static_cast<uint32_t>(engine) & static_cast<uint32_t>(CanvasEngine::Gl)) {
|
||||
#ifdef THORVG_GL_RASTER_SUPPORT
|
||||
if (!GlRenderer::init()) return Result::InsufficientCondition;
|
||||
nonSupport = false;
|
||||
|
@ -64,20 +66,24 @@ Result Initializer::init(CanvasEngine engine, uint32_t threads) noexcept
|
|||
|
||||
TaskScheduler::init(threads);
|
||||
|
||||
initialized = true;
|
||||
|
||||
return Result::Success;
|
||||
}
|
||||
|
||||
|
||||
Result Initializer::term(CanvasEngine engine) noexcept
|
||||
{
|
||||
if (!initialized) return Result::InsufficientCondition;
|
||||
|
||||
auto nonSupport = true;
|
||||
|
||||
if (engine == CanvasEngine::Sw) {
|
||||
if (static_cast<uint32_t>(engine) & static_cast<uint32_t>(CanvasEngine::Sw)) {
|
||||
#ifdef THORVG_SW_RASTER_SUPPORT
|
||||
if (!SwRenderer::term()) return Result::InsufficientCondition;
|
||||
nonSupport = false;
|
||||
#endif
|
||||
} else if (engine == CanvasEngine::Gl) {
|
||||
} else if (static_cast<uint32_t>(engine) & static_cast<uint32_t>(CanvasEngine::Gl)) {
|
||||
#ifdef THORVG_GL_RASTER_SUPPORT
|
||||
if (!GlRenderer::term()) return Result::InsufficientCondition;
|
||||
nonSupport = false;
|
||||
|
@ -92,5 +98,7 @@ Result Initializer::term(CanvasEngine engine) noexcept
|
|||
|
||||
if (!LoaderMgr::term()) return Result::Unknown;
|
||||
|
||||
initialized = false;
|
||||
|
||||
return Result::Success;
|
||||
}
|
Loading…
Add table
Reference in a new issue