1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2014 Google Inc.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL
9cb93a386Sopenharmony_ci// DO NOT USE -- FOR INTERNAL TESTING ONLY
10cb93a386Sopenharmony_ci
11cb93a386Sopenharmony_ci#ifndef sk_shader_DEFINED
12cb93a386Sopenharmony_ci#define sk_shader_DEFINED
13cb93a386Sopenharmony_ci
14cb93a386Sopenharmony_ci#include "include/c/sk_types.h"
15cb93a386Sopenharmony_ci
16cb93a386Sopenharmony_ciSK_C_PLUS_PLUS_BEGIN_GUARD
17cb93a386Sopenharmony_ci
18cb93a386Sopenharmony_ciSK_API void sk_shader_ref(sk_shader_t*);
19cb93a386Sopenharmony_ciSK_API void sk_shader_unref(sk_shader_t*);
20cb93a386Sopenharmony_ci
21cb93a386Sopenharmony_citypedef enum {
22cb93a386Sopenharmony_ci    CLAMP_SK_SHADER_TILEMODE,
23cb93a386Sopenharmony_ci    REPEAT_SK_SHADER_TILEMODE,
24cb93a386Sopenharmony_ci    MIRROR_SK_SHADER_TILEMODE,
25cb93a386Sopenharmony_ci} sk_shader_tilemode_t;
26cb93a386Sopenharmony_ci
27cb93a386Sopenharmony_ci/**
28cb93a386Sopenharmony_ci    Returns a shader that generates a linear gradient between the two
29cb93a386Sopenharmony_ci    specified points.
30cb93a386Sopenharmony_ci
31cb93a386Sopenharmony_ci    @param points The start and end points for the gradient.
32cb93a386Sopenharmony_ci    @param colors The array[count] of colors, to be distributed between
33cb93a386Sopenharmony_ci                  the two points
34cb93a386Sopenharmony_ci    @param colorPos May be NULL. array[count] of SkScalars, or NULL, of
35cb93a386Sopenharmony_ci                    the relative position of each corresponding color
36cb93a386Sopenharmony_ci                    in the colors array. If this is NULL, the the
37cb93a386Sopenharmony_ci                    colors are distributed evenly between the start
38cb93a386Sopenharmony_ci                    and end point.  If this is not null, the values
39cb93a386Sopenharmony_ci                    must begin with 0, end with 1.0, and intermediate
40cb93a386Sopenharmony_ci                    values must be strictly increasing.
41cb93a386Sopenharmony_ci    @param colorCount Must be >=2. The number of colors (and pos if not
42cb93a386Sopenharmony_ci                      NULL) entries.
43cb93a386Sopenharmony_ci    @param mode The tiling mode
44cb93a386Sopenharmony_ci*/
45cb93a386Sopenharmony_ciSK_API sk_shader_t* sk_shader_new_linear_gradient(const sk_point_t points[2],
46cb93a386Sopenharmony_ci                                           const sk_color_t colors[],
47cb93a386Sopenharmony_ci                                           const float colorPos[],
48cb93a386Sopenharmony_ci                                           int colorCount,
49cb93a386Sopenharmony_ci                                           sk_shader_tilemode_t tileMode,
50cb93a386Sopenharmony_ci                                           const sk_matrix_t* localMatrix);
51cb93a386Sopenharmony_ci
52cb93a386Sopenharmony_ci
53cb93a386Sopenharmony_ci/**
54cb93a386Sopenharmony_ci    Returns a shader that generates a radial gradient given the center
55cb93a386Sopenharmony_ci    and radius.
56cb93a386Sopenharmony_ci
57cb93a386Sopenharmony_ci    @param center The center of the circle for this gradient
58cb93a386Sopenharmony_ci    @param radius Must be positive. The radius of the circle for this
59cb93a386Sopenharmony_ci                  gradient
60cb93a386Sopenharmony_ci    @param colors The array[count] of colors, to be distributed
61cb93a386Sopenharmony_ci                  between the center and edge of the circle
62cb93a386Sopenharmony_ci    @param colorPos May be NULL. The array[count] of the relative
63cb93a386Sopenharmony_ci                    position of each corresponding color in the colors
64cb93a386Sopenharmony_ci                    array. If this is NULL, the the colors are
65cb93a386Sopenharmony_ci                    distributed evenly between the center and edge of
66cb93a386Sopenharmony_ci                    the circle.  If this is not null, the values must
67cb93a386Sopenharmony_ci                    begin with 0, end with 1.0, and intermediate
68cb93a386Sopenharmony_ci                    values must be strictly increasing.
69cb93a386Sopenharmony_ci    @param count Must be >= 2. The number of colors (and pos if not
70cb93a386Sopenharmony_ci                 NULL) entries
71cb93a386Sopenharmony_ci    @param tileMode The tiling mode
72cb93a386Sopenharmony_ci    @param localMatrix May be NULL
73cb93a386Sopenharmony_ci*/
74cb93a386Sopenharmony_ciSK_API sk_shader_t* sk_shader_new_radial_gradient(const sk_point_t* center,
75cb93a386Sopenharmony_ci                                           float radius,
76cb93a386Sopenharmony_ci                                           const sk_color_t colors[],
77cb93a386Sopenharmony_ci                                           const float colorPos[],
78cb93a386Sopenharmony_ci                                           int colorCount,
79cb93a386Sopenharmony_ci                                           sk_shader_tilemode_t tileMode,
80cb93a386Sopenharmony_ci                                           const sk_matrix_t* localMatrix);
81cb93a386Sopenharmony_ci
82cb93a386Sopenharmony_ci/**
83cb93a386Sopenharmony_ci    Returns a shader that generates a sweep gradient given a center.
84cb93a386Sopenharmony_ci
85cb93a386Sopenharmony_ci    @param center The coordinates of the center of the sweep
86cb93a386Sopenharmony_ci    @param colors The array[count] of colors, to be distributed around
87cb93a386Sopenharmony_ci                  the center.
88cb93a386Sopenharmony_ci    @param colorPos May be NULL. The array[count] of the relative
89cb93a386Sopenharmony_ci                    position of each corresponding color in the colors
90cb93a386Sopenharmony_ci                    array. If this is NULL, the the colors are
91cb93a386Sopenharmony_ci                    distributed evenly between the center and edge of
92cb93a386Sopenharmony_ci                    the circle.  If this is not null, the values must
93cb93a386Sopenharmony_ci                    begin with 0, end with 1.0, and intermediate
94cb93a386Sopenharmony_ci                    values must be strictly increasing.
95cb93a386Sopenharmony_ci    @param colorCount Must be >= 2. The number of colors (and pos if
96cb93a386Sopenharmony_ci                      not NULL) entries
97cb93a386Sopenharmony_ci    @param localMatrix May be NULL
98cb93a386Sopenharmony_ci*/
99cb93a386Sopenharmony_ciSK_API sk_shader_t* sk_shader_new_sweep_gradient(const sk_point_t* center,
100cb93a386Sopenharmony_ci                                          const sk_color_t colors[],
101cb93a386Sopenharmony_ci                                          const float colorPos[],
102cb93a386Sopenharmony_ci                                          int colorCount,
103cb93a386Sopenharmony_ci                                          const sk_matrix_t* localMatrix);
104cb93a386Sopenharmony_ci
105cb93a386Sopenharmony_ci/**
106cb93a386Sopenharmony_ci    Returns a shader that generates a conical gradient given two circles, or
107cb93a386Sopenharmony_ci    returns NULL if the inputs are invalid. The gradient interprets the
108cb93a386Sopenharmony_ci    two circles according to the following HTML spec.
109cb93a386Sopenharmony_ci    http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
110cb93a386Sopenharmony_ci
111cb93a386Sopenharmony_ci    Returns a shader that generates a sweep gradient given a center.
112cb93a386Sopenharmony_ci
113cb93a386Sopenharmony_ci    @param start, startRadius Defines the first circle.
114cb93a386Sopenharmony_ci    @param end, endRadius Defines the first circle.
115cb93a386Sopenharmony_ci    @param colors The array[count] of colors, to be distributed between
116cb93a386Sopenharmony_ci                  the two circles.
117cb93a386Sopenharmony_ci    @param colorPos May be NULL. The array[count] of the relative
118cb93a386Sopenharmony_ci                    position of each corresponding color in the colors
119cb93a386Sopenharmony_ci                    array. If this is NULL, the the colors are
120cb93a386Sopenharmony_ci                    distributed evenly between the two circles.  If
121cb93a386Sopenharmony_ci                    this is not null, the values must begin with 0,
122cb93a386Sopenharmony_ci                    end with 1.0, and intermediate values must be
123cb93a386Sopenharmony_ci                    strictly increasing.
124cb93a386Sopenharmony_ci    @param colorCount Must be >= 2. The number of colors (and pos if
125cb93a386Sopenharmony_ci                      not NULL) entries
126cb93a386Sopenharmony_ci    @param tileMode The tiling mode
127cb93a386Sopenharmony_ci    @param localMatrix May be NULL
128cb93a386Sopenharmony_ci
129cb93a386Sopenharmony_ci*/
130cb93a386Sopenharmony_ciSK_API sk_shader_t* sk_shader_new_two_point_conical_gradient(
131cb93a386Sopenharmony_ci        const sk_point_t* start,
132cb93a386Sopenharmony_ci        float startRadius,
133cb93a386Sopenharmony_ci        const sk_point_t* end,
134cb93a386Sopenharmony_ci        float endRadius,
135cb93a386Sopenharmony_ci        const sk_color_t colors[],
136cb93a386Sopenharmony_ci        const float colorPos[],
137cb93a386Sopenharmony_ci        int colorCount,
138cb93a386Sopenharmony_ci        sk_shader_tilemode_t tileMode,
139cb93a386Sopenharmony_ci        const sk_matrix_t* localMatrix);
140cb93a386Sopenharmony_ci
141cb93a386Sopenharmony_ciSK_C_PLUS_PLUS_END_GUARD
142cb93a386Sopenharmony_ci
143cb93a386Sopenharmony_ci#endif
144