diff options
author | 2017-05-09 15:56:06 -0400 | |
---|---|---|
committer | 2017-05-10 15:32:19 +0000 | |
commit | efa48d599de15d960d7335a4a93a6bbeb97d3c41 (patch) | |
tree | 6b95700087faeaaec0ea030d0fa5e17b515cebc1 /experimental/go-skia/types.go | |
parent | 05fd8cf08970763832d6690ca1823168dd6f071f (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/types.go')
-rw-r--r-- | experimental/go-skia/types.go | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/experimental/go-skia/types.go b/experimental/go-skia/types.go new file mode 100644 index 0000000000..637eceea96 --- /dev/null +++ b/experimental/go-skia/types.go @@ -0,0 +1,65 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +// Created by cgo -godefs. Enum fields in structs were fixed by hand. +// command: go tool cgo -godefs ctypes.go > types.go +// +// The purpose of this file is to have Go structs with the same memory +// layout as their C counterparts. For enums we want the underlying primitive +// types to match. +// +// TODO(stephan): Add tests that allow to detect failure on platforms other +// than Linux and changes in the underlying C types. + +package skia + +type Color uint32 + +type ColorType uint32 + +const ( + UNKNOWN_COLORTYPE ColorType = 0x0 + RGBA_8888_COLORTYPE ColorType = 0x1 + BGRA_8888_COLORTYPE ColorType = 0x2 + ALPHA_8_COLORTYPE ColorType = 0x3 +) + +type AlphaType uint32 + +const ( + OPAQUE_ALPHATYPE AlphaType = 0x0 + PREMUL_ALPHATYPE AlphaType = 0x1 + UNPREMUL_ALPHATYPE AlphaType = 0x2 +) + +type PixelGeometry uint32 + +const ( + UNKNOWN_SK_PIXELGEOMETRY PixelGeometry = 0x0 + RGB_H_SK_PIXELGEOMETRY PixelGeometry = 0x1 + BGR_H_SK_PIXELGEOMETRY PixelGeometry = 0x2 + RGB_V_SK_PIXELGEOMETRY PixelGeometry = 0x3 + BGR_V_SK_PIXELGEOMETRY PixelGeometry = 0x4 +) + +type ImageInfo struct { + Width int32 + Height int32 + ColorType ColorType + AlphaType AlphaType +} + +type SurfaceProps struct { + PixelGeometry PixelGeometry +} + +type Rect struct { + Left float32 + Top float32 + Right float32 + Bottom float32 +} |