diff options
author | Robert Phillips <robertphillips@google.com> | 2017-03-29 13:06:57 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-29 18:28:02 +0000 |
commit | 769e80d23d1c1d240b1d510034ec57d19e768d07 (patch) | |
tree | 851e8c62bb7b3260ca5e41b1951e4678f95e1770 | |
parent | 3e306f6bf40c4ade5e1c216fcc8043006d7dbcee (diff) |
More GrSurfaceProxy-clean up
Split out of: https://skia-review.googlesource.com/c/10484/ (Omnibus: Push instantiation of GrTextures later (post TextureSampler))
Change-Id: I1ee39a23c749e420dce0ad561ee1c8b09bdcc763
Reviewed-on: https://skia-review.googlesource.com/10485
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
-rw-r--r-- | include/gpu/GrContext.h | 1 | ||||
-rw-r--r-- | include/gpu/GrCoordTransform.h | 25 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 25 | ||||
-rw-r--r-- | src/gpu/GrCoordTransform.cpp | 18 | ||||
-rw-r--r-- | src/gpu/effects/GrConfigConversionEffect.cpp | 24 | ||||
-rw-r--r-- | src/gpu/effects/GrConfigConversionEffect.h | 4 | ||||
-rw-r--r-- | src/gpu/effects/GrSimpleTextureEffect.h | 44 | ||||
-rw-r--r-- | src/gpu/effects/GrSingleTextureEffect.cpp | 36 | ||||
-rw-r--r-- | src/gpu/effects/GrSingleTextureEffect.h | 12 | ||||
-rw-r--r-- | tests/IntTextureTest.cpp | 6 |
10 files changed, 13 insertions, 182 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index ea4f4228fd..bd9c079fa0 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -430,7 +430,6 @@ private: * of effects that make a readToUPM->writeToPM->readToUPM cycle invariant. Otherwise, they * return NULL. They also can perform a swizzle as part of the draw. */ - sk_sp<GrFragmentProcessor> createPMToUPMEffect(GrTexture*, const SkMatrix&); sk_sp<GrFragmentProcessor> createPMToUPMEffect(sk_sp<GrTextureProxy>, const SkMatrix&); sk_sp<GrFragmentProcessor> createUPMToPMEffect(sk_sp<GrTextureProxy>, const SkMatrix&); /** Called before either of the above two functions to determine the appropriate fragment diff --git a/include/gpu/GrCoordTransform.h b/include/gpu/GrCoordTransform.h index 6df6586c7a..368c39e1d9 100644 --- a/include/gpu/GrCoordTransform.h +++ b/include/gpu/GrCoordTransform.h @@ -31,16 +31,10 @@ public: } /** - * Create a transformation that maps [0, 1] to a texture's boundaries. The precision is inferred - * from the texture size and filter. The texture origin also implies whether a y-reversal should + * Create a transformation that maps [0, 1] to a proxy's boundaries. The precision is inferred + * from the proxy size and filter. The proxy origin also implies whether a y-reversal should * be performed. */ - GrCoordTransform(const GrTexture* texture, GrSamplerParams::FilterMode filter) { - SkASSERT(texture); - SkDEBUGCODE(fInProcessor = false); - this->reset(SkMatrix::I(), texture, filter); - } - GrCoordTransform(GrResourceProvider* resourceProvider, GrTextureProxy* proxy, GrSamplerParams::FilterMode filter) { SkASSERT(proxy); @@ -49,16 +43,9 @@ public: } /** - * Create a transformation from a matrix. The precision is inferred from the texture size and - * filter. The texture origin also implies whether a y-reversal should be performed. + * Create a transformation from a matrix. The precision is inferred from the proxy size and + * filter. The proxy origin also implies whether a y-reversal should be performed. */ - GrCoordTransform(const SkMatrix& m, const GrTexture* texture, - GrSamplerParams::FilterMode filter) { - SkASSERT(texture); - SkDEBUGCODE(fInProcessor = false); - this->reset(m, texture, filter); - } - GrCoordTransform(GrResourceProvider* resourceProvider, const SkMatrix& m, GrTextureProxy* proxy, GrSamplerParams::FilterMode filter) { SkASSERT(proxy); @@ -74,10 +61,6 @@ public: this->reset(m, precision); } - // MDB TODO: rm the GrTexture* flavor of reset - void reset(const SkMatrix&, const GrTexture*, GrSamplerParams::FilterMode filter, - bool normalize = true); - void reset(GrResourceProvider*, const SkMatrix&, GrTextureProxy*, GrSamplerParams::FilterMode filter, bool normalize = true); diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 56d811761b..fbfaa22609 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -474,9 +474,10 @@ bool GrContext::readSurfacePixels(GrSurface* src, SkColorSpace* srcColorSpace, tempDrawInfo.fTempSurfaceDesc.fOrigin); if (tempRTC) { SkMatrix textureMatrix = SkMatrix::MakeTrans(SkIntToScalar(left), SkIntToScalar(top)); + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(sk_ref_sp(src->asTexture())); sk_sp<GrFragmentProcessor> fp; if (unpremul) { - fp = this->createPMToUPMEffect(src->asTexture(), textureMatrix); + fp = this->createPMToUPMEffect(proxy, textureMatrix); fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), tempDrawInfo.fSwizzle); if (fp) { unpremul = false; // we no longer need to do this on CPU after the read back. @@ -487,7 +488,8 @@ bool GrContext::readSurfacePixels(GrSurface* src, SkColorSpace* srcColorSpace, } } if (!fp && tempRTC) { - fp = GrSimpleTextureEffect::Make(src->asTexture(), nullptr, textureMatrix); + fp = GrSimpleTextureEffect::Make(this->resourceProvider(), std::move(proxy), + nullptr, textureMatrix); fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), tempDrawInfo.fSwizzle); } if (fp) { @@ -865,25 +867,6 @@ void GrContext::testPMConversionsIfNecessary(uint32_t flags) { } } -sk_sp<GrFragmentProcessor> GrContext::createPMToUPMEffect(GrTexture* texture, - const SkMatrix& matrix) { - ASSERT_SINGLE_OWNER - // We should have already called this->testPMConversionsIfNecessary(). - SkASSERT(fDidTestPMConversions); - if (kRGBA_half_GrPixelConfig == texture->config()) { - return GrFragmentProcessor::UnpremulOutput( - GrSimpleTextureEffect::Make(texture, nullptr, matrix)); - } else { - GrConfigConversionEffect::PMConversion pmToUPM = - static_cast<GrConfigConversionEffect::PMConversion>(fPMToUPMConversion); - if (GrConfigConversionEffect::kPMConversionCnt != pmToUPM) { - return GrConfigConversionEffect::Make(texture, pmToUPM, matrix); - } else { - return nullptr; - } - } -} - sk_sp<GrFragmentProcessor> GrContext::createPMToUPMEffect(sk_sp<GrTextureProxy> proxy, const SkMatrix& matrix) { ASSERT_SINGLE_OWNER diff --git a/src/gpu/GrCoordTransform.cpp b/src/gpu/GrCoordTransform.cpp index 7b280f33c4..b22f3258fc 100644 --- a/src/gpu/GrCoordTransform.cpp +++ b/src/gpu/GrCoordTransform.cpp @@ -50,24 +50,6 @@ static GrSLPrecision compute_precision(const GrShaderCaps* caps, return precision; } -void GrCoordTransform::reset(const SkMatrix& m, const GrTexture* texture, - GrSamplerParams::FilterMode filter, bool normalize) { - SkASSERT(texture); - SkASSERT(!fInProcessor); - - fMatrix = m; - fTexture = texture; - fNormalize = normalize; - fReverseY = kBottomLeft_GrSurfaceOrigin == texture->origin(); - - if (texture->getContext()) { - fPrecision = compute_precision(texture->getContext()->caps()->shaderCaps(), - texture->width(), texture->height(), filter); - } else { - fPrecision = kDefault_GrSLPrecision; - } -} - void GrCoordTransform::reset(GrResourceProvider* resourceProvider, const SkMatrix& m, GrTextureProxy* proxy, GrSamplerParams::FilterMode filter, bool normalize) { diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index 790a47490c..62008c7364 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -87,18 +87,6 @@ private: }; /////////////////////////////////////////////////////////////////////////////// -GrConfigConversionEffect::GrConfigConversionEffect(GrTexture* texture, - PMConversion pmConversion, - const SkMatrix& matrix) - : INHERITED(texture, nullptr, matrix, kNone_OptimizationFlags) - , fPMConversion(pmConversion) { - this->initClassID<GrConfigConversionEffect>(); - // We expect to get here with non-BGRA/RGBA only if we're doing not doing a premul/unpremul - // conversion. - SkASSERT(kRGBA_8888_GrPixelConfig == texture->config() || - kBGRA_8888_GrPixelConfig == texture->config()); -} - GrConfigConversionEffect::GrConfigConversionEffect(GrResourceProvider* resourceProvider, sk_sp<GrTextureProxy> proxy, PMConversion pmConversion, @@ -275,18 +263,6 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context } } -sk_sp<GrFragmentProcessor> GrConfigConversionEffect::Make(GrTexture* texture, - PMConversion pmConversion, - const SkMatrix& matrix) { - if (kRGBA_8888_GrPixelConfig != texture->config() && - kBGRA_8888_GrPixelConfig != texture->config()) { - // The PM conversions assume colors are 0..255 - return nullptr; - } - return sk_sp<GrFragmentProcessor>( - new GrConfigConversionEffect(texture, pmConversion, matrix)); -} - sk_sp<GrFragmentProcessor> GrConfigConversionEffect::Make(GrResourceProvider* resourceProvider, sk_sp<GrTextureProxy> proxy, PMConversion pmConversion, diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h index d71b228a7b..d3e40ddd00 100644 --- a/src/gpu/effects/GrConfigConversionEffect.h +++ b/src/gpu/effects/GrConfigConversionEffect.h @@ -30,8 +30,6 @@ public: kPMConversionCnt }; - static sk_sp<GrFragmentProcessor> Make(GrTexture*, PMConversion, const SkMatrix&); - static sk_sp<GrFragmentProcessor> Make(GrResourceProvider*, sk_sp<GrTextureProxy>, PMConversion, const SkMatrix&); @@ -48,8 +46,6 @@ public: PMConversion* PMToUPMRule, PMConversion* UPMToPMRule); private: - GrConfigConversionEffect(GrTexture*, PMConversion, const SkMatrix& matrix); - GrConfigConversionEffect(GrResourceProvider*, sk_sp<GrTextureProxy>, PMConversion, const SkMatrix& matrix); diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h index b3030bfc6f..8edec81a83 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.h +++ b/src/gpu/effects/GrSimpleTextureEffect.h @@ -21,32 +21,6 @@ class GrInvariantOutput; class GrSimpleTextureEffect : public GrSingleTextureEffect { public: /* unfiltered, clamp mode */ - static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& matrix) { - return sk_sp<GrFragmentProcessor>( - new GrSimpleTextureEffect(tex, std::move(colorSpaceXform), matrix, - GrSamplerParams::kNone_FilterMode)); - } - - /* clamp mode */ - static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& matrix, - GrSamplerParams::FilterMode filterMode) { - return sk_sp<GrFragmentProcessor>( - new GrSimpleTextureEffect(tex, std::move(colorSpaceXform), matrix, filterMode)); - } - - static sk_sp<GrFragmentProcessor> Make(GrTexture* tex, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& matrix, - const GrSamplerParams& p) { - return sk_sp<GrFragmentProcessor>(new GrSimpleTextureEffect(tex, std::move(colorSpaceXform), - matrix, p)); - } - - /* unfiltered, clamp mode */ static sk_sp<GrFragmentProcessor> Make(GrResourceProvider* resourceProvider, sk_sp<GrTextureProxy> proxy, sk_sp<GrColorSpaceXform> colorSpaceXform, @@ -85,24 +59,6 @@ public: const char* name() const override { return "SimpleTexture"; } private: - GrSimpleTextureEffect(GrTexture* texture, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& matrix, - GrSamplerParams::FilterMode filterMode) - : INHERITED(texture, std::move(colorSpaceXform), matrix, filterMode, - ModulationFlags(texture->config())) { - this->initClassID<GrSimpleTextureEffect>(); - } - - GrSimpleTextureEffect(GrTexture* texture, - sk_sp<GrColorSpaceXform>colorSpaceXform, - const SkMatrix& matrix, - const GrSamplerParams& params) - : INHERITED(texture, std::move(colorSpaceXform), matrix, params, - ModulationFlags(texture->config())) { - this->initClassID<GrSimpleTextureEffect>(); - } - GrSimpleTextureEffect(GrResourceProvider*, sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>, const SkMatrix& matrix, GrSamplerParams::FilterMode); diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp index 4f624b3f28..ee6a31b019 100644 --- a/src/gpu/effects/GrSingleTextureEffect.cpp +++ b/src/gpu/effects/GrSingleTextureEffect.cpp @@ -9,42 +9,6 @@ #include "GrTextureProxy.h" -GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& m, OptimizationFlags optFlags) - : INHERITED(optFlags) - , fCoordTransform(m, texture, GrSamplerParams::kNone_FilterMode) - , fTextureSampler(texture) - , fColorSpaceXform(std::move(colorSpaceXform)) { - this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); -} - -GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& m, - GrSamplerParams::FilterMode filterMode, - OptimizationFlags optFlags) - : INHERITED(optFlags) - , fCoordTransform(m, texture, filterMode) - , fTextureSampler(texture, filterMode) - , fColorSpaceXform(std::move(colorSpaceXform)) { - this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); -} - -GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& m, const GrSamplerParams& params, - OptimizationFlags optFlags) - : INHERITED(optFlags) - , fCoordTransform(m, texture, params.filterMode()) - , fTextureSampler(texture, params) - , fColorSpaceXform(std::move(colorSpaceXform)) { - this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); -} - GrSingleTextureEffect::GrSingleTextureEffect(GrResourceProvider* resourceProvider, OptimizationFlags optFlags, sk_sp<GrTextureProxy> proxy, diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h index 0ae5447bac..fb945dea6b 100644 --- a/src/gpu/effects/GrSingleTextureEffect.h +++ b/src/gpu/effects/GrSingleTextureEffect.h @@ -32,18 +32,6 @@ public: protected: /** unfiltered, clamp mode */ - GrSingleTextureEffect(GrTexture*, sk_sp<GrColorSpaceXform>, const SkMatrix&, - OptimizationFlags optFlags); - /** clamp mode */ - GrSingleTextureEffect(GrTexture*, sk_sp<GrColorSpaceXform>, const SkMatrix&, - GrSamplerParams::FilterMode filterMode, OptimizationFlags optFlags); - GrSingleTextureEffect(GrTexture*, - sk_sp<GrColorSpaceXform>, - const SkMatrix&, - const GrSamplerParams&, - OptimizationFlags optFlags); - - /** unfiltered, clamp mode */ GrSingleTextureEffect(GrResourceProvider*, OptimizationFlags, sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>, const SkMatrix&); /** clamp mode */ diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp index 346f56bc68..8ef57318ed 100644 --- a/tests/IntTextureTest.cpp +++ b/tests/IntTextureTest.cpp @@ -221,6 +221,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { } texture->writePixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, testData.get()); + sk_sp<GrTextureProxy> intTextureProxy = GrSurfaceProxy::MakeWrapped(sk_ref_sp(texture)); + texture = nullptr; // unused from here on out + sk_sp<GrRenderTargetContext> rtContext = context->makeRenderTargetContext( SkBackingFit::kExact, kS, kS, kRGBA_8888_GrPixelConfig, nullptr); @@ -234,7 +237,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { }; for (auto filter : kNamedFilters) { - sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture, nullptr, + sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(context->resourceProvider(), + intTextureProxy, nullptr, SkMatrix::I(), filter.fMode)); REPORTER_ASSERT(reporter, fp); |