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

Unified Diff: include/core/SkShader.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 | « gm/pixelsnap.cpp ('k') | include/effects/SkGradientShader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkShader.h
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 828467fec237ee07e8d086945d85049827e6c55f..3e4093645cc2f6ddc301171fc1021f0978293b1a 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -23,6 +23,8 @@ class SkXfermode;
class GrContext;
class GrFragmentProcessor;
+#define SK_SUPPORT_LEGACY_CREATESHADER_PTR
+
/** \class SkShader
*
* Shaders specify the source color(s) for what is being drawn. If a paint
@@ -335,25 +337,39 @@ public:
/**
* Call this to create a new "empty" shader, that will not draw anything.
*/
- static SkShader* CreateEmptyShader();
+ static sk_sp<SkShader> MakeEmptyShader();
/**
* Call this to create a new shader that just draws the specified color. This should always
* draw the same as a paint with this color (and no shader).
*/
- static SkShader* CreateColorShader(SkColor);
+ static sk_sp<SkShader> MakeColorShader(SkColor);
+
+ static sk_sp<SkShader> MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader> src,
+ SkXfermode::Mode);
- static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode::Mode);
+#ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR
+ static SkShader* CreateEmptyShader() { return MakeEmptyShader().release(); }
+ static SkShader* CreateColorShader(SkColor c) { return MakeColorShader(c).release(); }
+ static SkShader* CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix = nullptr) {
+ return MakeBitmapShader(src, tmx, tmy, localMatrix).release();
+ }
+ static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode::Mode mode);
+ static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode* xfer);
+ static SkShader* CreatePictureShader(const SkPicture* src, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix, const SkRect* tile);
+#endif
/**
* Create a new compose shader, given shaders dst, src, and a combining xfermode mode.
* The xfermode is called with the output of the two shaders, and its output is returned.
* If xfer is null, SkXfermode::kSrcOver_Mode is assumed.
*
- * Ownership of the shaders, and the xfermode if not null, is not transfered, so the caller
- * is still responsible for managing its reference-count for those objects.
+ * The caller is responsible for managing its reference-count for the xfer (if not null).
*/
- static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode* xfer);
+ static sk_sp<SkShader> MakeComposeShader(sk_sp<SkShader> dst, sk_sp<SkShader> src,
+ SkXfermode* xfer);
/** Call this to create a new shader that will draw with the specified bitmap.
*
@@ -369,9 +385,8 @@ public:
* @param tmy The tiling mode to use when sampling the bitmap in the y-direction.
* @return Returns a new shader object. Note: this function never returns null.
*/
- static SkShader* CreateBitmapShader(const SkBitmap& src,
- TileMode tmx, TileMode tmy,
- const SkMatrix* localMatrix = NULL);
+ static sk_sp<SkShader> MakeBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix = nullptr);
// NOTE: You can create an SkImage Shader with SkImage::newShader().
@@ -389,10 +404,8 @@ public:
* bounds.
* @return Returns a new shader object. Note: this function never returns null.
*/
- static SkShader* CreatePictureShader(const SkPicture* src,
- TileMode tmx, TileMode tmy,
- const SkMatrix* localMatrix,
- const SkRect* tile);
+ static sk_sp<SkShader> MakePictureShader(sk_sp<const SkPicture> src, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix, const SkRect* tile);
/**
* If this shader can be represented by another shader + a localMatrix, return that shader
« no previous file with comments | « gm/pixelsnap.cpp ('k') | include/effects/SkGradientShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698