From: Hermet Park Date: Fri, 22 May 2020 07:30:13 +0000 (+0900) Subject: common paint: revise bounds interface. X-Git-Tag: accepted/tizen/unified/20200806.062539~142 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a0521c83c3f56e9c022d5ed590d04f0d8e75baf6;p=platform%2Fcore%2Fgraphics%2Ftizenvg.git common paint: revise bounds interface. we don't use the reference style for user interfaces. Change-Id: Id70682bf8c2d8ea9ffab2ea6fb567eaa8639da60 --- diff --git a/inc/tizenvg.h b/inc/tizenvg.h index bfaa960..dbdcd66 100644 --- a/inc/tizenvg.h +++ b/inc/tizenvg.h @@ -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 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 gen() noexcept; diff --git a/src/lib/tvgScene.cpp b/src/lib/tvgScene.cpp index dba9637..93a64b1 100644 --- a/src/lib/tvgScene.cpp +++ b/src/lib/tvgScene.cpp @@ -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; diff --git a/src/lib/tvgSceneImpl.h b/src/lib/tvgSceneImpl.h index abd29e6..9064b53 100644 --- a/src/lib/tvgSceneImpl.h +++ b/src/lib/tvgSceneImpl.h @@ -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(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(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; } diff --git a/src/lib/tvgShape.cpp b/src/lib/tvgShape.cpp index 342f456..c8483e1 100644 --- a/src/lib/tvgShape.cpp +++ b/src/lib/tvgShape.cpp @@ -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); diff --git a/src/lib/tvgShapeImpl.h b/src/lib/tvgShapeImpl.h index e2ba294..1800b70 100644 --- a/src/lib/tvgShapeImpl.h +++ b/src/lib/tvgShapeImpl.h @@ -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); diff --git a/src/lib/tvgShapePath.h b/src/lib/tvgShapePath.h index 9dafdf9..68205f4 100644 --- a/src/lib/tvgShapePath.h +++ b/src/lib/tvgShapePath.h @@ -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; }