diff options
author | Robert Phillips <robertphillips@google.com> | 2017-07-25 10:16:35 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-25 17:34:29 +0000 |
commit | 066f020bb6cb9dbb12b977fcddd93982201777fe (patch) | |
tree | 792f93eeb1503885417576d7b3f8d5627b6357af | |
parent | e4832b287c6d0ae4a4a193f0144736f7eb6a824d (diff) |
Reduce dependence on GrSurface's origin field (take 3)
TBR=bsalomon@google.com
Change-Id: I8c95c6774897dbd87e3c5c87d92f75c5b64d4e76
Reviewed-on: https://skia-review.googlesource.com/26424
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
30 files changed, 76 insertions, 63 deletions
diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h index 61c3ecb8d7..0bfa294c3c 100644 --- a/include/private/GrRenderTargetProxy.h +++ b/include/private/GrRenderTargetProxy.h @@ -66,7 +66,7 @@ protected: SkBackingFit, SkBudgeted, uint32_t flags); // Wrapped version - GrRenderTargetProxy(sk_sp<GrSurface>); + GrRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin); sk_sp<GrSurface> createSurface(GrResourceProvider*) const override; diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h index 71eaf138bf..efd078a1c3 100644 --- a/include/private/GrSurfaceProxy.h +++ b/include/private/GrSurfaceProxy.h @@ -173,8 +173,8 @@ private: class GrSurfaceProxy : public GrIORefProxy { public: - static sk_sp<GrSurfaceProxy> MakeWrapped(sk_sp<GrSurface>); - static sk_sp<GrTextureProxy> MakeWrapped(sk_sp<GrTexture>); + static sk_sp<GrSurfaceProxy> MakeWrapped(sk_sp<GrSurface>, GrSurfaceOrigin); + static sk_sp<GrTextureProxy> MakeWrapped(sk_sp<GrTexture>, GrSurfaceOrigin); static sk_sp<GrTextureProxy> MakeDeferred(GrResourceProvider*, const GrSurfaceDesc&, SkBackingFit, @@ -352,7 +352,7 @@ protected: } // Wrapped version - GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit); + GrSurfaceProxy(sk_sp<GrSurface> surface, GrSurfaceOrigin origin, SkBackingFit fit); virtual ~GrSurfaceProxy(); diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h index 60be19ecef..4d87533691 100644 --- a/include/private/GrTextureProxy.h +++ b/include/private/GrTextureProxy.h @@ -45,7 +45,7 @@ protected: GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted, const void* srcData, size_t srcRowBytes, uint32_t flags); // Wrapped version - GrTextureProxy(sk_sp<GrSurface>); + GrTextureProxy(sk_sp<GrSurface>, GrSurfaceOrigin); SkDestinationSurfaceColorMode mipColorMode() const { return fMipColorMode; } diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp index fb12afbaeb..a30bc4be35 100644 --- a/src/effects/GrCircleBlurFragmentProcessor.cpp +++ b/src/effects/GrCircleBlurFragmentProcessor.cpp @@ -174,7 +174,8 @@ static sk_sp<GrTextureProxy> create_profile_texture(GrResourceProvider* resource builder[0] = sigmaToCircleRRatioFixed; builder.finish(); - sk_sp<GrTextureProxy> blurProfile = resourceProvider->findProxyByUniqueKey(key); + sk_sp<GrTextureProxy> blurProfile = resourceProvider->findProxyByUniqueKey( + key, kTopLeft_GrSurfaceOrigin); if (!blurProfile) { static constexpr int kProfileTextureWidth = 512; GrSurfaceDesc texDesc; diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index d1a4b3af7a..9ecedbd53e 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -955,7 +955,8 @@ sk_sp<GrTextureProxy> GrRectBlurEffect::CreateBlurProfileTexture( builder[0] = profileSize; builder.finish(); - sk_sp<GrTextureProxy> blurProfile(resourceProvider->findProxyByUniqueKey(key)); + sk_sp<GrTextureProxy> blurProfile(resourceProvider->findProxyByUniqueKey( + key, kTopLeft_GrSurfaceOrigin)); if (!blurProfile) { GrSurfaceDesc texDesc; texDesc.fOrigin = kTopLeft_GrSurfaceOrigin; @@ -1125,7 +1126,8 @@ static sk_sp<GrTextureProxy> find_or_create_rrect_blur_mask(GrContext* context, } builder.finish(); - sk_sp<GrTextureProxy> mask(context->resourceProvider()->findProxyByUniqueKey(key)); + sk_sp<GrTextureProxy> mask(context->resourceProvider()->findProxyByUniqueKey( + key, kBottomLeft_GrSurfaceOrigin)); if (!mask) { // TODO: this could be approx but the texture coords will need to be updated sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContextWithFallback( diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp index f48e2913a1..ca74772158 100644 --- a/src/gpu/GrAHardwareBufferImageGenerator.cpp +++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp @@ -126,7 +126,7 @@ sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::makeProxy(GrContext* cont // return a cached GrTexture if invoked with the same context if (fOriginalTexture && fOwningContextID == context->uniqueID()) { - return GrSurfaceProxy::MakeWrapped(sk_ref_sp(fOriginalTexture)); + return GrSurfaceProxy::MakeWrapped(sk_ref_sp(fOriginalTexture), kTopLeft_GrSurfaceOrigin); } while (GL_NO_ERROR != glGetError()) {} //clear GL errors @@ -215,7 +215,7 @@ sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::makeProxy(GrContext* cont //TODO: GrResourceCache should delete GrTexture, when GrContext is deleted. Currently //TODO: SkMessageBus ignores messages for deleted contexts and GrTexture will leak. context->getResourceCache()->insertCrossContextGpuResource(fOriginalTexture); - return GrSurfaceProxy::MakeWrapped(std::move(tex)); + return GrSurfaceProxy::MakeWrapped(std::move(tex), kTopLeft_GrSurfaceOrigin); } bool GrAHardwareBufferImageGenerator::onIsValid(GrContext* context) const { diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp index dac81681cd..3de6fec85c 100644 --- a/src/gpu/GrBackendTextureImageGenerator.cpp +++ b/src/gpu/GrBackendTextureImageGenerator.cpp @@ -165,7 +165,7 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture( SkASSERT(fRefHelper->fBorrowingContextID == context->uniqueID()); - sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex)); + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), fSurfaceOrigin); if (0 == origin.fX && 0 == origin.fY && info.width() == fBackendTexture.width() && info.height() == fBackendTexture.height()) { diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp index 6fb2c6a3a8..85e791ef90 100644 --- a/src/gpu/GrBitmapTextureMaker.cpp +++ b/src/gpu/GrBitmapTextureMaker.cpp @@ -37,7 +37,8 @@ sk_sp<GrTextureProxy> GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeM sk_sp<GrTextureProxy> proxy; if (fOriginalKey.isValid()) { - proxy = this->context()->resourceProvider()->findProxyByUniqueKey(fOriginalKey); + proxy = this->context()->resourceProvider()->findProxyByUniqueKey( + fOriginalKey, kTopLeft_GrSurfaceOrigin); if (proxy) { return proxy; } diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp index 3a31d0baf7..0a63e40076 100644 --- a/src/gpu/GrClipStackClip.cpp +++ b/src/gpu/GrClipStackClip.cpp @@ -394,7 +394,8 @@ sk_sp<GrTextureProxy> GrClipStackClip::createAlphaClipMask(GrContext* context, GrUniqueKey key; create_clip_mask_key(reducedClip.elementsGenID(), reducedClip.ibounds(), &key); - sk_sp<GrTextureProxy> proxy(resourceProvider->findProxyByUniqueKey(key)); + sk_sp<GrTextureProxy> proxy(resourceProvider->findProxyByUniqueKey( + key, kBottomLeft_GrSurfaceOrigin)); if (proxy) { return proxy; } @@ -432,7 +433,8 @@ sk_sp<GrTextureProxy> GrClipStackClip::createSoftwareClipMask( GrUniqueKey key; create_clip_mask_key(reducedClip.elementsGenID(), reducedClip.ibounds(), &key); - sk_sp<GrTextureProxy> proxy(context->resourceProvider()->findProxyByUniqueKey(key)); + sk_sp<GrTextureProxy> proxy(context->resourceProvider()->findProxyByUniqueKey( + key, kTopLeft_GrSurfaceOrigin)); if (proxy) { return proxy; } diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 19343ac73c..25408fbde7 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -745,7 +745,7 @@ sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackend return nullptr; } - sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface))); + sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface), origin)); if (!proxy) { return nullptr; } @@ -767,7 +767,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContex return nullptr; } - sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface))); + sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface), origin)); if (!proxy) { return nullptr; } @@ -789,7 +789,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetC return nullptr; } - sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(rt))); + sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(rt), origin)); if (!proxy) { return nullptr; } @@ -815,7 +815,7 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRend return nullptr; } - sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface))); + sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(surface), origin)); if (!proxy) { return nullptr; } diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp index 37bad65a1f..f4f0883ccf 100644 --- a/src/gpu/GrDrawOpAtlas.cpp +++ b/src/gpu/GrDrawOpAtlas.cpp @@ -39,7 +39,8 @@ std::unique_ptr<GrDrawOpAtlas> GrDrawOpAtlas::Make(GrContext* ctx, GrPixelConfig // should receive special attention. // Note: When switching over to the deferred proxy, use the kExact flag to create // the atlas and assert that the width & height are powers of 2. - sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(texture)); + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(texture), + kTopLeft_GrSurfaceOrigin); if (!proxy) { return nullptr; } diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp index eef5f3ec31..83809114ff 100644 --- a/src/gpu/GrRenderTargetProxy.cpp +++ b/src/gpu/GrRenderTargetProxy.cpp @@ -34,8 +34,8 @@ GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc } // Wrapped version -GrRenderTargetProxy::GrRenderTargetProxy(sk_sp<GrSurface> surf) - : INHERITED(std::move(surf), SkBackingFit::kExact) +GrRenderTargetProxy::GrRenderTargetProxy(sk_sp<GrSurface> surf, GrSurfaceOrigin origin) + : INHERITED(std::move(surf), origin, SkBackingFit::kExact) , fSampleCnt(fTarget->asRenderTarget()->numStencilSamples()) , fRenderTargetFlags(fTarget->asRenderTarget()->renderTargetPriv().flags()) { } diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp index cc9ec2a315..6061b33e1b 100644 --- a/src/gpu/GrResourceProvider.cpp +++ b/src/gpu/GrResourceProvider.cpp @@ -140,7 +140,7 @@ sk_sp<GrTextureProxy> GrResourceProvider::createTextureProxy(const GrSurfaceDesc if (make_info(desc.fWidth, desc.fHeight, desc.fConfig, &srcInfo)) { sk_sp<GrTexture> tex = this->getExactScratch(desc, budgeted, 0); - sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex)); + sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin); if (proxy) { sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(std::move(proxy), nullptr); @@ -153,7 +153,7 @@ sk_sp<GrTextureProxy> GrResourceProvider::createTextureProxy(const GrSurfaceDesc } sk_sp<GrTexture> tex(fGpu->createTexture(desc, budgeted, &mipLevel, 1)); - return GrSurfaceProxy::MakeWrapped(std::move(tex)); + return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin); } sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, @@ -312,7 +312,8 @@ void GrResourceProvider::assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextur } // MDB TODO (caching): this side-steps the issue of texture proxies with unique IDs -sk_sp<GrTextureProxy> GrResourceProvider::findProxyByUniqueKey(const GrUniqueKey& key) { +sk_sp<GrTextureProxy> GrResourceProvider::findProxyByUniqueKey(const GrUniqueKey& key, + GrSurfaceOrigin origin) { ASSERT_SINGLE_OWNER sk_sp<GrTexture> texture(this->findAndRefTextureByUniqueKey(key)); @@ -320,7 +321,7 @@ sk_sp<GrTextureProxy> GrResourceProvider::findProxyByUniqueKey(const GrUniqueKey return nullptr; } - return GrSurfaceProxy::MakeWrapped(std::move(texture)); + return GrSurfaceProxy::MakeWrapped(std::move(texture), origin); } const GrBuffer* GrResourceProvider::createPatternedIndexBuffer(const uint16_t* pattern, diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h index b553cc4a98..28207b7a87 100644 --- a/src/gpu/GrResourceProvider.h +++ b/src/gpu/GrResourceProvider.h @@ -55,7 +55,7 @@ public: /** Finds a texture by unique key. If the texture is found it is ref'ed and returned. */ // MDB TODO (caching): If this were actually caching proxies (rather than shallowly // wrapping GrSurface caching) we would not need the origin parameter. - sk_sp<GrTextureProxy> findProxyByUniqueKey(const GrUniqueKey& key); + sk_sp<GrTextureProxy> findProxyByUniqueKey(const GrUniqueKey& key, GrSurfaceOrigin); /** * Finds a texture that approximately matches the descriptor. Will be at least as large in width diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp index 2199529739..f479a483fe 100644 --- a/src/gpu/GrSoftwarePathRenderer.cpp +++ b/src/gpu/GrSoftwarePathRenderer.cpp @@ -205,7 +205,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { sk_sp<GrTextureProxy> proxy; if (useCache) { - proxy = fResourceProvider->findProxyByUniqueKey(maskKey); + proxy = fResourceProvider->findProxyByUniqueKey(maskKey, kTopLeft_GrSurfaceOrigin); } if (!proxy) { SkBackingFit fit = useCache ? SkBackingFit::kExact : SkBackingFit::kApprox; diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index b4e4685918..804cabbacd 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -20,12 +20,12 @@ #include "SkMathPriv.h" -GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit) +GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, GrSurfaceOrigin origin, SkBackingFit fit) : INHERITED(std::move(surface)) , fConfig(fTarget->config()) , fWidth(fTarget->width()) , fHeight(fTarget->height()) - , fOrigin(fTarget->origin()) + , fOrigin(origin) , fFit(fit) , fBudgeted(fTarget->resourcePriv().isBudgeted()) , fFlags(0) @@ -34,6 +34,7 @@ GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit) , fGpuMemorySize(kInvalidGpuMemorySize) , fLastOpList(nullptr) { SkASSERT(kDefault_GrSurfaceOrigin != fOrigin); + SkASSERT(fTarget->origin() == fOrigin); } GrSurfaceProxy::~GrSurfaceProxy() { @@ -145,34 +146,34 @@ GrTextureOpList* GrSurfaceProxy::getLastTextureOpList() { return fLastOpList ? fLastOpList->asTextureOpList() : nullptr; } -sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrSurface> surf) { +sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrSurface> surf, GrSurfaceOrigin origin) { if (!surf) { return nullptr; } if (surf->asTexture()) { if (surf->asRenderTarget()) { - return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(std::move(surf))); + return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(std::move(surf), origin)); } else { - return sk_sp<GrSurfaceProxy>(new GrTextureProxy(std::move(surf))); + return sk_sp<GrSurfaceProxy>(new GrTextureProxy(std::move(surf), origin)); } } else { SkASSERT(surf->asRenderTarget()); // Not texturable - return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(surf))); + return sk_sp<GrSurfaceProxy>(new GrRenderTargetProxy(std::move(surf), origin)); } } -sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex) { +sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex, GrSurfaceOrigin origin) { if (!tex) { return nullptr; } if (tex->asRenderTarget()) { - return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex))); + return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(std::move(tex), origin)); } else { - return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex))); + return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex), origin)); } } @@ -270,14 +271,14 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferredMipMap( return nullptr; } - return GrSurfaceProxy::MakeWrapped(std::move(tex)); + return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin); } sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrappedBackend(GrContext* context, GrBackendTexture& backendTex, GrSurfaceOrigin origin) { sk_sp<GrTexture> tex(context->resourceProvider()->wrapBackendTexture(backendTex, origin)); - return GrSurfaceProxy::MakeWrapped(std::move(tex)); + return GrSurfaceProxy::MakeWrapped(std::move(tex), origin); } #ifdef SK_DEBUG diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp index 11cb5b3c90..166cb9d54b 100644 --- a/src/gpu/GrTextureAdjuster.cpp +++ b/src/gpu/GrTextureAdjuster.cpp @@ -46,7 +46,8 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c GrUniqueKey key; this->makeCopyKey(copyParams, &key, nullptr); if (key.isValid()) { - sk_sp<GrTextureProxy> cachedCopy = fContext->resourceProvider()->findProxyByUniqueKey(key); + sk_sp<GrTextureProxy> cachedCopy = fContext->resourceProvider()->findProxyByUniqueKey( + key, this->originalProxy()->origin()); if (cachedCopy) { return cachedCopy; } diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp index 96bcea4d61..2962ddb4c2 100644 --- a/src/gpu/GrTextureMaker.cpp +++ b/src/gpu/GrTextureMaker.cpp @@ -41,18 +41,17 @@ sk_sp<GrTextureProxy> GrTextureMaker::refTextureProxyForParams(const GrSamplerPa } } - SkDEBUGCODE(GrSurfaceOrigin origOrigin); + GrSurfaceOrigin origOrigin; GrUniqueKey copyKey; this->makeCopyKey(copyParams, ©Key, dstColorSpace); if (copyKey.isValid()) { -#ifdef SK_DEBUG if (original) { origOrigin = original->origin(); } else { origOrigin = kTopLeft_GrSurfaceOrigin; } -#endif - sk_sp<GrTextureProxy> result(fContext->resourceProvider()->findProxyByUniqueKey(copyKey)); + sk_sp<GrTextureProxy> result(fContext->resourceProvider()->findProxyByUniqueKey( + copyKey, origOrigin)); if (result) { return result; } diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp index 310b36d7c6..21533df0ee 100644 --- a/src/gpu/GrTextureProxy.cpp +++ b/src/gpu/GrTextureProxy.cpp @@ -17,8 +17,8 @@ GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, S SkASSERT(!srcData); // currently handled in Make() } -GrTextureProxy::GrTextureProxy(sk_sp<GrSurface> surf) - : INHERITED(std::move(surf), SkBackingFit::kExact) +GrTextureProxy::GrTextureProxy(sk_sp<GrSurface> surf, GrSurfaceOrigin origin) + : INHERITED(std::move(surf), origin, SkBackingFit::kExact) , fIsMipMapped(fTarget->asTexture()->texturePriv().hasMipMaps()) , fMipColorMode(fTarget->asTexture()->texturePriv().mipColorMode()) { } diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp index a9a56e18c4..1bb0e239fd 100644 --- a/src/gpu/GrTextureRenderTargetProxy.cpp +++ b/src/gpu/GrTextureRenderTargetProxy.cpp @@ -24,10 +24,11 @@ GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps, // Wrapped version // This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and // GrRenderTargetProxy) so its constructor must be explicitly called. -GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf) - : GrSurfaceProxy(surf, SkBackingFit::kExact) - , GrTextureProxy(surf) - , GrRenderTargetProxy(surf) { +GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf, + GrSurfaceOrigin origin) + : GrSurfaceProxy(surf, origin, SkBackingFit::kExact) + , GrTextureProxy(surf, origin) + , GrRenderTargetProxy(surf, origin) { SkASSERT(surf->asTexture()); SkASSERT(surf->asRenderTarget()); } diff --git a/src/gpu/GrTextureRenderTargetProxy.h b/src/gpu/GrTextureRenderTargetProxy.h index ed64d9072d..7005169b22 100644 --- a/src/gpu/GrTextureRenderTargetProxy.h +++ b/src/gpu/GrTextureRenderTargetProxy.h @@ -30,7 +30,7 @@ private: SkBackingFit, SkBudgeted, uint32_t flags); // Wrapped version - GrTextureRenderTargetProxy(sk_sp<GrSurface>); + GrTextureRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin); bool instantiate(GrResourceProvider*) override; sk_sp<GrSurface> createSurface(GrResourceProvider*) const override; diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 80ea1ca522..e426b95af0 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -246,7 +246,7 @@ sk_sp<GrTextureProxy> GrMakeCachedBitmapProxy(GrResourceProvider* resourceProvid sk_sp<GrTextureProxy> proxy; if (originalKey.isValid()) { - proxy = resourceProvider->findProxyByUniqueKey(originalKey); + proxy = resourceProvider->findProxyByUniqueKey(originalKey, kTopLeft_GrSurfaceOrigin); } if (!proxy) { // Pass nullptr for |dstColorSpace|. This is lenient - we allow a wider range of diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp index dcc53625a1..65e3c97cc6 100644 --- a/src/gpu/effects/GrTextureStripAtlas.cpp +++ b/src/gpu/effects/GrTextureStripAtlas.cpp @@ -207,7 +207,8 @@ 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; diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index adc23599ad..3bed9e8298 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -277,7 +277,7 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, } const SkBudgeted budgeted = SkBudgeted::kNo; - sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(tex))); + sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeWrapped(std::move(tex), origin)); return sk_make_sp<SkImage_Gpu>(ctx, kNeedNewImageUniqueID, at, std::move(proxy), std::move(colorSpace), budgeted); } diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp index 6c03d7d01e..aff19f8d79 100644 --- a/src/image/SkImage_Lazy.cpp +++ b/src/image/SkImage_Lazy.cpp @@ -748,7 +748,8 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx, // 1. Check the cache for a pre-existing one if (key.isValid()) { - if (sk_sp<GrTextureProxy> proxy = ctx->resourceProvider()->findProxyByUniqueKey(key)) { + if (sk_sp<GrTextureProxy> proxy = ctx->resourceProvider()->findProxyByUniqueKey( + key, kTopLeft_GrSurfaceOrigin)) { SK_HISTOGRAM_ENUMERATION("LockTexturePath", kPreExisting_LockTexturePath, kLockTexturePathCount); return proxy; diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index d67f1038fc..f1d6a269bc 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -184,7 +184,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info) if (!tex) { continue; } - auto proxy = GrSurfaceProxy::MakeWrapped(std::move(tex)); + auto proxy = GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin); auto texCtx = context->contextPriv().makeWrappedSurfaceContext( std::move(proxy), nullptr); SkImageInfo info = SkImageInfo::Make( diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp index 513b680045..23ca695d42 100644 --- a/tests/ProxyConversionTest.cpp +++ b/tests/ProxyConversionTest.cpp @@ -29,7 +29,7 @@ static sk_sp<GrSurfaceProxy> make_wrapped_FBO0(GrResourceProvider* provider, sk_sp<GrRenderTarget> defaultFBO(provider->wrapBackendRenderTarget(backendRT, desc.fOrigin)); SkASSERT(!defaultFBO->asTexture()); - return GrSurfaceProxy::MakeWrapped(std::move(defaultFBO)); + return GrSurfaceProxy::MakeWrapped(std::move(defaultFBO), desc.fOrigin); } static sk_sp<GrSurfaceProxy> make_wrapped_offscreen_rt(GrResourceProvider* provider, @@ -40,7 +40,7 @@ static sk_sp<GrSurfaceProxy> make_wrapped_offscreen_rt(GrResourceProvider* provi sk_sp<GrTexture> tex(provider->createTexture(desc, budgeted)); - return GrSurfaceProxy::MakeWrapped(std::move(tex)); + return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin); } static sk_sp<GrSurfaceProxy> make_wrapped_texture(GrResourceProvider* provider, @@ -48,7 +48,7 @@ static sk_sp<GrSurfaceProxy> make_wrapped_texture(GrResourceProvider* provider, SkBudgeted budgeted) { sk_sp<GrTexture> tex(provider->createTexture(desc, budgeted)); - return GrSurfaceProxy::MakeWrapped(std::move(tex)); + return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin); } // Test converting between RenderTargetProxies and TextureProxies for wrapped diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp index a30766b838..3648122652 100644 --- a/tests/ProxyRefTest.cpp +++ b/tests/ProxyRefTest.cpp @@ -87,7 +87,7 @@ static sk_sp<GrTextureProxy> make_wrapped(GrContext* context) { sk_sp<GrTexture> tex(context->resourceProvider()->createTexture(desc, SkBudgeted::kNo)); - return GrSurfaceProxy::MakeWrapped(std::move(tex)); + return GrSurfaceProxy::MakeWrapped(std::move(tex), desc.fOrigin); } DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index dd1f4cbe43..547d3b2ce3 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -236,7 +236,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { sk_sp<GrRenderTarget> defaultFBO( provider->wrapBackendRenderTarget(backendRT, origin)); - sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(defaultFBO)); + sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(defaultFBO, + origin)); check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight, config, defaultFBO->uniqueID(), SkBudgeted::kNo); @@ -252,7 +253,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { tex = provider->createTexture(desc, budgeted); sk_sp<GrRenderTarget> rt(sk_ref_sp(tex->asRenderTarget())); - sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(rt)); + sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(rt, origin)); check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight, config, rt->uniqueID(), budgeted); @@ -267,7 +268,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { tex = provider->createTexture(desc, budgeted); } - sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(tex)); + sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(tex, origin)); check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight, config, tex->uniqueID(), budgeted); check_texture(reporter, provider, sProxy->asTextureProxy(), diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp index 96db1f7722..4aa055d431 100644 --- a/tests/ResourceAllocatorTest.cpp +++ b/tests/ResourceAllocatorTest.cpp @@ -56,7 +56,7 @@ static sk_sp<GrSurfaceProxy> make_backend(GrContext* context, const ProxyParams& sk_sp<GrSurface> tex = context->resourceProvider()->wrapBackendTexture( backendTex, p.fOrigin, kBorrow_GrWrapOwnership); - return GrSurfaceProxy::MakeWrapped(std::move(tex)); + return GrSurfaceProxy::MakeWrapped(std::move(tex), p.fOrigin); } static void cleanup_backend(GrContext* context, GrBackendObject* backendTexHandle) { |