OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkDropShadowImageFilter.h" | 8 #include "SkDropShadowImageFilter.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } else { | 105 } else { |
106 *dst = src; | 106 *dst = src; |
107 } | 107 } |
108 | 108 |
109 SkRect shadowBounds = *dst; | 109 SkRect shadowBounds = *dst; |
110 shadowBounds.offset(fDx, fDy); | 110 shadowBounds.offset(fDx, fDy); |
111 shadowBounds.outset(SkScalarMul(fSigmaX, SkIntToScalar(3)), | 111 shadowBounds.outset(SkScalarMul(fSigmaX, SkIntToScalar(3)), |
112 SkScalarMul(fSigmaY, SkIntToScalar(3))); | 112 SkScalarMul(fSigmaY, SkIntToScalar(3))); |
113 dst->join(shadowBounds); | 113 dst->join(shadowBounds); |
114 } | 114 } |
| 115 |
| 116 bool SkDropShadowImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix&
ctm, |
| 117 SkIRect* dst) const { |
| 118 SkIRect bounds = src; |
| 119 if (getInput(0) && !getInput(0)->filterBounds(src, ctm, &bounds)) { |
| 120 return false; |
| 121 } |
| 122 SkVector offsetVec, localOffsetVec = SkVector::Make(fDx, fDy); |
| 123 ctm.mapVectors(&offsetVec, &localOffsetVec, 1); |
| 124 bounds.offset(-SkScalarCeilToInt(offsetVec.x()), |
| 125 -SkScalarCeilToInt(offsetVec.y())); |
| 126 SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY); |
| 127 ctm.mapVectors(&sigma, &localSigma, 1); |
| 128 bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), |
| 129 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); |
| 130 bounds.join(src); |
| 131 *dst = bounds; |
| 132 return true; |
| 133 } |
OLD | NEW |