Revert "Defer more renderTargetContexts in the GPU image filter paths"
authorRobert Phillips <robertphillips@google.com>
Tue, 15 Nov 2016 22:17:22 +0000 (22:17 +0000)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Tue, 15 Nov 2016 22:17:40 +0000 (22:17 +0000)
This reverts commit fd01ce05ef7902c49b0272b3524a389693c72b35.

Reason for revert: see if this is the cause of the Nexus7 assertion failure

Original change's description:
> Defer more renderTargetContexts in the GPU image filter paths
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4767
>
> Change-Id: I4c1f27247ef340a49d1ac96761810e77e6047ca2
> Reviewed-on: https://skia-review.googlesource.com/4767
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
>

TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Change-Id: I158f96ec1252481345fc5dca15086ffd4b47cb95
Reviewed-on: https://skia-review.googlesource.com/4875
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
include/gpu/GrContext.h
src/core/SkBlurImageFilter.cpp
src/core/SkGpuBlurUtils.cpp
src/core/SkImageFilter.cpp
src/effects/SkAlphaThresholdFilter.cpp
src/effects/SkBlurMaskFilter.cpp
src/gpu/GrBlurUtils.cpp
src/gpu/GrContext.cpp

index 67f6c93..6b2c27a 100644 (file)
@@ -197,8 +197,7 @@ public:
 
     // Create a new render target context as above but have it backed by a deferred-style
     // GrRenderTargetProxy rather than one that is backed by an actual GrRenderTarget
-    sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
-                                                 SkBackingFit fit, 
+    sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(SkBackingFit fit, 
                                                  int width, int height,
                                                  GrPixelConfig config,
                                                  sk_sp<SkColorSpace> colorSpace,
@@ -222,18 +221,6 @@ public:
                                                  const SkSurfaceProps* surfaceProps = nullptr,
                                                  SkBudgeted budgeted = SkBudgeted::kYes);
 
-    // Create a new render target context as above but have it backed by a deferred-style
-    // GrRenderTargetProxy rather than one that is backed by an actual GrRenderTarget
-    sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
-                                                 SkBackingFit fit,
-                                                 int width, int height,
-                                                 GrPixelConfig config,
-                                                 sk_sp<SkColorSpace> colorSpace,
-                                                 int sampleCnt = 0,
-                                                 GrSurfaceOrigin origin = kDefault_GrSurfaceOrigin,
-                                                 const SkSurfaceProps* surfaceProps = nullptr,
-                                                 SkBudgeted budgeted = SkBudgeted::kYes);
-
     ///////////////////////////////////////////////////////////////////////////
     // Misc.
 
index 0713055..d531b44 100644 (file)
@@ -15,7 +15,6 @@
 
 #if SK_SUPPORT_GPU
 #include "GrContext.h"
-#include "GrTextureProxy.h"
 #include "SkGr.h"
 #endif
 
@@ -111,8 +110,8 @@ static void get_box3_params(SkScalar s, int *kernelSize, int* kernelSize3, int *
 }
 
 sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* source,
-                                                           const Context& ctx,
-                                                           SkIPoint* offset) const {
+                                                       const Context& ctx,
+                                                       SkIPoint* offset) const {
     SkIPoint inputOffset = SkIPoint::Make(0, 0);
 
     sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
@@ -166,11 +165,9 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* sourc
         }
 
         // TODO: Get the colorSpace from the renderTargetContext (once it has one)
-        return SkSpecialImage::MakeDeferredFromGpu(
-                                           context,
-                                           SkIRect::MakeWH(dstBounds.width(), dstBounds.height()),
+        return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(dstBounds.width(), dstBounds.height()),
                                            kNeedNewImageUniqueID_SpecialImage,
-                                           sk_ref_sp(renderTargetContext->asDeferredTexture()),
+                                           renderTargetContext->asTexture(),
                                            sk_ref_sp(input->getColorSpace()), &source->props());
     }
 #endif
index 1236e2b..8107642 100644 (file)
@@ -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->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> dstRenderTargetContext(context->makeRenderTargetContext(
         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->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> tmpRenderTargetContext(context->makeRenderTargetContext(
         fit, width, height, config, colorSpace, 0, kDefault_GrSurfaceOrigin));
     if (!tmpRenderTargetContext) {
         return nullptr;
@@ -261,8 +261,6 @@ 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);
@@ -352,17 +350,14 @@ 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.
         GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode);
         sk_sp<GrTexture> tex(srcRenderTargetContext->asTexture());
-
-        // 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);
 
index df46a13..09c26d3 100644 (file)
@@ -20,9 +20,8 @@
 #include "SkWriteBuffer.h"
 #if SK_SUPPORT_GPU
 #include "GrContext.h"
-#include "GrFixedClip.h"
 #include "GrRenderTargetContext.h"
-#include "GrTextureProxy.h"
+#include "GrFixedClip.h"
 #include "SkGrPriv.h"
 #endif
 
@@ -286,7 +285,7 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
 
     sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace());
     GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get());
-    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext(
+    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContext(
         SkBackingFit::kApprox, bounds.width(), bounds.height(), config, std::move(colorSpace)));
     if (!renderTargetContext) {
         return nullptr;
@@ -299,10 +298,9 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
     GrFixedClip clip(dstIRect);
     renderTargetContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
 
-    return SkSpecialImage::MakeDeferredFromGpu(context, dstIRect,
-                                               kNeedNewImageUniqueID_SpecialImage,
-                                               sk_ref_sp(renderTargetContext->asDeferredTexture()),
-                                               sk_ref_sp(renderTargetContext->getColorSpace()));
+    return SkSpecialImage::MakeFromGpu(dstIRect, kNeedNewImageUniqueID_SpecialImage,
+                                       renderTargetContext->asTexture(),
+                                       sk_ref_sp(renderTargetContext->getColorSpace()));
 }
 #endif
 
index abf924c..b1c8b21 100644 (file)
@@ -16,9 +16,8 @@
 #if SK_SUPPORT_GPU
 #include "GrAlphaThresholdFragmentProcessor.h"
 #include "GrContext.h"
-#include "GrFixedClip.h"
 #include "GrRenderTargetContext.h"
-#include "GrTextureProxy.h"
+#include "GrFixedClip.h"
 #endif
 
 class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter {
@@ -38,9 +37,7 @@ protected:
                                         SkIPoint* offset) const override;
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrTextureProxy> createMaskTexture(GrContext*, 
-                                            const SkMatrix&,
-                                            const SkIRect& bounds) const;
+    sk_sp<GrTexture> createMaskTexture(GrContext*, const SkMatrix&, const SkIRect& bounds) const;
 #endif
 
 private:
@@ -96,29 +93,29 @@ SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region,
 }
 
 #if SK_SUPPORT_GPU
-sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* context,
-                                                                    const SkMatrix& inMatrix,
-                                                                    const SkIRect& bounds) const {
+sk_sp<GrTexture> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* context,
+                                                               const SkMatrix& inMatrix,
+                                                               const SkIRect& bounds) const {
 
-    sk_sp<GrRenderTargetContext> rtContext(context->makeDeferredRenderTargetContextWithFallback(
+    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContextWithFallback(
         SkBackingFit::kApprox, bounds.width(), bounds.height(), kAlpha_8_GrPixelConfig, nullptr));
-    if (!rtContext) {
+    if (!renderTargetContext) {
         return nullptr;
     }
 
     GrPaint grPaint;
     grPaint.setPorterDuffXPFactory(SkBlendMode::kSrc);
     SkRegion::Iterator iter(fRegion);
-    rtContext->clear(nullptr, 0x0, true);
+    renderTargetContext->clear(nullptr, 0x0, true);
 
     GrFixedClip clip(SkIRect::MakeWH(bounds.width(), bounds.height()));
     while (!iter.done()) {
         SkRect rect = SkRect::Make(iter.rect());
-        rtContext->drawRect(clip, grPaint, inMatrix, rect);
+        renderTargetContext->drawRect(clip, grPaint, inMatrix, rect);
         iter.next();
     }
 
-    return sk_ref_sp(rtContext->asDeferredTexture());
+    return renderTargetContext->asTexture();
 }
 #endif
 
@@ -161,7 +158,7 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage*
         SkMatrix matrix(ctx.ctm());
         matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
 
-        sk_sp<GrTextureProxy> maskTexture(this->createMaskTexture(context, matrix, bounds));
+        sk_sp<GrTexture> maskTexture(this->createMaskTexture(context, matrix, bounds));
         if (!maskTexture) {
             return nullptr;
         }
@@ -170,12 +167,12 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage*
         sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(input->getColorSpace(),
                                                                            outProps.colorSpace());
         sk_sp<GrFragmentProcessor> fp(GrAlphaThresholdFragmentProcessor::Make(
-                                            inputTexture.get(),
-                                            std::move(colorSpaceXform),
-                                            maskTexture->instantiate(context->textureProvider()),
-                                            fInnerThreshold,
-                                            fOuterThreshold,
-                                            bounds));
+                                                                         inputTexture.get(),
+                                                                         std::move(colorSpaceXform),
+                                                                         maskTexture.get(),
+                                                                         fInnerThreshold,
+                                                                         fOuterThreshold,
+                                                                         bounds));
         if (!fp) {
             return nullptr;
         }
index 4dcd022..0a98fa8 100644 (file)
@@ -1122,7 +1122,7 @@ static sk_sp<GrTexture> find_or_create_rrect_blur_mask(GrContext* context,
     sk_sp<GrTexture> mask(context->textureProvider()->findAndRefTextureByUniqueKey(key));
     if (!mask) {
         // TODO: this could be approx but the texture coords will need to be updated
-        sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContextWithFallback(
+        sk_sp<GrRenderTargetContext> rtc(context->makeRenderTargetContextWithFallback(
             SkBackingFit::kExact, size.fWidth, size.fHeight, kAlpha_8_GrPixelConfig, nullptr));
         if (!rtc) {
             return nullptr;
@@ -1139,8 +1139,8 @@ static sk_sp<GrTexture> find_or_create_rrect_blur_mask(GrContext* context,
                                                                        srcTexture.get(),
                                                                        nullptr,
                                                                        SkIRect::MakeWH(
-                                                                                    size.fWidth,
-                                                                                    size.fHeight),
+                                                                           size.fWidth,
+                                                                           size.fHeight),
                                                                        nullptr,
                                                                        xformedSigma, xformedSigma,
                                                                        SkBackingFit::kExact));
index d31a7a7..58d12af 100644 (file)
@@ -13,7 +13,6 @@
 #include "effects/GrSimpleTextureEffect.h"
 #include "GrStyle.h"
 #include "GrTexture.h"
-#include "GrTextureProxy.h"
 #include "GrTextureProvider.h"
 #include "SkDraw.h"
 #include "SkGrPriv.h"
@@ -93,25 +92,25 @@ static bool sw_draw_with_mask_filter(GrRenderTargetContext* renderTargetContext,
 }
 
 // Create a mask of 'devPath' and place the result in 'mask'.
-static sk_sp<GrTextureProxy> create_mask_GPU(GrContext* context,
-                                             const SkIRect& maskRect,
-                                             const SkPath& devPath,
-                                             SkStrokeRec::InitStyle fillOrHairline,
-                                             bool doAA,
-                                             int sampleCnt) {
+static sk_sp<GrTexture> 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> rtContext(context->makeDeferredRenderTargetContextWithFallback(
+    sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContextWithFallback(
         SkBackingFit::kApprox, maskRect.width(), maskRect.height(), kAlpha_8_GrPixelConfig, nullptr,
         sampleCnt));
-    if (!rtContext) {
+    if (!renderTargetContext) {
         return nullptr;
     }
 
-    rtContext->clear(nullptr, 0x0, true);
+    renderTargetContext->clear(nullptr, 0x0, true);
 
     GrPaint tempPaint;
     tempPaint.setAntiAlias(doAA);
@@ -125,8 +124,8 @@ static sk_sp<GrTextureProxy> create_mask_GPU(GrContext* context,
     // the origin using tempPaint.
     SkMatrix translate;
     translate.setTranslate(-SkIntToScalar(maskRect.fLeft), -SkIntToScalar(maskRect.fTop));
-    rtContext->drawPath(clip, tempPaint, translate, devPath, GrStyle(fillOrHairline));
-    return sk_ref_sp(rtContext->asDeferredTexture());
+    renderTargetContext->drawPath(clip, tempPaint, translate, devPath, GrStyle(fillOrHairline));
+    return renderTargetContext->asTexture();;
 }
 
 static void draw_path_with_mask_filter(GrContext* context,
@@ -205,17 +204,16 @@ static void draw_path_with_mask_filter(GrContext* context,
             return;
         }
 
-        sk_sp<GrTextureProxy> mask(create_mask_GPU(context,
-                                                   finalIRect,
-                                                   *path,
-                                                   fillOrHairline,
-                                                   paint->isAntiAlias(),
-                                                   renderTargetContext->numColorSamples()));
+        sk_sp<GrTexture> mask(create_mask_GPU(context,
+                                              finalIRect,
+                                              *path,
+                                              fillOrHairline,
+                                              paint->isAntiAlias(),
+                                              renderTargetContext->numColorSamples()));
         if (mask) {
             GrTexture* filtered;
 
-            if (maskFilter->filterMaskGPU(mask->instantiate(context->textureProvider()),
-                                          viewMatrix, finalIRect, &filtered)) {
+            if (maskFilter->filterMaskGPU(mask.get(), 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)) {
index d7c66a0..71203d6 100644 (file)
@@ -744,23 +744,6 @@ 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,