From 1d4db59a25c67b305ebda4b02ef657f5c5a3439f Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 13 Dec 2021 18:56:25 +0900 Subject: [PATCH] common: revise the identifier() implementation 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 | 10 ++-------- src/lib/tvgFill.cpp | 5 +++++ src/lib/tvgFill.h | 1 + src/lib/tvgLinearGradient.cpp | 2 +- src/lib/tvgPaint.cpp | 6 ++++++ src/lib/tvgPaint.h | 1 + src/lib/tvgPicture.cpp | 2 +- src/lib/tvgRadialGradient.cpp | 2 +- src/lib/tvgScene.cpp | 2 +- src/lib/tvgShape.cpp | 2 +- 10 files changed, 20 insertions(+), 13 deletions(-) diff --git a/inc/thorvg.h b/inc/thorvg.h index 80d19e40..49e112de 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -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); }; diff --git a/src/lib/tvgFill.cpp b/src/lib/tvgFill.cpp index f26168aa..4bfb93c1 100644 --- a/src/lib/tvgFill.cpp +++ b/src/lib/tvgFill.cpp @@ -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 diff --git a/src/lib/tvgFill.h b/src/lib/tvgFill.h index 42518499..912091f8 100644 --- a/src/lib/tvgFill.h +++ b/src/lib/tvgFill.h @@ -54,6 +54,7 @@ struct Fill::Impl uint32_t cnt = 0; FillSpread spread; DuplicateMethod* dup = nullptr; + uint32_t id; ~Impl() { diff --git a/src/lib/tvgLinearGradient.cpp b/src/lib/tvgLinearGradient.cpp index 46ca45fc..6ec7ddab 100644 --- a/src/lib/tvgLinearGradient.cpp +++ b/src/lib/tvgLinearGradient.cpp @@ -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(pImpl)); } diff --git a/src/lib/tvgPaint.cpp b/src/lib/tvgPaint.cpp index 5a634027..d256ac0e 100644 --- a/src/lib/tvgPaint.cpp +++ b/src/lib/tvgPaint.cpp @@ -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 diff --git a/src/lib/tvgPaint.h b/src/lib/tvgPaint.h index 5b9e0db7..8cfae719 100644 --- a/src/lib/tvgPaint.h +++ b/src/lib/tvgPaint.h @@ -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() { diff --git a/src/lib/tvgPicture.cpp b/src/lib/tvgPicture.cpp index 580cb5b5..52f73cbb 100644 --- a/src/lib/tvgPicture.cpp +++ b/src/lib/tvgPicture.cpp @@ -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(pImpl)); } diff --git a/src/lib/tvgRadialGradient.cpp b/src/lib/tvgRadialGradient.cpp index c289ca59..42a83461 100644 --- a/src/lib/tvgRadialGradient.cpp +++ b/src/lib/tvgRadialGradient.cpp @@ -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(pImpl)); } diff --git a/src/lib/tvgScene.cpp b/src/lib/tvgScene.cpp index 1516b2eb..4b2f77dd 100644 --- a/src/lib/tvgScene.cpp +++ b/src/lib/tvgScene.cpp @@ -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(pImpl)); } diff --git a/src/lib/tvgShape.cpp b/src/lib/tvgShape.cpp index 42b2c0db..8db56359 100644 --- a/src/lib/tvgShape.cpp +++ b/src/lib/tvgShape.cpp @@ -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(pImpl)); }