aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-11-21 11:05:03 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-11-21 11:05:03 -0800
commitd728f0c1a94fe926b59d8ebc9ae174019ccd3606 (patch)
tree961028483a484d07da315a039104253cd85cb736 /src/gpu
parent43c847b7f281c071a33980359e4d5839855da20f (diff)
Defer more renderTargetContexts in the GPU image filter paths - take 2
This is a reland of https://skia-review.googlesource.com/c/4767/ (Defer more renderTargetContexts in the GPU image filter paths). The addition of guards on instantiation && accessRenderTarget failure should prevent a reoccurence of this Nexus7 failures. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2514543002 TBR=bsalomon@google.com Review-Url: https://codereview.chromium.org/2514543002
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrBlurUtils.cpp44
-rw-r--r--src/gpu/GrContext.cpp17
2 files changed, 42 insertions, 19 deletions
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 58d12af178..97fa623e2f 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -13,6 +13,7 @@
#include "effects/GrSimpleTextureEffect.h"
#include "GrStyle.h"
#include "GrTexture.h"
+#include "GrTextureProxy.h"
#include "GrTextureProvider.h"
#include "SkDraw.h"
#include "SkGrPriv.h"
@@ -92,25 +93,25 @@ static bool sw_draw_with_mask_filter(GrRenderTargetContext* renderTargetContext,
}
// Create a mask of 'devPath' and place the result in 'mask'.
-static sk_sp<GrTexture> create_mask_GPU(GrContext* context,
- const SkIRect& maskRect,
- const SkPath& devPath,
- SkStrokeRec::InitStyle fillOrHairline,
- bool doAA,
- int sampleCnt) {
+static sk_sp<GrTextureProxy> create_mask_GPU(GrContext* context,
+ const SkIRect& maskRect,
+ const SkPath& devPath,
+ SkStrokeRec::InitStyle fillOrHairline,
+ bool doAA,
+ int sampleCnt) {
if (!doAA) {
// Don't need MSAA if mask isn't AA
sampleCnt = 0;
}
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContextWithFallback(
+ sk_sp<GrRenderTargetContext> rtContext(context->makeDeferredRenderTargetContextWithFallback(
SkBackingFit::kApprox, maskRect.width(), maskRect.height(), kAlpha_8_GrPixelConfig, nullptr,
sampleCnt));
- if (!renderTargetContext) {
+ if (!rtContext) {
return nullptr;
}
- renderTargetContext->clear(nullptr, 0x0, true);
+ rtContext->clear(nullptr, 0x0, true);
GrPaint tempPaint;
tempPaint.setAntiAlias(doAA);
@@ -124,8 +125,8 @@ static sk_sp<GrTexture> create_mask_GPU(GrContext* context,
// the origin using tempPaint.
SkMatrix translate;
translate.setTranslate(-SkIntToScalar(maskRect.fLeft), -SkIntToScalar(maskRect.fTop));
- renderTargetContext->drawPath(clip, tempPaint, translate, devPath, GrStyle(fillOrHairline));
- return renderTargetContext->asTexture();;
+ rtContext->drawPath(clip, tempPaint, translate, devPath, GrStyle(fillOrHairline));
+ return sk_ref_sp(rtContext->asDeferredTexture());
}
static void draw_path_with_mask_filter(GrContext* context,
@@ -204,16 +205,21 @@ static void draw_path_with_mask_filter(GrContext* context,
return;
}
- sk_sp<GrTexture> mask(create_mask_GPU(context,
- finalIRect,
- *path,
- fillOrHairline,
- paint->isAntiAlias(),
- renderTargetContext->numColorSamples()));
- if (mask) {
+ sk_sp<GrTextureProxy> maskProxy(create_mask_GPU(context,
+ finalIRect,
+ *path,
+ fillOrHairline,
+ paint->isAntiAlias(),
+ renderTargetContext->numColorSamples()));
+ if (maskProxy) {
GrTexture* filtered;
- if (maskFilter->filterMaskGPU(mask.get(), viewMatrix, finalIRect, &filtered)) {
+ GrTexture* mask = maskProxy->instantiate(context->textureProvider());
+ if (!mask) {
+ return;
+ }
+
+ if (maskFilter->filterMaskGPU(mask, viewMatrix, finalIRect, &filtered)) {
// filterMaskGPU gives us ownership of a ref to the result
sk_sp<GrTexture> atu(filtered);
if (draw_mask(renderTargetContext, clip, viewMatrix, finalIRect, paint, filtered)) {
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 4994ae04c3..1a5ee20721 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -748,6 +748,23 @@ sk_sp<GrRenderTargetContext> GrContext::makeRenderTargetContextWithFallback(
sampleCnt, origin, surfaceProps, budgeted);
}
+sk_sp<GrRenderTargetContext> GrContext::makeDeferredRenderTargetContextWithFallback(
+ SkBackingFit fit,
+ int width, int height,
+ GrPixelConfig config,
+ sk_sp<SkColorSpace> colorSpace,
+ int sampleCnt,
+ GrSurfaceOrigin origin,
+ const SkSurfaceProps* surfaceProps,
+ SkBudgeted budgeted) {
+ if (!this->caps()->isConfigRenderable(config, sampleCnt > 0)) {
+ config = GrPixelConfigFallback(config);
+ }
+
+ return this->makeDeferredRenderTargetContext(fit, width, height, config, std::move(colorSpace),
+ sampleCnt, origin, surfaceProps, budgeted);
+}
+
sk_sp<GrRenderTargetContext> GrContext::makeRenderTargetContext(SkBackingFit fit,
int width, int height,
GrPixelConfig config,