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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 paint.addColorTextureProcessor(srcTexture, matrix, params); | 219 paint.addColorTextureProcessor(srcTexture, matrix, params); |
220 } | 220 } |
221 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, | 221 scale_rect(&dstRect, i < scaleFactorX ? 0.5f : 1.0f, |
222 i < scaleFactorY ? 0.5f : 1.0f); | 222 i < scaleFactorY ? 0.5f : 1.0f); |
223 context->drawRectToRect(paint, dstRect, srcRect); | 223 context->drawRectToRect(paint, dstRect, srcRect); |
224 srcRect = dstRect; | 224 srcRect = dstRect; |
225 srcTexture = dstTexture; | 225 srcTexture = dstTexture; |
226 SkTSwap(dstTexture, tempTexture); | 226 SkTSwap(dstTexture, tempTexture); |
227 } | 227 } |
228 | 228 |
229 SkIRect srcIRect; | 229 const SkIRect srcIRect = srcRect.roundOut(); |
230 srcRect.roundOut(&srcIRect); | |
231 | 230 |
232 // For really small blurs(Certainly no wider than 5x5 on desktop gpus) it is
faster to just | 231 // For really small blurs(Certainly no wider than 5x5 on desktop gpus) it is
faster to just |
233 // launch a single non separable kernel vs two launches | 232 // launch a single non separable kernel vs two launches |
234 if (sigmaX > 0.0f && sigmaY > 0 && | 233 if (sigmaX > 0.0f && sigmaY > 0 && |
235 (2 * radiusX + 1) * (2 * radiusY + 1) <= MAX_KERNEL_SIZE) { | 234 (2 * radiusX + 1) * (2 * radiusY + 1) <= MAX_KERNEL_SIZE) { |
236 // We shouldn't be scaling because this is a small size blur | 235 // We shouldn't be scaling because this is a small size blur |
237 SkASSERT((scaleFactorX == scaleFactorY) == 1); | 236 SkASSERT((scaleFactorX == scaleFactorY) == 1); |
238 context->setRenderTarget(dstTexture->asRenderTarget()); | 237 context->setRenderTarget(dstTexture->asRenderTarget()); |
239 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); | 238 SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height()); |
240 convolve_gaussian_2d(context, srcRect, dstRect, srcTexture, | 239 convolve_gaussian_2d(context, srcRect, dstRect, srcTexture, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 context->drawRectToRect(paint, dstRect, srcRect); | 302 context->drawRectToRect(paint, dstRect, srcRect); |
304 srcRect = dstRect; | 303 srcRect = dstRect; |
305 srcTexture = dstTexture; | 304 srcTexture = dstTexture; |
306 SkTSwap(dstTexture, tempTexture); | 305 SkTSwap(dstTexture, tempTexture); |
307 } | 306 } |
308 return SkRef(srcTexture); | 307 return SkRef(srcTexture); |
309 } | 308 } |
310 #endif | 309 #endif |
311 | 310 |
312 } | 311 } |
OLD | NEW |