diff options
author | reed <reed@google.com> | 2016-03-29 11:32:50 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-29 11:32:50 -0700 |
commit | cfb6bdf767796c950f89985445738d2d8e7f12b0 (patch) | |
tree | 5b412fe9d767eef852f55316a99eb9776751ccaf /src/effects | |
parent | 3ebd2760dd34da6f5af23e9c7cb1b6a61e9cea9d (diff) |
switch xfermodes over to sk_sp
waiting on https://codereview.chromium.org/1835163002/
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1832223002
Review URL: https://codereview.chromium.org/1832223002
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkArithmeticMode.cpp | 14 | ||||
-rw-r--r-- | src/effects/SkAvoidXfermode.cpp | 2 | ||||
-rw-r--r-- | src/effects/SkLayerDrawLooper.cpp | 2 | ||||
-rw-r--r-- | src/effects/SkPixelXorXfermode.cpp | 2 | ||||
-rw-r--r-- | src/effects/SkXfermodeImageFilter.cpp | 20 |
5 files changed, 23 insertions, 17 deletions
diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp index 32238f1f9e..b225e6d4c1 100644 --- a/src/effects/SkArithmeticMode.cpp +++ b/src/effects/SkArithmeticMode.cpp @@ -60,7 +60,7 @@ SkFlattenable* SkArithmeticMode_scalar::CreateProc(SkReadBuffer& buffer) { const SkScalar k3 = buffer.readScalar(); const SkScalar k4 = buffer.readScalar(); const bool enforcePMColor = buffer.readBool(); - return SkArithmeticMode::Create(k1, k2, k3, k4, enforcePMColor); + return SkArithmeticMode::Make(k1, k2, k3, k4, enforcePMColor).release(); } static int pinToByte(int value) { @@ -137,18 +137,16 @@ void SkArithmeticMode_scalar::toString(SkString* str) const { /////////////////////////////////////////////////////////////////////////////// -SkXfermode* SkArithmeticMode::Create(SkScalar k1, SkScalar k2, - SkScalar k3, SkScalar k4, - bool enforcePMColor) { +sk_sp<SkXfermode> SkArithmeticMode::Make(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4, + bool enforcePMColor) { if (SkScalarNearlyZero(k1) && SkScalarNearlyEqual(k2, SK_Scalar1) && SkScalarNearlyZero(k3) && SkScalarNearlyZero(k4)) { - return SkXfermode::Create(SkXfermode::kSrc_Mode); + return SkXfermode::Make(SkXfermode::kSrc_Mode); } else if (SkScalarNearlyZero(k1) && SkScalarNearlyZero(k2) && SkScalarNearlyEqual(k3, SK_Scalar1) && SkScalarNearlyZero(k4)) { - return SkXfermode::Create(SkXfermode::kDst_Mode); + return SkXfermode::Make(SkXfermode::kDst_Mode); } - - return new SkArithmeticMode_scalar(k1, k2, k3, k4, enforcePMColor); + return sk_make_sp<SkArithmeticMode_scalar>(k1, k2, k3, k4, enforcePMColor); } diff --git a/src/effects/SkAvoidXfermode.cpp b/src/effects/SkAvoidXfermode.cpp index d9678f5834..4b7e63667a 100644 --- a/src/effects/SkAvoidXfermode.cpp +++ b/src/effects/SkAvoidXfermode.cpp @@ -25,7 +25,7 @@ SkFlattenable* SkAvoidXfermode::CreateProc(SkReadBuffer& buffer) { const SkColor color = buffer.readColor(); const unsigned tolerance = buffer.readUInt(); const unsigned mode = buffer.readUInt(); - return Create(color, tolerance, (Mode)mode); + return Make(color, tolerance, (Mode)mode).release(); } void SkAvoidXfermode::flatten(SkWriteBuffer& buffer) const { diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp index 0a5c4f9df3..b3430bb1e4 100644 --- a/src/effects/SkLayerDrawLooper.cpp +++ b/src/effects/SkLayerDrawLooper.cpp @@ -104,7 +104,7 @@ void SkLayerDrawLooper::LayerDrawLooperContext::ApplyInfo( dst->setColorFilter(sk_ref_sp(src.getColorFilter())); } if (bits & kXfermode_Bit) { - dst->setXfermode(src.getXfermode()); + dst->setXfermode(sk_ref_sp(src.getXfermode())); } // we don't override these diff --git a/src/effects/SkPixelXorXfermode.cpp b/src/effects/SkPixelXorXfermode.cpp index c69fe0933b..4ad3f1bd76 100644 --- a/src/effects/SkPixelXorXfermode.cpp +++ b/src/effects/SkPixelXorXfermode.cpp @@ -27,7 +27,7 @@ void SkPixelXorXfermode::flatten(SkWriteBuffer& wb) const { } SkFlattenable* SkPixelXorXfermode::CreateProc(SkReadBuffer& buffer) { - return Create(buffer.readColor()); + return Make(buffer.readColor()).release(); } #ifndef SK_IGNORE_TO_STRING diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index 8f7fdc70e3..8cd75127ba 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -23,22 +23,30 @@ /////////////////////////////////////////////////////////////////////////////// -SkXfermodeImageFilter::SkXfermodeImageFilter(SkXfermode* mode, +sk_sp<SkImageFilter> SkXfermodeImageFilter::Make(sk_sp<SkXfermode> mode, SkImageFilter* background, + SkImageFilter* foreground, + const CropRect* cropRect) { + SkImageFilter* inputs[2] = { background, foreground }; + return sk_sp<SkImageFilter>(new SkXfermodeImageFilter(mode, inputs, cropRect)); +} + +SkXfermodeImageFilter::SkXfermodeImageFilter(sk_sp<SkXfermode> mode, SkImageFilter* inputs[2], const CropRect* cropRect) : INHERITED(2, inputs, cropRect) - , fMode(SkSafeRef(mode)) { -} + , fMode(std::move(mode)) +{} SkFlattenable* SkXfermodeImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); - SkAutoTUnref<SkXfermode> mode(buffer.readXfermode()); - return Create(mode, common.getInput(0), common.getInput(1), &common.cropRect()); + sk_sp<SkXfermode> mode(buffer.readXfermode()); + return Make(std::move(mode), common.getInput(0), + common.getInput(1), &common.cropRect()).release(); } void SkXfermodeImageFilter::flatten(SkWriteBuffer& buffer) const { this->INHERITED::flatten(buffer); - buffer.writeFlattenable(fMode); + buffer.writeFlattenable(fMode.get()); } bool SkXfermodeImageFilter::onFilterImageDeprecated(Proxy* proxy, |