| 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 SkASSERT(kBGRA_8888_GrPixelConfig == srcTexture->config() || | 219 SkASSERT(kBGRA_8888_GrPixelConfig == srcTexture->config() || |
| 220 kRGBA_8888_GrPixelConfig == srcTexture->config() || | 220 kRGBA_8888_GrPixelConfig == srcTexture->config() || |
| 221 kSRGBA_8888_GrPixelConfig == srcTexture->config() || | 221 kSRGBA_8888_GrPixelConfig == srcTexture->config() || |
| 222 kSBGRA_8888_GrPixelConfig == srcTexture->config() || | 222 kSBGRA_8888_GrPixelConfig == srcTexture->config() || |
| 223 kAlpha_8_GrPixelConfig == srcTexture->config()); | 223 kAlpha_8_GrPixelConfig == srcTexture->config()); |
| 224 | 224 |
| 225 const int width = dstBounds.width(); | 225 const int width = dstBounds.width(); |
| 226 const int height = dstBounds.height(); | 226 const int height = dstBounds.height(); |
| 227 const GrPixelConfig config = srcTexture->config(); | 227 const GrPixelConfig config = srcTexture->config(); |
| 228 | 228 |
| 229 sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(SkBackingFit::kA
pprox, | 229 sk_sp<GrDrawContext> dstDrawContext(context->makeDrawContext(SkBackingFit::k
Approx, |
| 230 width, height, c
onfig, colorSpace, | 230 width, height,
config, colorSpace, |
| 231 0, kDefault_GrSu
rfaceOrigin)); | 231 0, kDefault_GrS
urfaceOrigin)); |
| 232 if (!dstDrawContext) { | 232 if (!dstDrawContext) { |
| 233 return nullptr; | 233 return nullptr; |
| 234 } | 234 } |
| 235 | 235 |
| 236 // For really small blurs (certainly no wider than 5x5 on desktop gpus) it i
s faster to just | 236 // For really small blurs (certainly no wider than 5x5 on desktop gpus) it i
s faster to just |
| 237 // launch a single non separable kernel vs two launches | 237 // launch a single non separable kernel vs two launches |
| 238 if (sigmaX > 0.0f && sigmaY > 0.0f && | 238 if (sigmaX > 0.0f && sigmaY > 0.0f && |
| 239 (2 * radiusX + 1) * (2 * radiusY + 1) <= MAX_KERNEL_SIZE) { | 239 (2 * radiusX + 1) * (2 * radiusY + 1) <= MAX_KERNEL_SIZE) { |
| 240 // We shouldn't be scaling because this is a small size blur | 240 // We shouldn't be scaling because this is a small size blur |
| 241 SkASSERT((1 == scaleFactorX) && (1 == scaleFactorY)); | 241 SkASSERT((1 == scaleFactorX) && (1 == scaleFactorY)); |
| 242 | 242 |
| 243 convolve_gaussian_2d(dstDrawContext.get(), clip, localDstBounds, srcOffs
et, | 243 convolve_gaussian_2d(dstDrawContext.get(), clip, localDstBounds, srcOffs
et, |
| 244 srcTexture.get(), radiusX, radiusY, sigmaX, sigmaY,
srcBounds); | 244 srcTexture.get(), radiusX, radiusY, sigmaX, sigmaY,
srcBounds); |
| 245 | 245 |
| 246 return dstDrawContext; | 246 return dstDrawContext; |
| 247 } | 247 } |
| 248 | 248 |
| 249 sk_sp<GrDrawContext> tmpDrawContext(context->newDrawContext(SkBackingFit::kA
pprox, | 249 sk_sp<GrDrawContext> tmpDrawContext(context->makeDrawContext(SkBackingFit::k
Approx, |
| 250 width, height, c
onfig, colorSpace, | 250 width, height,
config, colorSpace, |
| 251 0, kDefault_GrSu
rfaceOrigin)); | 251 0, kDefault_GrS
urfaceOrigin)); |
| 252 if (!tmpDrawContext) { | 252 if (!tmpDrawContext) { |
| 253 return nullptr; | 253 return nullptr; |
| 254 } | 254 } |
| 255 | 255 |
| 256 sk_sp<GrDrawContext> srcDrawContext; | 256 sk_sp<GrDrawContext> srcDrawContext; |
| 257 | 257 |
| 258 SkASSERT(SkIsPow2(scaleFactorX) && SkIsPow2(scaleFactorY)); | 258 SkASSERT(SkIsPow2(scaleFactorX) && SkIsPow2(scaleFactorY)); |
| 259 | 259 |
| 260 for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) { | 260 for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) { |
| 261 GrPaint paint; | 261 GrPaint paint; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 dstDrawContext.swap(tmpDrawContext); | 371 dstDrawContext.swap(tmpDrawContext); |
| 372 } | 372 } |
| 373 | 373 |
| 374 return srcDrawContext; | 374 return srcDrawContext; |
| 375 } | 375 } |
| 376 | 376 |
| 377 } | 377 } |
| 378 | 378 |
| 379 #endif | 379 #endif |
| 380 | 380 |
| OLD | NEW |