comon render: split declaration and body. 05/236805/1
authorHermet Park <chuneon.park@samsung.com>
Mon, 22 Jun 2020 07:44:11 +0000 (16:44 +0900)
committerHermet Park <chuneon.park@samsung.com>
Mon, 22 Jun 2020 07:44:36 +0000 (16:44 +0900)
Change-Id: I39eb1dfb929b7811fab82956aedbb15f001390e7

src/lib/meson.build
src/lib/tvgCommon.h
src/lib/tvgRender.cpp [new file with mode: 0644]
src/lib/tvgRender.h

index 32db5f1..9675206 100644 (file)
@@ -6,7 +6,7 @@ source_file = [
    'tvgCommon.h',
    'tvgLoader.h',
    'tvgLoaderMgr.h',
-   'tvgRenderCommon.h',
+   'tvgRender.h',
    'tvgSceneImpl.h',
    'tvgShapePath.h',
    'tvgShapeImpl.h',
@@ -17,6 +17,7 @@ source_file = [
    'tvgLinearGradient.cpp',
    'tvgLoaderMgr.cpp',
    'tvgRadialGradient.cpp',
+   'tvgRender.cpp',
    'tvgScene.cpp',
    'tvgShape.cpp',
    'tvgSwCanvas.cpp',
index d147521..2b0e9c1 100644 (file)
@@ -39,7 +39,7 @@ using namespace tvg;
 
 #include "tvgLoader.h"
 #include "tvgLoaderMgr.h"
-#include "tvgRenderCommon.h"
+#include "tvgRender.h"
 #include "tvgShapePath.h"
 #include "tvgShapeImpl.h"
 #include "tvgSceneImpl.h"
diff --git a/src/lib/tvgRender.cpp b/src/lib/tvgRender.cpp
new file mode 100644 (file)
index 0000000..4b4afc3
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *               http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+#ifndef _TVG_RENDER_CPP_
+#define _TVG_RENDER_CPP_
+
+#include "tvgCommon.h"
+#include "tvgRender.h"
+
+
+/************************************************************************/
+/* Internal Class Implementation                                        */
+/************************************************************************/
+
+
+/************************************************************************/
+/* External Class Implementation                                        */
+/************************************************************************/
+
+bool RenderTransform::update()
+{
+    constexpr auto PI = 3.141592f;
+
+    //Init Status
+    if (fabsf(x) <= FLT_EPSILON && fabsf(y) <= FLT_EPSILON &&
+        fabsf(degree) <= FLT_EPSILON && fabsf(factor - 1) <= FLT_EPSILON) {
+        return false;
+    }
+
+    //identity
+    e11 = 1.0f;
+    e12 = 0.0f;
+    e13 = 0.0f;
+    e21 = 0.0f;
+    e22 = 1.0f;
+    e23 = 0.0f;
+    e31 = 0.0f;
+    e32 = 0.0f;
+    e33 = 1.0f;
+
+    //scale
+    e11 *= factor;
+    e22 *= factor;
+    e33 *= factor;
+
+    //rotation
+    if (fabsf(degree) > FLT_EPSILON) {
+        auto radian = degree / 180.0f * PI;
+        auto cosVal = cosf(radian);
+        auto sinVal = sinf(radian);
+
+        auto t11 = e11 * cosVal + e12 * sinVal;
+        auto t12 = e11 * -sinVal + e12 * cosVal;
+        auto t21 = e21 * cosVal + e22 * sinVal;
+        auto t22 = e21 * -sinVal + e22 * cosVal;
+        auto t31 = e31 * cosVal + e32 * sinVal;
+        auto t32 = e31 * -sinVal + e32 * cosVal;
+
+        e11 = t11;
+        e12 = t12;
+        e21 = t21;
+        e22 = t22;
+        e31 = t31;
+        e32 = t32;
+    }
+
+    e31 += x;
+    e32 += y;
+
+    return true;
+}
+
+
+RenderTransform::RenderTransform()
+{
+}
+
+
+RenderTransform::RenderTransform(const RenderTransform* lhs, const RenderTransform* rhs)
+{
+    assert(lhs && rhs);
+
+    auto dx = rhs->x * lhs->factor;
+    auto dy = rhs->y * lhs->factor;
+    auto tx = dx * lhs->e11 + dy * lhs->e12 + lhs->e13;
+    auto ty = dx * lhs->e21 + dy * lhs->e22 + lhs->e23;
+
+    x = lhs->x + tx;
+    y = lhs->y + ty;
+    degree = lhs->degree + rhs->degree;
+    factor = lhs->factor * rhs->factor;
+
+    update();
+}
+
+#endif //_TVG_RENDER_CPP_
index a581067..74feb77 100644 (file)
@@ -14,8 +14,8 @@
  *  limitations under the License.
  *
  */
-#ifndef _TVG_RENDER_COMMON_H_
-#define _TVG_RENDER_COMMON_H_
+#ifndef _TVG_RENDER_H_
+#define _TVG_RENDER_H_
 
 namespace tvg
 {
@@ -42,79 +42,10 @@ struct RenderTransform
     float degree = 0.0f;  //rotation degree
     float factor = 1.0f;  //scale factor
 
-    bool update()
-    {
-        constexpr auto PI = 3.141592f;
-
-        //Init Status
-        if (fabsf(x) <= FLT_EPSILON && fabsf(y) <= FLT_EPSILON &&
-            fabsf(degree) <= FLT_EPSILON && fabsf(factor - 1) <= FLT_EPSILON) {
-            return false;
-        }
-
-        //identity
-        e11 = 1.0f;
-        e12 = 0.0f;
-        e13 = 0.0f;
-        e21 = 0.0f;
-        e22 = 1.0f;
-        e23 = 0.0f;
-        e31 = 0.0f;
-        e32 = 0.0f;
-        e33 = 1.0f;
-
-        //scale
-        e11 *= factor;
-        e22 *= factor;
-        e33 *= factor;
-
-        //rotation
-        if (fabsf(degree) > FLT_EPSILON) {
-            auto radian = degree / 180.0f * PI;
-            auto cosVal = cosf(radian);
-            auto sinVal = sinf(radian);
-
-            auto t11 = e11 * cosVal + e12 * sinVal;
-            auto t12 = e11 * -sinVal + e12 * cosVal;
-            auto t21 = e21 * cosVal + e22 * sinVal;
-            auto t22 = e21 * -sinVal + e22 * cosVal;
-            auto t31 = e31 * cosVal + e32 * sinVal;
-            auto t32 = e31 * -sinVal + e32 * cosVal;
-
-            e11 = t11;
-            e12 = t12;
-            e21 = t21;
-            e22 = t22;
-            e31 = t31;
-            e32 = t32;
-        }
-
-        e31 += x;
-        e32 += y;
-
-        return true;
-    }
+    bool update();
 
-    RenderTransform()
-    {
-    }
-
-    RenderTransform(const RenderTransform* lhs, const RenderTransform* rhs)
-    {
-        assert(lhs && rhs);
-
-        auto dx = rhs->x * lhs->factor;
-        auto dy = rhs->y * lhs->factor;
-        auto tx = dx * lhs->e11 + dy * lhs->e12 + lhs->e13;
-        auto ty = dx * lhs->e21 + dy * lhs->e22 + lhs->e23;
-
-        x = lhs->x + tx;
-        y = lhs->y + ty;
-        degree = lhs->degree + rhs->degree;
-        factor = lhs->factor * rhs->factor;
-
-        update();
-    }
+    RenderTransform();
+    RenderTransform(const RenderTransform* lhs, const RenderTransform* rhs);
 };
 
 
@@ -190,4 +121,4 @@ struct RenderInitializer
 
 }
 
-#endif //_TVG_RENDER_COMMON_H_
+#endif //_TVG_RENDER_H_
\ No newline at end of file