OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The Android Open Source Project | 2 * Copyright 2011 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (d % 2 == 1) { | 62 if (d % 2 == 1) { |
63 *lowOffset = *highOffset = (d - 1) / 2; | 63 *lowOffset = *highOffset = (d - 1) / 2; |
64 *kernelSize3 = d; | 64 *kernelSize3 = d; |
65 } else { | 65 } else { |
66 *highOffset = d / 2; | 66 *highOffset = d / 2; |
67 *lowOffset = *highOffset - 1; | 67 *lowOffset = *highOffset - 1; |
68 *kernelSize3 = d + 1; | 68 *kernelSize3 = d + 1; |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 bool SkBlurImageFilter::onFilterImage(Proxy* proxy, | 72 bool SkBlurImageFilter::onFilterImageDeprecated(Proxy* proxy, |
73 const SkBitmap& source, const Context& ctx
, | 73 const SkBitmap& source, const Co
ntext& ctx, |
74 SkBitmap* dst, SkIPoint* offset) const { | 74 SkBitmap* dst, SkIPoint* offset)
const { |
75 SkBitmap src = source; | 75 SkBitmap src = source; |
76 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 76 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
77 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { | 77 if (!this->filterInputDeprecated(0, proxy, source, ctx, &src, &srcOffset)) { |
78 return false; | 78 return false; |
79 } | 79 } |
80 | 80 |
81 if (src.colorType() != kN32_SkColorType) { | 81 if (src.colorType() != kN32_SkColorType) { |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 SkIRect srcBounds = src.bounds(); | 85 SkIRect srcBounds = src.bounds(); |
86 srcBounds.offset(srcOffset); | 86 srcBounds.offset(srcOffset); |
87 SkIRect dstBounds; | 87 SkIRect dstBounds; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 | 192 |
193 void SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& c
tm, | 193 void SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& c
tm, |
194 SkIRect* dst, MapDirection) const { | 194 SkIRect* dst, MapDirection) const { |
195 *dst = src; | 195 *dst = src; |
196 SkVector sigma = map_sigma(fSigma, ctm); | 196 SkVector sigma = map_sigma(fSigma, ctm); |
197 dst->outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), | 197 dst->outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), |
198 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); | 198 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); |
199 } | 199 } |
200 | 200 |
201 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 201 bool SkBlurImageFilter::filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& s
rc, |
202 SkBitmap* result, SkIPoint* offset) const
{ | 202 const Context& ctx, |
| 203 SkBitmap* result, SkIPoint* off
set) const { |
203 #if SK_SUPPORT_GPU | 204 #if SK_SUPPORT_GPU |
204 SkBitmap input = src; | 205 SkBitmap input = src; |
205 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 206 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
206 if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) { | 207 if (!this->filterInputGPUDeprecated(0, proxy, src, ctx, &input, &srcOffset))
{ |
207 return false; | 208 return false; |
208 } | 209 } |
209 SkIRect srcBounds = input.bounds(); | 210 SkIRect srcBounds = input.bounds(); |
210 srcBounds.offset(srcOffset); | 211 srcBounds.offset(srcOffset); |
211 SkIRect dstBounds; | 212 SkIRect dstBounds; |
212 if (!this->applyCropRect(this->mapContext(ctx), srcBounds, &dstBounds)) { | 213 if (!this->applyCropRect(this->mapContext(ctx), srcBounds, &dstBounds)) { |
213 return false; | 214 return false; |
214 } | 215 } |
215 if (!srcBounds.intersect(dstBounds)) { | 216 if (!srcBounds.intersect(dstBounds)) { |
216 return false; | 217 return false; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 str->appendf("SkBlurImageFilter: ("); | 252 str->appendf("SkBlurImageFilter: ("); |
252 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); | 253 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); |
253 | 254 |
254 if (this->getInput(0)) { | 255 if (this->getInput(0)) { |
255 this->getInput(0)->toString(str); | 256 this->getInput(0)->toString(str); |
256 } | 257 } |
257 | 258 |
258 str->append("))"); | 259 str->append("))"); |
259 } | 260 } |
260 #endif | 261 #endif |
OLD | NEW |