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

Unified Diff: src/core/SkCanvas.cpp

Issue 1822623002: switch colorfilters to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: manual rebase 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/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 3acb9136e25814bacb4a725d402820986f56fdf6..0031468212f8a27a7c7e0448afc413c5a74fcefb 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -391,16 +391,17 @@ static SkPaint* set_if_needed(SkLazyPaint* lazy, const SkPaint& orig) {
* If the paint has an imagefilter, but it can be simplified to just a colorfilter, return that
* colorfilter, else return nullptr.
*/
-static SkColorFilter* image_to_color_filter(const SkPaint& paint) {
+static sk_sp<SkColorFilter> image_to_color_filter(const SkPaint& paint) {
SkImageFilter* imgf = paint.getImageFilter();
if (!imgf) {
return nullptr;
}
- SkColorFilter* imgCF;
- if (!imgf->asAColorFilter(&imgCF)) {
+ SkColorFilter* imgCFPtr;
+ if (!imgf->asAColorFilter(&imgCFPtr)) {
return nullptr;
}
+ sk_sp<SkColorFilter> imgCF(imgCFPtr);
SkColorFilter* paintCF = paint.getColorFilter();
if (nullptr == paintCF) {
@@ -410,8 +411,7 @@ static SkColorFilter* image_to_color_filter(const SkPaint& paint) {
// The paint has both a colorfilter(paintCF) and an imagefilter-which-is-a-colorfilter(imgCF)
// and we need to combine them into a single colorfilter.
- SkAutoTUnref<SkColorFilter> autoImgCF(imgCF);
- return SkColorFilter::CreateComposeFilter(imgCF, paintCF);
+ return SkColorFilter::MakeComposeFilter(imgCF, sk_ref_sp(paintCF));
f(malita) 2016/03/21 22:24:19 std::move(imgCF)
reed1 2016/03/22 13:47:10 Done.
}
/**
@@ -455,10 +455,10 @@ public:
fTempLayerForImageFilter = false;
fDone = false;
- SkColorFilter* simplifiedCF = image_to_color_filter(fOrigPaint);
+ auto simplifiedCF = image_to_color_filter(fOrigPaint);
if (simplifiedCF) {
SkPaint* paint = set_if_needed(&fLazyPaintInit, fOrigPaint);
- paint->setColorFilter(simplifiedCF)->unref();
+ paint->setColorFilter(simplifiedCF);
f(malita) 2016/03/21 22:24:19 std::move(simplifiedCF)
reed1 2016/03/22 13:47:10 Done.
paint->setImageFilter(nullptr);
fPaint = paint;
}

Powered by Google App Engine
This is Rietveld 408576698