lottie/vector: refactor the vregion class 70/184670/2
authorsubhransu mohanty <sub.mohanty@samsung.com>
Fri, 20 Jul 2018 05:38:18 +0000 (14:38 +0900)
committerHermet Park <chuneon.park@samsung.com>
Fri, 20 Jul 2018 05:44:07 +0000 (05:44 +0000)
Change-Id: I093000d097cee2045b32b04ef8774b1aaa2706d8

src/vector/vregion.cpp
src/vector/vregion.h

index 7738690..da81953 100644 (file)
@@ -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(&regionPrivate){}
+    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<VRegionData*>(&shared_empty);
+
+}
+
 VRegion &VRegion::operator=(const VRegion &r)
 {
     r.d->ref.ref();
index b5d019c..00155e9 100644 (file)
@@ -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 &region);
-    VRegion(VRegion &&other): d(other.d) { other.d = const_cast<VRegionData*>(&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)
 {