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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 *dst = src; | 233 *dst = src; |
234 } | 234 } |
235 | 235 |
236 dst->outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)), | 236 dst->outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)), |
237 SkScalarMul(fSigma.height(), SkIntToScalar(3))); | 237 SkScalarMul(fSigma.height(), SkIntToScalar(3))); |
238 } | 238 } |
239 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
SkMatrix& ctm, | 239 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
SkMatrix& ctm, |
240 SkBitmap* result, SkIPoint* offset) { | 240 SkBitmap* result, SkIPoint* offset) { |
241 #if SK_SUPPORT_GPU | 241 #if SK_SUPPORT_GPU |
242 SkBitmap input; | 242 SkBitmap input; |
243 if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &in
put, offset)) { | 243 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| 244 if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &in
put, &srcOffset)) { |
244 return false; | 245 return false; |
245 } | 246 } |
246 GrTexture* source = input.getTexture(); | 247 GrTexture* source = input.getTexture(); |
247 SkIRect rect; | 248 SkIRect rect; |
248 src.getBounds(&rect); | 249 src.getBounds(&rect); |
| 250 rect.offset(srcOffset); |
249 if (!this->applyCropRect(&rect, ctm)) { | 251 if (!this->applyCropRect(&rect, ctm)) { |
250 return false; | 252 return false; |
251 } | 253 } |
252 SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height())
; | 254 SkVector sigma, localSigma = SkVector::Make(fSigma.width(), fSigma.height())
; |
253 ctm.mapVectors(&sigma, &localSigma, 1); | 255 ctm.mapVectors(&sigma, &localSigma, 1); |
| 256 offset->fX = rect.fLeft; |
| 257 offset->fY = rect.fTop; |
| 258 rect.offset(-srcOffset); |
254 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext(
), | 259 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext(
), |
255 source, | 260 source, |
256 false, | 261 false, |
257 SkRect::Make(rect), | 262 SkRect::Make(rect), |
258 true, | 263 true, |
259 sigma.x(), | 264 sigma.x(), |
260 sigma.y())); | 265 sigma.y())); |
261 offset->fX = rect.fLeft; | |
262 offset->fY = rect.fTop; | |
263 return SkImageFilterUtils::WrapTexture(tex, rect.width(), rect.height(), res
ult); | 266 return SkImageFilterUtils::WrapTexture(tex, rect.width(), rect.height(), res
ult); |
264 #else | 267 #else |
265 SkDEBUGFAIL("Should not call in GPU-less build"); | 268 SkDEBUGFAIL("Should not call in GPU-less build"); |
266 return false; | 269 return false; |
267 #endif | 270 #endif |
268 } | 271 } |
OLD | NEW |