| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 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 "SkOffsetImageFilter.h" | 8 #include "SkOffsetImageFilter.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 "SkFlattenableBuffers.h" | 12 #include "SkFlattenableBuffers.h" |
| 13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
| 14 #include "SkPaint.h" | 14 #include "SkPaint.h" |
| 15 | 15 |
| 16 bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, | 16 bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, |
| 17 const SkMatrix& matrix, | 17 const SkMatrix& matrix, |
| 18 SkBitmap* result, | 18 SkBitmap* result, |
| 19 SkIPoint* loc) { | 19 SkIPoint* loc) { |
| 20 SkImageFilter* input = getInput(0); | 20 SkImageFilter* input = getInput(0); |
| 21 SkBitmap src = source; | 21 SkBitmap src = source; |
| 22 if (cropRect().isLargest()) { | 22 if (!cropRectIsSet()) { |
| 23 if (input && !input->filterImage(proxy, source, matrix, &src, loc)) { | 23 if (input && !input->filterImage(proxy, source, matrix, &src, loc)) { |
| 24 return false; | 24 return false; |
| 25 } | 25 } |
| 26 | 26 |
| 27 SkVector vec; | 27 SkVector vec; |
| 28 matrix.mapVectors(&vec, &fOffset, 1); | 28 matrix.mapVectors(&vec, &fOffset, 1); |
| 29 | 29 |
| 30 loc->fX += SkScalarRoundToInt(vec.fX); | 30 loc->fX += SkScalarRoundToInt(vec.fX); |
| 31 loc->fY += SkScalarRoundToInt(vec.fY); | 31 loc->fY += SkScalarRoundToInt(vec.fY); |
| 32 *result = src; | 32 *result = src; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 dst->offset(SkScalarRoundToInt(vec.fX), SkScalarRoundToInt(vec.fY)); | 64 dst->offset(SkScalarRoundToInt(vec.fX), SkScalarRoundToInt(vec.fY)); |
| 65 return true; | 65 return true; |
| 66 } | 66 } |
| 67 | 67 |
| 68 void SkOffsetImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { | 68 void SkOffsetImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { |
| 69 this->INHERITED::flatten(buffer); | 69 this->INHERITED::flatten(buffer); |
| 70 buffer.writePoint(fOffset); | 70 buffer.writePoint(fOffset); |
| 71 } | 71 } |
| 72 | 72 |
| 73 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter
* input, | 73 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter
* input, |
| 74 const SkIRect* cropRect) : INHERITED(in
put, cropRect) { | 74 const CropRect* cropRect) : INHERITED(i
nput, cropRect) { |
| 75 fOffset.set(dx, dy); | 75 fOffset.set(dx, dy); |
| 76 } | 76 } |
| 77 | 77 |
| 78 SkOffsetImageFilter::SkOffsetImageFilter(SkFlattenableReadBuffer& buffer) : INHE
RITED(buffer) { | 78 SkOffsetImageFilter::SkOffsetImageFilter(SkFlattenableReadBuffer& buffer) : INHE
RITED(buffer) { |
| 79 buffer.readPoint(&fOffset); | 79 buffer.readPoint(&fOffset); |
| 80 } | 80 } |
| OLD | NEW |