OLD | NEW |
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 static void convolve_gaussian_1d(GrContext* context, | 46 static void convolve_gaussian_1d(GrContext* context, |
47 const SkRect& srcRect, | 47 const SkRect& srcRect, |
48 const SkRect& dstRect, | 48 const SkRect& dstRect, |
49 GrTexture* texture, | 49 GrTexture* texture, |
50 Gr1DKernelEffect::Direction direction, | 50 Gr1DKernelEffect::Direction direction, |
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(); | |
57 SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian( | 56 SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian( |
58 texture, direction, radius, sigma, useBounds, bounds)); | 57 texture, direction, radius, sigma, useBounds, bounds)); |
59 paint.addColorProcessor(conv); | 58 paint.addColorProcessor(conv); |
60 context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect); | 59 context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect); |
61 } | 60 } |
62 | 61 |
63 static void convolve_gaussian_2d(GrContext* context, | 62 static void convolve_gaussian_2d(GrContext* context, |
64 const SkRect& srcRect, | 63 const SkRect& srcRect, |
65 const SkRect& dstRect, | 64 const SkRect& dstRect, |
66 GrTexture* texture, | 65 GrTexture* texture, |
67 int radiusX, | 66 int radiusX, |
68 int radiusY, | 67 int radiusY, |
69 SkScalar sigmaX, | 68 SkScalar sigmaX, |
70 SkScalar sigmaY, | 69 SkScalar sigmaY, |
71 bool useBounds, | 70 bool useBounds, |
72 SkIRect bounds) { | 71 SkIRect bounds) { |
73 SkISize size = SkISize::Make(2 * radiusX + 1, 2 * radiusY + 1); | 72 SkISize size = SkISize::Make(2 * radiusX + 1, 2 * radiusY + 1); |
74 SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY); | 73 SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY); |
75 GrPaint paint; | 74 GrPaint paint; |
76 paint.reset(); | |
77 SkAutoTUnref<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::CreateGaus
sian( | 75 SkAutoTUnref<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::CreateGaus
sian( |
78 texture, bounds, size, 1.0, 0.0, kernelOffset, | 76 texture, bounds, size, 1.0, 0.0, kernelOffset, |
79 useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_
Mode, | 77 useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_
Mode, |
80 true, sigmaX, sigmaY)); | 78 true, sigmaX, sigmaY)); |
81 paint.addColorProcessor(conv); | 79 paint.addColorProcessor(conv); |
82 context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect); | 80 context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect); |
83 } | 81 } |
84 | 82 |
85 static void convolve_gaussian(GrContext* context, | 83 static void convolve_gaussian(GrContext* context, |
86 const SkRect& srcRect, | 84 const SkRect& srcRect, |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect); | 295 context->drawNonAARectToRect(paint, SkMatrix::I(), dstRect, srcRect); |
298 srcRect = dstRect; | 296 srcRect = dstRect; |
299 srcTexture = dstTexture; | 297 srcTexture = dstTexture; |
300 SkTSwap(dstTexture, tempTexture); | 298 SkTSwap(dstTexture, tempTexture); |
301 } | 299 } |
302 return SkRef(srcTexture); | 300 return SkRef(srcTexture); |
303 } | 301 } |
304 #endif | 302 #endif |
305 | 303 |
306 } | 304 } |
OLD | NEW |