sk_shader.h 6.0 KB

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