2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
9 // DO NOT USE -- FOR INTERNAL TESTING ONLY
11 #ifndef sk_types_DEFINED
12 #define sk_types_DEFINED
25 typedef uint32_t sk_color_t;
27 #define sk_color_set_argb(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
28 #define sk_color_get_a(c) (((c) >> 24) & 0xFF)
29 #define sk_color_get_r(c) (((c) >> 16) & 0xFF)
30 #define sk_color_get_g(c) (((c) >> 8) & 0xFF)
31 #define sk_color_get_b(c) (((c) >> 0) & 0xFF)
35 RGBA_8888_SK_COLORTYPE,
36 BGRA_8888_SK_COLORTYPE,
43 UNPREMUL_SK_ALPHATYPE,
46 sk_colortype_t sk_colortype_get_default_8888();
51 sk_colortype_t colorType;
52 sk_alphatype_t alphaType;
62 typedef struct sk_path_t sk_path_t;
64 sk_path_t* sk_path_new();
65 void sk_path_delete(sk_path_t*);
66 void sk_path_move_to(sk_path_t*, float x, float y);
67 void sk_path_line_to(sk_path_t*, float x, float y);
68 void sk_path_quad_to(sk_path_t*, float x0, float y0, float x1, float y1);
69 void sk_path_close(sk_path_t*);
71 typedef struct sk_paint_t sk_paint_t;
73 sk_paint_t* sk_paint_new();
74 void sk_paint_delete(sk_paint_t*);
75 bool sk_paint_is_antialias(const sk_paint_t*);
76 void sk_paint_set_antialias(sk_paint_t*, bool);
77 sk_color_t sk_paint_get_color(const sk_paint_t*);
78 void sk_paint_set_color(sk_paint_t*, sk_color_t);
80 typedef struct sk_canvas_t sk_canvas_t;
81 typedef struct sk_image_t sk_image_t;
83 void sk_canvas_save(sk_canvas_t*);
84 void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
85 void sk_canvas_restore(sk_canvas_t*);
87 void sk_canvas_translate(sk_canvas_t*, float dx, float dy);
88 void sk_canvas_scale(sk_canvas_t*, float sx, float sy);
90 void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*);
91 void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
92 void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
93 void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*);
94 void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*, float x, float y, const sk_paint_t*);
97 * Return a new image that has made a copy of the provided pixels, or NULL on failure.
98 * Balance with a call to sk_image_unref().
100 sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t*, const void* pixels, size_t rowBytes);
101 void sk_image_ref(const sk_image_t*);
102 void sk_image_unref(const sk_image_t*);
103 int sk_image_get_width(const sk_image_t*);
104 int sk_image_get_height(const sk_image_t*);
105 uint32_t sk_image_get_unique_id(const sk_image_t*);
107 typedef struct sk_surface_t sk_surface_t;
109 sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t*);
110 sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t*, void* pixels, size_t rowBytes);
111 void sk_surface_delete(sk_surface_t*);
114 * Return the canvas associated with this surface. Note: the canvas is owned by the surface,
115 * so the returned object is only valid while the owning surface is valid.
117 sk_canvas_t* sk_surface_get_canvas(sk_surface_t*);
118 sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*);
122 void sk_test_capi(SkCanvas*);