Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Unified Diff: experimental/sk_surface.cpp

Issue 633183002: Implement C path functions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Removed unused entry point Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/sk_surface.h ('k') | gyp/experimental.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/sk_surface.cpp
diff --git a/experimental/sk_surface.cpp b/experimental/sk_surface.cpp
index 1158b42cdcc81e3c59ea5cd36a672b4aa65a8ff7..ae37c464b2aba1e135b9f7170578b6c4779c1ec4 100644
--- a/experimental/sk_surface.cpp
+++ b/experimental/sk_surface.cpp
@@ -27,6 +27,10 @@ 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 SkImage* AsImage(const sk_image_t* cimage) {
return reinterpret_cast<const SkImage*>(cimage);
}
@@ -102,6 +106,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 +226,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);
« no previous file with comments | « experimental/sk_surface.h ('k') | gyp/experimental.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698