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

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: partial update of skia call-sites 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
Index: include/core/SkShader.h
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index 828467fec237ee07e8d086945d85049827e6c55f..5d90004fa65f647065fcb03abbb46357f39c9f9e 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,15 +337,35 @@ 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
mtklein 2016/03/08 14:49:11 Wanna make it one more step general to cover all C
reed1 2016/03/08 15:15:19 Could. My thought had been that the effort was so
+ static SkShader* CreateEmptyShader() { return MakeEmptyShader().release(); }
+ static SkShader* CreateColorShader(SkColor c) { return MakeColorShader(c).release(); }
+ static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode::Mode mode) {
+ return MakeComposeShader(dst, src, mode).release();
+ }
+ static SkShader* CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode* xfer) {
+ return MakeComposeShader(dst, src, xfer).release();
+ }
+ static SkShader* CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix = nullptr) {
+ return MakeBitmapShader(src, tmx, tmy, localMatrix).release();
+ }
+ static SkShader* CreatePictureShader(const SkPicture* src, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix, const SkRect* tile) {
+ return MakePictureShader(src, tmx, tmy, localMatrix, tile).release();
+ }
+#endif
/**
* Create a new compose shader, given shaders dst, src, and a combining xfermode mode.
@@ -353,7 +375,8 @@ public:
* Ownership of the shaders, and the xfermode if not null, is not transfered, so the caller
f(malita) 2016/03/08 15:50:35 Is the ownership comment still useful?
reed1 2016/03/08 20:17:15 Nope. Will remove.
* is still responsible for managing its reference-count for those objects.
*/
- 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 +392,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 +411,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(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

Powered by Google App Engine
This is Rietveld 408576698