| 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 sk_sp<SkImageFilter> SkLocalMatrixImageFilter::Make(const SkMatrix& localM, |
| 14 sk_sp<SkImageFilter> input)
{ |
| 15 if (!input) { |
| 16 return nullptr; |
| 17 } |
| 18 if (localM.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask
)) { |
| 19 return nullptr; |
| 20 } |
| 21 if (localM.isIdentity()) { |
| 22 return input; |
| 23 } |
| 24 return sk_sp<SkImageFilter>(new SkLocalMatrixImageFilter(localM, input)); |
| 25 } |
| 26 |
| 13 SkLocalMatrixImageFilter::SkLocalMatrixImageFilter(const SkMatrix& localM, | 27 SkLocalMatrixImageFilter::SkLocalMatrixImageFilter(const SkMatrix& localM, |
| 14 sk_sp<SkImageFilter> input) | 28 sk_sp<SkImageFilter> input) |
| 15 : INHERITED(&input, 1, nullptr) | 29 : INHERITED(&input, 1, nullptr) |
| 16 , fLocalM(localM) { | 30 , fLocalM(localM) { |
| 17 } | 31 } |
| 18 | 32 |
| 19 sk_sp<SkFlattenable> SkLocalMatrixImageFilter::CreateProc(SkReadBuffer& buffer)
{ | 33 sk_sp<SkFlattenable> SkLocalMatrixImageFilter::CreateProc(SkReadBuffer& buffer)
{ |
| 20 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 34 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 21 SkMatrix lm; | 35 SkMatrix lm; |
| 22 buffer.readMatrix(&lm); | 36 buffer.readMatrix(&lm); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 MapDirection direction) const { | 53 MapDirection direction) const { |
| 40 return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM
), direction); | 54 return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM
), direction); |
| 41 } | 55 } |
| 42 | 56 |
| 43 #ifndef SK_IGNORE_TO_STRING | 57 #ifndef SK_IGNORE_TO_STRING |
| 44 void SkLocalMatrixImageFilter::toString(SkString* str) const { | 58 void SkLocalMatrixImageFilter::toString(SkString* str) const { |
| 45 str->append("SkLocalMatrixImageFilter: ("); | 59 str->append("SkLocalMatrixImageFilter: ("); |
| 46 str->append(")"); | 60 str->append(")"); |
| 47 } | 61 } |
| 48 #endif | 62 #endif |
| OLD | NEW |