| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL | 8 // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL |
| 9 // DO NOT USE -- FOR INTERNAL TESTING ONLY | 9 // DO NOT USE -- FOR INTERNAL TESTING ONLY |
| 10 | 10 |
| 11 #ifndef sk_types_DEFINED | 11 #ifndef sk_surface_DEFINED |
| 12 #define sk_types_DEFINED | 12 #define sk_surface_DEFINED |
| 13 | 13 |
| 14 #include <stdint.h> | 14 #include "sk_types.h" |
| 15 #include <stddef.h> | |
| 16 | 15 |
| 17 #ifndef __cplusplus | 16 SK_C_PLUS_PLUS_BEGIN_GUARD |
| 18 #include <stdbool.h> | |
| 19 #endif | |
| 20 | |
| 21 #ifdef __cplusplus | |
| 22 extern "C" { | |
| 23 #endif | |
| 24 | |
| 25 typedef uint32_t sk_color_t; | |
| 26 | |
| 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) | |
| 32 | |
| 33 typedef enum { | |
| 34 UNKNOWN_SK_COLORTYPE, | |
| 35 RGBA_8888_SK_COLORTYPE, | |
| 36 BGRA_8888_SK_COLORTYPE, | |
| 37 ALPHA_8_SK_COLORTYPE, | |
| 38 } sk_colortype_t; | |
| 39 | |
| 40 typedef enum { | |
| 41 OPAQUE_SK_ALPHATYPE, | |
| 42 PREMUL_SK_ALPHATYPE, | |
| 43 UNPREMUL_SK_ALPHATYPE, | |
| 44 } sk_alphatype_t; | |
| 45 | |
| 46 sk_colortype_t sk_colortype_get_default_8888(); | |
| 47 | |
| 48 typedef struct { | |
| 49 int32_t width; | |
| 50 int32_t height; | |
| 51 sk_colortype_t colorType; | |
| 52 sk_alphatype_t alphaType; | |
| 53 } sk_imageinfo_t; | |
| 54 | |
| 55 typedef struct { | |
| 56 float left; | |
| 57 float top; | |
| 58 float right; | |
| 59 float bottom; | |
| 60 } sk_rect_t; | |
| 61 | |
| 62 typedef struct sk_path_t sk_path_t; | |
| 63 | |
| 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*); | |
| 70 | |
| 71 typedef struct sk_paint_t sk_paint_t; | |
| 72 | |
| 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); | |
| 79 | |
| 80 typedef struct sk_canvas_t sk_canvas_t; | |
| 81 typedef struct sk_image_t sk_image_t; | |
| 82 | |
| 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*); | |
| 86 | |
| 87 void sk_canvas_translate(sk_canvas_t*, float dx, float dy); | |
| 88 void sk_canvas_scale(sk_canvas_t*, float sx, float sy); | |
| 89 | |
| 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, con
st sk_paint_t*); | |
| 95 | |
| 96 /** | |
| 97 * Return a new image that has made a copy of the provided pixels, or NULL on f
ailure. | |
| 98 * Balance with a call to sk_image_unref(). | |
| 99 */ | |
| 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*); | |
| 106 | |
| 107 typedef struct sk_surface_t sk_surface_t; | |
| 108 | 17 |
| 109 sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t*); | 18 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); | 19 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*); | 20 void sk_surface_delete(sk_surface_t*); |
| 112 | 21 |
| 113 /** | 22 /** |
| 114 * Return the canvas associated with this surface. Note: the canvas is owned by
the surface, | 23 * 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. | 24 * so the returned object is only valid while the owning surface is valid. |
| 116 */ | 25 */ |
| 117 sk_canvas_t* sk_surface_get_canvas(sk_surface_t*); | 26 sk_canvas_t* sk_surface_get_canvas(sk_surface_t*); |
| 27 |
| 28 /** |
| 29 * Call sk_image_unref() when the returned image is no longer used. |
| 30 */ |
| 118 sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*); | 31 sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*); |
| 119 | 32 |
| 120 #ifdef __cplusplus | 33 #ifdef __cplusplus |
| 121 class SkCanvas; | 34 class SkCanvas; |
| 122 void sk_test_capi(SkCanvas*); | 35 void sk_test_capi(SkCanvas*); |
| 123 } | |
| 124 #endif | 36 #endif |
| 125 | 37 |
| 38 SK_C_PLUS_PLUS_END_GUARD |
| 39 |
| 126 #endif | 40 #endif |
| OLD | NEW |