common: revise the identifier() implementation
authorHermet Park <chuneon.park@samsung.com>
Mon, 13 Dec 2021 09:56:25 +0000 (18:56 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Tue, 14 Dec 2021 07:51:54 +0000 (23:51 -0800)
Migrate the id property to the base class internals
so that pimpl classes could access the data easier.

This is a sort of prerequisite change for the coming texmap anti-aliasing.

inc/thorvg.h
src/lib/tvgFill.cpp
src/lib/tvgFill.h
src/lib/tvgLinearGradient.cpp
src/lib/tvgPaint.cpp
src/lib/tvgPaint.h
src/lib/tvgPicture.cpp
src/lib/tvgRadialGradient.cpp
src/lib/tvgScene.cpp
src/lib/tvgShape.cpp

index 80d19e40eaaf3ccd874942f9a30242b99c68b552..49e112def54267cae27b1ff70bf5341502c60d83 100644 (file)
@@ -53,10 +53,6 @@ protected: \
     friend IteratorAccessor
 
 
-#define _TVG_DECALRE_IDENTIFIER() \
-protected: \
-    unsigned _id
-
 namespace tvg
 {
 
@@ -345,10 +341,9 @@ public:
      *
      * @BETA_API
      */
-    uint32_t identifier() const { return _id; }
+    uint32_t identifier() const noexcept;
 
     _TVG_DECLARE_ACCESSOR();
-    _TVG_DECALRE_IDENTIFIER();
     _TVG_DECLARE_PRIVATE(Paint);
 };
 
@@ -454,9 +449,8 @@ public:
      *
      * @BETA_API
      */
-    uint32_t identifier() const { return _id; }
+    uint32_t identifier() const noexcept;
 
-    _TVG_DECALRE_IDENTIFIER();
     _TVG_DECLARE_PRIVATE(Fill);
 };
 
index f26168aa6cf6aa09a12185bcf67abde1e77cff2a..4bfb93c102139578f6c26894fab3ef0107d06797 100644 (file)
@@ -108,3 +108,8 @@ Fill* Fill::duplicate() const noexcept
 {
     return pImpl->duplicate();
 }
+
+uint32_t Fill::identifier() const noexcept
+{
+    return pImpl->id;
+}
\ No newline at end of file
index 4251849953fe80813cc018b38adcce31104fce90..912091f8cb8949974d1ca88b10db41b779ff2344 100644 (file)
@@ -54,6 +54,7 @@ struct Fill::Impl
     uint32_t cnt = 0;
     FillSpread spread;
     DuplicateMethod<Fill>* dup = nullptr;
+    uint32_t id;
 
     ~Impl()
     {
index 46ca45fcffc61edf5526701056c97c86cb655d72..6ec7ddab201f9db5d8ac59267544f67439a13eac 100644 (file)
@@ -54,7 +54,7 @@ struct LinearGradient::Impl
 
 LinearGradient::LinearGradient():pImpl(new Impl())
 {
-    _id = TVG_CLASS_ID_LINEAR;
+    Fill::pImpl->id = TVG_CLASS_ID_LINEAR;
     Fill::pImpl->method(new FillDup<LinearGradient::Impl>(pImpl));
 }
 
index 5a634027d57c2afebcb39f9627dd8f95b9dafd61..d256ac0e1651b377add5db4cfcddabcc85b47cd0 100644 (file)
@@ -395,3 +395,9 @@ uint8_t Paint::opacity() const noexcept
 {
     return pImpl->opacity;
 }
+
+
+uint32_t Paint::identifier() const noexcept
+{
+    return pImpl->id;
+}
\ No newline at end of file
index 5b9e0db7c21d6760b2ef4b096dfd23119e9dd18b..8cfae719031c5e1059e3d95acdef1bbebca048b8 100644 (file)
@@ -58,6 +58,7 @@ namespace tvg
         Paint* cmpTarget = nullptr;
         CompositeMethod cmpMethod = CompositeMethod::None;
         uint32_t ctxFlag = ContextFlag::Invalid;
+        uint32_t id;
         uint8_t opacity = 255;
 
         ~Impl() {
index 580cb5b5c80cd726123a80e1bde724abe49521e4..52f73cbbe87274003a63261c0d3a59ae1443553b 100644 (file)
@@ -28,7 +28,7 @@
 
 Picture::Picture() : pImpl(new Impl(this))
 {
-    _id = TVG_CLASS_ID_PICTURE;
+    Paint::pImpl->id = TVG_CLASS_ID_PICTURE;
     Paint::pImpl->method(new PaintMethod<Picture::Impl>(pImpl));
 }
 
index c289ca5911d920466433186e9c513d5b76e3e130..42a83461e37da32e02125a937d9b8602cc66da15 100644 (file)
@@ -52,7 +52,7 @@ struct RadialGradient::Impl
 
 RadialGradient::RadialGradient():pImpl(new Impl())
 {
-    _id = TVG_CLASS_ID_RADIAL;
+    Fill::pImpl->id = TVG_CLASS_ID_RADIAL;
     Fill::pImpl->method(new FillDup<RadialGradient::Impl>(pImpl));
 }
 
index 1516b2eb01da03a23394ab4c80a26d6cf21d96f3..4b2f77dde99d566e6c50f68fe0ff1de5c4ed79bd 100644 (file)
@@ -27,7 +27,7 @@
 
 Scene::Scene() : pImpl(new Impl())
 {
-    _id = TVG_CLASS_ID_SCENE;
+    Paint::pImpl->id = TVG_CLASS_ID_SCENE;
     Paint::pImpl->method(new PaintMethod<Scene::Impl>(pImpl));
 }
 
index 42b2c0db813823da33a6d5703be22183f9cade94..8db563593207e9bd12dae2c1e3445a555a504a4c 100644 (file)
@@ -34,7 +34,7 @@ constexpr auto PATH_KAPPA = 0.552284f;
 
 Shape :: Shape() : pImpl(new Impl(this))
 {
-    _id = TVG_CLASS_ID_SHAPE;
+    Paint::pImpl->id = TVG_CLASS_ID_SHAPE;
     Paint::pImpl->method(new PaintMethod<Shape::Impl>(pImpl));
 }