Added the C API for SkPath::computeTightBounds()
authorMatthew Leibowitz <mattleibow@live.com>
Thu, 11 May 2017 03:09:40 +0000 (05:09 +0200)
committerMatthew Leibowitz <mattleibow@live.com>
Thu, 11 May 2017 03:09:40 +0000 (05:09 +0200)
include/c/sk_path.h
src/c/sk_path.cpp

index 5e0aa73..c38e9ba 100644 (file)
@@ -99,6 +99,8 @@ SK_C_API void sk_path_add_circle(sk_path_t*, float x, float y, float radius, sk_
  */
 SK_C_API bool sk_path_get_bounds(const sk_path_t*, sk_rect_t*);
 
+SK_C_API void sk_path_compute_tight_bounds(const sk_path_t*, sk_rect_t*);
+
 /** Set the beginning of the next contour relative to the last point on the
         previous contour. If there is no previous contour, this is treated the
         same as sk_path_move_to. 
index 2188121..5c37bf4 100644 (file)
@@ -235,6 +235,13 @@ bool sk_path_get_bounds(const sk_path_t* cpath, sk_rect_t* crect) {
     return true;
 }
 
+void sk_path_compute_tight_bounds(const sk_path_t* cpath, sk_rect_t* crect) {
+    if (crect) {
+        const SkPath& path = AsPath(*cpath);
+        *crect = ToRect(path.computeTightBounds());
+    }
+}
+
 int sk_path_count_points(const sk_path_t* cpath) {
     const SkPath& path = AsPath(*cpath);
     return path.countPoints();