diff options
author | Robert Phillips <robertphillips@google.com> | 2017-07-21 08:44:46 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-21 14:05:33 +0000 |
commit | 467022b1861033d968195687da15270c208279ff (patch) | |
tree | 34de5b201fb4dc64090c292cdc7bf924d073cae6 /src/gpu/effects | |
parent | 594838a44dd1253e71c1b0330018d2b5180ccc32 (diff) |
Reduce dependence on GrSurface's origin field
Unfortunately, GrGPU and its ilk are still using the GrSurface's origin a lot. I will clean that up in a second CL.
Change-Id: Iba729440ce8ea8d24bb7f4e5de55ed576a0f176d
Reviewed-on: https://skia-review.googlesource.com/24700
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/effects')
-rw-r--r-- | src/gpu/effects/GrBicubicEffect.cpp | 5 | ||||
-rw-r--r-- | src/gpu/effects/GrConfigConversionEffect.cpp | 1 | ||||
-rw-r--r-- | src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp | 7 | ||||
-rw-r--r-- | src/gpu/effects/GrMatrixConvolutionEffect.cpp | 7 | ||||
-rw-r--r-- | src/gpu/effects/GrTextureDomain.cpp | 16 | ||||
-rw-r--r-- | src/gpu/effects/GrTextureDomain.h | 3 | ||||
-rw-r--r-- | src/gpu/effects/GrTextureStripAtlas.cpp | 15 |
7 files changed, 31 insertions, 23 deletions
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp index 6d8072f231..f7441bc043 100644 --- a/src/gpu/effects/GrBicubicEffect.cpp +++ b/src/gpu/effects/GrBicubicEffect.cpp @@ -120,13 +120,14 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) { void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor) { const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>(); - GrTexture* texture = processor.textureSampler(0).peekTexture(); + GrSurfaceProxy* proxy = processor.textureSampler(0).proxy(); + GrTexture* texture = proxy->priv().peekTexture(); float imageIncrement[2]; imageIncrement[0] = 1.0f / texture->width(); imageIncrement[1] = 1.0f / texture->height(); pdman.set2fv(fImageIncrementUni, 1, imageIncrement); - fDomain.setData(pdman, bicubicEffect.domain(), texture); + fDomain.setData(pdman, bicubicEffect.domain(), proxy); if (SkToBool(bicubicEffect.colorSpaceXform())) { fColorSpaceHelper.setData(pdman, bicubicEffect.colorSpaceXform()); } diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index e4989de507..e8d04771f5 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -133,6 +133,7 @@ bool GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context return false; } GrSurfaceDesc desc; + desc.fOrigin = kTopLeft_GrSurfaceOrigin; desc.fWidth = kSize; desc.fHeight = kSize; desc.fConfig = kConfig; diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp index 4d1a99d83e..1ab9b78cfc 100644 --- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp +++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp @@ -121,10 +121,11 @@ void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor) { const GrGaussianConvolutionFragmentProcessor& conv = processor.cast<GrGaussianConvolutionFragmentProcessor>(); - GrTexture& texture = *conv.textureSampler(0).peekTexture(); + GrSurfaceProxy* proxy = conv.textureSampler(0).proxy(); + GrTexture& texture = *proxy->priv().peekTexture(); float imageIncrement[2] = {0}; - float ySign = texture.origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f; + float ySign = proxy->origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f; switch (conv.direction()) { case Gr1DKernelEffect::kX_Direction: imageIncrement[0] = 1.0f / texture.width(); @@ -149,7 +150,7 @@ void GrGLConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman, pdman.set2f(fBoundsUni, inv * bounds[0], inv * bounds[1]); } else { SkScalar inv = SkScalarInvert(SkIntToScalar(texture.height())); - if (texture.origin() != kTopLeft_GrSurfaceOrigin) { + if (proxy->origin() != kTopLeft_GrSurfaceOrigin) { pdman.set2f(fBoundsUni, 1.0f - (inv * bounds[1]), 1.0f - (inv * bounds[0])); } else { pdman.set2f(fBoundsUni, inv * bounds[1], inv * bounds[0]); diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp index bc1537c8b4..abfe5b3774 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -131,10 +131,11 @@ void GrGLMatrixConvolutionEffect::GenKey(const GrProcessor& processor, void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& processor) { const GrMatrixConvolutionEffect& conv = processor.cast<GrMatrixConvolutionEffect>(); - GrTexture* texture = conv.textureSampler(0).peekTexture(); + GrSurfaceProxy* proxy = conv.textureSampler(0).proxy(); + GrTexture* texture = proxy->priv().peekTexture(); float imageIncrement[2]; - float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f; + float ySign = proxy->origin() == kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f; imageIncrement[0] = 1.0f / texture->width(); imageIncrement[1] = ySign / texture->height(); pdman.set2fv(fImageIncrementUni, 1, imageIncrement); @@ -145,7 +146,7 @@ void GrGLMatrixConvolutionEffect::onSetData(const GrGLSLProgramDataManager& pdma pdman.set4fv(fKernelUni, arrayCount, conv.kernel()); pdman.set1f(fGainUni, conv.gain()); pdman.set1f(fBiasUni, conv.bias()); - fDomain.setData(pdman, conv.domain(), texture); + fDomain.setData(pdman, conv.domain(), proxy); } GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> proxy, diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index a8ce0ab6c5..f2b78586d7 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -161,7 +161,8 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder, void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman, const GrTextureDomain& textureDomain, - GrTexture* tex) { + GrSurfaceProxy* proxy) { + GrTexture* tex = proxy->priv().peekTexture(); SkASSERT(textureDomain.mode() == fMode); if (kIgnore_Mode != textureDomain.mode()) { SkScalar wInv = SK_Scalar1 / tex->width(); @@ -180,7 +181,7 @@ void GrTextureDomain::GLDomain::setData(const GrGLSLProgramDataManager& pdman, SkASSERT(values[3] >= 0.0f && values[3] <= 1.0f); // vertical flip if necessary - if (kBottomLeft_GrSurfaceOrigin == tex->origin()) { + if (kBottomLeft_GrSurfaceOrigin == proxy->origin()) { values[1] = 1.0f - values[1]; values[3] = 1.0f - values[3]; // The top and bottom were just flipped, so correct the ordering @@ -270,9 +271,9 @@ GrGLSLFragmentProcessor* GrTextureDomainEffect::onCreateGLSLInstance() const { const GrFragmentProcessor& fp) override { const GrTextureDomainEffect& tde = fp.cast<GrTextureDomainEffect>(); const GrTextureDomain& domain = tde.fTextureDomain; - GrTexture* texture = tde.textureSampler(0).peekTexture(); + GrSurfaceProxy* proxy = tde.textureSampler(0).proxy(); - fGLDomain.setData(pdman, domain, texture); + fGLDomain.setData(pdman, domain, proxy); if (SkToBool(tde.colorSpaceXform())) { fColorSpaceHelper.setData(pdman, tde.colorSpaceXform()); } @@ -372,16 +373,17 @@ GrGLSLFragmentProcessor* GrDeviceSpaceTextureDecalFragmentProcessor::onCreateGLS const GrFragmentProcessor& fp) override { const GrDeviceSpaceTextureDecalFragmentProcessor& dstdfp = fp.cast<GrDeviceSpaceTextureDecalFragmentProcessor>(); - GrTexture* texture = dstdfp.textureSampler(0).peekTexture(); + GrSurfaceProxy* proxy = dstdfp.textureSampler(0).proxy(); + GrTexture* texture = proxy->priv().peekTexture(); - fGLDomain.setData(pdman, dstdfp.fTextureDomain, texture); + fGLDomain.setData(pdman, dstdfp.fTextureDomain, proxy); float iw = 1.f / texture->width(); float ih = 1.f / texture->height(); float scaleAndTransData[4] = { iw, ih, -dstdfp.fDeviceSpaceOffset.fX * iw, -dstdfp.fDeviceSpaceOffset.fY * ih }; - if (texture->origin() == kBottomLeft_GrSurfaceOrigin) { + if (proxy->origin() == kBottomLeft_GrSurfaceOrigin) { scaleAndTransData[1] = -scaleAndTransData[1]; scaleAndTransData[3] = 1 - scaleAndTransData[3]; } diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h index cbc55ecdba..8be1a2bc66 100644 --- a/src/gpu/effects/GrTextureDomain.h +++ b/src/gpu/effects/GrTextureDomain.h @@ -115,8 +115,7 @@ public: * texture domain. The rectangle is automatically adjusted to account for the texture's * origin. */ - void setData(const GrGLSLProgramDataManager& pdman, const GrTextureDomain& textureDomain, - GrTexture* texure); + void setData(const GrGLSLProgramDataManager&, const GrTextureDomain&, GrSurfaceProxy*); enum { kDomainKeyBits = 2, // See DomainKey(). diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp index 72817b2133..02c8ce8faa 100644 --- a/src/gpu/effects/GrTextureStripAtlas.cpp +++ b/src/gpu/effects/GrTextureStripAtlas.cpp @@ -193,11 +193,6 @@ GrTextureStripAtlas::AtlasRow* GrTextureStripAtlas::getLRU() { } void GrTextureStripAtlas::lockTexture() { - GrSurfaceDesc texDesc; - texDesc.fOrigin = kTopLeft_GrSurfaceOrigin; - texDesc.fWidth = fDesc.fWidth; - texDesc.fHeight = fDesc.fHeight; - texDesc.fConfig = fDesc.fConfig; static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); GrUniqueKey key; @@ -205,8 +200,15 @@ void GrTextureStripAtlas::lockTexture() { builder[0] = static_cast<uint32_t>(fCacheKey); builder.finish(); - sk_sp<GrTextureProxy> proxy = fDesc.fContext->resourceProvider()->findProxyByUniqueKey(key); + sk_sp<GrTextureProxy> proxy = fDesc.fContext->resourceProvider()->findProxyByUniqueKey( + key, kTopLeft_GrSurfaceOrigin); if (!proxy) { + GrSurfaceDesc texDesc; + texDesc.fOrigin = kTopLeft_GrSurfaceOrigin; + texDesc.fWidth = fDesc.fWidth; + texDesc.fHeight = fDesc.fHeight; + texDesc.fConfig = fDesc.fConfig; + proxy = GrSurfaceProxy::MakeDeferred(fDesc.fContext->resourceProvider(), texDesc, SkBackingFit::kExact, SkBudgeted::kYes, @@ -215,6 +217,7 @@ void GrTextureStripAtlas::lockTexture() { return; } + SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin); fDesc.fContext->resourceProvider()->assignUniqueKeyToProxy(key, proxy.get()); // This is a new texture, so all of our cache info is now invalid this->initLRU(); |