Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: include/effects/SkGradientShader.h

Issue 1772463002: use Make instead of Create to return a shared shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkShader.h ('k') | samplecode/PerlinPatch.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/effects/SkGradientShader.h
diff --git a/include/effects/SkGradientShader.h b/include/effects/SkGradientShader.h
index ae11e2dafd1fb81f0580f8e6d71c2d2d56d93fac..e474f38a4e2e0227cfa1d8bdc538a56ce2d09a01 100644
--- a/include/effects/SkGradientShader.h
+++ b/include/effects/SkGradientShader.h
@@ -42,15 +42,14 @@ public:
@param count Must be >=2. The number of colors (and pos if not NULL) entries.
@param mode The tiling mode
*/
- static SkShader* CreateLinear(const SkPoint pts[2],
- const SkColor colors[], const SkScalar pos[], int count,
- SkShader::TileMode mode,
- uint32_t flags, const SkMatrix* localMatrix);
-
- static SkShader* CreateLinear(const SkPoint pts[2],
- const SkColor colors[], const SkScalar pos[], int count,
- SkShader::TileMode mode) {
- return CreateLinear(pts, colors, pos, count, mode, 0, NULL);
+ static sk_sp<SkShader> MakeLinear(const SkPoint pts[2],
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeLinear(const SkPoint pts[2],
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode) {
+ return MakeLinear(pts, colors, pos, count, mode, 0, NULL);
}
/** Returns a shader that generates a radial gradient given the center and radius.
@@ -69,15 +68,14 @@ public:
@param count Must be >= 2. The number of colors (and pos if not NULL) entries
@param mode The tiling mode
*/
- static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
- const SkColor colors[], const SkScalar pos[], int count,
- SkShader::TileMode mode,
- uint32_t flags, const SkMatrix* localMatrix);
-
- static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
- const SkColor colors[], const SkScalar pos[], int count,
- SkShader::TileMode mode) {
- return CreateRadial(center, radius, colors, pos, count, mode, 0, NULL);
+ static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius,
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeRadial(const SkPoint& center, SkScalar radius,
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode) {
+ return MakeRadial(center, radius, colors, pos, count, mode, 0, NULL);
}
/**
@@ -86,18 +84,17 @@ public:
* two circles according to the following HTML spec.
* http://dev.w3.org/html5/2dcontext/#dom-context-2d-createradialgradient
*/
- static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startRadius,
- const SkPoint& end, SkScalar endRadius,
- const SkColor colors[], const SkScalar pos[], int count,
- SkShader::TileMode mode,
- uint32_t flags, const SkMatrix* localMatrix);
-
- static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startRadius,
- const SkPoint& end, SkScalar endRadius,
- const SkColor colors[], const SkScalar pos[], int count,
- SkShader::TileMode mode) {
- return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
- 0, NULL);
+ static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor colors[], const SkScalar pos[],
+ int count, SkShader::TileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeTwoPointConical(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor colors[], const SkScalar pos[],
+ int count, SkShader::TileMode mode) {
+ return MakeTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
+ 0, NULL);
}
/** Returns a shader that generates a sweep gradient given a center.
@@ -115,14 +112,67 @@ public:
intermediate values must be strictly increasing.
@param count Must be >= 2. The number of colors (and pos if not NULL) entries
*/
+ static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
+ const SkColor colors[], const SkScalar pos[], int count,
+ uint32_t flags, const SkMatrix* localMatrix);
+ static sk_sp<SkShader> MakeSweep(SkScalar cx, SkScalar cy,
+ const SkColor colors[], const SkScalar pos[], int count) {
+ return MakeSweep(cx, cy, colors, pos, count, 0, NULL);
+ }
+
+#ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR
+ static SkShader* CreateLinear(const SkPoint pts[2],
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix) {
+ return MakeLinear(pts, colors, pos, count, mode, flags, localMatrix).release();
+ }
+ static SkShader* CreateLinear(const SkPoint pts[2],
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode) {
+ return CreateLinear(pts, colors, pos, count, mode, 0, NULL);
+ }
+
+ static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix) {
+ return MakeRadial(center, radius, colors, pos, count, mode, flags, localMatrix).release();
+ }
+
+ static SkShader* CreateRadial(const SkPoint& center, SkScalar radius,
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode) {
+ return CreateRadial(center, radius, colors, pos, count, mode, 0, NULL);
+ }
+
+ static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode,
+ uint32_t flags, const SkMatrix* localMatrix) {
+ return MakeTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
+ flags, localMatrix).release();
+ }
+ static SkShader* CreateTwoPointConical(const SkPoint& start, SkScalar startRadius,
+ const SkPoint& end, SkScalar endRadius,
+ const SkColor colors[], const SkScalar pos[], int count,
+ SkShader::TileMode mode) {
+ return CreateTwoPointConical(start, startRadius, end, endRadius, colors, pos, count, mode,
+ 0, NULL);
+ }
+
static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
const SkColor colors[], const SkScalar pos[], int count,
- uint32_t flags, const SkMatrix* localMatrix);
-
+ uint32_t flags, const SkMatrix* localMatrix) {
+ return MakeSweep(cx, cy, colors, pos, count, flags, localMatrix).release();
+ }
static SkShader* CreateSweep(SkScalar cx, SkScalar cy,
const SkColor colors[], const SkScalar pos[], int count) {
return CreateSweep(cx, cy, colors, pos, count, 0, NULL);
}
+#endif
+
SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
};
« no previous file with comments | « include/core/SkShader.h ('k') | samplecode/PerlinPatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698