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

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

Issue 20789003: Small optimization for convolution shader: only apply the bounds check in (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Make direction() context Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/gpu/effects/GrConvolutionEffect.h » ('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 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkGpuBlurUtils.h" 8 #include "SkGpuBlurUtils.h"
9 9
10 #include "SkRect.h" 10 #include "SkRect.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 static void convolve_gaussian(GrContext* context, 42 static void convolve_gaussian(GrContext* context,
43 GrTexture* texture, 43 GrTexture* texture,
44 const SkRect& srcRect, 44 const SkRect& srcRect,
45 const SkRect& dstRect, 45 const SkRect& dstRect,
46 bool cropToSrcRect, 46 bool cropToSrcRect,
47 float sigma, 47 float sigma,
48 int radius, 48 int radius,
49 Gr1DKernelEffect::Direction direction) { 49 Gr1DKernelEffect::Direction direction) {
50 GrPaint paint; 50 GrPaint paint;
51 paint.reset(); 51 paint.reset();
52 float cropRect[4] = { 0.0f, 1.0f, 0.0f, 1.0f }; 52 float bounds[2] = { 0.0f, 1.0f };
53 if (cropToSrcRect) { 53 if (cropToSrcRect) {
54 if (direction == Gr1DKernelEffect::kX_Direction) { 54 if (direction == Gr1DKernelEffect::kX_Direction) {
55 cropRect[0] = SkScalarToFloat(srcRect.left()) / texture->width(); 55 bounds[0] = SkScalarToFloat(srcRect.left()) / texture->width();
56 cropRect[1] = SkScalarToFloat(srcRect.right()) / texture->width(); 56 bounds[1] = SkScalarToFloat(srcRect.right()) / texture->width();
57 } else { 57 } else {
58 cropRect[2] = SkScalarToFloat(srcRect.top()) / texture->height(); 58 bounds[0] = SkScalarToFloat(srcRect.top()) / texture->height();
59 cropRect[3] = SkScalarToFloat(srcRect.bottom()) / texture->height(); 59 bounds[1] = SkScalarToFloat(srcRect.bottom()) / texture->height();
60 } 60 }
61 } 61 }
62 62
63 SkAutoTUnref<GrEffectRef> conv(GrConvolutionEffect::CreateGaussian(texture, 63 SkAutoTUnref<GrEffectRef> conv(GrConvolutionEffect::CreateGaussian(texture,
64 direction , 64 direction ,
65 radius, 65 radius,
66 sigma, 66 sigma,
67 cropToSrc Rect, 67 cropToSrc Rect,
68 cropRect) ); 68 bounds));
69 paint.addColorEffect(conv); 69 paint.addColorEffect(conv);
70 context->drawRectToRect(paint, dstRect, srcRect); 70 context->drawRectToRect(paint, dstRect, srcRect);
71 } 71 }
72 72
73 GrTexture* GaussianBlur(GrContext* context, 73 GrTexture* GaussianBlur(GrContext* context,
74 GrTexture* srcTexture, 74 GrTexture* srcTexture,
75 bool canClobberSrc, 75 bool canClobberSrc,
76 const SkRect& rect, 76 const SkRect& rect,
77 bool cropToRect, 77 bool cropToRect,
78 float sigmaX, 78 float sigmaX,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } else if (srcTexture == temp2.texture()) { 214 } else if (srcTexture == temp2.texture()) {
215 return temp2.detach(); 215 return temp2.detach();
216 } else { 216 } else {
217 srcTexture->ref(); 217 srcTexture->ref();
218 return srcTexture; 218 return srcTexture;
219 } 219 }
220 } 220 }
221 #endif 221 #endif
222 222
223 } 223 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/effects/GrConvolutionEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698