| 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" |
| 11 | 11 |
| 12 #if SK_SUPPORT_GPU | 12 #if SK_SUPPORT_GPU |
| 13 #include "effects/GrConvolutionEffect.h" | 13 #include "effects/GrConvolutionEffect.h" |
| 14 #include "effects/GrTextureDomainEffect.h" | 14 #include "effects/GrTextureDomain.h" |
| 15 #include "GrContext.h" | 15 #include "GrContext.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 namespace SkGpuBlurUtils { | 18 namespace SkGpuBlurUtils { |
| 19 | 19 |
| 20 #if SK_SUPPORT_GPU | 20 #if SK_SUPPORT_GPU |
| 21 | 21 |
| 22 #define MAX_BLUR_SIGMA 4.0f | 22 #define MAX_BLUR_SIGMA 4.0f |
| 23 | 23 |
| 24 static void scale_rect(SkRect* rect, float xScale, float yScale) { | 24 static void scale_rect(SkRect* rect, float xScale, float yScale) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 if (cropToRect && i == 1) { | 166 if (cropToRect && i == 1) { |
| 167 dstRect.offset(-dstRect.fLeft, -dstRect.fTop); | 167 dstRect.offset(-dstRect.fLeft, -dstRect.fTop); |
| 168 SkRect domain; | 168 SkRect domain; |
| 169 matrix.mapRect(&domain, rect); | 169 matrix.mapRect(&domain, rect); |
| 170 domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width()
: 0.0f, | 170 domain.inset(i < scaleFactorX ? SK_ScalarHalf / srcTexture->width()
: 0.0f, |
| 171 i < scaleFactorY ? SK_ScalarHalf / srcTexture->height()
: 0.0f); | 171 i < scaleFactorY ? SK_ScalarHalf / srcTexture->height()
: 0.0f); |
| 172 SkAutoTUnref<GrEffectRef> effect(GrTextureDomainEffect::Create( | 172 SkAutoTUnref<GrEffectRef> effect(GrTextureDomainEffect::Create( |
| 173 srcTexture, | 173 srcTexture, |
| 174 matrix, | 174 matrix, |
| 175 domain, | 175 domain, |
| 176 GrTextureDomainEffect::kDecal_WrapMode, | 176 GrTextureDomain::kDecal_Mode, |
| 177 GrTextureParams::kBilerp_FilterMode)); | 177 GrTextureParams::kBilerp_FilterMode)); |
| 178 paint.addColorEffect(effect); | 178 paint.addColorEffect(effect); |
| 179 } else { | 179 } else { |
| 180 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k
Bilerp_FilterMode); | 180 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k
Bilerp_FilterMode); |
| 181 paint.addColorTextureEffect(srcTexture, matrix, params); | 181 paint.addColorTextureEffect(srcTexture, matrix, params); |
| 182 } | 182 } |
| 183 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, | 183 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, |
| 184 i < scaleFactorY ? 0.5f : 1.0f); | 184 i < scaleFactorY ? 0.5f : 1.0f); |
| 185 context->drawRectToRect(paint, dstRect, srcRect); | 185 context->drawRectToRect(paint, dstRect, srcRect); |
| 186 srcRect = dstRect; | 186 srcRect = dstRect; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } else if (srcTexture == temp2.texture()) { | 256 } else if (srcTexture == temp2.texture()) { |
| 257 return temp2.detach(); | 257 return temp2.detach(); |
| 258 } else { | 258 } else { |
| 259 srcTexture->ref(); | 259 srcTexture->ref(); |
| 260 return srcTexture; | 260 return srcTexture; |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 #endif | 263 #endif |
| 264 | 264 |
| 265 } | 265 } |
| OLD | NEW |