blob: 41dd2715b06423a8cede2acd008f229b0102dd4a [file] [log] [blame]
reed73c25012014-11-17 06:15:42 -08001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
9// DO NOT USE -- FOR INTERNAL TESTING ONLY
10
11#ifndef sk_types_DEFINED
12#define sk_types_DEFINED
13
14#include <stdint.h>
15#include <stddef.h>
16
17#ifdef __cplusplus
18 #define SK_C_PLUS_PLUS_BEGIN_GUARD extern "C" {
19 #define SK_C_PLUS_PLUS_END_GUARD }
20#else
21 #include <stdbool.h>
22 #define SK_C_PLUS_PLUS_BEGIN_GUARD
23 #define SK_C_PLUS_PLUS_END_GUARD
24#endif
25
halcanary219f18f2015-09-01 10:01:38 -070026#ifndef SK_API
27#define SK_API
28#endif
29
reed73c25012014-11-17 06:15:42 -080030///////////////////////////////////////////////////////////////////////////////////////
31
32SK_C_PLUS_PLUS_BEGIN_GUARD
33
34typedef uint32_t sk_color_t;
35
halcanaryc9119062015-09-01 10:45:09 -070036/* This macro assumes all arguments are >=0 and <=255. */
reed73c25012014-11-17 06:15:42 -080037#define sk_color_set_argb(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
38#define sk_color_get_a(c) (((c) >> 24) & 0xFF)
39#define sk_color_get_r(c) (((c) >> 16) & 0xFF)
40#define sk_color_get_g(c) (((c) >> 8) & 0xFF)
41#define sk_color_get_b(c) (((c) >> 0) & 0xFF)
42
43typedef enum {
44 UNKNOWN_SK_COLORTYPE,
45 RGBA_8888_SK_COLORTYPE,
46 BGRA_8888_SK_COLORTYPE,
47 ALPHA_8_SK_COLORTYPE,
48} sk_colortype_t;
49
50typedef enum {
51 OPAQUE_SK_ALPHATYPE,
52 PREMUL_SK_ALPHATYPE,
53 UNPREMUL_SK_ALPHATYPE,
54} sk_alphatype_t;
55
reede3719892014-12-22 17:46:00 -080056typedef enum {
57 INTERSECT_SK_CLIPTYPE,
58 DIFFERENCE_SK_CLIPTYPE,
59} sk_cliptype_t;
60
robertphillips702edbd2015-06-23 06:26:08 -070061typedef enum {
62 UNKNOWN_SK_PIXELGEOMETRY,
63 RGB_H_SK_PIXELGEOMETRY,
64 BGR_H_SK_PIXELGEOMETRY,
65 RGB_V_SK_PIXELGEOMETRY,
66 BGR_V_SK_PIXELGEOMETRY,
67} sk_pixelgeometry_t;
68
halcanaryc9119062015-09-01 10:45:09 -070069/**
70 Return the default sk_colortype_t; this is operating-system dependent.
71*/
halcanary219f18f2015-09-01 10:01:38 -070072SK_API sk_colortype_t sk_colortype_get_default_8888();
reed73c25012014-11-17 06:15:42 -080073
74typedef struct {
75 int32_t width;
76 int32_t height;
77 sk_colortype_t colorType;
78 sk_alphatype_t alphaType;
79} sk_imageinfo_t;
80
81typedef struct {
robertphillips702edbd2015-06-23 06:26:08 -070082 sk_pixelgeometry_t pixelGeometry;
83} sk_surfaceprops_t;
84
85typedef struct {
reedafa278e2014-11-24 19:11:48 -080086 float x;
87 float y;
88} sk_point_t;
89
90typedef struct {
reed871872f2015-06-22 12:48:26 -070091 int32_t left;
92 int32_t top;
93 int32_t right;
94 int32_t bottom;
95} sk_irect_t;
96
97typedef struct {
reed73c25012014-11-17 06:15:42 -080098 float left;
99 float top;
100 float right;
101 float bottom;
102} sk_rect_t;
103
reedafa278e2014-11-24 19:11:48 -0800104typedef struct {
105 float mat[9];
106} sk_matrix_t;
107
halcanaryc9119062015-09-01 10:45:09 -0700108/**
109 A sk_canvas_t encapsulates all of the state about drawing into a
110 destination This includes a reference to the destination itself,
111 and a stack of matrix/clip values.
112*/
reed73c25012014-11-17 06:15:42 -0800113typedef struct sk_canvas_t sk_canvas_t;
halcanaryc9119062015-09-01 10:45:09 -0700114/**
115 A sk_data_ holds an immutable data buffer.
116*/
reedb2a5d7e2014-12-25 14:16:21 -0800117typedef struct sk_data_t sk_data_t;
halcanaryc9119062015-09-01 10:45:09 -0700118/**
119 A sk_image_t is an abstraction for drawing a rectagle of pixels.
120 The content of the image is always immutable, though the actual
121 storage may change, if for example that image can be re-created via
122 encoded data or other means.
123*/
reed73c25012014-11-17 06:15:42 -0800124typedef struct sk_image_t sk_image_t;
halcanaryc9119062015-09-01 10:45:09 -0700125/**
126 A sk_maskfilter_t is an object that perform transformations on an
127 alpha-channel mask before drawing it; it may be installed into a
128 sk_paint_t. Each time a primitive is drawn, it is first
129 scan-converted into a alpha mask, which os handed to the
130 maskfilter, which may create a new mask is to render into the
131 destination.
132 */
reed0eafc9b2014-12-23 14:11:11 -0800133typedef struct sk_maskfilter_t sk_maskfilter_t;
halcanaryc9119062015-09-01 10:45:09 -0700134/**
135 A sk_paint_t holds the style and color information about how to
136 draw geometries, text and bitmaps.
137*/
reed73c25012014-11-17 06:15:42 -0800138typedef struct sk_paint_t sk_paint_t;
halcanaryc9119062015-09-01 10:45:09 -0700139/**
140 A sk_path_t encapsulates compound (multiple contour) geometric
141 paths consisting of straight line segments, quadratic curves, and
142 cubic curves.
143*/
reedb2a5d7e2014-12-25 14:16:21 -0800144typedef struct sk_path_t sk_path_t;
halcanaryc9119062015-09-01 10:45:09 -0700145/**
146 A sk_picture_t holds recorded canvas drawing commands to be played
147 back at a later time.
148*/
reede3719892014-12-22 17:46:00 -0800149typedef struct sk_picture_t sk_picture_t;
halcanaryc9119062015-09-01 10:45:09 -0700150/**
151 A sk_picture_recorder_t holds a sk_canvas_t that records commands
152 to create a sk_picture_t.
153*/
reede3719892014-12-22 17:46:00 -0800154typedef struct sk_picture_recorder_t sk_picture_recorder_t;
halcanaryc9119062015-09-01 10:45:09 -0700155/**
156 A sk_shader_t specifies the source color(s) for what is being drawn. If a
157 paint has no shader, then the paint's color is used. If the paint
158 has a shader, then the shader's color(s) are use instead, but they
159 are modulated by the paint's alpha.
160*/
reedafa278e2014-11-24 19:11:48 -0800161typedef struct sk_shader_t sk_shader_t;
halcanaryc9119062015-09-01 10:45:09 -0700162/**
163 A sk_surface_t holds the destination for drawing to a canvas. For
164 raster drawing, the destination is an array of pixels in memory.
165 For GPU drawing, the destination is a texture or a framebuffer.
166*/
reed73c25012014-11-17 06:15:42 -0800167typedef struct sk_surface_t sk_surface_t;
168
halcanary7568d0b2015-07-31 13:38:06 -0700169typedef enum {
170 CLEAR_SK_XFERMODE_MODE,
171 SRC_SK_XFERMODE_MODE,
172 DST_SK_XFERMODE_MODE,
173 SRCOVER_SK_XFERMODE_MODE,
174 DSTOVER_SK_XFERMODE_MODE,
175 SRCIN_SK_XFERMODE_MODE,
176 DSTIN_SK_XFERMODE_MODE,
177 SRCOUT_SK_XFERMODE_MODE,
178 DSTOUT_SK_XFERMODE_MODE,
179 SRCATOP_SK_XFERMODE_MODE,
180 DSTATOP_SK_XFERMODE_MODE,
181 XOR_SK_XFERMODE_MODE,
182 PLUS_SK_XFERMODE_MODE,
183 MODULATE_SK_XFERMODE_MODE,
184 SCREEN_SK_XFERMODE_MODE,
185 OVERLAY_SK_XFERMODE_MODE,
186 DARKEN_SK_XFERMODE_MODE,
187 LIGHTEN_SK_XFERMODE_MODE,
188 COLORDODGE_SK_XFERMODE_MODE,
189 COLORBURN_SK_XFERMODE_MODE,
190 HARDLIGHT_SK_XFERMODE_MODE,
191 SOFTLIGHT_SK_XFERMODE_MODE,
192 DIFFERENCE_SK_XFERMODE_MODE,
193 EXCLUSION_SK_XFERMODE_MODE,
194 MULTIPLY_SK_XFERMODE_MODE,
195 HUE_SK_XFERMODE_MODE,
196 SATURATION_SK_XFERMODE_MODE,
197 COLOR_SK_XFERMODE_MODE,
198 LUMINOSITY_SK_XFERMODE_MODE,
199} sk_xfermode_mode_t;
200
reed73c25012014-11-17 06:15:42 -0800201//////////////////////////////////////////////////////////////////////////////////////////
202
reed73c25012014-11-17 06:15:42 -0800203SK_C_PLUS_PLUS_END_GUARD
204
205#endif