common: code refactoring. 39/239839/2
authorHermet Park <chuneon.park@samsung.com>
Thu, 30 Jul 2020 06:10:59 +0000 (15:10 +0900)
committerHermet Park <chuneon.park@samsung.com>
Thu, 30 Jul 2020 06:15:31 +0000 (15:15 +0900)
changed just internal variable & method names.

no logical changes.

Change-Id: I01782ec59dec3ff2232e03de7b3863100d9cc27f

src/lib/tvgCanvasImpl.h
src/lib/tvgPaint.cpp
src/lib/tvgPaint.h
src/lib/tvgScene.cpp
src/lib/tvgSceneImpl.h
src/lib/tvgShape.cpp
src/lib/tvgShapeImpl.h

index a1b9b78..2776735 100644 (file)
@@ -56,7 +56,7 @@ struct Canvas::Impl
         if (!renderer->clear()) return Result::InsufficientCondition;
 
         for (auto paint : paints) {
-            paint->IMPL->method->dispose(*renderer);
+            paint->IMPL->method()->dispose(*renderer);
             delete(paint);
         }
         paints.clear();
@@ -70,13 +70,13 @@ struct Canvas::Impl
 
         //Update single paint node
         if (paint) {
-            if (!paint->IMPL->method->update(*renderer, nullptr, RenderUpdateFlag::None)) {
+            if (!paint->IMPL->method()->update(*renderer, nullptr, RenderUpdateFlag::None)) {
                 return Result::InsufficientCondition;
             }
         //Update retained all paint nodes
         } else {
             for(auto paint: paints) {
-                if (!paint->IMPL->method->update(*renderer, nullptr, RenderUpdateFlag::None)) {
+                if (!paint->IMPL->method()->update(*renderer, nullptr, RenderUpdateFlag::None)) {
                     return Result::InsufficientCondition;
                 }
             }
@@ -91,7 +91,7 @@ struct Canvas::Impl
         if (!renderer->preRender()) return Result::InsufficientCondition;
 
         for(auto paint: paints) {
-            if(!paint->IMPL->method->render(*renderer)) return Result::InsufficientCondition;
+            if(!paint->IMPL->method()->render(*renderer)) return Result::InsufficientCondition;
         }
 
         if (!renderer->postRender()) return Result::InsufficientCondition;
index cbd68c6..8aa62d2 100644 (file)
@@ -39,35 +39,35 @@ Paint :: ~Paint()
 
 Result Paint::rotate(float degree) noexcept
 {
-    if (IMPL->method->rotate(degree)) return Result::Success;
+    if (IMPL->method()->rotate(degree)) return Result::Success;
     return Result::FailedAllocation;
 }
 
 
 Result Paint::scale(float factor) noexcept
 {
-    if (IMPL->method->scale(factor)) return Result::Success;
+    if (IMPL->method()->scale(factor)) return Result::Success;
     return Result::FailedAllocation;
 }
 
 
 Result Paint::translate(float x, float y) noexcept
 {
-    if (IMPL->method->translate(x, y)) return Result::Success;
+    if (IMPL->method()->translate(x, y)) return Result::Success;
     return Result::FailedAllocation;
 }
 
 
 Result Paint::transform(const Matrix& m) noexcept
 {
-    if (IMPL->method->transform(m)) return Result::Success;
+    if (IMPL->method()->transform(m)) return Result::Success;
     return Result::FailedAllocation;
 }
 
 
 Result Paint::bounds(float* x, float* y, float* w, float* h) const noexcept
 {
-    if (IMPL->method->bounds(x, y, w, h)) return Result::Success;
+    if (IMPL->method()->bounds(x, y, w, h)) return Result::Success;
     return Result::InsufficientCondition;
 }
 
index 31dcbf4..45e4c01 100644 (file)
@@ -19,9 +19,9 @@
 
 namespace tvg
 {
-    struct PaintMethod
+    struct StrategyMethod
     {
-        virtual ~PaintMethod(){}
+        virtual ~StrategyMethod(){}
 
         virtual bool dispose(RenderMethod& renderer) = 0;
         virtual bool update(RenderMethod& renderer, const RenderTransform* pTransform, uint32_t pFlag) = 0;
@@ -37,21 +37,31 @@ namespace tvg
 
     struct Paint::Impl
     {
-        PaintMethod* method = nullptr;
+        StrategyMethod* smethod = nullptr;
 
         ~Impl() {
-            if (method) delete(method);
+            if (smethod) delete(smethod);
+        }
+
+        void method(StrategyMethod* method)
+        {
+            smethod = method;
+        }
+
+        StrategyMethod* method()
+        {
+            return smethod;
         }
     };
 
 
     template<class T>
-    struct TransformMethod : PaintMethod
+    struct PaintMethod : StrategyMethod
     {
         T* inst = nullptr;
 
-        TransformMethod(T* inst) : inst(_inst) {}
-        ~TransformMethod(){}
+        PaintMethod(T* _inst) : inst(_inst) {}
+        ~PaintMethod(){}
 
         bool rotate(float degree) override
         {
index 4d04364..d34d57a 100644 (file)
@@ -25,7 +25,7 @@
 
 Scene::Scene() : pImpl(make_unique<Impl>())
 {
-    Paint::IMPL->method = IMPL->transformMethod();
+    Paint::IMPL->method(new PaintMethod<Scene::Impl>(IMPL));
 }
 
 
index bd49714..0ba1f1f 100644 (file)
@@ -40,7 +40,7 @@ struct Scene::Impl
     bool dispose(RenderMethod& renderer)
     {
         for (auto paint : paints) {
-            paint->IMPL->method->dispose(renderer);
+            paint->IMPL->method()->dispose(renderer);
             delete(paint);
         }
         paints.clear();
@@ -51,7 +51,7 @@ struct Scene::Impl
     bool updateInternal(RenderMethod &renderer, const RenderTransform* transform, uint32_t flag)
     {
         for(auto paint: paints) {
-            if (!paint->IMPL->method->update(renderer, transform, flag))  return false;
+            if (!paint->IMPL->method()->update(renderer, transform, flag))  return false;
         }
         return true;
     }
@@ -94,7 +94,7 @@ struct Scene::Impl
     bool render(RenderMethod &renderer)
     {
         for(auto paint: paints) {
-            if(!paint->IMPL->method->render(renderer)) return false;
+            if(!paint->IMPL->method()->render(renderer)) return false;
         }
         return true;
     }
@@ -118,7 +118,7 @@ struct Scene::Impl
                 auto w2 = 0.0f;
                 auto h2 = 0.0f;
 
-                if (paint->IMPL->method->bounds(&x2, &y2, &w2, &h2)) return false;
+                if (paint->IMPL->method()->bounds(&x2, &y2, &w2, &h2)) return false;
 
                 //Merge regions
                 if (x2 < x) x = x2;
@@ -203,12 +203,6 @@ struct Scene::Impl
         if (!loader->read()) return Result::Unknown;
         return Result::Success;
     }
-
-    PaintMethod* transformMethod()
-    {
-        return new TransformMethod<Scene::Impl>(this);
-    }
-
 };
 
 #endif //_TVG_SCENE_IMPL_H_
\ No newline at end of file
index f42c160..7d26614 100644 (file)
@@ -31,7 +31,7 @@ constexpr auto PATH_KAPPA = 0.552284f;
 
 Shape :: Shape() : pImpl(make_unique<Impl>(this))
 {
-    Paint::IMPL->method = IMPL->transformMethod();
+    Paint::IMPL->method(new PaintMethod<Shape::Impl>(IMPL));
 }
 
 
index 955deb6..a7755da 100644 (file)
@@ -236,12 +236,6 @@ struct Shape::Impl
 
         return true;
     }
-
-
-    PaintMethod* transformMethod()
-    {
-        return new TransformMethod<Shape::Impl>(this);
-    }
 };
 
 #endif //_TVG_SHAPE_IMPL_H_
\ No newline at end of file