common: code refactoring
authorHermet Park <chuneon.park@samsung.com>
Mon, 19 Jul 2021 11:07:58 +0000 (20:07 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Thu, 22 Jul 2021 08:24:22 +0000 (17:24 +0900)
unify tvg class identifiers

src/lib/sw_engine/tvgSwFill.cpp
src/lib/sw_engine/tvgSwRaster.cpp
src/lib/tvgCommon.h
src/lib/tvgLinearGradient.cpp
src/lib/tvgPicture.cpp
src/lib/tvgRadialGradient.cpp
src/lib/tvgSaverImpl.h
src/lib/tvgScene.cpp
src/lib/tvgSceneImpl.h
src/lib/tvgShape.cpp

index 19eda1c..ac7b57f 100644 (file)
@@ -276,9 +276,9 @@ bool fillGenColorTable(SwFill* fill, const Fill* fdata, const Matrix* transform,
         if (!_updateColorTable(fill, fdata, surface, opacity)) return false;
     }
 
-    if (fdata->id() == FILL_ID_LINEAR) {
+    if (fdata->id() == TVG_CLASS_ID_LINEAR) {
         return _prepareLinear(fill, static_cast<const LinearGradient*>(fdata), transform);
-    } else if (fdata->id() == FILL_ID_RADIAL) {
+    } else if (fdata->id() == TVG_CLASS_ID_RADIAL) {
         return _prepareRadial(fill, static_cast<const RadialGradient*>(fdata), transform);
     }
 
index b41da00..169da04 100644 (file)
@@ -1104,7 +1104,7 @@ bool rasterGradientShape(SwSurface* surface, SwShape* shape, unsigned id)
 
     //Fast Track
     if (shape->rect) {
-        if (id == FILL_ID_LINEAR) {
+        if (id == TVG_CLASS_ID_LINEAR) {
             if (translucent) return _rasterTranslucentLinearGradientRect(surface, shape->bbox, shape->fill);
             return _rasterOpaqueLinearGradientRect(surface, shape->bbox, shape->fill);
         } else {
@@ -1113,7 +1113,7 @@ bool rasterGradientShape(SwSurface* surface, SwShape* shape, unsigned id)
         }
     } else {
         if (!shape->rle) return false;
-        if (id == FILL_ID_LINEAR) {
+        if (id == TVG_CLASS_ID_LINEAR) {
             if (translucent) return _rasterTranslucentLinearGradientRle(surface, shape->rle, shape->fill);
             return _rasterOpaqueLinearGradientRle(surface, shape->rle, shape->fill);
         } else {
@@ -1170,7 +1170,7 @@ bool rasterGradientStroke(SwSurface* surface, SwShape* shape, unsigned id)
 
     auto translucent = shape->stroke->fill->translucent || (surface->compositor && surface->compositor->method != CompositeMethod::None);
 
-    if (id == FILL_ID_LINEAR) {
+    if (id == TVG_CLASS_ID_LINEAR) {
         if (translucent) return _rasterTranslucentLinearGradientRle(surface, shape->strokeRle, shape->stroke->fill);
         return _rasterOpaqueLinearGradientRle(surface, shape->strokeRle, shape->stroke->fill);
     } else {
index 1be9fb1..6ef28b3 100644 (file)
 using namespace std;
 using namespace tvg;
 
-#define FILL_ID_LINEAR 0
-#define FILL_ID_RADIAL 1
-
-#define PAINT_ID_SHAPE   0
-#define PAINT_ID_SCENE   1
-#define PAINT_ID_PICTURE 2
+//TVG class identifier values
+#define TVG_CLASS_ID_UNDEFINED 0
+#define TVG_CLASS_ID_SHAPE     1
+#define TVG_CLASS_ID_SCENE     2
+#define TVG_CLASS_ID_PICTURE   3
+#define TVG_CLASS_ID_LINEAR    4
+#define TVG_CLASS_ID_RADIAL    5
 
 //for MSVC Compat
 #ifdef _MSC_VER
index 2374353..57f2b3f 100644 (file)
@@ -54,7 +54,7 @@ struct LinearGradient::Impl
 
 LinearGradient::LinearGradient():pImpl(new Impl())
 {
-    _id = FILL_ID_LINEAR;
+    _id = TVG_CLASS_ID_LINEAR;
     Fill::pImpl->method(new FillDup<LinearGradient::Impl>(pImpl));
 }
 
index acfe2b0..7fda461 100644 (file)
@@ -28,7 +28,7 @@
 
 Picture::Picture() : pImpl(new Impl(this))
 {
-    _id = PAINT_ID_PICTURE;
+    _id = TVG_CLASS_ID_PICTURE;
     Paint::pImpl->method(new PaintMethod<Picture::Impl>(pImpl));
 }
 
index fac2d4e..2680286 100644 (file)
@@ -52,7 +52,7 @@ struct RadialGradient::Impl
 
 RadialGradient::RadialGradient():pImpl(new Impl())
 {
-    _id = FILL_ID_RADIAL;
+    _id = TVG_CLASS_ID_RADIAL;
     Fill::pImpl->method(new FillDup<RadialGradient::Impl>(pImpl));
 }
 
index 8013238..deba0f2 100644 (file)
@@ -248,7 +248,7 @@ struct Saver::Impl
         writeMemberIndicator(fillTvgFlag);
         skipInBufferMemberDataSize();
 
-        if (f->id() == FILL_ID_RADIAL) {
+        if (f->id() == TVG_CLASS_ID_RADIAL) {
             float argRadial[3];
             auto radGrad = static_cast<const RadialGradient*>(f);
             if (radGrad->radial(argRadial, argRadial + 1,argRadial + 2) != Result::Success) {
@@ -459,15 +459,15 @@ struct Saver::Impl
         ByteCounter dataByteCnt = 0;
 
         switch (paint->id()) {
-            case PAINT_ID_SHAPE: {
+            case TVG_CLASS_ID_SHAPE: {
                 dataByteCnt += serializeShape(paint);
                 break;
             }
-            case PAINT_ID_SCENE: {
+            case TVG_CLASS_ID_SCENE: {
                 dataByteCnt += serializeScene(paint);
                 break;
             }
-            case PAINT_ID_PICTURE: {
+            case TVG_CLASS_ID_PICTURE: {
                 dataByteCnt += serializePicture(paint);
                 break;
             }
index 9ec6f05..08cc743 100644 (file)
@@ -27,7 +27,7 @@
 
 Scene::Scene() : pImpl(new Impl(this))
 {
-    _id = PAINT_ID_SCENE;
+    _id = TVG_CLASS_ID_SCENE;
     Paint::pImpl->method(new PaintMethod<Scene::Impl>(pImpl));
 }
 
index d4ef719..eb062be 100644 (file)
@@ -65,7 +65,7 @@ struct Scene::Impl
 
         //If scene has several children or only scene, it may require composition.
         if (paints.count > 1) return true;
-        if (paints.count == 1 && (*paints.data)->id() == PAINT_ID_SCENE) return true;
+        if (paints.count == 1 && (*paints.data)->id() == TVG_CLASS_ID_SCENE) return true;
         return false;
     }
 
index 3e67195..1ba9a46 100644 (file)
@@ -38,7 +38,7 @@ constexpr auto PATH_KAPPA = 0.552284f;
 
 Shape :: Shape() : pImpl(new Impl(this))
 {
-    _id = PAINT_ID_SHAPE;
+    _id = TVG_CLASS_ID_SHAPE;
     Paint::pImpl->method(new PaintMethod<Shape::Impl>(pImpl));
 }