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

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

Issue 1264103004: Port SkBlurImage opts to SkOpts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: typo Created 5 years, 4 months 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
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"
11 #include "SkGpuBlurUtils.h"
12 #include "SkOpts.h"
11 #include "SkReadBuffer.h" 13 #include "SkReadBuffer.h"
12 #include "SkWriteBuffer.h" 14 #include "SkWriteBuffer.h"
13 #include "SkGpuBlurUtils.h"
14 #include "SkBlurImage_opts.h"
15 #if SK_SUPPORT_GPU 15 #if SK_SUPPORT_GPU
16 #include "GrContext.h" 16 #include "GrContext.h"
17 #endif 17 #endif
18 18
19 // This rather arbitrary-looking value results in a maximum box blur kernel size 19 // This rather arbitrary-looking value results in a maximum box blur kernel size
20 // of 1000 pixels on the raster path, which matches the WebKit and Firefox 20 // of 1000 pixels on the raster path, which matches the WebKit and Firefox
21 // implementations. Since the GPU path does not compute a box blur, putting 21 // implementations. Since the GPU path does not compute a box blur, putting
22 // the limit on sigma ensures consistent behaviour between the GPU and 22 // the limit on sigma ensures consistent behaviour between the GPU and
23 // raster paths. 23 // raster paths.
24 #define MAX_SIGMA SkIntToScalar(532) 24 #define MAX_SIGMA SkIntToScalar(532)
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 197 }
198 198
199 offset->fX = srcBounds.fLeft; 199 offset->fX = srcBounds.fLeft;
200 offset->fY = srcBounds.fTop; 200 offset->fY = srcBounds.fTop;
201 srcBounds.offset(-srcOffset); 201 srcBounds.offset(-srcOffset);
202 const SkPMColor* s = src.getAddr32(srcBounds.left(), srcBounds.top()); 202 const SkPMColor* s = src.getAddr32(srcBounds.left(), srcBounds.top());
203 SkPMColor* t = temp.getAddr32(0, 0); 203 SkPMColor* t = temp.getAddr32(0, 0);
204 SkPMColor* d = dst->getAddr32(0, 0); 204 SkPMColor* d = dst->getAddr32(0, 0);
205 int w = dstBounds.width(), h = dstBounds.height(); 205 int w = dstBounds.width(), h = dstBounds.height();
206 int sw = src.rowBytesAsPixels(); 206 int sw = src.rowBytesAsPixels();
207 SkBoxBlurProc boxBlurX, boxBlurXY, boxBlurYX; 207
208 if (!SkBoxBlurGetPlatformProcs(&boxBlurX, &boxBlurXY, &boxBlurYX)) { 208 auto boxBlurX = SkOpts::box_blur_xx,
djsollen 2015/08/04 14:39:56 instead of Auto would it be more clear if we used
mtklein 2015/08/04 14:46:44 Both seem fine to me. Do you prefer SkOpts::BoxBl
djsollen 2015/08/04 14:56:17 Yeah, I find it more clear as a reader.
209 boxBlurX = boxBlur<kX, kX>; 209 boxBlurXY = SkOpts::box_blur_xy,
210 boxBlurXY = boxBlur<kX, kY>; 210 boxBlurYX = SkOpts::box_blur_yx;
211 boxBlurYX = boxBlur<kY, kX>; 211 if (!boxBlurX ) { boxBlurX = boxBlur<kX, kX>; }
212 } 212 if (!boxBlurXY) { boxBlurXY = boxBlur<kX, kY>; }
213 if (!boxBlurYX) { boxBlurYX = boxBlur<kY, kX>; }
213 214
214 if (kernelSizeX > 0 && kernelSizeY > 0) { 215 if (kernelSizeX > 0 && kernelSizeY > 0) {
215 boxBlurX(s, sw, t, kernelSizeX, lowOffsetX, highOffsetX, w, h); 216 boxBlurX(s, sw, t, kernelSizeX, lowOffsetX, highOffsetX, w, h);
216 boxBlurX(t, w, d, kernelSizeX, highOffsetX, lowOffsetX, w, h); 217 boxBlurX(t, w, d, kernelSizeX, highOffsetX, lowOffsetX, w, h);
217 boxBlurXY(d, w, t, kernelSizeX3, highOffsetX, highOffsetX, w, h); 218 boxBlurXY(d, w, t, kernelSizeX3, highOffsetX, highOffsetX, w, h);
218 boxBlurX(t, h, d, kernelSizeY, lowOffsetY, highOffsetY, h, w); 219 boxBlurX(t, h, d, kernelSizeY, lowOffsetY, highOffsetY, h, w);
219 boxBlurX(d, h, t, kernelSizeY, highOffsetY, lowOffsetY, h, w); 220 boxBlurX(d, h, t, kernelSizeY, highOffsetY, lowOffsetY, h, w);
220 boxBlurXY(t, h, d, kernelSizeY3, highOffsetY, highOffsetY, h, w); 221 boxBlurXY(t, h, d, kernelSizeY3, highOffsetY, highOffsetY, h, w);
221 } else if (kernelSizeX > 0) { 222 } else if (kernelSizeX > 0) {
222 boxBlurX(s, sw, d, kernelSizeX, lowOffsetX, highOffsetX, w, h); 223 boxBlurX(s, sw, d, kernelSizeX, lowOffsetX, highOffsetX, w, h);
(...skipping 30 matching lines...) Expand all
253 } 254 }
254 *dst = bounds; 255 *dst = bounds;
255 return true; 256 return true;
256 } 257 }
257 258
258 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, 259 bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
259 SkBitmap* result, SkIPoint* offset) const { 260 SkBitmap* result, SkIPoint* offset) const {
260 #if SK_SUPPORT_GPU 261 #if SK_SUPPORT_GPU
261 SkBitmap input = src; 262 SkBitmap input = src;
262 SkIPoint srcOffset = SkIPoint::Make(0, 0); 263 SkIPoint srcOffset = SkIPoint::Make(0, 0);
263 if (this->getInput(0) && 264 if (this->getInput(0) &&
264 !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffse t)) { 265 !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffse t)) {
265 return false; 266 return false;
266 } 267 }
267 SkIRect rect; 268 SkIRect rect;
268 if (!this->applyCropRect(ctx, proxy, input, &srcOffset, &rect, &input)) { 269 if (!this->applyCropRect(ctx, proxy, input, &srcOffset, &rect, &input)) {
269 return false; 270 return false;
270 } 271 }
271 GrTexture* source = input.getTexture(); 272 GrTexture* source = input.getTexture();
272 SkVector sigma = mapSigma(fSigma, ctx.ctm()); 273 SkVector sigma = mapSigma(fSigma, ctx.ctm());
273 offset->fX = rect.fLeft; 274 offset->fX = rect.fLeft;
(...skipping 22 matching lines...) Expand all
296 str->appendf("SkBlurImageFilter: ("); 297 str->appendf("SkBlurImageFilter: (");
297 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight); 298 str->appendf("sigma: (%f, %f) input (", fSigma.fWidth, fSigma.fHeight);
298 299
299 if (this->getInput(0)) { 300 if (this->getInput(0)) {
300 this->getInput(0)->toString(str); 301 this->getInput(0)->toString(str);
301 } 302 }
302 303
303 str->append("))"); 304 str->append("))");
304 } 305 }
305 #endif 306 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698