mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
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:
parent
4cdf648e14
commit
1d4db59a25
10 changed files with 20 additions and 13 deletions
10
inc/thorvg.h
10
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);
|
||||
};
|
||||
|
||||
|
|
|
@ -108,3 +108,8 @@ Fill* Fill::duplicate() const noexcept
|
|||
{
|
||||
return pImpl->duplicate();
|
||||
}
|
||||
|
||||
uint32_t Fill::identifier() const noexcept
|
||||
{
|
||||
return pImpl->id;
|
||||
}
|
|
@ -54,6 +54,7 @@ struct Fill::Impl
|
|||
uint32_t cnt = 0;
|
||||
FillSpread spread;
|
||||
DuplicateMethod<Fill>* dup = nullptr;
|
||||
uint32_t id;
|
||||
|
||||
~Impl()
|
||||
{
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -395,3 +395,9 @@ uint8_t Paint::opacity() const noexcept
|
|||
{
|
||||
return pImpl->opacity;
|
||||
}
|
||||
|
||||
|
||||
uint32_t Paint::identifier() const noexcept
|
||||
{
|
||||
return pImpl->id;
|
||||
}
|
|
@ -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() {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue