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

Unified Diff: src/core/SkShader.cpp

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 | « src/core/SkReadBuffer.h ('k') | src/effects/SkTileImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkShader.cpp
diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp
index 75f527bff3f1d6f3db531c2dd941f4e9c8ff2a77..7b322fb6272e0f9017005191f3a3a54f235549a5 100644
--- a/src/core/SkShader.cpp
+++ b/src/core/SkShader.cpp
@@ -229,18 +229,18 @@ SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const {
return nullptr;
}
-SkShader* SkShader::CreateEmptyShader() { return new SkEmptyShader; }
+sk_sp<SkShader> SkShader::MakeEmptyShader() { return sk_make_sp<SkEmptyShader>(); }
-SkShader* SkShader::CreateColorShader(SkColor color) { return new SkColorShader(color); }
+sk_sp<SkShader> SkShader::MakeColorShader(SkColor color) { return sk_make_sp<SkColorShader>(color); }
-SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy,
- const SkMatrix* localMatrix) {
- return SkCreateBitmapShader(src, tmx, tmy, localMatrix, nullptr);
+sk_sp<SkShader> SkShader::MakeBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix) {
+ return SkMakeBitmapShader(src, tmx, tmy, localMatrix, nullptr);
}
-SkShader* SkShader::CreatePictureShader(const SkPicture* src, TileMode tmx, TileMode tmy,
- const SkMatrix* localMatrix, const SkRect* tile) {
- return SkPictureShader::Create(src, tmx, tmy, localMatrix, tile);
+sk_sp<SkShader> SkShader::MakePictureShader(sk_sp<const SkPicture> src, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix, const SkRect* tile) {
+ return SkPictureShader::Make(std::move(src), tmx, tmy, localMatrix, tile);
}
#ifndef SK_IGNORE_TO_STRING
@@ -362,7 +362,7 @@ void SkColorShader::toString(SkString* str) const {
///////////////////////////////////////////////////////////////////////////////
SkFlattenable* SkEmptyShader::CreateProc(SkReadBuffer&) {
- return SkShader::CreateEmptyShader();
+ return SkShader::MakeEmptyShader().release();
}
#ifndef SK_IGNORE_TO_STRING
@@ -376,3 +376,18 @@ void SkEmptyShader::toString(SkString* str) const {
str->append(")");
}
#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR
+SkShader* SkShader::CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode::Mode mode) {
+ return MakeComposeShader(sk_ref_sp(dst), sk_ref_sp(src), mode).release();
+}
+SkShader* SkShader::CreateComposeShader(SkShader* dst, SkShader* src, SkXfermode* xfer) {
+ return MakeComposeShader(sk_ref_sp(dst), sk_ref_sp(src), xfer).release();
+}
+SkShader* SkShader::CreatePictureShader(const SkPicture* src, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix, const SkRect* tile) {
+ return MakePictureShader(sk_ref_sp(src), tmx, tmy, localMatrix, tile).release();
+}
+#endif
« no previous file with comments | « src/core/SkReadBuffer.h ('k') | src/effects/SkTileImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698