diff options
author | reed <reed@chromium.org> | 2014-11-17 06:15:42 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-17 06:15:42 -0800 |
commit | 73c250112026b84b38e6dc8c93e0cfc31918dc9d (patch) | |
tree | fc1f9610535d407c8d2d262549337b0c9c72a558 /include/c | |
parent | 1379b87ae463246e586b869f7457ce5befc4472c (diff) |
separate c headers
BUG=skia:
Review URL: https://codereview.chromium.org/728323002
Diffstat (limited to 'include/c')
-rw-r--r-- | include/c/sk_canvas.h | 33 | ||||
-rw-r--r-- | include/c/sk_image.h | 31 | ||||
-rw-r--r-- | include/c/sk_paint.h | 27 | ||||
-rw-r--r-- | include/c/sk_path.h | 45 | ||||
-rw-r--r-- | include/c/sk_surface.h | 106 | ||||
-rw-r--r-- | include/c/sk_types.h | 82 |
6 files changed, 228 insertions, 96 deletions
diff --git a/include/c/sk_canvas.h b/include/c/sk_canvas.h new file mode 100644 index 0000000000..a99d1b8662 --- /dev/null +++ b/include/c/sk_canvas.h @@ -0,0 +1,33 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL +// DO NOT USE -- FOR INTERNAL TESTING ONLY + +#ifndef sk_canvas_DEFINED +#define sk_canvas_DEFINED + +#include "sk_types.h" + +SK_C_PLUS_PLUS_BEGIN_GUARD + +void sk_canvas_save(sk_canvas_t*); +void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); +void sk_canvas_restore(sk_canvas_t*); + +void sk_canvas_translate(sk_canvas_t*, float dx, float dy); +void sk_canvas_scale(sk_canvas_t*, float sx, float sy); + +void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*); +void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); +void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); +void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*); +void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*, float x, float y, const sk_paint_t*); + +SK_C_PLUS_PLUS_END_GUARD + +#endif diff --git a/include/c/sk_image.h b/include/c/sk_image.h new file mode 100644 index 0000000000..244956399c --- /dev/null +++ b/include/c/sk_image.h @@ -0,0 +1,31 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL +// DO NOT USE -- FOR INTERNAL TESTING ONLY + +#ifndef sk_image_DEFINED +#define sk_image_DEFINED + +#include "sk_types.h" + +SK_C_PLUS_PLUS_BEGIN_GUARD + +/** + * Return a new image that has made a copy of the provided pixels, or NULL on failure. + * Balance with a call to sk_image_unref(). + */ +sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t*, const void* pixels, size_t rowBytes); +void sk_image_ref(const sk_image_t*); +void sk_image_unref(const sk_image_t*); +int sk_image_get_width(const sk_image_t*); +int sk_image_get_height(const sk_image_t*); +uint32_t sk_image_get_unique_id(const sk_image_t*); + +SK_C_PLUS_PLUS_END_GUARD + +#endif diff --git a/include/c/sk_paint.h b/include/c/sk_paint.h new file mode 100644 index 0000000000..840433b1b0 --- /dev/null +++ b/include/c/sk_paint.h @@ -0,0 +1,27 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL +// DO NOT USE -- FOR INTERNAL TESTING ONLY + +#ifndef sk_paint_DEFINED +#define sk_paint_DEFINED + +#include "sk_types.h" + +SK_C_PLUS_PLUS_BEGIN_GUARD + +sk_paint_t* sk_paint_new(); +void sk_paint_delete(sk_paint_t*); +bool sk_paint_is_antialias(const sk_paint_t*); +void sk_paint_set_antialias(sk_paint_t*, bool); +sk_color_t sk_paint_get_color(const sk_paint_t*); +void sk_paint_set_color(sk_paint_t*, sk_color_t); + +SK_C_PLUS_PLUS_END_GUARD + +#endif diff --git a/include/c/sk_path.h b/include/c/sk_path.h new file mode 100644 index 0000000000..801e1480f9 --- /dev/null +++ b/include/c/sk_path.h @@ -0,0 +1,45 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL +// DO NOT USE -- FOR INTERNAL TESTING ONLY + +#ifndef sk_path_DEFINED +#define sk_path_DEFINED + +#include "sk_types.h" + +SK_C_PLUS_PLUS_BEGIN_GUARD + +typedef enum { + CW_SK_PATH_DIRECTION, + CCW_SK_PATH_DIRECTION, +} sk_path_direction_t; + +sk_path_t* sk_path_new(); +void sk_path_delete(sk_path_t*); + +void sk_path_move_to(sk_path_t*, float x, float y); +void sk_path_line_to(sk_path_t*, float x, float y); +void sk_path_quad_to(sk_path_t*, float x0, float y0, float x1, float y1); +void sk_path_conic_to(sk_path_t*, float x0, float y0, float x1, float y1, float w); +void sk_path_cubic_to(sk_path_t*, float x0, float y0, float x1, float y1, float x2, float y2); +void sk_path_close(sk_path_t*); + +void sk_path_add_rect(sk_path_t*, const sk_rect_t*, sk_path_direction_t); +void sk_path_add_oval(sk_path_t*, const sk_rect_t*, sk_path_direction_t); + +/** + * If the path is empty, return false and set the rect parameter to [0, 0, 0, 0]. + * else return true and set the rect parameter to the bounds of the control-points + * of the path. + */ +bool sk_path_get_bounds(const sk_path_t*, sk_rect_t*); + +SK_C_PLUS_PLUS_END_GUARD + +#endif diff --git a/include/c/sk_surface.h b/include/c/sk_surface.h index 5fcf9ddd41..96aa32f974 100644 --- a/include/c/sk_surface.h +++ b/include/c/sk_surface.h @@ -8,103 +8,12 @@ // EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL // DO NOT USE -- FOR INTERNAL TESTING ONLY -#ifndef sk_types_DEFINED -#define sk_types_DEFINED +#ifndef sk_surface_DEFINED +#define sk_surface_DEFINED -#include <stdint.h> -#include <stddef.h> +#include "sk_types.h" -#ifndef __cplusplus -#include <stdbool.h> -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef uint32_t sk_color_t; - -#define sk_color_set_argb(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) -#define sk_color_get_a(c) (((c) >> 24) & 0xFF) -#define sk_color_get_r(c) (((c) >> 16) & 0xFF) -#define sk_color_get_g(c) (((c) >> 8) & 0xFF) -#define sk_color_get_b(c) (((c) >> 0) & 0xFF) - -typedef enum { - UNKNOWN_SK_COLORTYPE, - RGBA_8888_SK_COLORTYPE, - BGRA_8888_SK_COLORTYPE, - ALPHA_8_SK_COLORTYPE, -} sk_colortype_t; - -typedef enum { - OPAQUE_SK_ALPHATYPE, - PREMUL_SK_ALPHATYPE, - UNPREMUL_SK_ALPHATYPE, -} sk_alphatype_t; - -sk_colortype_t sk_colortype_get_default_8888(); - -typedef struct { - int32_t width; - int32_t height; - sk_colortype_t colorType; - sk_alphatype_t alphaType; -} sk_imageinfo_t; - -typedef struct { - float left; - float top; - float right; - float bottom; -} sk_rect_t; - -typedef struct sk_path_t sk_path_t; - -sk_path_t* sk_path_new(); -void sk_path_delete(sk_path_t*); -void sk_path_move_to(sk_path_t*, float x, float y); -void sk_path_line_to(sk_path_t*, float x, float y); -void sk_path_quad_to(sk_path_t*, float x0, float y0, float x1, float y1); -void sk_path_close(sk_path_t*); - -typedef struct sk_paint_t sk_paint_t; - -sk_paint_t* sk_paint_new(); -void sk_paint_delete(sk_paint_t*); -bool sk_paint_is_antialias(const sk_paint_t*); -void sk_paint_set_antialias(sk_paint_t*, bool); -sk_color_t sk_paint_get_color(const sk_paint_t*); -void sk_paint_set_color(sk_paint_t*, sk_color_t); - -typedef struct sk_canvas_t sk_canvas_t; -typedef struct sk_image_t sk_image_t; - -void sk_canvas_save(sk_canvas_t*); -void sk_canvas_save_layer(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); -void sk_canvas_restore(sk_canvas_t*); - -void sk_canvas_translate(sk_canvas_t*, float dx, float dy); -void sk_canvas_scale(sk_canvas_t*, float sx, float sy); - -void sk_canvas_draw_paint(sk_canvas_t*, const sk_paint_t*); -void sk_canvas_draw_rect(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); -void sk_canvas_draw_oval(sk_canvas_t*, const sk_rect_t*, const sk_paint_t*); -void sk_canvas_draw_path(sk_canvas_t*, const sk_path_t*, const sk_paint_t*); -void sk_canvas_draw_image(sk_canvas_t*, const sk_image_t*, float x, float y, const sk_paint_t*); - -/** - * Return a new image that has made a copy of the provided pixels, or NULL on failure. - * Balance with a call to sk_image_unref(). - */ -sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t*, const void* pixels, size_t rowBytes); -void sk_image_ref(const sk_image_t*); -void sk_image_unref(const sk_image_t*); -int sk_image_get_width(const sk_image_t*); -int sk_image_get_height(const sk_image_t*); -uint32_t sk_image_get_unique_id(const sk_image_t*); - -typedef struct sk_surface_t sk_surface_t; +SK_C_PLUS_PLUS_BEGIN_GUARD sk_surface_t* sk_surface_new_raster(const sk_imageinfo_t*); sk_surface_t* sk_surface_new_raster_direct(const sk_imageinfo_t*, void* pixels, size_t rowBytes); @@ -115,12 +24,17 @@ void sk_surface_delete(sk_surface_t*); * so the returned object is only valid while the owning surface is valid. */ sk_canvas_t* sk_surface_get_canvas(sk_surface_t*); + +/** + * Call sk_image_unref() when the returned image is no longer used. + */ sk_image_t* sk_surface_new_image_snapshot(sk_surface_t*); #ifdef __cplusplus class SkCanvas; void sk_test_capi(SkCanvas*); -} #endif +SK_C_PLUS_PLUS_END_GUARD + #endif diff --git a/include/c/sk_types.h b/include/c/sk_types.h new file mode 100644 index 0000000000..71ce219c01 --- /dev/null +++ b/include/c/sk_types.h @@ -0,0 +1,82 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL +// DO NOT USE -- FOR INTERNAL TESTING ONLY + +#ifndef sk_types_DEFINED +#define sk_types_DEFINED + +#include <stdint.h> +#include <stddef.h> + +#ifdef __cplusplus + #define SK_C_PLUS_PLUS_BEGIN_GUARD extern "C" { + #define SK_C_PLUS_PLUS_END_GUARD } +#else + #include <stdbool.h> + #define SK_C_PLUS_PLUS_BEGIN_GUARD + #define SK_C_PLUS_PLUS_END_GUARD +#endif + +/////////////////////////////////////////////////////////////////////////////////////// + +SK_C_PLUS_PLUS_BEGIN_GUARD + +typedef uint32_t sk_color_t; + +#define sk_color_set_argb(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) +#define sk_color_get_a(c) (((c) >> 24) & 0xFF) +#define sk_color_get_r(c) (((c) >> 16) & 0xFF) +#define sk_color_get_g(c) (((c) >> 8) & 0xFF) +#define sk_color_get_b(c) (((c) >> 0) & 0xFF) + +typedef enum { + UNKNOWN_SK_COLORTYPE, + RGBA_8888_SK_COLORTYPE, + BGRA_8888_SK_COLORTYPE, + ALPHA_8_SK_COLORTYPE, +} sk_colortype_t; + +typedef enum { + OPAQUE_SK_ALPHATYPE, + PREMUL_SK_ALPHATYPE, + UNPREMUL_SK_ALPHATYPE, +} sk_alphatype_t; + +sk_colortype_t sk_colortype_get_default_8888(); + +typedef struct { + int32_t width; + int32_t height; + sk_colortype_t colorType; + sk_alphatype_t alphaType; +} sk_imageinfo_t; + +typedef struct { + float left; + float top; + float right; + float bottom; +} sk_rect_t; + +typedef struct sk_canvas_t sk_canvas_t; +typedef struct sk_image_t sk_image_t; +typedef struct sk_paint_t sk_paint_t; +typedef struct sk_path_t sk_path_t; +typedef struct sk_surface_t sk_surface_t; + +////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus + class SkCanvas; + void sk_test_capi(SkCanvas*); +#endif + +SK_C_PLUS_PLUS_END_GUARD + +#endif |