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

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

Issue 1814473003: Revert of Add sk_sp helpers and switch Blink SkShader clients to the new APIs (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 7d4ae14f3a8b6cb1e3bb06b3958e2ee29a0e8141..36e0b9dced3cb5361d473b31a0b6fb066daf9bed 100644
--- a/third_party/WebKit/Source/platform/graphics/Image.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Image.cpp
@@ -185,11 +185,11 @@
namespace {
-sk_sp<SkShader> createPatternShader(const SkImage* image, const SkMatrix& shaderMatrix,
+PassRefPtr<SkShader> createPatternShader(const SkImage* image, const SkMatrix& shaderMatrix,
const SkPaint& paint, const FloatSize& spacing)
{
if (spacing.isZero())
- return image->makeShader(SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &shaderMatrix);
+ return adoptRef(image->newShader(SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &shaderMatrix));
// 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 @@
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(tileRect);
canvas->drawImage(image, 0, 0, &paint);
- sk_sp<SkPicture> picture(recorder.endRecordingAsPicture());
-
- return SkShader::MakePictureShader(
- std::move(picture), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &shaderMatrix, nullptr);
+ RefPtr<const SkPicture> picture = adoptRef(recorder.endRecordingAsPicture());
+
+ return adoptRef(SkShader::CreatePictureShader(
+ picture.get(), SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &shaderMatrix, nullptr));
}
} // anonymous namespace
@@ -249,8 +249,9 @@
paint.setXfermodeMode(compositeOp);
paint.setFilterQuality(context.computeFilterQuality(this, destRect, normSrcRect));
paint.setAntiAlias(context.shouldAntialias());
- paint.setShader(createPatternShader(image.get(), localMatrix, paint,
- FloatSize(repeatSpacing.width() / scale.width(), repeatSpacing.height() / scale.height())));
+ RefPtr<SkShader> shader = createPatternShader(image.get(), localMatrix, paint,
+ FloatSize(repeatSpacing.width() / scale.width(), repeatSpacing.height() / scale.height()));
+ paint.setShader(shader.get());
context.drawRect(destRect, paint);
}

Powered by Google App Engine
This is Rietveld 408576698