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 "SkString.h" | 11 #include "SkString.h" |
11 | 12 |
12 SkImageFilter* SkLocalMatrixImageFilter::Create(const SkMatrix& localM, SkImageF
ilter* input) { | 13 SkImageFilter* SkLocalMatrixImageFilter::Create(const SkMatrix& localM, SkImageF
ilter* input) { |
13 if (!input) { | 14 if (!input) { |
14 return nullptr; | 15 return nullptr; |
15 } | 16 } |
16 if (localM.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask
)) { | 17 if (localM.getType() & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask
)) { |
17 return nullptr; | 18 return nullptr; |
18 } | 19 } |
19 if (localM.isIdentity()) { | 20 if (localM.isIdentity()) { |
(...skipping 12 matching lines...) Expand all Loading... |
32 SkMatrix lm; | 33 SkMatrix lm; |
33 buffer.readMatrix(&lm); | 34 buffer.readMatrix(&lm); |
34 return SkLocalMatrixImageFilter::Create(lm, common.getInput(0)); | 35 return SkLocalMatrixImageFilter::Create(lm, common.getInput(0)); |
35 } | 36 } |
36 | 37 |
37 void SkLocalMatrixImageFilter::flatten(SkWriteBuffer& buffer) const { | 38 void SkLocalMatrixImageFilter::flatten(SkWriteBuffer& buffer) const { |
38 this->INHERITED::flatten(buffer); | 39 this->INHERITED::flatten(buffer); |
39 buffer.writeMatrix(fLocalM); | 40 buffer.writeMatrix(fLocalM); |
40 } | 41 } |
41 | 42 |
42 SkSpecialImage* SkLocalMatrixImageFilter::onFilterImage(SkSpecialImage* source,
const Context& ctx, | 43 sk_sp<SkSpecialImage> SkLocalMatrixImageFilter::onFilterImage(SkSpecialImage* so
urce, |
43 SkIPoint* offset) const
{ | 44 const Context& ctx
, |
| 45 SkIPoint* offset)
const { |
44 Context localCtx(SkMatrix::Concat(ctx.ctm(), fLocalM), ctx.clipBounds(), ctx
.cache()); | 46 Context localCtx(SkMatrix::Concat(ctx.ctm(), fLocalM), ctx.clipBounds(), ctx
.cache()); |
45 return this->filterInput(0, source, localCtx, offset); | 47 return this->filterInput(0, source, localCtx, offset); |
46 } | 48 } |
47 | 49 |
48 SkIRect SkLocalMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMat
rix& matrix, | 50 SkIRect SkLocalMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMat
rix& matrix, |
49 MapDirection direction) const { | 51 MapDirection direction) const { |
50 return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM
), direction); | 52 return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM
), direction); |
51 } | 53 } |
52 | 54 |
53 #ifndef SK_IGNORE_TO_STRING | 55 #ifndef SK_IGNORE_TO_STRING |
54 void SkLocalMatrixImageFilter::toString(SkString* str) const { | 56 void SkLocalMatrixImageFilter::toString(SkString* str) const { |
55 str->append("SkLocalMatrixImageFilter: ("); | 57 str->append("SkLocalMatrixImageFilter: ("); |
56 str->append(")"); | 58 str->append(")"); |
57 } | 59 } |
58 #endif | 60 #endif |
OLD | NEW |