Chromium Code Reviews| Index: experimental/sk_surface.cpp |
| diff --git a/experimental/sk_surface.cpp b/experimental/sk_surface.cpp |
| index 1158b42cdcc81e3c59ea5cd36a672b4aa65a8ff7..cd1261b0cc772d662071beede07bcf78a9ef7e67 100644 |
| --- a/experimental/sk_surface.cpp |
| +++ b/experimental/sk_surface.cpp |
| @@ -27,6 +27,14 @@ static const SkPath& AsPath(const sk_path_t& cpath) { |
| return reinterpret_cast<const SkPath&>(cpath); |
| } |
| +static SkPath* as_path(sk_path_t* cpath) { |
| + return reinterpret_cast<SkPath*>(cpath); |
| +} |
| + |
| +static const SkPath* as_path(const sk_path_t* cpath) { |
|
reed1
2014/10/08 12:12:46
do we need this one? if so, can it take/return a r
robertphillips
2014/10/08 12:56:18
Apparently it is not needed, I've removed it.
|
| + return reinterpret_cast<const SkPath*>(cpath); |
| +} |
| + |
| static const SkImage* AsImage(const sk_image_t* cimage) { |
| return reinterpret_cast<const SkImage*>(cimage); |
| } |
| @@ -102,6 +110,32 @@ void sk_paint_set_color(sk_paint_t* cpaint, sk_color_t c) { |
| /////////////////////////////////////////////////////////////////////////////////////////// |
| +sk_path_t* sk_path_new() { |
| + return (sk_path_t*)SkNEW(SkPath); |
| +} |
| + |
| +void sk_path_delete(sk_path_t* cpath) { |
| + SkDELETE(as_path(cpath)); |
| +} |
| + |
| +void sk_path_move_to(sk_path_t* cpath, float x, float y) { |
| + as_path(cpath)->moveTo(x, y); |
| +} |
| + |
| +void sk_path_line_to(sk_path_t* cpath, float x, float y) { |
| + as_path(cpath)->lineTo(x, y); |
| +} |
| + |
| +void sk_path_quad_to(sk_path_t* cpath, float x0, float y0, float x1, float y1) { |
| + as_path(cpath)->quadTo(x0, y0, x1, y1); |
| +} |
| + |
| +void sk_path_close(sk_path_t* cpath) { |
| + as_path(cpath)->close(); |
| +} |
| + |
| +/////////////////////////////////////////////////////////////////////////////////////////// |
| + |
| void sk_canvas_save(sk_canvas_t* ccanvas) { |
| AsCanvas(ccanvas)->save(); |
| } |
| @@ -196,11 +230,20 @@ void sk_test_capi(SkCanvas* canvas) { |
| sk_paint_set_color(cpaint, 0xFF00FF00); |
| sk_canvas_draw_rect(ccanvas, &cr, cpaint); |
| + sk_path_t* cpath = sk_path_new(); |
| + sk_path_move_to(cpath, 50, 50); |
| + sk_path_line_to(cpath, 100, 100); |
| + sk_path_line_to(cpath, 50, 100); |
| + sk_path_close(cpath); |
| + |
| + sk_canvas_draw_path(ccanvas, cpath, cpaint); |
| + |
| sk_image_t* cimage = sk_surface_new_image_snapshot(csurface); |
| // HERE WE CROSS THE C..C++ boundary |
| canvas->drawImage((const SkImage*)cimage, 20, 20, NULL); |
| + sk_path_delete(cpath); |
| sk_paint_delete(cpaint); |
| sk_image_unref(cimage); |
| sk_surface_delete(csurface); |