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

Unified Diff: src/core/SkPictureShader.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: 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: src/core/SkPictureShader.cpp
diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp
index 3919471b1bd43178f571fb5adb4a5391abb0d9d0..cc1a7b3af74ba1c43a77277b2765716e21d42a41 100644
--- a/src/core/SkPictureShader.cpp
+++ b/src/core/SkPictureShader.cpp
@@ -102,12 +102,12 @@ SkPictureShader::SkPictureShader(const SkPicture* picture, TileMode tmx, TileMod
, fTmy(tmy) {
}
-SkShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx, TileMode tmy,
- const SkMatrix* localMatrix, const SkRect* tile) {
+sk_sp<SkShader> SkPictureShader::Make(const SkPicture* picture, TileMode tmx, TileMode tmy,
+ const SkMatrix* localMatrix, const SkRect* tile) {
if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty())) {
- return SkShader::CreateEmptyShader();
+ return SkShader::MakeEmptyShader();
}
- return new SkPictureShader(picture, tmx, tmy, localMatrix, tile);
+ return sk_sp<SkShader>(new SkPictureShader(picture, tmx, tmy, localMatrix, tile));
}
SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) {
@@ -136,7 +136,7 @@ SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) {
picture.reset(SkPicture::CreateFromBuffer(buffer));
}
}
- return SkPictureShader::Create(picture, mx, my, &lm, &tile);
+ return SkPictureShader::Make(picture, mx, my, &lm, &tile).release();
}
void SkPictureShader::flatten(SkWriteBuffer& buffer) const {
@@ -155,8 +155,8 @@ void SkPictureShader::flatten(SkWriteBuffer& buffer) const {
}
}
-SkShader* SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkMatrix* localM,
- const int maxTextureSize) const {
+sk_sp<SkShader> SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkMatrix* localM,
+ const int maxTextureSize) const {
SkASSERT(fPicture && !fPicture->cullRect().isEmpty());
SkMatrix m;
@@ -203,7 +203,7 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkM
const SkISize tileSize = scaledSize.toCeil();
#endif
if (tileSize.isEmpty()) {
- return SkShader::CreateEmptyShader();
+ return SkShader::MakeEmptyShader();
}
// The actual scale, compensating for rounding & clamping.
@@ -238,7 +238,7 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& viewMatrix, const SkM
tileInfo.getSafeSize(tileInfo.minRowBytes())));
}
- return tileShader.detach();
+ return sk_sp<SkShader>(tileShader.detach());
}
size_t SkPictureShader::onContextSize(const ContextRec&) const {
@@ -246,8 +246,8 @@ size_t SkPictureShader::onContextSize(const ContextRec&) const {
}
SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void* storage) const {
- SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(*rec.fMatrix, rec.fLocalMatrix));
- if (nullptr == bitmapShader.get()) {
+ sk_sp<SkShader> bitmapShader(this->refBitmapShader(*rec.fMatrix, rec.fLocalMatrix));
+ if (!bitmapShader) {
return nullptr;
}
return PictureShaderContext::Create(storage, *this, rec, bitmapShader);
@@ -256,7 +256,8 @@ SkShader::Context* SkPictureShader::onCreateContext(const ContextRec& rec, void*
/////////////////////////////////////////////////////////////////////////////////////////
SkShader::Context* SkPictureShader::PictureShaderContext::Create(void* storage,
- const SkPictureShader& shader, const ContextRec& rec, SkShader* bitmapShader) {
+ const SkPictureShader& shader, const ContextRec& rec,
+ sk_sp<SkShader> bitmapShader) {
PictureShaderContext* ctx = new (storage) PictureShaderContext(shader, rec, bitmapShader);
f(malita) 2016/03/08 15:50:35 std::move(bitmapShader)
if (nullptr == ctx->fBitmapShaderContext) {
ctx->~PictureShaderContext();
@@ -266,9 +267,9 @@ SkShader::Context* SkPictureShader::PictureShaderContext::Create(void* storage,
}
SkPictureShader::PictureShaderContext::PictureShaderContext(
- const SkPictureShader& shader, const ContextRec& rec, SkShader* bitmapShader)
+ const SkPictureShader& shader, const ContextRec& rec, sk_sp<SkShader> bitmapShader)
: INHERITED(shader, rec)
- , fBitmapShader(SkRef(bitmapShader))
+ , fBitmapShader(bitmapShader)
f(malita) 2016/03/08 15:50:35 ditto
reed1 2016/03/08 20:17:15 Done, but I think I had to change the subsequent r
{
fBitmapShaderContextStorage = sk_malloc_throw(bitmapShader->contextSize(rec));
fBitmapShaderContext = bitmapShader->createContext(rec, fBitmapShaderContextStorage);
@@ -325,7 +326,7 @@ const GrFragmentProcessor* SkPictureShader::asFragmentProcessor(
if (context) {
maxTextureSize = context->caps()->maxTextureSize();
}
- SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix, maxTextureSize));
+ sk_sp<SkShader> bitmapShader(this->refBitmapShader(viewM, localMatrix, maxTextureSize));
if (!bitmapShader) {
return nullptr;
}
« src/core/SkDraw.cpp ('K') | « src/core/SkPictureShader.h ('k') | src/core/SkReadBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698