Home | History | Annotate | Download | only in c
      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  */
      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 
     26 #ifndef SK_API
     27 #define SK_API
     28 #endif
     29 
     30 ///////////////////////////////////////////////////////////////////////////////////////
     31 
     32 SK_C_PLUS_PLUS_BEGIN_GUARD
     33 
     34 typedef uint32_t sk_color_t;
     35 
     36 /* This macro assumes all arguments are >=0 and <=255. */
     37 #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 
     43 typedef 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 
     50 typedef enum {
     51     OPAQUE_SK_ALPHATYPE,
     52     PREMUL_SK_ALPHATYPE,
     53     UNPREMUL_SK_ALPHATYPE,
     54 } sk_alphatype_t;
     55 
     56 typedef enum {
     57     INTERSECT_SK_CLIPTYPE,
     58     DIFFERENCE_SK_CLIPTYPE,
     59 } sk_cliptype_t;
     60 
     61 typedef 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 
     69 /**
     70     Return the default sk_colortype_t; this is operating-system dependent.
     71 */
     72 SK_API sk_colortype_t sk_colortype_get_default_8888();
     73 
     74 typedef struct {
     75     int32_t         width;
     76     int32_t         height;
     77     sk_colortype_t  colorType;
     78     sk_alphatype_t  alphaType;
     79 } sk_imageinfo_t;
     80 
     81 typedef struct {
     82     sk_pixelgeometry_t pixelGeometry;
     83 } sk_surfaceprops_t;
     84 
     85 typedef struct {
     86     float   x;
     87     float   y;
     88 } sk_point_t;
     89 
     90 typedef struct {
     91     int32_t left;
     92     int32_t top;
     93     int32_t right;
     94     int32_t bottom;
     95 } sk_irect_t;
     96 
     97 typedef struct {
     98     float   left;
     99     float   top;
    100     float   right;
    101     float   bottom;
    102 } sk_rect_t;
    103 
    104 typedef struct {
    105     float   mat[9];
    106 } sk_matrix_t;
    107 
    108 /**
    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 */
    113 typedef struct sk_canvas_t sk_canvas_t;
    114 /**
    115     A sk_data_ holds an immutable data buffer.
    116 */
    117 typedef struct sk_data_t sk_data_t;
    118 /**
    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 */
    124 typedef struct sk_image_t sk_image_t;
    125 /**
    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  */
    133 typedef struct sk_maskfilter_t sk_maskfilter_t;
    134 /**
    135     A sk_paint_t holds the style and color information about how to
    136     draw geometries, text and bitmaps.
    137 */
    138 typedef struct sk_paint_t sk_paint_t;
    139 /**
    140     A sk_path_t encapsulates compound (multiple contour) geometric
    141     paths consisting of straight line segments, quadratic curves, and
    142     cubic curves.
    143 */
    144 typedef struct sk_path_t sk_path_t;
    145 /**
    146     A sk_picture_t holds recorded canvas drawing commands to be played
    147     back at a later time.
    148 */
    149 typedef struct sk_picture_t sk_picture_t;
    150 /**
    151     A sk_picture_recorder_t holds a sk_canvas_t that records commands
    152     to create a sk_picture_t.
    153 */
    154 typedef struct sk_picture_recorder_t sk_picture_recorder_t;
    155 /**
    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 */
    161 typedef struct sk_shader_t sk_shader_t;
    162 /**
    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 */
    167 typedef struct sk_surface_t sk_surface_t;
    168 
    169 typedef 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 
    201 //////////////////////////////////////////////////////////////////////////////////////////
    202 
    203 SK_C_PLUS_PLUS_END_GUARD
    204 
    205 #endif
    206