From cfdac7e78c87e5d8dee90c61fcf29bf86a246562 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Fri, 20 Jul 2018 14:38:18 +0900 Subject: [PATCH] lottie/vector: refactor the vregion class Change-Id: I093000d097cee2045b32b04ef8774b1aaa2706d8 --- src/vector/vregion.cpp | 17 +++++++++++++++-- src/vector/vregion.h | 14 +++----------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/vector/vregion.cpp b/src/vector/vregion.cpp index 7738690..da81953 100644 --- a/src/vector/vregion.cpp +++ b/src/vector/vregion.cpp @@ -2044,14 +2044,21 @@ typedef region_type_t VRegionPrivate; V_BEGIN_NAMESPACE static VRegionPrivate regionPrivate = {{0,0,0,0}, NULL}; -const VRegion::VRegionData VRegion::shared_empty; + +struct VRegionData { + VRegionData():ref(-1),rgn(®ionPrivate){} + RefCount ref; + VRegionPrivate *rgn; +}; + +const VRegionData shared_empty; inline VRect box_to_rect(box_type_t *box) { return VRect(box->x1, box->y1, box->x2 - box->x1, box->y2 - box->y1); } -void VRegion::cleanUp(VRegion::VRegionData *x) +void VRegion::cleanUp(VRegionData *x) { if (x->rgn) { PREFIX(_fini)(x->rgn); @@ -2109,6 +2116,12 @@ VRegion::VRegion(const VRegion &r) d->ref.ref(); } +VRegion::VRegion(VRegion &&other): d(other.d) +{ + other.d = const_cast(&shared_empty); + +} + VRegion &VRegion::operator=(const VRegion &r) { r.d->ref.ref(); diff --git a/src/vector/vregion.h b/src/vector/vregion.h index b5d019c..00155e9 100644 --- a/src/vector/vregion.h +++ b/src/vector/vregion.h @@ -8,8 +8,7 @@ V_BEGIN_NAMESPACE -typedef struct pixman_region region_type_t; -typedef region_type_t VRegionPrivate; +struct VRegionData; class VRegion { @@ -18,7 +17,7 @@ public: VRegion(int x, int y, int w, int h); VRegion(const VRect &r); VRegion(const VRegion ®ion); - VRegion(VRegion &&other): d(other.d) { other.d = const_cast(&shared_empty); } + VRegion(VRegion &&other); ~VRegion(); VRegion &operator=(const VRegion &); VRegion &operator=(VRegion &&); @@ -53,16 +52,9 @@ private: bool within(const VRect &r) const; VRegion copy() const; void detach(); - - struct VRegionData { - VRegionData():ref(-1),rgn(nullptr){} - RefCount ref; - VRegionPrivate *rgn; - }; + void cleanUp(VRegionData *x); struct VRegionData *d; - static const struct VRegionData shared_empty; - static void cleanUp(VRegionData *x); }; inline void VRegion::translate(int dx, int dy) { -- 2.34.1