From fb208defedd896619b5ab1781a33311c9ef58656 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 15 Jun 2020 20:55:55 +0900 Subject: [PATCH] common engine: manage engine initializing context. Change-Id: Ida3997fd7cc9ee0916d48290168cdb884e946833 --- src/lib/tvgEngine.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/lib/tvgEngine.cpp b/src/lib/tvgEngine.cpp index 40b1308..5038cb8 100644 --- a/src/lib/tvgEngine.cpp +++ b/src/lib/tvgEngine.cpp @@ -24,6 +24,8 @@ /************************************************************************/ /* Internal Class Implementation */ /************************************************************************/ +static bool initialized = false; + /************************************************************************/ @@ -32,11 +34,13 @@ Result Engine::init() noexcept { + if (initialized) return Result::InsufficientCondition; + //TODO: Initialize Raster engines by configuration. + SwRenderer::init(); + GlRenderer::init(); - int ret = 0; - ret |= SwRenderer::init(); - ret |= GlRenderer::init(); + initialized = true; return Result::Success; } @@ -44,9 +48,13 @@ Result Engine::init() noexcept Result Engine::term() noexcept { - int ret = 0; - ret |= SwRenderer::term(); - ret |= GlRenderer::term(); + if (!initialized) return Result::InsufficientCondition; + + //TODO: Terminate only allowed engines. + SwRenderer::term(); + GlRenderer::term(); + + initialized = false; return Result::Success; } -- 2.7.4