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