From 7097940c225170ec763cfdc567a820236657f1f9 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Sat, 18 Apr 2020 23:07:15 +0900 Subject: [PATCH] code refactoring. revise internal class & variable names for better code readibility. Change-Id: I7f1b4474f3129c3be04444350496485f000afd15 --- src/lib/gl_engine/tvgGlRenderer.cpp | 12 ++++----- src/lib/sw_engine/tvgSwRenderer.cpp | 12 ++++----- src/lib/tvgCommon.h | 52 ++++++++++++++++++------------------- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/lib/gl_engine/tvgGlRenderer.cpp b/src/lib/gl_engine/tvgGlRenderer.cpp index 92f00dd..2357539 100644 --- a/src/lib/gl_engine/tvgGlRenderer.cpp +++ b/src/lib/gl_engine/tvgGlRenderer.cpp @@ -24,7 +24,7 @@ /* Internal Class Implementation */ /************************************************************************/ -static RenderMethodInit engineInit; +static RenderInitializer renderInit; struct GlShape { @@ -58,31 +58,31 @@ void* GlRenderer::prepare(const ShapeNode& shape, void* data, UpdateFlag flags) int GlRenderer::init() { - return RenderMethodInit::init(engineInit, new GlRenderer); + return RenderInitializer::init(renderInit, new GlRenderer); } int GlRenderer::term() { - return RenderMethodInit::term(engineInit); + return RenderInitializer::term(renderInit); } size_t GlRenderer::unref() { - return RenderMethodInit::unref(engineInit); + return RenderInitializer::unref(renderInit); } size_t GlRenderer::ref() { - return RenderMethodInit::ref(engineInit); + return RenderInitializer::ref(renderInit); } GlRenderer* GlRenderer::inst() { - return dynamic_cast(RenderMethodInit::inst(engineInit)); + return dynamic_cast(RenderInitializer::inst(renderInit)); } diff --git a/src/lib/sw_engine/tvgSwRenderer.cpp b/src/lib/sw_engine/tvgSwRenderer.cpp index a4f126d..0e09da6 100644 --- a/src/lib/sw_engine/tvgSwRenderer.cpp +++ b/src/lib/sw_engine/tvgSwRenderer.cpp @@ -24,7 +24,7 @@ /* Internal Class Implementation */ /************************************************************************/ -static RenderMethodInit engineInit; +static RenderInitializer renderInit; /************************************************************************/ @@ -70,31 +70,31 @@ void* SwRenderer::prepare(const ShapeNode& shape, void* data, UpdateFlag flags) int SwRenderer::init() { - return RenderMethodInit::init(engineInit, new SwRenderer); + return RenderInitializer::init(renderInit, new SwRenderer); } int SwRenderer::term() { - return RenderMethodInit::term(engineInit); + return RenderInitializer::term(renderInit); } size_t SwRenderer::unref() { - return RenderMethodInit::unref(engineInit); + return RenderInitializer::unref(renderInit); } size_t SwRenderer::ref() { - return RenderMethodInit::ref(engineInit); + return RenderInitializer::ref(renderInit); } SwRenderer* SwRenderer::inst() { - return dynamic_cast(RenderMethodInit::inst(engineInit)); + return dynamic_cast(RenderInitializer::inst(renderInit)); } diff --git a/src/lib/tvgCommon.h b/src/lib/tvgCommon.h index d7d1d4d..90e1b9f 100644 --- a/src/lib/tvgCommon.h +++ b/src/lib/tvgCommon.h @@ -40,60 +40,60 @@ public: virtual size_t unref() = 0; }; -struct RenderMethodInit +struct RenderInitializer { RenderMethod* pInst = nullptr; size_t refCnt = 0; - bool initted = false; + bool initialized = false; - static int init(RenderMethodInit& initter, RenderMethod* engine) + static int init(RenderInitializer& renderInit, RenderMethod* engine) { assert(engine); - if (initter.pInst || initter.refCnt > 0) return -1; - initter.pInst = engine; - initter.refCnt = 0; - initter.initted = true; + if (renderInit.pInst || renderInit.refCnt > 0) return -1; + renderInit.pInst = engine; + renderInit.refCnt = 0; + renderInit.initialized = true; return 0; } - static int term(RenderMethodInit& initter) + static int term(RenderInitializer& renderInit) { - if (!initter.pInst || !initter.initted) return -1; + if (!renderInit.pInst || !renderInit.initialized) return -1; - initter.initted = false; + renderInit.initialized = false; //Still it's refered.... - if (initter.refCnt > 0) return 0; - delete(initter.pInst); - initter.pInst = nullptr; + if (renderInit.refCnt > 0) return 0; + delete(renderInit.pInst); + renderInit.pInst = nullptr; return 0; } - static size_t unref(RenderMethodInit& initter) + static size_t unref(RenderInitializer& renderInit) { - assert(initter.refCnt > 0); - --initter.refCnt; + assert(renderInit.refCnt > 0); + --renderInit.refCnt; //engine has been requested to termination - if (!initter.initted && initter.refCnt == 0) { - if (initter.pInst) { - delete(initter.pInst); - initter.pInst = nullptr; + if (!renderInit.initialized && renderInit.refCnt == 0) { + if (renderInit.pInst) { + delete(renderInit.pInst); + renderInit.pInst = nullptr; } } - return initter.refCnt; + return renderInit.refCnt; } - static RenderMethod* inst(RenderMethodInit& initter) + static RenderMethod* inst(RenderInitializer& renderInit) { - assert(initter.pInst); - return initter.pInst; + assert(renderInit.pInst); + return renderInit.pInst; } - static size_t ref(RenderMethodInit& initter) + static size_t ref(RenderInitializer& renderInit) { - return ++initter.refCnt; + return ++renderInit.refCnt; } }; -- 2.7.4