Adding bindings for SkNWayCanvas and SkNoDrawCanvas
authorMatthew Leibowitz <mattleibow@live.com>
Thu, 24 May 2018 17:09:50 +0000 (19:09 +0200)
committerMatthew Leibowitz <mattleibow@live.com>
Thu, 24 May 2018 17:09:50 +0000 (19:09 +0200)
include/c/sk_canvas.h
include/c/sk_types.h
src/c/sk_canvas.cpp
src/c/sk_types_priv.h

index cd44564e8205ccdf448c7eadd6299d481472d414..6c7f7998648cf9d886d01cc0750a297a84acc06b 100644 (file)
@@ -351,6 +351,15 @@ SK_C_API void sk_canvas_draw_image_nine(sk_canvas_t* t, const sk_image_t* image,
 
 SK_C_API void sk_canvas_draw_vertices(sk_canvas_t* ccanvas, sk_vertices_t* vertices, sk_blendmode_t mode, const sk_paint_t* paint);
 
+SK_C_API sk_nodraw_canvas_t* sk_nodraw_canvas_new(int width, int height);
+SK_C_API void sk_nodraw_canvas_destroy(sk_nodraw_canvas_t*);
+
+SK_C_API sk_nway_canvas_t* sk_nway_canvas_new(int width, int height);
+SK_C_API void sk_nway_canvas_destroy(sk_nway_canvas_t*);
+SK_C_API void sk_nway_canvas_add_canvas(sk_nway_canvas_t*, sk_canvas_t* canvas);
+SK_C_API void sk_nway_canvas_remove_canvas(sk_nway_canvas_t*, sk_canvas_t* canvas);
+SK_C_API void sk_nway_canvas_remove_all(sk_nway_canvas_t*);
+
 SK_C_PLUS_PLUS_END_GUARD
 
 #endif
index 905bd5b5939a2d2b9b982b77a33c40ed8e3e64db..c8d4bb6494ae41a314748ad1c9993ab6847a926e 100644 (file)
@@ -183,6 +183,8 @@ typedef enum {
     and a stack of matrix/clip values.
 */
 typedef struct sk_canvas_t sk_canvas_t;
+typedef struct sk_nodraw_canvas_t sk_nodraw_canvas_t;
+typedef struct sk_nway_canvas_t sk_nway_canvas_t;
 /**
     A sk_data_ holds an immutable data buffer.
 */
index 1266be60148c28fc08ac0e56e534d824c0dc245d..d0558348ef37cfedfe4d5ec7f5fec8a5fb0978f8 100644 (file)
@@ -297,3 +297,31 @@ void sk_canvas_draw_image_nine(sk_canvas_t* ccanvas,
 void sk_canvas_draw_vertices(sk_canvas_t* ccanvas, sk_vertices_t* vertices, sk_blendmode_t mode, const sk_paint_t* paint) {
     AsCanvas(ccanvas)->drawVertices(AsVertices(vertices), (SkBlendMode)mode, AsPaint(*paint));
 }
+
+sk_nodraw_canvas_t* sk_nodraw_canvas_new(int width, int height) {
+    return ToNoDrawCanvas(new SkNoDrawCanvas(width, height));
+}
+
+void sk_nodraw_canvas_destroy(sk_nodraw_canvas_t* t) {
+    delete AsNoDrawCanvas(t);
+}
+
+sk_nway_canvas_t* sk_nway_canvas_new(int width, int height) {
+    return ToNWayCanvas(new SkNWayCanvas(width, height));
+}
+
+void sk_nway_canvas_destroy(sk_nway_canvas_t* t) {
+    delete AsNWayCanvas(t);
+}
+
+void sk_nway_canvas_add_canvas(sk_nway_canvas_t* t, sk_canvas_t* canvas) {
+    AsNWayCanvas(t)->addCanvas(AsCanvas(canvas));
+}
+
+void sk_nway_canvas_remove_canvas(sk_nway_canvas_t* t, sk_canvas_t* canvas) {
+    AsNWayCanvas(t)->removeCanvas(AsCanvas(canvas));
+}
+
+void sk_nway_canvas_remove_all(sk_nway_canvas_t* t) {
+    AsNWayCanvas(t)->removeAll();
+}
index dd345457871e11c6488533e8c644d41f15697127..fa854799ce1e4896c62a8f8c38da6abcac7c883e 100644 (file)
@@ -10,6 +10,8 @@
 
 #include "SkImageInfo.h"
 #include "SkCanvas.h"
+#include "SkNoDrawCanvas.h"
+#include "SkNWayCanvas.h"
 #include "SkSurface.h"
 #include "SkVertices.h"
 #include "SkBlurTypes.h"
@@ -251,6 +253,22 @@ static inline SkCanvas* AsCanvas(sk_canvas_t* ccanvas) {
     return reinterpret_cast<SkCanvas*>(ccanvas);
 }
 
+static inline sk_nodraw_canvas_t* ToNoDrawCanvas(SkNoDrawCanvas* canvas) {
+    return reinterpret_cast<sk_nodraw_canvas_t*>(canvas);
+}
+
+static inline SkNoDrawCanvas* AsNoDrawCanvas(sk_nodraw_canvas_t* ccanvas) {
+    return reinterpret_cast<SkNoDrawCanvas*>(ccanvas);
+}
+
+static inline sk_nway_canvas_t* ToNWayCanvas(SkNWayCanvas* canvas) {
+    return reinterpret_cast<sk_nway_canvas_t*>(canvas);
+}
+
+static inline SkNWayCanvas* AsNWayCanvas(sk_nway_canvas_t* ccanvas) {
+    return reinterpret_cast<SkNWayCanvas*>(ccanvas);
+}
+
 static inline SkPictureRecorder* AsPictureRecorder(sk_picture_recorder_t* crec) {
     return reinterpret_cast<SkPictureRecorder*>(crec);
 }