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

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

Issue 812063002: Change to create device coord coordset (Closed) Base URL: https://skia.googlesource.com/skia.git@vm-off-context
Patch Set: ignoring bleed Created 6 years 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 | « src/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.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 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 int radius, 51 int radius,
52 float sigma, 52 float sigma,
53 bool useBounds, 53 bool useBounds,
54 float bounds[2]) { 54 float bounds[2]) {
55 GrPaint paint; 55 GrPaint paint;
56 paint.reset(); 56 paint.reset();
57 SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian( 57 SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
58 texture, direction, radius, sigma, useBounds, bounds)); 58 texture, direction, radius, sigma, useBounds, bounds));
59 paint.reset(); 59 paint.reset();
60 paint.addColorProcessor(conv); 60 paint.addColorProcessor(conv);
61 context->drawRectToRect(paint, SkMatrix::I(), dstRect, srcRect); 61 context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect);
62 } 62 }
63 63
64 static void convolve_gaussian_2d(GrContext* context, 64 static void convolve_gaussian_2d(GrContext* context,
65 const SkRect& srcRect, 65 const SkRect& srcRect,
66 const SkRect& dstRect, 66 const SkRect& dstRect,
67 GrTexture* texture, 67 GrTexture* texture,
68 int radiusX, 68 int radiusX,
69 int radiusY, 69 int radiusY,
70 SkScalar sigmaX, 70 SkScalar sigmaX,
71 SkScalar sigmaY, 71 SkScalar sigmaY,
72 bool useBounds, 72 bool useBounds,
73 SkIRect bounds) { 73 SkIRect bounds) {
74 SkISize size = SkISize::Make(2 * radiusX + 1, 2 * radiusY + 1); 74 SkISize size = SkISize::Make(2 * radiusX + 1, 2 * radiusY + 1);
75 SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY); 75 SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY);
76 GrPaint paint; 76 GrPaint paint;
77 paint.reset(); 77 paint.reset();
78 SkAutoTUnref<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::CreateGaus sian( 78 SkAutoTUnref<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::CreateGaus sian(
79 texture, bounds, size, 1.0, 0.0, kernelOffset, 79 texture, bounds, size, 1.0, 0.0, kernelOffset,
80 useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_ Mode, 80 useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_ Mode,
81 true, sigmaX, sigmaY)); 81 true, sigmaX, sigmaY));
82 paint.reset(); 82 paint.reset();
83 paint.addColorProcessor(conv); 83 paint.addColorProcessor(conv);
84 context->drawRectToRect(paint, SkMatrix::I(), dstRect, srcRect); 84 context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect);
85 } 85 }
86 86
87 static void convolve_gaussian(GrContext* context, 87 static void convolve_gaussian(GrContext* context,
88 const SkRect& srcRect, 88 const SkRect& srcRect,
89 const SkRect& dstRect, 89 const SkRect& dstRect,
90 GrTexture* texture, 90 GrTexture* texture,
91 Gr1DKernelEffect::Direction direction, 91 Gr1DKernelEffect::Direction direction,
92 int radius, 92 int radius,
93 float sigma, 93 float sigma,
94 bool cropToSrcRect) { 94 bool cropToSrcRect) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 domain, 210 domain,
211 GrTextureDomain::kDecal_Mode, 211 GrTextureDomain::kDecal_Mode,
212 GrTextureParams::kBilerp_FilterMode)); 212 GrTextureParams::kBilerp_FilterMode));
213 paint.addColorProcessor(fp); 213 paint.addColorProcessor(fp);
214 } else { 214 } else {
215 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k Bilerp_FilterMode); 215 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k Bilerp_FilterMode);
216 paint.addColorTextureProcessor(srcTexture, matrix, params); 216 paint.addColorTextureProcessor(srcTexture, matrix, params);
217 } 217 }
218 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, 218 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f,
219 i < scaleFactorY ? 0.5f : 1.0f); 219 i < scaleFactorY ? 0.5f : 1.0f);
220 context->drawRectToRect(paint, SkMatrix::I(), dstRect, srcRect); 220 context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect);
221 srcRect = dstRect; 221 srcRect = dstRect;
222 srcTexture = dstTexture; 222 srcTexture = dstTexture;
223 SkTSwap(dstTexture, tempTexture); 223 SkTSwap(dstTexture, tempTexture);
224 } 224 }
225 225
226 const SkIRect srcIRect = srcRect.roundOut(); 226 const SkIRect srcIRect = srcRect.roundOut();
227 227
228 // For really small blurs(Certainly no wider than 5x5 on desktop gpus) it is faster to just 228 // For really small blurs(Certainly no wider than 5x5 on desktop gpus) it is faster to just
229 // launch a single non separable kernel vs two launches 229 // launch a single non separable kernel vs two launches
230 if (sigmaX > 0.0f && sigmaY > 0 && 230 if (sigmaX > 0.0f && sigmaY > 0 &&
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 matrix.setIDiv(srcTexture->width(), srcTexture->height()); 289 matrix.setIDiv(srcTexture->width(), srcTexture->height());
290 context->setRenderTarget(dstTexture->asRenderTarget()); 290 context->setRenderTarget(dstTexture->asRenderTarget());
291 291
292 GrPaint paint; 292 GrPaint paint;
293 // FIXME: this should be mitchell, not bilinear. 293 // FIXME: this should be mitchell, not bilinear.
294 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBile rp_FilterMode); 294 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBile rp_FilterMode);
295 paint.addColorTextureProcessor(srcTexture, matrix, params); 295 paint.addColorTextureProcessor(srcTexture, matrix, params);
296 296
297 SkRect dstRect(srcRect); 297 SkRect dstRect(srcRect);
298 scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY); 298 scale_rect(&dstRect, (float) scaleFactorX, (float) scaleFactorY);
299 context->drawRectToRect(paint, SkMatrix::I(), dstRect, srcRect); 299 context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect);
300 srcRect = dstRect; 300 srcRect = dstRect;
301 srcTexture = dstTexture; 301 srcTexture = dstTexture;
302 SkTSwap(dstTexture, tempTexture); 302 SkTSwap(dstTexture, tempTexture);
303 } 303 }
304 return SkRef(srcTexture); 304 return SkRef(srcTexture);
305 } 305 }
306 #endif 306 #endif
307 307
308 } 308 }
OLDNEW
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698