we don't use the reference style for user interfaces.
Change-Id: Id70682bf8c2d8ea9ffab2ea6fb567eaa8639da60
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;
};
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;
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;
}
-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;
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;
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
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;
}
}
-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);
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);
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;
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;
}