Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Unified Diff: src/core/SkGpuBlurUtils.cpp

Issue 2514543002: Defer more renderTargetContexts in the GPU image filter paths - take 2 (Closed)
Patch Set: Add more bullet proofing Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBlurImageFilter.cpp ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkGpuBlurUtils.cpp
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index 84cc8d8d148c76fef8274aa16c2f6ba7762921e7..f210178cefd768403d1d5c08497ba5ee77bcc4a6 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -229,7 +229,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
const int height = dstBounds.height();
const GrPixelConfig config = srcTexture->config();
- sk_sp<GrRenderTargetContext> dstRenderTargetContext(context->makeRenderTargetContext(
+ sk_sp<GrRenderTargetContext> dstRenderTargetContext(context->makeDeferredRenderTargetContext(
fit, width, height, config, colorSpace, 0, kDefault_GrSurfaceOrigin));
if (!dstRenderTargetContext) {
return nullptr;
@@ -248,7 +248,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
return dstRenderTargetContext;
}
- sk_sp<GrRenderTargetContext> tmpRenderTargetContext(context->makeRenderTargetContext(
+ sk_sp<GrRenderTargetContext> tmpRenderTargetContext(context->makeDeferredRenderTargetContext(
fit, width, height, config, colorSpace, 0, kDefault_GrSurfaceOrigin));
if (!tmpRenderTargetContext) {
return nullptr;
@@ -261,6 +261,8 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
GrPaint paint;
paint.setGammaCorrect(dstRenderTargetContext->isGammaCorrect());
+ // TODO: this matrix relies on the final instantiated size of the texture. This
+ // will have to be deferred for TextureProxys
SkMatrix matrix;
matrix.setIDiv(srcTexture->width(), srcTexture->height());
SkIRect dstRect(srcRect);
@@ -292,6 +294,9 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
srcRenderTargetContext = dstRenderTargetContext;
srcRect = dstRect;
srcTexture = srcRenderTargetContext->asTexture();
+ if (!srcTexture) {
+ return nullptr;
+ }
dstRenderTargetContext.swap(tmpRenderTargetContext);
localSrcBounds = srcRect;
}
@@ -314,6 +319,9 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
srcBounds, srcOffset);
srcRenderTargetContext = dstRenderTargetContext;
srcTexture = srcRenderTargetContext->asTexture();
+ if (!srcTexture) {
+ return nullptr;
+ }
srcRect.offsetTo(0, 0);
dstRenderTargetContext.swap(tmpRenderTargetContext);
localSrcBounds = srcRect;
@@ -350,14 +358,20 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
clearRect = SkIRect::MakeXYWH(srcRect.fRight, srcRect.fTop, 1, srcRect.height());
srcRenderTargetContext->clear(&clearRect, 0x0, false);
- SkMatrix matrix;
- matrix.setIDiv(srcRenderTargetContext->width(), srcRenderTargetContext->height());
-
GrPaint paint;
paint.setGammaCorrect(dstRenderTargetContext->isGammaCorrect());
// FIXME: this should be mitchell, not bilinear.
GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kBilerp_FilterMode);
sk_sp<GrTexture> tex(srcRenderTargetContext->asTexture());
+ if (!tex) {
+ return nullptr;
+ }
+
+ // TODO: this matrix relies on the final instantiated size of the texture. This
+ // will have to be deferred for TextureProxys
+ SkMatrix matrix;
+ matrix.setIDiv(tex->width(), tex->height());
+
paint.addColorTextureProcessor(tex.get(), nullptr, matrix, params);
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
« no previous file with comments | « src/core/SkBlurImageFilter.cpp ('k') | src/core/SkImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698