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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 const SkRect& dstRect, | 52 const SkRect& dstRect, |
53 GrTexture* texture, | 53 GrTexture* texture, |
54 Gr1DKernelEffect::Direction direction, | 54 Gr1DKernelEffect::Direction direction, |
55 int radius, | 55 int radius, |
56 float sigma, | 56 float sigma, |
57 bool useBounds, | 57 bool useBounds, |
58 float bounds[2]) { | 58 float bounds[2]) { |
59 GrPaint paint; | 59 GrPaint paint; |
60 SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian( | 60 SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian( |
61 paint.getProcessorDataManager(), texture, direction, radius, sigma, useB
ounds, bounds)); | 61 paint.getProcessorDataManager(), texture, direction, radius, sigma, useB
ounds, bounds)); |
62 paint.addColorProcessor(conv); | 62 paint.addColorFragmentProcessor(conv); |
63 drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, sr
cRect); | 63 drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, sr
cRect); |
64 } | 64 } |
65 | 65 |
66 static void convolve_gaussian_2d(GrDrawContext* drawContext, | 66 static void convolve_gaussian_2d(GrDrawContext* drawContext, |
67 GrRenderTarget* rt, | 67 GrRenderTarget* rt, |
68 const GrClip& clip, | 68 const GrClip& clip, |
69 const SkRect& srcRect, | 69 const SkRect& srcRect, |
70 const SkRect& dstRect, | 70 const SkRect& dstRect, |
71 GrTexture* texture, | 71 GrTexture* texture, |
72 int radiusX, | 72 int radiusX, |
73 int radiusY, | 73 int radiusY, |
74 SkScalar sigmaX, | 74 SkScalar sigmaX, |
75 SkScalar sigmaY, | 75 SkScalar sigmaY, |
76 bool useBounds, | 76 bool useBounds, |
77 SkIRect bounds) { | 77 SkIRect bounds) { |
78 SkISize size = SkISize::Make(2 * radiusX + 1, 2 * radiusY + 1); | 78 SkISize size = SkISize::Make(2 * radiusX + 1, 2 * radiusY + 1); |
79 SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY); | 79 SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY); |
80 GrPaint paint; | 80 GrPaint paint; |
81 SkAutoTUnref<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::CreateGaus
sian( | 81 SkAutoTUnref<GrFragmentProcessor> conv(GrMatrixConvolutionEffect::CreateGaus
sian( |
82 paint.getProcessorDataManager(), | 82 paint.getProcessorDataManager(), |
83 texture, bounds, size, 1.0, 0.0, kernelOffset, | 83 texture, bounds, size, 1.0, 0.0, kernelOffset, |
84 useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_
Mode, | 84 useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_
Mode, |
85 true, sigmaX, sigmaY)); | 85 true, sigmaX, sigmaY)); |
86 paint.addColorProcessor(conv); | 86 paint.addColorFragmentProcessor(conv); |
87 drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, sr
cRect); | 87 drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, sr
cRect); |
88 } | 88 } |
89 | 89 |
90 static void convolve_gaussian(GrDrawContext* drawContext, | 90 static void convolve_gaussian(GrDrawContext* drawContext, |
91 GrRenderTarget* rt, | 91 GrRenderTarget* rt, |
92 const GrClip& clip, | 92 const GrClip& clip, |
93 const SkRect& srcRect, | 93 const SkRect& srcRect, |
94 const SkRect& dstRect, | 94 const SkRect& dstRect, |
95 GrTexture* texture, | 95 GrTexture* texture, |
96 Gr1DKernelEffect::Direction direction, | 96 Gr1DKernelEffect::Direction direction, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 matrix.mapRect(&domain, rect); | 209 matrix.mapRect(&domain, rect); |
210 domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width()
: 0.0f, | 210 domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width()
: 0.0f, |
211 i < scaleFactorY ? SK_ScalarHalf / srcTexture->height()
: 0.0f); | 211 i < scaleFactorY ? SK_ScalarHalf / srcTexture->height()
: 0.0f); |
212 SkAutoTUnref<GrFragmentProcessor> fp( GrTextureDomainEffect::Creat
e( | 212 SkAutoTUnref<GrFragmentProcessor> fp( GrTextureDomainEffect::Creat
e( |
213 paint.getProcessorDataManager(), | 213 paint.getProcessorDataManager(), |
214 srcTexture, | 214 srcTexture, |
215 matrix, | 215 matrix, |
216 domain, | 216 domain, |
217 GrTextureDomain::kDecal_Mode, | 217 GrTextureDomain::kDecal_Mode, |
218 GrTextureParams::kBilerp_FilterMode)); | 218 GrTextureParams::kBilerp_FilterMode)); |
219 paint.addColorProcessor(fp); | 219 paint.addColorFragmentProcessor(fp); |
220 } else { | 220 } else { |
221 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k
Bilerp_FilterMode); | 221 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k
Bilerp_FilterMode); |
222 paint.addColorTextureProcessor(srcTexture, matrix, params); | 222 paint.addColorTextureProcessor(srcTexture, matrix, params); |
223 } | 223 } |
224 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, | 224 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, |
225 i < scaleFactorY ? 0.5f : 1.0f); | 225 i < scaleFactorY ? 0.5f : 1.0f); |
226 | 226 |
227 GrDrawContext* dstDrawContext = context->drawContext(); | 227 GrDrawContext* dstDrawContext = context->drawContext(); |
228 if (!dstDrawContext) { | 228 if (!dstDrawContext) { |
229 return NULL; | 229 return NULL; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 srcRect = dstRect; | 359 srcRect = dstRect; |
360 srcTexture = dstTexture; | 360 srcTexture = dstTexture; |
361 SkTSwap(dstTexture, tempTexture); | 361 SkTSwap(dstTexture, tempTexture); |
362 } | 362 } |
363 | 363 |
364 return SkRef(srcTexture); | 364 return SkRef(srcTexture); |
365 } | 365 } |
366 #endif | 366 #endif |
367 | 367 |
368 } | 368 } |
OLD | NEW |