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

Unified Diff: third_party/WebKit/Source/platform/graphics/Image.cpp

Issue 1779833002: Switch Blink SkShader clients to sk_sp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.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
Index: third_party/WebKit/Source/platform/graphics/Image.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Image.cpp b/third_party/WebKit/Source/platform/graphics/Image.cpp
index 5ab1d6f47e714896ef405937e8ceda2110650766..0bb2a7b5a7cfdc4944777e1487ceed970befc92c 100644
--- a/third_party/WebKit/Source/platform/graphics/Image.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Image.cpp
@@ -185,11 +185,11 @@ void Image::drawTiled(GraphicsContext& ctxt, const FloatRect& dstRect, const Flo
namespace {
-PassRefPtr<SkShader> createPatternShader(const SkImage* image, const SkMatrix& shaderMatrix,
+sk_sp<SkShader> createPatternShader(const SkImage* image, const SkMatrix& shaderMatrix,
const SkPaint& paint, const FloatSize& spacing)
{
if (spacing.isZero())
- return adoptRef(image->newShader(SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &shaderMatrix));
+ return sk_sp<SkShader>(image->newShader(SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &shaderMatrix));
reed1 2016/03/09 21:09:06 I will add SkImage::makeShader(...) NOW
f(malita) 2016/03/10 13:57:58 Thanks, done.
// Arbitrary tiling is currently only supported for SkPictureShader - so we use it instead
// of a plain bitmap shader to implement spacing.
@@ -200,10 +200,10 @@ PassRefPtr<SkShader> createPatternShader(const SkImage* image, const SkMatrix& s
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(tileRect);
canvas->drawImage(image, 0, 0, &paint);
- RefPtr<const SkPicture> picture = adoptRef(recorder.endRecordingAsPicture());
+ sk_sp<const SkPicture> picture(recorder.endRecordingAsPicture());
- return adoptRef(SkShader::CreatePictureShader(
- picture.get(), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &shaderMatrix, nullptr));
+ return SkShader::MakePictureShader(
+ std::move(picture), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &shaderMatrix, nullptr);
}
} // anonymous namespace
@@ -249,9 +249,9 @@ void Image::drawPattern(GraphicsContext& context, const FloatRect& floatSrcRect,
paint.setXfermodeMode(compositeOp);
paint.setFilterQuality(context.computeFilterQuality(this, destRect, normSrcRect));
paint.setAntiAlias(context.shouldAntialias());
- RefPtr<SkShader> shader = createPatternShader(image.get(), localMatrix, paint,
+ auto shader = createPatternShader(image.get(), localMatrix, paint,
FloatSize(repeatSpacing.width() / scale.width(), repeatSpacing.height() / scale.height()));
- paint.setShader(shader.get());
+ paint.setShader(std::move(shader));
reed1 2016/03/09 21:09:06 move up 2 lines and eliminate named variable shade
f(malita) 2016/03/10 13:57:58 Done.
context.drawRect(destRect, paint);
}

Powered by Google App Engine
This is Rietveld 408576698