Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkGradientShader.h
1 /*
2  * Copyright 2006 The Android Open Source Project
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 #ifndef SkGradientShader_DEFINED
9 #define SkGradientShader_DEFINED
10 
11 #include "SkShader.h"
12 
18 class SK_API SkGradientShader {
19 public:
20  enum Flags {
26  kInterpolateColorsInPremul_Flag = 1 << 0,
27  };
28 
45  static sk_sp<SkShader> MakeLinear(const SkPoint pts[2],
46  const SkColor colors[], const SkScalar pos[], int count,
47  SkShader::TileMode mode,
48  uint32_t flags, const SkMatrix* localMatrix);
49  static sk_sp<SkShader> MakeLinear(const SkPoint pts[2],
50  const SkColor colors[], const SkScalar pos[], int count,
51  SkShader::TileMode mode) {
52  return MakeLinear(pts, colors, pos, count, mode, 0, NULL);
53  }
54 
71  static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius,
72  const SkColor colors[], const SkScalar pos[], int count,
73  SkShader::TileMode mode,
74  uint32_t flags, const SkMatrix* localMatrix);
75  static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius,
76  const SkColor colors[], const SkScalar pos[], int count,
77  SkShader::TileMode mode) {
78  return MakeRadial(center, radius, colors, pos, count, mode, 0, NULL);
79  }
80 
87  static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar startRadius,
88  const SkPoint& end, SkScalar endRadius,
89  const SkColor colors[], const SkScalar pos[],
90  int count, SkShader::TileMode mode,
91  uint32_t flags, const SkMatrix* localMatrix);
92  static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar startRadius,
93  const SkPoint& end, SkScalar endRadius,
94  const SkColor colors[], const SkScalar pos[],
95  int count, SkShader::TileMode mode) {
96  return MakeTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
97  0, NULL);
98  }
99 
115  static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
116  const SkColor colors[], const SkScalar pos[], int count,
117  uint32_t flags, const SkMatrix* localMatrix);
118  static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
119  const SkColor colors[], const SkScalar pos[], int count) {
120  return MakeSweep(cx, cy, colors, pos, count, 0, NULL);
121  }
122 
123 #ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR
124  static SkShader* CreateLinear(const SkPoint pts[2],
125  const SkColor colors[], const SkScalar pos[], int count,
126  SkShader::TileMode mode,
127  uint32_t flags, const SkMatrix* localMatrix) {
128  return MakeLinear(pts, colors, pos, count, mode, flags, localMatrix).release();
129  }
130  static SkShader* CreateLinear(const SkPoint pts[2],
131  const SkColor colors[], const SkScalar pos[], int count,
132  SkShader::TileMode mode) {
133  return CreateLinear(pts, colors, pos, count, mode, 0, NULL);
134  }
135 
136  static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
137  const SkColor colors[], const SkScalar pos[], int count,
138  SkShader::TileMode mode,
139  uint32_t flags, const SkMatrix* localMatrix) {
140  return MakeRadial(center, radius, colors, pos, count, mode, flags, localMatrix).release();
141  }
142 
143  static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
144  const SkColor colors[], const SkScalar pos[], int count,
145  SkShader::TileMode mode) {
146  return CreateRadial(center, radius, colors, pos, count, mode, 0, NULL);
147  }
148 
149  static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startRadius,
150  const SkPoint& end, SkScalar endRadius,
151  const SkColor colors[], const SkScalar pos[], int count,
152  SkShader::TileMode mode,
153  uint32_t flags, const SkMatrix* localMatrix) {
154  return MakeTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
155  flags, localMatrix).release();
156  }
157  static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startRadius,
158  const SkPoint& end, SkScalar endRadius,
159  const SkColor colors[], const SkScalar pos[], int count,
160  SkShader::TileMode mode) {
161  return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
162  0, NULL);
163  }
164 
165  static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
166  const SkColor colors[], const SkScalar pos[], int count,
167  uint32_t flags, const SkMatrix* localMatrix) {
168  return MakeSweep(cx, cy, colors, pos, count, flags, localMatrix).release();
169  }
170  static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
171  const SkColor colors[], const SkScalar pos[], int count) {
172  return CreateSweep(cx, cy, colors, pos, count, 0, NULL);
173  }
174 #endif
175 
176 
177  SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
178 };
179 
180 #endif
Shaders specify the source color(s) for what is being drawn.
Definition: SkShader.h:38
Definition: SkPoint.h:156
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:26
Flags
Definition: SkGradientShader.h:20
SkGradientShader hosts factories for creating subclasses of SkShader that render linear and radial gr...
Definition: SkGradientShader.h:18
uint32_t SkColor
32 bit ARGB color value, not premultiplied.
Definition: SkColor.h:28
TileMode
Definition: SkShader.h:51