| 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 texture, direction, radius, sigma, useBounds, bounds)); | 61 paint.getProcessorDataManager(), texture, direction, radius, sigma, useB
ounds, bounds)); |
| 62 paint.addColorProcessor(conv); | 62 paint.addColorProcessor(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 texture, bounds, size, 1.0, 0.0, kernelOffset, | 83 texture, bounds, size, 1.0, 0.0, kernelOffset, |
| 83 useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_
Mode, | 84 useBounds ? GrTextureDomain::kClamp_Mode : GrTextureDomain::kIgnore_
Mode, |
| 84 true, sigmaX, sigmaY)); | 85 true, sigmaX, sigmaY)); |
| 85 paint.addColorProcessor(conv); | 86 paint.addColorProcessor(conv); |
| 86 drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, sr
cRect); | 87 drawContext->drawNonAARectToRect(rt, clip, paint, SkMatrix::I(), dstRect, sr
cRect); |
| 87 } | 88 } |
| 88 | 89 |
| 89 static void convolve_gaussian(GrDrawContext* drawContext, | 90 static void convolve_gaussian(GrDrawContext* drawContext, |
| 90 GrRenderTarget* rt, | 91 GrRenderTarget* rt, |
| 91 const GrClip& clip, | 92 const GrClip& clip, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 SkMatrix matrix; | 208 SkMatrix matrix; |
| 208 matrix.setIDiv(srcTexture->width(), srcTexture->height()); | 209 matrix.setIDiv(srcTexture->width(), srcTexture->height()); |
| 209 SkRect dstRect(srcRect); | 210 SkRect dstRect(srcRect); |
| 210 if (cropToRect && i == 1) { | 211 if (cropToRect && i == 1) { |
| 211 dstRect.offset(-dstRect.fLeft, -dstRect.fTop); | 212 dstRect.offset(-dstRect.fLeft, -dstRect.fTop); |
| 212 SkRect domain; | 213 SkRect domain; |
| 213 matrix.mapRect(&domain, rect); | 214 matrix.mapRect(&domain, rect); |
| 214 domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width()
: 0.0f, | 215 domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width()
: 0.0f, |
| 215 i < scaleFactorY ? SK_ScalarHalf / srcTexture->height()
: 0.0f); | 216 i < scaleFactorY ? SK_ScalarHalf / srcTexture->height()
: 0.0f); |
| 216 SkAutoTUnref<GrFragmentProcessor> fp( GrTextureDomainEffect::Creat
e( | 217 SkAutoTUnref<GrFragmentProcessor> fp( GrTextureDomainEffect::Creat
e( |
| 218 paint.getProcessorDataManager(), |
| 217 srcTexture, | 219 srcTexture, |
| 218 matrix, | 220 matrix, |
| 219 domain, | 221 domain, |
| 220 GrTextureDomain::kDecal_Mode, | 222 GrTextureDomain::kDecal_Mode, |
| 221 GrTextureParams::kBilerp_FilterMode)); | 223 GrTextureParams::kBilerp_FilterMode)); |
| 222 paint.addColorProcessor(fp); | 224 paint.addColorProcessor(fp); |
| 223 } else { | 225 } else { |
| 224 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k
Bilerp_FilterMode); | 226 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k
Bilerp_FilterMode); |
| 225 paint.addColorTextureProcessor(srcTexture, matrix, params); | 227 paint.addColorTextureProcessor(srcTexture, matrix, params); |
| 226 } | 228 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 SkMatrix::I(), dstRect, srcRect); | 310 SkMatrix::I(), dstRect, srcRect); |
| 309 srcRect = dstRect; | 311 srcRect = dstRect; |
| 310 srcTexture = dstTexture; | 312 srcTexture = dstTexture; |
| 311 SkTSwap(dstTexture, tempTexture); | 313 SkTSwap(dstTexture, tempTexture); |
| 312 } | 314 } |
| 313 return SkRef(srcTexture); | 315 return SkRef(srcTexture); |
| 314 } | 316 } |
| 315 #endif | 317 #endif |
| 316 | 318 |
| 317 } | 319 } |
| OLD | NEW |