Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: experimental/sk_surface.h

Issue 629903004: implement some so we can test it (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | experimental/sk_surface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /*
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 */
1 7
8 #ifndef sk_types_DEFINED
9 #define sk_types_DEFINED
10
11 #include <stdint.h>
12 #include <stddef.h>
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
2 17
3 typedef uint32_t sk_color_t; 18 typedef uint32_t sk_color_t;
4 19
5 sk_color_t sk_color_set_argb(uint8_t a, uint8_t r, uint8_t g, uint8_t b); 20 #define sk_color_set_argb(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
6 uint8_t sk_color_get_a(sk_color_t); 21 #define sk_color_get_a(c) (((c) >> 24) & 0xFF)
22 #define sk_color_get_r(c) (((c) >> 16) & 0xFF)
23 #define sk_color_get_g(c) (((c) >> 8) & 0xFF)
24 #define sk_color_get_b(c) (((c) >> 0) & 0xFF)
7 25
8 typedef enum { 26 typedef enum {
9 UNKNOWN_SK_COLORTYPE, 27 UNKNOWN_SK_COLORTYPE,
10 RGBA_8888_SK_COLORTYPE, 28 RGBA_8888_SK_COLORTYPE,
11 BGRA_8888_SK_COLORTYPE, 29 BGRA_8888_SK_COLORTYPE,
12 ALPHA_8_SK_COLORTYPE, 30 ALPHA_8_SK_COLORTYPE,
13 } sk_colortype_t; 31 } sk_colortype_t;
14 32
15 typedef struct sk_imageinfo_t { 33 typedef enum {
34 PREMUL_SK_ALPHATYPE,
35 UNPREMUL_SK_ALPHATYPE,
36 } sk_alphatype_t;
37
38 typedef struct {
16 int32_t width; 39 int32_t width;
17 int32_t height; 40 int32_t height;
18 sk_colortype_t colorType; 41 sk_colortype_t colorType;
19 sk_alphatype_t colorType; 42 sk_alphatype_t alphaType;
20 }; 43 } sk_imageinfo_t;
21 44
22 typedef struct sk_rect_t { 45 typedef struct {
23 float left; 46 float left;
24 float top; 47 float top;
25 float right; 48 float right;
26 float bottom; 49 float bottom;
27 }; 50 } sk_rect_t;
28 51
29 typedef struct sk_matrix_t { 52 typedef struct sk_path_t sk_path_t;
30 float mat[9];
31 };
32
33 void sk_matrix_set_identity(sk_matrix_t*);
34
35 typedef struct sk_path_t;
36 53
37 sk_path_t* sk_path_new(); 54 sk_path_t* sk_path_new();
38 void sk_path_move_to(sk_path*, float x, float y); 55 void sk_path_move_to(sk_path_t*, float x, float y);
39 void sk_path_line_to(sk_path*, float x, float y); 56 void sk_path_line_to(sk_path_t*, float x, float y);
40 void sk_path_quad_to(sk_path*, float x0, float y1, float x1, float y1); 57 void sk_path_quad_to(sk_path_t*, float x0, float y0, float x1, float y1);
41 void sk_path_get_bounds(const sk_path_t*, sk_rect_t*); 58 void sk_path_get_bounds(const sk_path_t*, sk_rect_t*);
42 59
43 typedef struct sk_paint_t; 60 typedef struct sk_paint_t sk_paint_t;
44 61
45 sk_paint_t* sk_paint_new(); 62 sk_paint_t* sk_paint_new();
63 void sk_paint_delete(sk_paint_t*);
46 bool sk_paint_is_antialias(sk_paint_t*); 64 bool sk_paint_is_antialias(sk_paint_t*);
47 void sk_paint_set_antialias(sk_paint_t*, bool); 65 void sk_paint_set_antialias(sk_paint_t*, bool);
48 sk_color_t sk_paint_get_color(const sk_paint_t*); 66 sk_color_t sk_paint_get_color(const sk_paint_t*);
49 void sk_paint_set_color(sk_paint_t*, sk_color_t); 67 void sk_paint_set_color(sk_paint_t*, sk_color_t);
50 68
51 typedef struct sk_canvas_t; 69 typedef struct sk_canvas_t sk_canvas_t;
70 typedef struct sk_image_t sk_image_t;
52 71
53 void sk_canvas_save(sk_canvas_t*); 72 void sk_canvas_save(sk_canvas_t*);
54 void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); 73 void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
55 void sk_canvas_restore(sk_canvas_t*); 74 void sk_canvas_restore(sk_canvas_t*);
56 75
57 void sk_canvas_translate(sk_canvas_t*, sk_scalar_t dx, sk_scalar_t dy); 76 void sk_canvas_translate(sk_canvas_t*, float dx, float dy);
58 void sk_canvas_scale(sk_canvas_t*, sk_scalar_t sx, sk_scalar_t sy); 77 void sk_canvas_scale(sk_canvas_t*, float sx, float sy);
59 void sk_canvas_concat(sk_canvas_t*, const sk_matrix_t*);
60 78
61 void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*); 79 void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*);
62 void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); 80 void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
63 void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); 81 void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*);
64 void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*); 82 void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*);
65 void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*, float x, float y, con st sk_paint_t*); 83 void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*, float x, float y, con st sk_paint_t*);
66 84
67 typedef struct sk_image_t; 85 sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t*, const void* pixels, size_t rowBytes);
68 86 void sk_image_ref(const sk_image_t*);
69 sk_image_t* sk_image_new_raster_copy(const sk_image_info_t*, const void* pixels, size_t rowBytes); 87 void sk_image_unref(const sk_image_t*);
70
71 int sk_image_get_width(const sk_image_t*); 88 int sk_image_get_width(const sk_image_t*);
72 int sk_image_get_height(const sk_image_t*); 89 int sk_image_get_height(const sk_image_t*);
73 uint32_t sk_image_get_unique_id(const sk_image_t*); 90 uint32_t sk_image_get_unique_id(const sk_image_t*);
74 91
75 typedef struct sk_surface_t; 92 typedef struct sk_surface_t sk_surface_t;
76 93
77 sk_surface_t* sk_surface_new_raster(const sk_image_info_t*) 94 sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t*);
78 sk_surface_t* sk_surface_new_raster_direct(const sk_image_info_t*, void* pixels, size_t rowBytes); 95 sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t*, void* pixels, size_t rowBytes);
79 void sk_surface_delete(sk_surface_t*); 96 void sk_surface_delete(sk_surface_t*);
80
81 sk_canvas_t* sk_surface_get_canvas(sk_surface_t*); 97 sk_canvas_t* sk_surface_get_canvas(sk_surface_t*);
82 sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*); 98 sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*);
83 99
100 #ifdef __cplusplus
101 class SkCanvas;
102 void sk_test_capi(SkCanvas*);
103 }
104 #endif
105
106 #endif
OLDNEW
« no previous file with comments | « no previous file | experimental/sk_surface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698