this method returns boundary of a scene.
Change-Id: I1a32c8e034f53822008048f1d8ae7062fb72cca3
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)
+ {
+ for(auto paint: paints) {
+ auto x2 = FLT_MAX;
+ auto y2 = FLT_MAX;
+ auto w2 = 0.0f;
+ auto h2 = 0.0f;
+
+ if (auto scene = dynamic_cast<Scene*>(paint)) {
+ 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;
+ }
+
+ //Merge regions
+ if (x2 < x) x = x2;
+ if (x + w < x2 + w2) w = (x2 + w2) - x;
+ if (y2 < y) y = x2;
+ if (y + h < y2 + h2) h = (y2 + h2) - y;
+ }
+ return true;
+ }
};
#endif //_TVG_SCENE_IMPL_H_
\ No newline at end of file
int Shape::bounds(float& x, float& y, float& w, float& h) const noexcept
{
auto impl = pImpl.get();
- assert(impl && impl->path);
+ assert(impl);
- if (!impl->path->bounds(x, y, w, h)) return -1;
+ if (!impl->bounds(x, y, w, h)) return -1;
return 0;
}
if (edata) return true;
return false;
}
+
+ bool bounds(float& x, float& y, float& w, float& h)
+ {
+ assert(path);
+ return path->bounds(x, y, w, h);
+ }
};
#endif //_TVG_SHAPE_IMPL_H_
\ No newline at end of file