diff options
author | djsollen <djsollen@google.com> | 2016-03-29 19:07:07 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-29 19:07:07 -0700 |
commit | 890579051d4096a8f769eadb9cde3f931d7abd7c (patch) | |
tree | 3c683bc8f4fc81d6b48fbf763c50540c39a64098 /src/core | |
parent | 308d988cba909ffbb456d4f327820a57df0d1d51 (diff) |
Revert of Switch SkLocalMatrixImageFilter and SkPaintImageFilter over to sk_sp (patchset #6 id:100001 of https://codereview.chromium.org/1842793002/ )
Reason for revert:
This CL is causing the autoroll into Chromium & google3 to fail.
Original issue's description:
> Switch SkLocalMatrixImageFilter and SkPaintImageFilter over to sk_sp
>
> TBR=reed@google.com
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1842793002
>
> Committed: https://skia.googlesource.com/skia/+/a33cf07a2273315363c0b6fb5d3ce811742f5a85
TBR=fmalita@chromium.org,reed@google.com,robertphillips@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1837293003
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkCanvas.cpp | 3 | ||||
-rw-r--r-- | src/core/SkImageFilter.cpp | 24 | ||||
-rw-r--r-- | src/core/SkLocalMatrixImageFilter.cpp | 21 | ||||
-rw-r--r-- | src/core/SkLocalMatrixImageFilter.h | 21 |
4 files changed, 24 insertions, 45 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 2f6477c41d..f1777441d6 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1161,8 +1161,9 @@ static void draw_filter_into_device(SkBaseDevice* src, const SkImageFilter* filt SkCanvas c(dst); + SkAutoTUnref<SkImageFilter> localF(filter->newWithLocalMatrix(ctm)); SkPaint p; - p.setImageFilter(filter->makeWithLocalMatrix(ctm)); + p.setImageFilter(localF); const SkScalar x = SkIntToScalar(src->getOrigin().x()); const SkScalar y = SkIntToScalar(src->getOrigin().y()); c.drawBitmap(srcBM, x, y, &p); diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index e999d3aebb..06076c6891 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -158,22 +158,6 @@ bool SkImageFilter::Common::unflatten(SkReadBuffer& buffer, int expectedCount) { /////////////////////////////////////////////////////////////////////////////////////////////////// -SkImageFilter::SkImageFilter(sk_sp<SkImageFilter>* inputs, - int inputCount, - const CropRect* cropRect) - : fInputCount(inputCount), - fInputs(new SkImageFilter*[inputCount]), - fUsesSrcInput(false), - fCropRect(cropRect ? *cropRect : CropRect(SkRect(), 0x0)), - fUniqueID(next_image_filter_unique_id()) { - for (int i = 0; i < inputCount; ++i) { - if (nullptr == inputs[i] || inputs[i]->usesSrcInput()) { - fUsesSrcInput = true; - } - fInputs[i] = SkSafeRef(inputs[i].get()); - } -} - SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const CropRect* cropRect) : fInputCount(inputCount), fInputs(new SkImageFilter*[inputCount]), @@ -184,7 +168,8 @@ SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const CropR if (nullptr == inputs[i] || inputs[i]->usesSrcInput()) { fUsesSrcInput = true; } - fInputs[i] = SkSafeRef(inputs[i]); + fInputs[i] = inputs[i]; + SkSafeRef(fInputs[i]); } } @@ -571,12 +556,11 @@ SkImageFilter* SkImageFilter::CreateMatrixFilter(const SkMatrix& matrix, return SkMatrixImageFilter::Create(matrix, filterQuality, input); } -sk_sp<SkImageFilter> SkImageFilter::makeWithLocalMatrix(const SkMatrix& matrix) const { +SkImageFilter* SkImageFilter::newWithLocalMatrix(const SkMatrix& matrix) const { // SkLocalMatrixImageFilter takes SkImage* in its factory, but logically that parameter // is *always* treated as a const ptr. Hence the const-cast here. // - SkImageFilter* nonConstThis = const_cast<SkImageFilter*>(this); - return SkLocalMatrixImageFilter::Make(matrix, sk_ref_sp<SkImageFilter>(nonConstThis)); + return SkLocalMatrixImageFilter::Create(matrix, const_cast<SkImageFilter*>(this)); } sk_sp<SkSpecialImage> SkImageFilter::filterInput(int index, diff --git a/src/core/SkLocalMatrixImageFilter.cpp b/src/core/SkLocalMatrixImageFilter.cpp index d1b5715b7f..15f2f0ef00 100644 --- a/src/core/SkLocalMatrixImageFilter.cpp +++ b/src/core/SkLocalMatrixImageFilter.cpp @@ -10,9 +10,21 @@ #include "SkSpecialImage.h" #include "SkString.h" -SkLocalMatrixImageFilter::SkLocalMatrixImageFilter(const SkMatrix& localM, - sk_sp<SkImageFilter> input) - : INHERITED(&input, 1, nullptr) +SkImageFilter* SkLocalMatrixImageFilter::Create(const SkMatrix& localM, SkImageFilter* input) { + if (!input) { + return nullptr; + } + if (localM.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)) { + return nullptr; + } + if (localM.isIdentity()) { + return SkRef(input); + } + return new SkLocalMatrixImageFilter(localM, input); +} + +SkLocalMatrixImageFilter::SkLocalMatrixImageFilter(const SkMatrix& localM, SkImageFilter* input) + : INHERITED(1, &input) , fLocalM(localM) { } @@ -20,8 +32,7 @@ SkFlattenable* SkLocalMatrixImageFilter::CreateProc(SkReadBuffer& buffer) { SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); SkMatrix lm; buffer.readMatrix(&lm); - return SkLocalMatrixImageFilter::Make(lm, - sk_ref_sp<SkImageFilter>(common.getInput(0))).release(); + return SkLocalMatrixImageFilter::Create(lm, common.getInput(0)); } void SkLocalMatrixImageFilter::flatten(SkWriteBuffer& buffer) const { diff --git a/src/core/SkLocalMatrixImageFilter.h b/src/core/SkLocalMatrixImageFilter.h index eb112b0f0d..412b391e18 100644 --- a/src/core/SkLocalMatrixImageFilter.h +++ b/src/core/SkLocalMatrixImageFilter.h @@ -16,28 +16,11 @@ */ class SkLocalMatrixImageFilter : public SkImageFilter { public: - static sk_sp<SkImageFilter> Make(const SkMatrix& localM, sk_sp<SkImageFilter> input) { - if (!input) { - return nullptr; - } - if (localM.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)) { - return nullptr; - } - if (localM.isIdentity()) { - return input; - } - return sk_sp<SkImageFilter>(new SkLocalMatrixImageFilter(localM, input)); - } + static SkImageFilter* Create(const SkMatrix& localM, SkImageFilter* input); SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLocalMatrixImageFilter) -#ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR - static SkImageFilter* Create(const SkMatrix& localM, SkImageFilter* input) { - return Make(localM, sk_sp<SkImageFilter>(SkSafeRef(input))).release(); - } -#endif - protected: void flatten(SkWriteBuffer&) const override; sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, @@ -45,7 +28,7 @@ protected: SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override; private: - SkLocalMatrixImageFilter(const SkMatrix& localM, sk_sp<SkImageFilter> input); + SkLocalMatrixImageFilter(const SkMatrix& localM, SkImageFilter* input); SkMatrix fLocalM; |