| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The Android Open Source Project | 2 * Copyright 2014 The Android Open Source Project |
| 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 "SkMatrixImageFilter.h" | 8 #include "SkMatrixImageFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 11 #include "SkDevice.h" | 11 #include "SkDevice.h" |
| 12 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
| 13 #include "SkReadBuffer.h" | 13 #include "SkReadBuffer.h" |
| 14 #include "SkWriteBuffer.h" | 14 #include "SkWriteBuffer.h" |
| 15 #include "SkMatrix.h" | 15 #include "SkMatrix.h" |
| 16 #include "SkRect.h" | 16 #include "SkRect.h" |
| 17 | 17 |
| 18 SkMatrixImageFilter::SkMatrixImageFilter(const SkMatrix& transform, | 18 SkMatrixImageFilter::SkMatrixImageFilter(const SkMatrix& transform, |
| 19 SkPaint::FilterLevel filterLevel, | 19 SkPaint::FilterLevel filterLevel, |
| 20 SkImageFilter* input) | 20 SkImageFilter* input, |
| 21 : INHERITED(1, &input), | 21 uint32_t uniqueID) |
| 22 : INHERITED(1, &input, NULL, uniqueID), |
| 22 fTransform(transform), | 23 fTransform(transform), |
| 23 fFilterLevel(filterLevel) { | 24 fFilterLevel(filterLevel) { |
| 24 } | 25 } |
| 25 | 26 |
| 26 SkMatrixImageFilter* SkMatrixImageFilter::Create(const SkMatrix& transform, | 27 SkMatrixImageFilter* SkMatrixImageFilter::Create(const SkMatrix& transform, |
| 27 SkPaint::FilterLevel filterLeve
l, | 28 SkPaint::FilterLevel filterLeve
l, |
| 28 SkImageFilter* input) { | 29 SkImageFilter* input, |
| 29 return SkNEW_ARGS(SkMatrixImageFilter, (transform, filterLevel, input)); | 30 uint32_t uniqueID) { |
| 31 return SkNEW_ARGS(SkMatrixImageFilter, (transform, filterLevel, input, uniqu
eID)); |
| 30 } | 32 } |
| 31 | 33 |
| 32 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | 34 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 33 SkMatrixImageFilter::SkMatrixImageFilter(SkReadBuffer& buffer) | 35 SkMatrixImageFilter::SkMatrixImageFilter(SkReadBuffer& buffer) |
| 34 : INHERITED(1, buffer) { | 36 : INHERITED(1, buffer) { |
| 35 buffer.readMatrix(&fTransform); | 37 buffer.readMatrix(&fTransform); |
| 36 fFilterLevel = static_cast<SkPaint::FilterLevel>(buffer.readInt()); | 38 fFilterLevel = static_cast<SkPaint::FilterLevel>(buffer.readInt()); |
| 37 } | 39 } |
| 38 #endif | 40 #endif |
| 39 | 41 |
| 40 SkFlattenable* SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) { | 42 SkFlattenable* SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 41 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 43 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
| 42 SkMatrix matrix; | 44 SkMatrix matrix; |
| 43 buffer.readMatrix(&matrix); | 45 buffer.readMatrix(&matrix); |
| 44 SkPaint::FilterLevel level = static_cast<SkPaint::FilterLevel>(buffer.readIn
t()); | 46 SkPaint::FilterLevel level = static_cast<SkPaint::FilterLevel>(buffer.readIn
t()); |
| 45 return Create(matrix, level, common.getInput(0)); | 47 return Create(matrix, level, common.getInput(0), common.uniqueID()); |
| 46 } | 48 } |
| 47 | 49 |
| 48 void SkMatrixImageFilter::flatten(SkWriteBuffer& buffer) const { | 50 void SkMatrixImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 49 this->INHERITED::flatten(buffer); | 51 this->INHERITED::flatten(buffer); |
| 50 buffer.writeMatrix(fTransform); | 52 buffer.writeMatrix(fTransform); |
| 51 buffer.writeInt(fFilterLevel); | 53 buffer.writeInt(fFilterLevel); |
| 52 } | 54 } |
| 53 | 55 |
| 54 SkMatrixImageFilter::~SkMatrixImageFilter() { | 56 SkMatrixImageFilter::~SkMatrixImageFilter() { |
| 55 } | 57 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 matrix.mapRect(&floatBounds, SkRect::Make(src)); | 129 matrix.mapRect(&floatBounds, SkRect::Make(src)); |
| 128 SkIRect bounds; | 130 SkIRect bounds; |
| 129 floatBounds.roundOut(&bounds); | 131 floatBounds.roundOut(&bounds); |
| 130 if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) { | 132 if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) { |
| 131 return false; | 133 return false; |
| 132 } | 134 } |
| 133 | 135 |
| 134 *dst = bounds; | 136 *dst = bounds; |
| 135 return true; | 137 return true; |
| 136 } | 138 } |
| OLD | NEW |