aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-11-15 22:17:22 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-15 22:17:40 +0000
commit4e344c8b93c7c2d1ef3cb7fd339bba55c479ece0 (patch)
tree73aade9f0896ae2b413ca495b132e486e8bf5949 /src
parentbe42c994b41a6d99b4bbf370aa1634350c773219 (diff)
Revert "Defer more renderTargetContexts in the GPU image filter paths"
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>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBlurImageFilter.cpp11
-rw-r--r--src/core/SkGpuBlurUtils.cpp15
-rw-r--r--src/core/SkImageFilter.cpp12
-rw-r--r--src/effects/SkAlphaThresholdFilter.cpp37
-rw-r--r--src/effects/SkBlurMaskFilter.cpp6
-rw-r--r--src/gpu/GrBlurUtils.cpp38
-rw-r--r--src/gpu/GrContext.cpp17
7 files changed, 52 insertions, 84 deletions
diff --git a/src/core/SkBlurImageFilter.cpp b/src/core/SkBlurImageFilter.cpp
index 0713055245..d531b44393 100644
--- a/src/core/SkBlurImageFilter.cpp
+++ b/src/core/SkBlurImageFilter.cpp
@@ -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
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index 1236e2bf18..8107642783 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->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);
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index df46a13d3c..09c26d387e 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -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
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index abf924ca06..b1c8b21460 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -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;
}
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index 4dcd022be0..0a98fa8c3a 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -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));
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index d31a7a7fba..58d12af178 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -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)) {
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index d7c66a0b5d..71203d6442 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -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,