common paint: revise bounds interface. 51/234151/2
authorHermet Park <chuneon.park@samsung.com>
Fri, 22 May 2020 07:30:13 +0000 (16:30 +0900)
committerHermet Park <chuneon.park@samsung.com>
Fri, 22 May 2020 07:32:32 +0000 (16:32 +0900)
we don't use the reference style for user interfaces.

Change-Id: Id70682bf8c2d8ea9ffab2ea6fb567eaa8639da60

inc/tizenvg.h
src/lib/tvgScene.cpp
src/lib/tvgSceneImpl.h
src/lib/tvgShape.cpp
src/lib/tvgShapeImpl.h
src/lib/tvgShapePath.h

index bfaa960..dbdcd66 100644 (file)
@@ -81,7 +81,7 @@ public:
     virtual int scale(float factor) = 0;
     virtual int translate(float x, float y) = 0;
 
-    virtual int bounds(float&x, float& y, float& w, float& h) const = 0;
+    virtual int bounds(float* x, float* y, float* w, float* h) const = 0;
 };
 
 
@@ -153,7 +153,7 @@ public:
     int stroke(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept;
     size_t stroke(const size_t** dashPattern) const noexcept;
 
-    int bounds(float&x, float& y, float& w, float& h) const noexcept override;
+    int bounds(float* x, float* y, float* w, float* h) const noexcept override;
 
     static std::unique_ptr<Shape> gen() noexcept;
 
@@ -183,7 +183,7 @@ public:
     int scale(float factor) noexcept override;
     int translate(float x, float y) noexcept override;
 
-    int bounds(float&x, float& y, float& w, float& h) const noexcept override;
+    int bounds(float* x, float* y, float* w, float* h) const noexcept override;
 
     static std::unique_ptr<Scene> gen() noexcept;
 
index dba9637..93a64b1 100644 (file)
@@ -91,16 +91,11 @@ int Scene::translate(float x, float y) noexcept
 }
 
 
-int Scene::bounds(float& x, float& y, float& w, float& h) const noexcept
+int Scene::bounds(float* x, float* y, float* w, float* h) const noexcept
 {
     auto impl = pImpl.get();
     assert(impl);
 
-    x = FLT_MAX;
-    y = FLT_MAX;
-    w = 0;
-    h = 0;
-
     if (!impl->bounds(x, y, w, h)) return -1;
 
     return 0;
index abd29e6..9064b53 100644 (file)
@@ -100,8 +100,13 @@ struct Scene::Impl
         return true;
     }
 
-    bool bounds(float& x, float& y, float& w, float& h)
+    bool bounds(float* px, float* py, float* pw, float* ph)
     {
+        auto x = FLT_MAX;
+        auto y = FLT_MAX;
+        auto w = 0.0f;
+        auto h = 0.0f;
+
         for(auto paint: paints) {
             auto x2 = FLT_MAX;
             auto y2 = FLT_MAX;
@@ -109,9 +114,9 @@ struct Scene::Impl
             auto h2 = 0.0f;
 
             if (auto scene = dynamic_cast<Scene*>(paint)) {
-                if (!SCENE_IMPL->bounds(x2, y2, w2, h2)) return false;
+                if (!SCENE_IMPL->bounds(&x2, &y2, &w2, &h2)) return false;
             } else if (auto shape = dynamic_cast<Shape*>(paint)) {
-                if (!SHAPE_IMPL->bounds(x2, y2, w2, h2)) return false;
+                if (!SHAPE_IMPL->bounds(&x2, &y2, &w2, &h2)) return false;
             }
 
             //Merge regions
@@ -120,6 +125,12 @@ struct Scene::Impl
             if (y2 < y) y = x2;
             if (y + h < y2 + h2) h = (y2 + h2) - y;
         }
+
+        if (px) *px = x;
+        if (py) *py = y;
+        if (pw) *pw = w;
+        if (ph) *ph = h;
+
         return true;
     }
 
index 342f456..c8483e1 100644 (file)
@@ -269,7 +269,7 @@ int Shape::translate(float x, float y) noexcept
 }
 
 
-int Shape::bounds(float& x, float& y, float& w, float& h) const noexcept
+int Shape::bounds(float* x, float* y, float* w, float* h) const noexcept
 {
     auto impl = pImpl.get();
     assert(impl);
index e2ba294..1800b70 100644 (file)
@@ -99,7 +99,7 @@ struct Shape::Impl
         return false;
     }
 
-    bool bounds(float& x, float& y, float& w, float& h)
+    bool bounds(float* x, float* y, float* w, float* h)
     {
         assert(path);
         return path->bounds(x, y, w, h);
index 9dafdf9..68205f4 100644 (file)
@@ -113,7 +113,7 @@ struct ShapePath
         cmds[cmdCnt++] = PathCommand::Close;
     }
 
-    bool bounds(float& x, float& y, float& w, float& h)
+    bool bounds(float* x, float* y, float* w, float* h)
     {
         if (ptsCnt == 0) return false;
 
@@ -127,10 +127,10 @@ struct ShapePath
             if (pts[i].y > max.y) max.y = pts[i].y;
         }
 
-        x = min.x;
-        y = min.y;
-        w = max.x - min.x;
-        h = max.y - min.y;
+        if (x) *x = min.x;
+        if (y) *y = min.y;
+        if (w) *w = max.x - min.x;
+        if (h) *h = max.y - min.y;
 
         return true;
     }