From 2326939576d1fdf743e58f09f69ba690179aa3f0 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Thu, 29 Nov 2018 15:36:11 +0900 Subject: [PATCH] lottie/vector: added unique(), refCount() and null() api to vpath class. Change-Id: Iff4ad6a37760b885ab390afe0b7748c924a646be --- src/vector/vcowptr.h | 7 +++++++ src/vector/vpath.h | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/vector/vcowptr.h b/src/vector/vcowptr.h index 64aa554..39a16e4 100644 --- a/src/vector/vcowptr.h +++ b/src/vector/vcowptr.h @@ -67,6 +67,13 @@ public: auto operator-> () const noexcept -> const element_type* { return &read(); } + int refCount() const noexcept + { + assert(mModel); + + return mModel->mRef; + } + bool unique() const noexcept { assert(mModel); diff --git a/src/vector/vpath.h b/src/vector/vpath.h index bc74316..8cec2d7 100644 --- a/src/vector/vpath.h +++ b/src/vector/vpath.h @@ -15,6 +15,7 @@ public: enum class Element : uchar { MoveTo, LineTo, CubicTo, Close }; bool empty() const; + bool null() const; void moveTo(const VPointF &p); void moveTo(float x, float y); void lineTo(const VPointF &p); @@ -49,10 +50,13 @@ public: const std::vector &elements() const; const std::vector & points() const; void clone(const VPath &srcPath); + bool unique() const { return d.unique();} + int refCount() const { return d.refCount();} private: struct VPathData { bool empty() const { return m_elements.empty(); } + bool null() const { return empty() && !m_elements.capacity();} void moveTo(float x, float y); void lineTo(float x, float y); void cubicTo(float cx1, float cy1, float cx2, float cy2, float ex, float ey); @@ -99,6 +103,14 @@ inline bool VPath::empty() const return d->empty(); } +/* + * path is empty as well as null(no memory for data allocated yet). + */ +inline bool VPath::null() const +{ + return d->null(); +} + inline void VPath::moveTo(const VPointF &p) { d.write().moveTo(p.x(), p.y()); -- 2.34.1