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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 198 } |
199 | 199 |
200 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 200 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
201 SkBitmap* result, SkIPoint* offset) const
{ | 201 SkBitmap* result, SkIPoint* offset) const
{ |
202 #if SK_SUPPORT_GPU | 202 #if SK_SUPPORT_GPU |
203 SkBitmap input = src; | 203 SkBitmap input = src; |
204 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 204 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
205 if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) { | 205 if (!this->filterInputGPU(0, proxy, src, ctx, &input, &srcOffset)) { |
206 return false; | 206 return false; |
207 } | 207 } |
208 SkIRect srcBounds, dstBounds; | 208 SkIRect rect; |
209 if (!this->applyCropRect(ctx, input, srcOffset, &dstBounds, &srcBounds)) { | 209 if (!this->applyCropRect(ctx, proxy, input, &srcOffset, &rect, &input)) { |
210 return false; | 210 return false; |
211 } | 211 } |
212 GrTexture* source = input.getTexture(); | 212 GrTexture* source = input.getTexture(); |
213 SkVector sigma = mapSigma(fSigma, ctx.ctm()); | 213 SkVector sigma = mapSigma(fSigma, ctx.ctm()); |
214 offset->fX = dstBounds.fLeft; | 214 offset->fX = rect.fLeft; |
215 offset->fY = dstBounds.fTop; | 215 offset->fY = rect.fTop; |
216 srcBounds.offset(-srcOffset); | 216 rect.offset(-srcOffset); |
217 dstBounds.offset(-srcOffset); | |
218 SkRect srcBoundsF(SkRect::Make(srcBounds)); | |
219 auto constraint = GrTextureProvider::FromImageFilter(ctx.sizeConstraint()); | 217 auto constraint = GrTextureProvider::FromImageFilter(ctx.sizeConstraint()); |
220 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext(
), | 218 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext(
), |
221 source, | 219 source, |
222 false, | 220 false, |
223 SkRect::Make(dstBou
nds), | 221 SkRect::Make(rect), |
224 &srcBoundsF, | 222 true, |
225 sigma.x(), | 223 sigma.x(), |
226 sigma.y(), | 224 sigma.y(), |
227 constraint)); | 225 constraint)); |
228 if (!tex) { | 226 if (!tex) { |
229 return false; | 227 return false; |
230 } | 228 } |
231 WrapTexture(tex, dstBounds.width(), dstBounds.height(), result); | 229 WrapTexture(tex, rect.width(), rect.height(), result); |
232 return true; | 230 return true; |
233 #else | 231 #else |
234 SkDEBUGFAIL("Should not call in GPU-less build"); | 232 SkDEBUGFAIL("Should not call in GPU-less build"); |
235 return false; | 233 return false; |
236 #endif | 234 #endif |
237 } | 235 } |
238 | 236 |
239 #ifndef SK_IGNORE_TO_STRING | 237 #ifndef SK_IGNORE_TO_STRING |
240 void SkBlurImageFilter::toString(SkString* str) const { | 238 void SkBlurImageFilter::toString(SkString* str) const { |
241 str->appendf("SkBlurImageFilter: ("); | 239 str->appendf("SkBlurImageFilter: ("); |
242 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); | 240 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); |
243 | 241 |
244 if (this->getInput(0)) { | 242 if (this->getInput(0)) { |
245 this->getInput(0)->toString(str); | 243 this->getInput(0)->toString(str); |
246 } | 244 } |
247 | 245 |
248 str->append("))"); | 246 str->append("))"); |
249 } | 247 } |
250 #endif | 248 #endif |
OLD | NEW |