aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/go-skia/ctypes.go
diff options
context:
space:
mode:
authorGravatar Stephan Altmueller <stephana@google.com>2017-05-09 15:56:06 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-10 15:32:19 +0000
commitefa48d599de15d960d7335a4a93a6bbeb97d3c41 (patch)
tree6b95700087faeaaec0ea030d0fa5e17b515cebc1 /experimental/go-skia/ctypes.go
parent05fd8cf08970763832d6690ca1823168dd6f071f (diff)
Experimental Go bindings for Skia
This CL implements Go bindings for a subset of the functions in the C API. It implements a Go version of the C demo program in experimental/c-api-example/skia-c-example.c and the output is identical. (Checked by hand). The main purpose is to establish a pattern of calling the Skia C API that is memory safe and provides a idiomatic Go interface to Skia. Follow up CLs will cover the entire C API, add documentation and establish a pattern to distribute the bindings more easily. BUG= Change-Id: I96ff7c3715164c533202ce300ab0312b1b07f884 Change-Id: I96ff7c3715164c533202ce300ab0312b1b07f884 Reviewed-on: https://skia-review.googlesource.com/10032 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Stephan Altmueller <stephana@google.com>
Diffstat (limited to 'experimental/go-skia/ctypes.go')
-rw-r--r--experimental/go-skia/ctypes.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/experimental/go-skia/ctypes.go b/experimental/go-skia/ctypes.go
new file mode 100644
index 0000000000..64953edc37
--- /dev/null
+++ b/experimental/go-skia/ctypes.go
@@ -0,0 +1,58 @@
+//+build ignore
+
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+package skia
+
+// This file is used to generate 'types.go'
+// from the corresponding type definitions in the C API.
+// Any C struct for which we would like to generate a
+// Go struct with the same memory layout should defined defined here.
+// Any enum that is used in Go should also be listed here, together
+// with the enum values that we want to use.
+
+/*
+#cgo CFLAGS: -I../../include/c
+#include "../../include/c/sk_types.h"
+*/
+import "C"
+
+type Color C.sk_color_t
+
+type ColorType C.sk_colortype_t
+
+const (
+ UNKNOWN_COLORTYPE ColorType = C.UNKNOWN_SK_COLORTYPE
+ RGBA_8888_COLORTYPE ColorType = C.RGBA_8888_SK_COLORTYPE
+ BGRA_8888_COLORTYPE ColorType = C.BGRA_8888_SK_COLORTYPE
+ ALPHA_8_COLORTYPE ColorType = C.ALPHA_8_SK_COLORTYPE
+)
+
+type AlphaType C.sk_alphatype_t
+
+const (
+ OPAQUE_ALPHATYPE AlphaType = C.OPAQUE_SK_ALPHATYPE
+ PREMUL_ALPHATYPE AlphaType = C.PREMUL_SK_ALPHATYPE
+ UNPREMUL_ALPHATYPE AlphaType = C.UNPREMUL_SK_ALPHATYPE
+)
+
+type PixelGeometry C.sk_pixelgeometry_t
+
+const (
+ UNKNOWN_SK_PIXELGEOMETRY PixelGeometry = C.UNKNOWN_SK_PIXELGEOMETRY
+ RGB_H_SK_PIXELGEOMETRY PixelGeometry = C.RGB_H_SK_PIXELGEOMETRY
+ BGR_H_SK_PIXELGEOMETRY PixelGeometry = C.BGR_H_SK_PIXELGEOMETRY
+ RGB_V_SK_PIXELGEOMETRY PixelGeometry = C.RGB_V_SK_PIXELGEOMETRY
+ BGR_V_SK_PIXELGEOMETRY PixelGeometry = C.BGR_V_SK_PIXELGEOMETRY
+)
+
+type ImageInfo C.sk_imageinfo_t
+
+type SurfaceProps C.sk_surfaceprops_t
+
+type Rect C.sk_rect_t