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" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons
t { | 69 void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons
t { |
70 if (getInput(0)) { | 70 if (getInput(0)) { |
71 getInput(0)->computeFastBounds(src, dst); | 71 getInput(0)->computeFastBounds(src, dst); |
72 } else { | 72 } else { |
73 *dst = src; | 73 *dst = src; |
74 } | 74 } |
| 75 SkRect copy = *dst; |
75 dst->offset(fOffset.fX, fOffset.fY); | 76 dst->offset(fOffset.fX, fOffset.fY); |
| 77 dst->join(copy); |
76 } | 78 } |
77 | 79 |
78 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm
, | 80 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm
, |
79 SkIRect* dst) { | 81 SkIRect* dst) const { |
80 SkVector vec; | 82 SkVector vec; |
81 ctm.mapVectors(&vec, &fOffset, 1); | 83 ctm.mapVectors(&vec, &fOffset, 1); |
82 | 84 |
83 *dst = src; | 85 *dst = src; |
84 dst->offset(SkScalarRoundToInt(vec.fX), SkScalarRoundToInt(vec.fY)); | 86 dst->offset(-SkScalarCeilToInt(vec.fX), -SkScalarCeilToInt(vec.fY)); |
| 87 dst->join(src); |
85 return true; | 88 return true; |
86 } | 89 } |
87 | 90 |
88 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { | 91 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { |
89 this->INHERITED::flatten(buffer); | 92 this->INHERITED::flatten(buffer); |
90 buffer.writePoint(fOffset); | 93 buffer.writePoint(fOffset); |
91 } | 94 } |
92 | 95 |
93 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter
* input, | 96 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter
* input, |
94 const CropRect* cropRect) : INHERITED(i
nput, cropRect) { | 97 const CropRect* cropRect) : INHERITED(i
nput, cropRect) { |
95 fOffset.set(dx, dy); | 98 fOffset.set(dx, dy); |
96 } | 99 } |
97 | 100 |
98 SkOffsetImageFilter::SkOffsetImageFilter(SkReadBuffer& buffer) | 101 SkOffsetImageFilter::SkOffsetImageFilter(SkReadBuffer& buffer) |
99 : INHERITED(1, buffer) { | 102 : INHERITED(1, buffer) { |
100 buffer.readPoint(&fOffset); | 103 buffer.readPoint(&fOffset); |
101 buffer.validate(SkScalarIsFinite(fOffset.fX) && | 104 buffer.validate(SkScalarIsFinite(fOffset.fX) && |
102 SkScalarIsFinite(fOffset.fY)); | 105 SkScalarIsFinite(fOffset.fY)); |
103 } | 106 } |
OLD | NEW |