| 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 "SkString.h" | 10 #include "SkString.h" |
| 11 | 11 |
| 12 SkImageFilter* SkLocalMatrixImageFilter::Create(const SkMatrix& localM, SkImageF
ilter* input) { | 12 SkImageFilter* SkLocalMatrixImageFilter::Create(const SkMatrix& localM, SkImageF
ilter* input) { |
| 13 if (!input) { | 13 if (!input) { |
| 14 return nullptr; | 14 return nullptr; |
| 15 } | 15 } |
| 16 if (localM.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask
)) { | 16 if (localM.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask
)) { |
| 17 return nullptr; | 17 return nullptr; |
| 18 } | 18 } |
| 19 if (localM.isIdentity()) { | 19 if (localM.isIdentity()) { |
| 20 return SkRef(input); | 20 return SkRef(input); |
| 21 } | 21 } |
| 22 return new SkLocalMatrixImageFilter(localM, input); | 22 return new SkLocalMatrixImageFilter(localM, input); |
| 23 } | 23 } |
| 24 | 24 |
| 25 SkLocalMatrixImageFilter::SkLocalMatrixImageFilter(const SkMatrix& localM, SkIma
geFilter* input) | 25 SkLocalMatrixImageFilter::SkLocalMatrixImageFilter(const SkMatrix& localM, SkIma
geFilter* input) |
| 26 : INHERITED(1, &input), fLocalM(localM) | 26 : INHERITED(1, &input) |
| 27 {} | 27 , fLocalM(localM) { |
| 28 } |
| 28 | 29 |
| 29 SkFlattenable* SkLocalMatrixImageFilter::CreateProc(SkReadBuffer& buffer) { | 30 SkFlattenable* SkLocalMatrixImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 30 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 31 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 31 SkMatrix lm; | 32 SkMatrix lm; |
| 32 buffer.readMatrix(&lm); | 33 buffer.readMatrix(&lm); |
| 33 return SkLocalMatrixImageFilter::Create(lm, common.getInput(0)); | 34 return SkLocalMatrixImageFilter::Create(lm, common.getInput(0)); |
| 34 } | 35 } |
| 35 | 36 |
| 36 void SkLocalMatrixImageFilter::flatten(SkWriteBuffer& buffer) const { | 37 void SkLocalMatrixImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 37 this->INHERITED::flatten(buffer); | 38 this->INHERITED::flatten(buffer); |
| 38 buffer.writeMatrix(fLocalM); | 39 buffer.writeMatrix(fLocalM); |
| 39 } | 40 } |
| 40 | 41 |
| 41 bool SkLocalMatrixImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBit
map& src, | 42 SkSpecialImage* SkLocalMatrixImageFilter::onFilterImage(SkSpecialImage* source,
const Context& ctx, |
| 42 const Context& ctx, | 43 SkIPoint* offset) const
{ |
| 43 SkBitmap* result, SkIPoin
t* offset) const { | |
| 44 Context localCtx(SkMatrix::Concat(ctx.ctm(), fLocalM), ctx.clipBounds(), ctx
.cache()); | 44 Context localCtx(SkMatrix::Concat(ctx.ctm(), fLocalM), ctx.clipBounds(), ctx
.cache()); |
| 45 return this->filterInputDeprecated(0, proxy, src, localCtx, result, offset); | 45 return this->filterInput(0, source, localCtx, offset); |
| 46 } | 46 } |
| 47 | 47 |
| 48 SkIRect SkLocalMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMat
rix& matrix, | 48 SkIRect SkLocalMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMat
rix& matrix, |
| 49 MapDirection direction) const { | 49 MapDirection direction) const { |
| 50 return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM
), direction); | 50 return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM
), direction); |
| 51 } | 51 } |
| 52 | 52 |
| 53 #ifndef SK_IGNORE_TO_STRING | 53 #ifndef SK_IGNORE_TO_STRING |
| 54 void SkLocalMatrixImageFilter::toString(SkString* str) const { | 54 void SkLocalMatrixImageFilter::toString(SkString* str) const { |
| 55 str->append("SkLocalMatrixImageFilter: ("); | 55 str->append("SkLocalMatrixImageFilter: ("); |
| 56 str->append(")"); | 56 str->append(")"); |
| 57 } | 57 } |
| 58 #endif | 58 #endif |
| OLD | NEW |