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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 const SkRect& srcRect, | 51 const SkRect& srcRect, |
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 texture, direction, radius, sigma, useBounds, bounds)); |
62 paint.addColorFragmentProcessor(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(), | |
83 texture, bounds, size, 1.0, 0.0, kernelOffset, | 82 texture, bounds, size, 1.0, 0.0, kernelOffset, |
84 useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_
Mode, | 83 useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_
Mode, |
85 true, sigmaX, sigmaY)); | 84 true, sigmaX, sigmaY)); |
86 paint.addColorFragmentProcessor(conv); | 85 paint.addColorFragmentProcessor(conv); |
87 drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, sr
cRect); | 86 drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, sr
cRect); |
88 } | 87 } |
89 | 88 |
90 static void convolve_gaussian(GrDrawContext* drawContext, | 89 static void convolve_gaussian(GrDrawContext* drawContext, |
91 GrRenderTarget* rt, | 90 GrRenderTarget* rt, |
92 const GrClip& clip, | 91 const GrClip& clip, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 GrPaint paint; | 201 GrPaint paint; |
203 SkMatrix matrix; | 202 SkMatrix matrix; |
204 matrix.setIDiv(srcTexture->width(), srcTexture->height()); | 203 matrix.setIDiv(srcTexture->width(), srcTexture->height()); |
205 SkRect dstRect(srcRect); | 204 SkRect dstRect(srcRect); |
206 if (cropToRect && i == 1) { | 205 if (cropToRect && i == 1) { |
207 dstRect.offset(-dstRect.fLeft, -dstRect.fTop); | 206 dstRect.offset(-dstRect.fLeft, -dstRect.fTop); |
208 SkRect domain; | 207 SkRect domain; |
209 matrix.mapRect(&domain, rect); | 208 matrix.mapRect(&domain, rect); |
210 domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width()
: 0.0f, | 209 domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width()
: 0.0f, |
211 i < scaleFactorY ? SK_ScalarHalf / srcTexture->height()
: 0.0f); | 210 i < scaleFactorY ? SK_ScalarHalf / srcTexture->height()
: 0.0f); |
212 SkAutoTUnref<GrFragmentProcessor> fp( GrTextureDomainEffect::Creat
e( | 211 SkAutoTUnref<GrFragmentProcessor> fp(GrTextureDomainEffect::Create( |
213 paint.getProcessorDataManager(), | |
214 srcTexture, | 212 srcTexture, |
215 matrix, | 213 matrix, |
216 domain, | 214 domain, |
217 GrTextureDomain::kDecal_Mode, | 215 GrTextureDomain::kDecal_Mode, |
218 GrTextureParams::kBilerp_FilterMode)); | 216 GrTextureParams::kBilerp_FilterMode)); |
219 paint.addColorFragmentProcessor(fp); | 217 paint.addColorFragmentProcessor(fp); |
220 } else { | 218 } else { |
221 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k
Bilerp_FilterMode); | 219 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k
Bilerp_FilterMode); |
222 paint.addColorTextureProcessor(srcTexture, matrix, params); | 220 paint.addColorTextureProcessor(srcTexture, matrix, params); |
223 } | 221 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 srcRect = dstRect; | 357 srcRect = dstRect; |
360 srcTexture = dstTexture; | 358 srcTexture = dstTexture; |
361 SkTSwap(dstTexture, tempTexture); | 359 SkTSwap(dstTexture, tempTexture); |
362 } | 360 } |
363 | 361 |
364 return SkRef(srcTexture); | 362 return SkRef(srcTexture); |
365 } | 363 } |
366 #endif | 364 #endif |
367 | 365 |
368 } | 366 } |
OLD | NEW |