Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: src/effects/SkBlurImageFilter.cpp

Issue 1431593002: Make SkBlurImageFilter capable of cropping during blur (GPU path). (Closed) Base URL: senorblanco-linux.mon:src/skia@blur-applyCropRect4-separate-loops
Patch Set: Fix uninitialized bounds in convolve_gaussian_2d() Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 rect; 208 SkIRect srcBounds, dstBounds;
209 if (!this->applyCropRect(ctx, proxy, input, &srcOffset, &rect, &input)) { 209 if (!this->applyCropRect(ctx, input, srcOffset, &dstBounds, &srcBounds)) {
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 = rect.fLeft; 214 offset->fX = dstBounds.fLeft;
215 offset->fY = rect.fTop; 215 offset->fY = dstBounds.fTop;
216 rect.offset(-srcOffset); 216 srcBounds.offset(-srcOffset);
217 dstBounds.offset(-srcOffset);
218 SkRect srcBoundsF(SkRect::Make(srcBounds));
217 auto constraint = GrTextureProvider::FromImageFilter(ctx.sizeConstraint()); 219 auto constraint = GrTextureProvider::FromImageFilter(ctx.sizeConstraint());
218 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext( ), 220 SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(source->getContext( ),
219 source, 221 source,
220 false, 222 false,
221 SkRect::Make(rect), 223 SkRect::Make(dstBou nds),
222 true, 224 &srcBoundsF,
223 sigma.x(), 225 sigma.x(),
224 sigma.y(), 226 sigma.y(),
225 constraint)); 227 constraint));
226 if (!tex) { 228 if (!tex) {
227 return false; 229 return false;
228 } 230 }
229 WrapTexture(tex, rect.width(), rect.height(), result); 231 WrapTexture(tex, dstBounds.width(), dstBounds.height(), result);
230 return true; 232 return true;
231 #else 233 #else
232 SkDEBUGFAIL("Should not call in GPU-less build"); 234 SkDEBUGFAIL("Should not call in GPU-less build");
233 return false; 235 return false;
234 #endif 236 #endif
235 } 237 }
236 238
237 #ifndef SK_IGNORE_TO_STRING 239 #ifndef SK_IGNORE_TO_STRING
238 void SkBlurImageFilter::toString(SkString* str) const { 240 void SkBlurImageFilter::toString(SkString* str) const {
239 str->appendf("SkBlurImageFilter: ("); 241 str->appendf("SkBlurImageFilter: (");
240 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); 242 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight);
241 243
242 if (this->getInput(0)) { 244 if (this->getInput(0)) {
243 this->getInput(0)->toString(str); 245 this->getInput(0)->toString(str);
244 } 246 }
245 247
246 str->append("))"); 248 str->append("))");
247 } 249 }
248 #endif 250 #endif
OLDNEW
« no previous file with comments | « no previous file | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698