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:49:10 +0000 (23:49 -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 80d19e4..49e112d 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 f26168a..4bfb93c 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 4251849..912091f 100644 (file)
@@ -54,6 +54,7 @@ struct Fill::Impl
     uint32_t cnt = 0;
     FillSpread spread;
     DuplicateMethod<Fill>* dup = nullptr;
+    uint32_t id;
 
     ~Impl()
     {
index 46ca45f..6ec7dda 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 5a63402..d256ac0 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 5b9e0db..8cfae71 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 580cb5b..52f73cb 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 c289ca5..42a8346 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 1516b2e..4b2f77d 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 42b2c0d..8db5635 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));
 }