| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkLocalMatrixImageFilter.h" | 8 #include "SkLocalMatrixImageFilter.h" |
| 9 #include "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
| 10 #include "SkSpecialImage.h" | 10 #include "SkSpecialImage.h" |
| 11 #include "SkString.h" | 11 #include "SkString.h" |
| 12 | 12 |
| 13 SkLocalMatrixImageFilter::SkLocalMatrixImageFilter(const SkMatrix& localM, | 13 SkLocalMatrixImageFilter::SkLocalMatrixImageFilter(const SkMatrix& localM, |
| 14 sk_sp<SkImageFilter> input) | 14 sk_sp<SkImageFilter> input) |
| 15 : INHERITED(&input, 1, nullptr) | 15 : INHERITED(&input, 1, nullptr) |
| 16 , fLocalM(localM) { | 16 , fLocalM(localM) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 SkFlattenable* SkLocalMatrixImageFilter::CreateProc(SkReadBuffer& buffer) { | 19 SkFlattenable* SkLocalMatrixImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 20 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 20 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 21 SkMatrix lm; | 21 SkMatrix lm; |
| 22 buffer.readMatrix(&lm); | 22 buffer.readMatrix(&lm); |
| 23 return SkLocalMatrixImageFilter::Make(lm, | 23 return SkLocalMatrixImageFilter::Make(lm, common.getInput(0)).release(); |
| 24 sk_ref_sp<SkImageFilter>(common.getInp
ut(0))).release(); | |
| 25 } | 24 } |
| 26 | 25 |
| 27 void SkLocalMatrixImageFilter::flatten(SkWriteBuffer& buffer) const { | 26 void SkLocalMatrixImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 28 this->INHERITED::flatten(buffer); | 27 this->INHERITED::flatten(buffer); |
| 29 buffer.writeMatrix(fLocalM); | 28 buffer.writeMatrix(fLocalM); |
| 30 } | 29 } |
| 31 | 30 |
| 32 sk_sp<SkSpecialImage> SkLocalMatrixImageFilter::onFilterImage(SkSpecialImage* so
urce, | 31 sk_sp<SkSpecialImage> SkLocalMatrixImageFilter::onFilterImage(SkSpecialImage* so
urce, |
| 33 const Context& ctx
, | 32 const Context& ctx
, |
| 34 SkIPoint* offset)
const { | 33 SkIPoint* offset)
const { |
| 35 Context localCtx(SkMatrix::Concat(ctx.ctm(), fLocalM), ctx.clipBounds(), ctx
.cache()); | 34 Context localCtx(SkMatrix::Concat(ctx.ctm(), fLocalM), ctx.clipBounds(), ctx
.cache()); |
| 36 return this->filterInput(0, source, localCtx, offset); | 35 return this->filterInput(0, source, localCtx, offset); |
| 37 } | 36 } |
| 38 | 37 |
| 39 SkIRect SkLocalMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMat
rix& matrix, | 38 SkIRect SkLocalMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMat
rix& matrix, |
| 40 MapDirection direction) const { | 39 MapDirection direction) const { |
| 41 return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM
), direction); | 40 return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM
), direction); |
| 42 } | 41 } |
| 43 | 42 |
| 44 #ifndef SK_IGNORE_TO_STRING | 43 #ifndef SK_IGNORE_TO_STRING |
| 45 void SkLocalMatrixImageFilter::toString(SkString* str) const { | 44 void SkLocalMatrixImageFilter::toString(SkString* str) const { |
| 46 str->append("SkLocalMatrixImageFilter: ("); | 45 str->append("SkLocalMatrixImageFilter: ("); |
| 47 str->append(")"); | 46 str->append(")"); |
| 48 } | 47 } |
| 49 #endif | 48 #endif |
| OLD | NEW |