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.
This commit is contained in:
Hermet Park 2021-12-13 18:56:25 +09:00 committed by Hermet Park
parent 4cdf648e14
commit 1d4db59a25
10 changed files with 20 additions and 13 deletions

View file

@ -53,10 +53,6 @@ protected: \
friend IteratorAccessor friend IteratorAccessor
#define _TVG_DECALRE_IDENTIFIER() \
protected: \
unsigned _id
namespace tvg namespace tvg
{ {
@ -345,10 +341,9 @@ public:
* *
* @BETA_API * @BETA_API
*/ */
uint32_t identifier() const { return _id; } uint32_t identifier() const noexcept;
_TVG_DECLARE_ACCESSOR(); _TVG_DECLARE_ACCESSOR();
_TVG_DECALRE_IDENTIFIER();
_TVG_DECLARE_PRIVATE(Paint); _TVG_DECLARE_PRIVATE(Paint);
}; };
@ -454,9 +449,8 @@ public:
* *
* @BETA_API * @BETA_API
*/ */
uint32_t identifier() const { return _id; } uint32_t identifier() const noexcept;
_TVG_DECALRE_IDENTIFIER();
_TVG_DECLARE_PRIVATE(Fill); _TVG_DECLARE_PRIVATE(Fill);
}; };

View file

@ -108,3 +108,8 @@ Fill* Fill::duplicate() const noexcept
{ {
return pImpl->duplicate(); return pImpl->duplicate();
} }
uint32_t Fill::identifier() const noexcept
{
return pImpl->id;
}

View file

@ -54,6 +54,7 @@ struct Fill::Impl
uint32_t cnt = 0; uint32_t cnt = 0;
FillSpread spread; FillSpread spread;
DuplicateMethod<Fill>* dup = nullptr; DuplicateMethod<Fill>* dup = nullptr;
uint32_t id;
~Impl() ~Impl()
{ {

View file

@ -54,7 +54,7 @@ struct LinearGradient::Impl
LinearGradient::LinearGradient():pImpl(new 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)); Fill::pImpl->method(new FillDup<LinearGradient::Impl>(pImpl));
} }

View file

@ -395,3 +395,9 @@ uint8_t Paint::opacity() const noexcept
{ {
return pImpl->opacity; return pImpl->opacity;
} }
uint32_t Paint::identifier() const noexcept
{
return pImpl->id;
}

View file

@ -58,6 +58,7 @@ namespace tvg
Paint* cmpTarget = nullptr; Paint* cmpTarget = nullptr;
CompositeMethod cmpMethod = CompositeMethod::None; CompositeMethod cmpMethod = CompositeMethod::None;
uint32_t ctxFlag = ContextFlag::Invalid; uint32_t ctxFlag = ContextFlag::Invalid;
uint32_t id;
uint8_t opacity = 255; uint8_t opacity = 255;
~Impl() { ~Impl() {

View file

@ -28,7 +28,7 @@
Picture::Picture() : pImpl(new Impl(this)) 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)); Paint::pImpl->method(new PaintMethod<Picture::Impl>(pImpl));
} }

View file

@ -52,7 +52,7 @@ struct RadialGradient::Impl
RadialGradient::RadialGradient():pImpl(new 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)); Fill::pImpl->method(new FillDup<RadialGradient::Impl>(pImpl));
} }

View file

@ -27,7 +27,7 @@
Scene::Scene() : pImpl(new Impl()) 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)); Paint::pImpl->method(new PaintMethod<Scene::Impl>(pImpl));
} }

View file

@ -34,7 +34,7 @@ constexpr auto PATH_KAPPA = 0.552284f;
Shape :: Shape() : pImpl(new Impl(this)) 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)); Paint::pImpl->method(new PaintMethod<Shape::Impl>(pImpl));
} }