diff options
40 files changed, 117 insertions, 162 deletions
diff --git a/bench/GrResourceCacheBench.cpp b/bench/GrResourceCacheBench.cpp index c48aed5e0b..d78af0a9e5 100644 --- a/bench/GrResourceCacheBench.cpp +++ b/bench/GrResourceCacheBench.cpp @@ -9,11 +9,10 @@ #if SK_SUPPORT_GPU -#include "GrContext.h" -#include "GrContextPriv.h" -#include "GrGpu.h" #include "GrGpuResource.h" #include "GrGpuResourcePriv.h" +#include "GrContext.h" +#include "GrGpu.h" #include "GrResourceCache.h" #include "SkCanvas.h" @@ -77,7 +76,7 @@ protected: // Set the cache budget to be very large so no purging occurs. context->setResourceCacheLimits(CACHE_SIZE_COUNT, 1 << 30); - GrResourceCache* cache = context->contextPriv().getResourceCache(); + GrResourceCache* cache = context->getResourceCache(); // Make sure the cache is empty. cache->purgeAllUnlocked(); @@ -123,7 +122,7 @@ protected: // Set the cache budget to be very large so no purging occurs. fContext->setResourceCacheLimits(CACHE_SIZE_COUNT, 1 << 30); - GrResourceCache* cache = fContext->contextPriv().getResourceCache(); + GrResourceCache* cache = fContext->getResourceCache(); // Make sure the cache is empty. cache->purgeAllUnlocked(); @@ -138,7 +137,7 @@ protected: if (!fContext) { return; } - GrResourceCache* cache = fContext->contextPriv().getResourceCache(); + GrResourceCache* cache = fContext->getResourceCache(); SkASSERT(CACHE_SIZE_COUNT == cache->getResourceCount()); for (int i = 0; i < loops; ++i) { for (int k = 0; k < CACHE_SIZE_COUNT; ++k) { diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 6b5d7500fa..84c71f87a7 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -305,6 +305,9 @@ public: GrAtlasGlyphCache* getAtlasGlyphCache() { return fAtlasGlyphCache; } GrTextBlobCache* getTextBlobCache() { return fTextBlobCache.get(); } bool abandoned() const; + GrResourceProvider* resourceProvider() { return fResourceProvider; } + const GrResourceProvider* resourceProvider() const { return fResourceProvider; } + GrResourceCache* getResourceCache() { return fResourceCache; } /** Reset GPU stats */ void resetGpuStats() const ; diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp index 36dc139cab..5dc23963f7 100644 --- a/src/gpu/GrBackendTextureImageGenerator.cpp +++ b/src/gpu/GrBackendTextureImageGenerator.cpp @@ -43,7 +43,7 @@ GrBackendTextureImageGenerator::Make(sk_sp<GrTexture> texture, GrSurfaceOrigin o // Attach our texture to this context's resource cache. This ensures that deletion will happen // in the correct thread/context. This adds the only ref to the texture that will persist from // this point. That ref will be released when the generator's RefHelper is freed. - context->contextPriv().getResourceCache()->insertCrossContextGpuResource(texture.get()); + context->getResourceCache()->insertCrossContextGpuResource(texture.get()); GrBackendTexture backendTexture = texture->getBackendTexture(); @@ -115,8 +115,8 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture( // always make a wrapped copy, where the release proc informs us that the context is done // with it. This is unfortunate - we'll have two texture objects referencing the same GPU // object. However, no client can ever see the original texture, so this should be safe. - tex = context->contextPriv().resourceProvider()->wrapBackendTexture( - fBackendTexture, kBorrow_GrWrapOwnership); + tex = context->resourceProvider()->wrapBackendTexture(fBackendTexture, + kBorrow_GrWrapOwnership); if (!tex) { return nullptr; } diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp index fc5fb66478..13ae404d3d 100644 --- a/src/gpu/GrBufferAllocPool.cpp +++ b/src/gpu/GrBufferAllocPool.cpp @@ -10,7 +10,6 @@ #include "GrBuffer.h" #include "GrCaps.h" #include "GrContext.h" -#include "GrContextPriv.h" #include "GrGpu.h" #include "GrResourceProvider.h" #include "GrTypes.h" @@ -369,11 +368,11 @@ void GrBufferAllocPool::flushCpuData(const BufferBlock& block, size_t flushSize) GrBuffer* GrBufferAllocPool::getBuffer(size_t size) { - auto resourceProvider = fGpu->getContext()->contextPriv().resourceProvider(); + GrResourceProvider* rp = fGpu->getContext()->resourceProvider(); // Shouldn't have to use this flag (https://bug.skia.org/4156) static const uint32_t kFlags = GrResourceProvider::kNoPendingIO_Flag; - return resourceProvider->createBuffer(size, fBufferType, kDynamic_GrAccessPattern, kFlags); + return rp->createBuffer(size, fBufferType, kDynamic_GrAccessPattern, kFlags); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index c13cd539c2..95d23441ac 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -484,7 +484,7 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst, ASSERT_OWNED_PROXY_PRIV(dst->asSurfaceProxy()); GR_CREATE_TRACE_MARKER_CONTEXT("GrContextPriv", "writeSurfacePixels", fContext); - if (!dst->asSurfaceProxy()->instantiate(this->resourceProvider())) { + if (!dst->asSurfaceProxy()->instantiate(fContext->resourceProvider())) { return false; } @@ -563,7 +563,7 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceContext* dst, return false; } - if (!tempProxy->instantiate(this->resourceProvider())) { + if (!tempProxy->instantiate(fContext->resourceProvider())) { return false; } GrTexture* texture = tempProxy->priv().peekTexture(); @@ -616,7 +616,7 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, GR_CREATE_TRACE_MARKER_CONTEXT("GrContextPriv", "readSurfacePixels", fContext); // MDB TODO: delay this instantiation until later in the method - if (!src->asSurfaceProxy()->instantiate(this->resourceProvider())) { + if (!src->asSurfaceProxy()->instantiate(fContext->resourceProvider())) { return false; } @@ -724,7 +724,7 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceContext* src, configToRead = tempDrawInfo.fReadConfig; } - if (!proxyToRead->instantiate(this->resourceProvider())) { + if (!proxyToRead->instantiate(fContext->resourceProvider())) { return false; } diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h index bbf67a569a..2da8f34cda 100644 --- a/src/gpu/GrContextPriv.h +++ b/src/gpu/GrContextPriv.h @@ -170,11 +170,6 @@ public: GrProxyProvider* proxyProvider() { return fContext->fProxyProvider; } const GrProxyProvider* proxyProvider() const { return fContext->fProxyProvider; } - GrResourceProvider* resourceProvider() { return fContext->fResourceProvider; } - const GrResourceProvider* resourceProvider() const { return fContext->fResourceProvider; } - - GrResourceCache* getResourceCache() { return fContext->fResourceCache; } - private: explicit GrContextPriv(GrContext* context) : fContext(context) {} GrContextPriv(const GrContextPriv&); // unimpl diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp index 24e19f5b5e..0ba9deca04 100644 --- a/src/gpu/GrDrawOpAtlas.cpp +++ b/src/gpu/GrDrawOpAtlas.cpp @@ -188,7 +188,7 @@ inline bool GrDrawOpAtlas::updatePlot(GrDeferredUploadTarget* target, AtlasID* i // MDB TODO: this is currently fine since the atlas' proxy is always pre-instantiated. // Once it is deferred more care must be taken upon instantiation failure. - if (!fProxies[pageIdx]->instantiate(fContext->contextPriv().resourceProvider())) { + if (!fProxies[pageIdx]->instantiate(fContext->resourceProvider())) { return false; } @@ -309,7 +309,7 @@ bool GrDrawOpAtlas::addToAtlas(AtlasID* id, GrDeferredUploadTarget* target, int sk_sp<Plot> plotsp(SkRef(newPlot.get())); // MDB TODO: this is currently fine since the atlas' proxy is always pre-instantiated. // Once it is deferred more care must be taken upon instantiation failure. - if (!fProxies[pageIdx]->instantiate(fContext->contextPriv().resourceProvider())) { + if (!fProxies[pageIdx]->instantiate(fContext->resourceProvider())) { return false; } GrTextureProxy* proxy = fProxies[pageIdx].get(); diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index e60468b0d1..7a7e0a3b0a 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -168,7 +168,7 @@ GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*, bool flushed = false; { - GrResourceAllocator alloc(fContext->contextPriv().resourceProvider()); + GrResourceAllocator alloc(fContext->resourceProvider()); for (int i = 0; i < fOpLists.count(); ++i) { fOpLists[i]->gatherProxyIntervals(&alloc); alloc.markEndOfOpList(i); @@ -194,7 +194,7 @@ GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*, // We always have to notify the cache when it requested a flush so it can reset its state. if (flushed || type == GrResourceCache::FlushType::kCacheRequested) { - fContext->contextPriv().getResourceCache()->notifyFlushOccurred(type); + fContext->getResourceCache()->notifyFlushOccurred(type); } for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) { onFlushCBObject->postFlush(fFlushState.nextTokenToFlush(), fFlushingOpListIDs.begin(), @@ -217,7 +217,7 @@ bool GrDrawingManager::executeOpLists(int startIndex, int stopIndex, GrOpFlushSt } #ifdef SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION - if (!fOpLists[i]->instantiate(fContext->contextPriv().resourceProvider())) { + if (!fOpLists[i]->instantiate(fContext->resourceProvider())) { SkDebugf("OpList failed to instantiate.\n"); fOpLists[i] = nullptr; continue; @@ -228,7 +228,7 @@ bool GrDrawingManager::executeOpLists(int startIndex, int stopIndex, GrOpFlushSt // TODO: handle this instantiation via lazy surface proxies? // Instantiate all deferred proxies (being built on worker threads) so we can upload them - fOpLists[i]->instantiateDeferredProxies(fContext->contextPriv().resourceProvider()); + fOpLists[i]->instantiateDeferredProxies(fContext->resourceProvider()); fOpLists[i]->prepare(flushState); } @@ -291,7 +291,7 @@ GrSemaphoresSubmitted GrDrawingManager::prepareSurfaceForExternalIO( result = this->flush(proxy, numSemaphores, backendSemaphores); } - if (!proxy->instantiate(fContext->contextPriv().resourceProvider())) { + if (!proxy->instantiate(fContext->resourceProvider())) { return result; } @@ -340,7 +340,7 @@ sk_sp<GrTextureOpList> GrDrawingManager::newTextureOpList(GrTextureProxy* textur fOpLists.back()->makeClosed(*fContext->caps()); } - sk_sp<GrTextureOpList> opList(new GrTextureOpList(fContext->contextPriv().resourceProvider(), + sk_sp<GrTextureOpList> opList(new GrTextureOpList(fContext->resourceProvider(), textureProxy, fContext->getAuditTrail())); diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h index 0162b4bd74..cbb28c494a 100644 --- a/src/gpu/GrDrawingManager.h +++ b/src/gpu/GrDrawingManager.h @@ -65,7 +65,7 @@ public: GrCoverageCountingPathRenderer* getCoverageCountingPathRenderer(); void flushIfNecessary() { - if (fContext->contextPriv().getResourceCache()->requestsFlush()) { + if (fContext->getResourceCache()->requestsFlush()) { this->internalFlush(nullptr, GrResourceCache::kCacheRequested, 0, nullptr); } } @@ -92,7 +92,7 @@ private: , fAtlasTextContext(nullptr) , fPathRendererChain(nullptr) , fSoftwarePathRenderer(nullptr) - , fFlushState(context->getGpu(), context->contextPriv().resourceProvider()) + , fFlushState(context->getGpu(), context->resourceProvider()) , fFlushing(false) {} void abandon(); diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 93f719ab48..3a095517b5 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -13,7 +13,6 @@ #include "GrBuffer.h" #include "GrCaps.h" #include "GrContext.h" -#include "GrContextPriv.h" #include "GrGpuResourcePriv.h" #include "GrMesh.h" #include "GrPathRendering.h" @@ -484,17 +483,15 @@ bool GrGpu::SamplePatternComparator::operator()(const SamplePattern& a, GrSemaphoresSubmitted GrGpu::finishFlush(int numSemaphores, GrBackendSemaphore backendSemaphores[]) { - GrResourceProvider* resourceProvider = fContext->contextPriv().resourceProvider(); - if (this->caps()->fenceSyncSupport()) { for (int i = 0; i < numSemaphores; ++i) { sk_sp<GrSemaphore> semaphore; if (backendSemaphores[i].isInitialized()) { - semaphore = resourceProvider->wrapBackendSemaphore( + semaphore = fContext->resourceProvider()->wrapBackendSemaphore( backendSemaphores[i], GrResourceProvider::SemaphoreWrapType::kWillSignal, kBorrow_GrWrapOwnership); } else { - semaphore = resourceProvider->makeSemaphore(false); + semaphore = fContext->resourceProvider()->makeSemaphore(false); } this->insertSemaphore(semaphore, false); diff --git a/src/gpu/GrGpuCommandBuffer.cpp b/src/gpu/GrGpuCommandBuffer.cpp index 096c3c4d38..1dc16c1caa 100644 --- a/src/gpu/GrGpuCommandBuffer.cpp +++ b/src/gpu/GrGpuCommandBuffer.cpp @@ -46,9 +46,8 @@ bool GrGpuRTCommandBuffer::draw(const GrPipeline& pipeline, SkASSERT(primProc.hasInstanceAttribs() == meshes[i].isInstanced()); } #endif - auto resourceProvider = this->gpu()->getContext()->contextPriv().resourceProvider(); - if (pipeline.isBad() || !primProc.instantiate(resourceProvider)) { + if (pipeline.isBad() || !primProc.instantiate(this->gpu()->getContext()->resourceProvider())) { return false; } diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp index 3d3c88bbe2..df8e72c5ed 100644 --- a/src/gpu/GrGpuResource.cpp +++ b/src/gpu/GrGpuResource.cpp @@ -7,7 +7,6 @@ #include "GrGpuResource.h" #include "GrContext.h" -#include "GrContextPriv.h" #include "GrResourceCache.h" #include "GrGpu.h" #include "GrGpuResourcePriv.h" @@ -16,8 +15,8 @@ static inline GrResourceCache* get_resource_cache(GrGpu* gpu) { SkASSERT(gpu); SkASSERT(gpu->getContext()); - SkASSERT(gpu->getContext()->contextPriv().getResourceCache()); - return gpu->getContext()->contextPriv().getResourceCache(); + SkASSERT(gpu->getContext()->getResourceCache()); + return gpu->getContext()->getResourceCache(); } GrGpuResource::GrGpuResource(GrGpu* gpu) diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp index 8de827c5b5..7fcd30f941 100644 --- a/src/gpu/GrOnFlushResourceProvider.cpp +++ b/src/gpu/GrOnFlushResourceProvider.cpp @@ -19,12 +19,10 @@ sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext( GrSurfaceDesc tmpDesc = desc; tmpDesc.fFlags |= kRenderTarget_GrSurfaceFlag; - auto proxyProvider = fDrawingMgr->getContext()->contextPriv().proxyProvider(); - auto resourceProvider = fDrawingMgr->getContext()->contextPriv().resourceProvider(); - // Because this is being allocated at the start of a flush we must ensure the proxy // will, when instantiated, have no pending IO. // TODO: fold the kNoPendingIO_Flag into GrSurfaceFlags? + GrProxyProvider* proxyProvider = fDrawingMgr->getContext()->contextPriv().proxyProvider(); sk_sp<GrSurfaceProxy> proxy = proxyProvider->createProxy(tmpDesc, SkBackingFit::kExact, SkBudgeted::kYes, GrResourceProvider::kNoPendingIO_Flag); @@ -44,7 +42,8 @@ sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext( // Since this is at flush time and these won't be allocated for us by the GrResourceAllocator // we have to manually ensure it is allocated here. The proxy had best have been created // with the kNoPendingIO flag! - if (!renderTargetContext->asSurfaceProxy()->instantiate(resourceProvider)) { + if (!renderTargetContext->asSurfaceProxy()->instantiate( + fDrawingMgr->getContext()->resourceProvider())) { return nullptr; } @@ -68,12 +67,11 @@ sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext( return nullptr; } - auto resourceProvider = fDrawingMgr->getContext()->contextPriv().resourceProvider(); - // Since this is at flush time and these won't be allocated for us by the GrResourceAllocator // we have to manually ensure it is allocated here. The proxy had best have been created // with the kNoPendingIO flag! - if (!renderTargetContext->asSurfaceProxy()->instantiate(resourceProvider)) { + if (!renderTargetContext->asSurfaceProxy()->instantiate( + fDrawingMgr->getContext()->resourceProvider())) { return nullptr; } @@ -84,20 +82,18 @@ sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext( sk_sp<GrBuffer> GrOnFlushResourceProvider::makeBuffer(GrBufferType intendedType, size_t size, const void* data) { - auto resourceProvider = fDrawingMgr->getContext()->contextPriv().resourceProvider(); - return sk_sp<GrBuffer>(resourceProvider->createBuffer(size, intendedType, - kDynamic_GrAccessPattern, - GrResourceProvider::kNoPendingIO_Flag, - data)); + GrResourceProvider* rp = fDrawingMgr->getContext()->resourceProvider(); + return sk_sp<GrBuffer>(rp->createBuffer(size, intendedType, kDynamic_GrAccessPattern, + GrResourceProvider::kNoPendingIO_Flag, + data)); } sk_sp<const GrBuffer> GrOnFlushResourceProvider::findOrMakeStaticBuffer(GrBufferType intendedType, size_t size, const void* data, const GrUniqueKey& key) { - auto resourceProvider = fDrawingMgr->getContext()->contextPriv().resourceProvider(); - sk_sp<const GrBuffer> buffer = resourceProvider->findOrMakeStaticBuffer(intendedType, size, - data, key); + GrResourceProvider* rp = fDrawingMgr->getContext()->resourceProvider(); + sk_sp<const GrBuffer> buffer = rp->findOrMakeStaticBuffer(intendedType, size, data, key); // Static buffers should never have pending IO. SkASSERT(!buffer->resourcePriv().hasPendingIO_debugOnly()); return buffer; diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp index 1e1d87a828..393823ca1b 100644 --- a/src/gpu/GrPathRendererChain.cpp +++ b/src/gpu/GrPathRendererChain.cpp @@ -34,7 +34,7 @@ GrPathRendererChain::GrPathRendererChain(GrContext* context, const Options& opti } if (options.fGpuPathRenderers & GpuPathRenderers::kStencilAndCover) { sk_sp<GrPathRenderer> pr( - GrStencilAndCoverPathRenderer::Create(context->contextPriv().resourceProvider(), caps)); + GrStencilAndCoverPathRenderer::Create(context->resourceProvider(), caps)); if (pr) { fChain.push_back(std::move(pr)); } diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp index 2b02b8df20..96cbca480c 100644 --- a/src/gpu/GrProcessor.cpp +++ b/src/gpu/GrProcessor.cpp @@ -18,7 +18,7 @@ #if GR_TEST_UTILS GrResourceProvider* GrProcessorTestData::resourceProvider() { - return fContext->contextPriv().resourceProvider(); + return fContext->resourceProvider(); } GrProxyProvider* GrProcessorTestData::proxyProvider() { diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 42a4fddc52..19540ebd7e 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -1425,11 +1425,9 @@ bool GrRenderTargetContext::waitOnSemaphores(int numSemaphores, return false; } - auto resourceProvider = fContext->contextPriv().resourceProvider(); - SkTArray<sk_sp<GrSemaphore>> semaphores(numSemaphores); for (int i = 0; i < numSemaphores; ++i) { - sk_sp<GrSemaphore> sema = resourceProvider->wrapBackendSemaphore( + sk_sp<GrSemaphore> sema = fContext->resourceProvider()->wrapBackendSemaphore( waitSemaphores[i], GrResourceProvider::SemaphoreWrapType::kWillWait, kAdopt_GrWrapOwnership); std::unique_ptr<GrOp> waitOp(GrSemaphoreOp::MakeWait(sema, fRenderTargetProxy.get())); diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h index 47cd922596..2ae52b922c 100644 --- a/src/gpu/GrRenderTargetContext.h +++ b/src/gpu/GrRenderTargetContext.h @@ -11,7 +11,6 @@ #include "../private/GrRenderTargetProxy.h" #include "GrColor.h" #include "GrContext.h" -#include "GrContextPriv.h" #include "GrPaint.h" #include "GrSurfaceContext.h" #include "GrTypesPriv.h" @@ -350,7 +349,7 @@ public: GrRenderTarget* accessRenderTarget() { // TODO: usage of this entry point needs to be reduced and potentially eliminated // since it ends the deferral of the GrRenderTarget's allocation - if (!fRenderTargetProxy->instantiate(fContext->contextPriv().resourceProvider())) { + if (!fRenderTargetProxy->instantiate(fContext->resourceProvider())) { return nullptr; } return fRenderTargetProxy->priv().peekRenderTarget(); diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index 0f62bc6a35..09ce76009a 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -26,7 +26,7 @@ static const int kMaxOpLookahead = 10; GrRenderTargetOpList::GrRenderTargetOpList(GrRenderTargetProxy* proxy, GrGpu* gpu, GrAuditTrail* auditTrail) - : INHERITED(gpu->getContext()->contextPriv().resourceProvider(), proxy, auditTrail) + : INHERITED(gpu->getContext()->resourceProvider(), proxy, auditTrail) , fLastClipStackGenID(SK_InvalidUniqueID) SkDEBUGCODE(, fNumClips(0)) { } diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp index f906773efc..0e6eee46d0 100644 --- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp +++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp @@ -9,7 +9,6 @@ #include "GrAutoLocaleSetter.h" #include "GrContext.h" -#include "GrContextPriv.h" #include "GrCoordTransform.h" #include "GrGLProgramBuilder.h" #include "GrProgramDesc.h" @@ -33,11 +32,7 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrPipeline& pipeline, const GrPrimitiveProcessor& primProc, GrProgramDesc* desc, GrGLGpu* gpu) { -#ifdef SK_DEBUG - GrResourceProvider* resourceProvider = gpu->getContext()->contextPriv().resourceProvider(); - - SkASSERT(!pipeline.isBad() && primProc.instantiate(resourceProvider)); -#endif + SkASSERT(!pipeline.isBad() && primProc.instantiate(gpu->getContext()->resourceProvider())); ATRACE_ANDROID_FRAMEWORK("Shader Compile"); GrAutoLocaleSetter als("C"); diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp index b2dfa6c375..86e5732eb9 100644 --- a/src/gpu/text/GrStencilAndCoverTextContext.cpp +++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp @@ -560,7 +560,7 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx, SkASSERT(fInstanceData); if (fInstanceData->count()) { - sk_sp<GrPathRange> glyphs(this->createGlyphs(ctx->contextPriv().resourceProvider())); + sk_sp<GrPathRange> glyphs(this->createGlyphs(ctx->resourceProvider())); if (fLastDrawnGlyphsID != glyphs->uniqueID()) { // Either this is the first draw or the glyphs object was purged since last draw. glyphs->loadPathsIfNeeded(fInstanceData->indices(), fInstanceData->count()); diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp index 10e757e3c9..1dbc4909ce 100644 --- a/src/gpu/vk/GrVkPipelineState.cpp +++ b/src/gpu/vk/GrVkPipelineState.cpp @@ -8,7 +8,6 @@ #include "GrVkPipelineState.h" #include "GrContext.h" -#include "GrContextPriv.h" #include "GrPipeline.h" #include "GrTexturePriv.h" #include "GrVkBufferView.h" @@ -264,12 +263,10 @@ void GrVkPipelineState::setData(GrVkGpu* gpu, fXferProcessor->setData(fDataManager, pipeline.getXferProcessor(), dstTexture, offset); } - GrResourceProvider* resourceProvider = gpu->getContext()->contextPriv().resourceProvider(); - GrResourceIOProcessor::TextureSampler dstTextureSampler; if (GrTextureProxy* dstTextureProxy = pipeline.dstTextureProxy()) { dstTextureSampler.reset(sk_ref_sp(dstTextureProxy)); - SkAssertResult(dstTextureSampler.instantiate(resourceProvider)); + SkAssertResult(dstTextureSampler.instantiate(gpu->getContext()->resourceProvider())); textureBindings.push_back(&dstTextureSampler); } diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index d08f0a4eeb..20e8349aa2 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -156,7 +156,7 @@ GrBackendObject SkImage_Gpu::onGetTextureHandle(bool flushPendingGrContextIO, GrSurfaceOrigin* origin) const { SkASSERT(fProxy); - if (!fProxy->instantiate(fContext->contextPriv().resourceProvider())) { + if (!fProxy->instantiate(fContext->resourceProvider())) { return 0; } @@ -180,7 +180,7 @@ GrTexture* SkImage_Gpu::onGetTexture() const { return nullptr; } - if (!proxy->instantiate(fContext->contextPriv().resourceProvider())) { + if (!proxy->instantiate(fContext->resourceProvider())) { return nullptr; } @@ -284,9 +284,7 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, return nullptr; } - GrResourceProvider* resourceProvider = ctx->contextPriv().resourceProvider(); - - sk_sp<GrTexture> tex = resourceProvider->wrapBackendTexture(backendTex, ownership); + sk_sp<GrTexture> tex = ctx->resourceProvider()->wrapBackendTexture(backendTex, ownership); if (!tex) { return nullptr; } @@ -587,7 +585,7 @@ sk_sp<SkImage> SkImage::MakeCrossContextFromEncoded(GrContext* context, sk_sp<Sk return codecImage; } - if (!proxy->instantiate(context->contextPriv().resourceProvider())) { + if (!proxy->instantiate(context->resourceProvider())) { return codecImage; } sk_sp<GrTexture> texture = sk_ref_sp(proxy->priv().peekTexture()); diff --git a/tests/BlendTest.cpp b/tests/BlendTest.cpp index b17b9f1e45..bf985aa2ae 100644 --- a/tests/BlendTest.cpp +++ b/tests/BlendTest.cpp @@ -95,9 +95,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target( backingDesc.fConfig = config; backingDesc.fSampleCnt = sampleCnt; - auto resourceProvider = context->contextPriv().resourceProvider(); - - *backingSurface = resourceProvider->createTexture(backingDesc, SkBudgeted::kNo); + *backingSurface = context->resourceProvider()->createTexture(backingDesc, SkBudgeted::kNo); if (!(*backingSurface)) { return nullptr; } diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp index c078422868..fe24bc14e6 100644 --- a/tests/ClipStackTest.cpp +++ b/tests/ClipStackTest.cpp @@ -1486,7 +1486,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ClipMaskCache, reporter, ctxInfo) { path.setFillType(SkPath::kEvenOdd_FillType); static const char* kTag = GrClipStackClip::kMaskTestTag; - GrResourceCache* cache = context->contextPriv().getResourceCache(); + GrResourceCache* cache = context->getResourceCache(); static constexpr int kN = 5; @@ -1496,7 +1496,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ClipMaskCache, reporter, ctxInfo) { stack.save(); stack.clipPath(path, m, SkClipOp::kIntersect, true); sk_sp<GrTextureProxy> mask = GrClipStackClip(&stack).testingOnly_createClipMask(context); - mask->instantiate(context->contextPriv().resourceProvider()); + mask->instantiate(context->resourceProvider()); GrTexture* tex = mask->priv().peekTexture(); REPORTER_ASSERT(reporter, 0 == strcmp(tex->getUniqueKey().tag(), kTag)); // Make sure mask isn't pinned in cache. diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp index 04bcca7c4d..0ff0d2c8fb 100644 --- a/tests/GrMipMappedTest.cpp +++ b/tests/GrMipMappedTest.cpp @@ -211,8 +211,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn return; } - auto resourceProvider = context->contextPriv().resourceProvider(); - for (auto willUseMips : {false, true}) { for (auto isWrapped : {false, true}) { GrMipMapped mipMapped = willUseMips ? GrMipMapped::kYes : GrMipMapped::kNo; @@ -242,7 +240,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn GrTextureProxy* texProxy = device->accessRenderTargetContext()->asTextureProxy(); REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped()); - texProxy->instantiate(resourceProvider); + texProxy->instantiate(context->resourceProvider()); GrTexture* texture = texProxy->priv().peekTexture(); REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped()); @@ -254,7 +252,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn texProxy = as_IB(image)->peekProxy(); REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped()); - texProxy->instantiate(resourceProvider); + texProxy->instantiate(context->resourceProvider()); texture = texProxy->priv().peekTexture(); REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped()); diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp index cd1ce1e053..f65744abeb 100644 --- a/tests/GrPipelineDynamicStateTest.cpp +++ b/tests/GrPipelineDynamicStateTest.cpp @@ -146,7 +146,7 @@ private: DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo) { GrContext* const context = ctxInfo.grContext(); - GrResourceProvider* rp = context->contextPriv().resourceProvider(); + GrResourceProvider* rp = context->resourceProvider(); sk_sp<GrRenderTargetContext> rtc( context->makeDeferredRenderTargetContext(SkBackingFit::kExact, kScreenSize, kScreenSize, diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index eab930145c..582510c1b4 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -24,8 +24,6 @@ // and render targets to GrSurface all work as expected. DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); - auto resourceProvider = context->contextPriv().resourceProvider(); - GrSurfaceDesc desc; desc.fFlags = kRenderTarget_GrSurfaceFlag; desc.fOrigin = kBottomLeft_GrSurfaceOrigin; @@ -33,7 +31,7 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) { desc.fHeight = 256; desc.fConfig = kRGBA_8888_GrPixelConfig; desc.fSampleCnt = 0; - sk_sp<GrSurface> texRT1 = resourceProvider->createTexture(desc, SkBudgeted::kNo); + sk_sp<GrSurface> texRT1 = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo); REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asRenderTarget()); REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asTexture()); @@ -46,7 +44,7 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) { desc.fFlags = kNone_GrSurfaceFlags; desc.fOrigin = kTopLeft_GrSurfaceOrigin; - sk_sp<GrTexture> tex1 = resourceProvider->createTexture(desc, SkBudgeted::kNo); + sk_sp<GrTexture> tex1 = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo); REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget()); REPORTER_ASSERT(reporter, tex1.get() == tex1->asTexture()); REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1.get()) == tex1->asTexture()); @@ -54,8 +52,8 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) { GrBackendTexture backendTex = context->getGpu()->createTestingOnlyBackendTexture( nullptr, 256, 256, kRGBA_8888_GrPixelConfig, false, GrMipMapped::kNo); - sk_sp<GrSurface> texRT2 = resourceProvider->wrapRenderableBackendTexture( - backendTex, 0, kBorrow_GrWrapOwnership); + sk_sp<GrSurface> texRT2 = context->resourceProvider()->wrapRenderableBackendTexture( + backendTex, 0, kBorrow_GrWrapOwnership); REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asRenderTarget()); REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asTexture()); @@ -74,7 +72,7 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) { DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider(); + GrResourceProvider* resourceProvider = context->resourceProvider(); const GrCaps* caps = context->caps(); GrPixelConfig configs[] = { diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp index 3105e9bb00..c33080888c 100644 --- a/tests/ImageFilterCacheTest.cpp +++ b/tests/ImageFilterCacheTest.cpp @@ -209,7 +209,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ct return; } - if (!srcProxy->instantiate(context->contextPriv().resourceProvider())) { + if (!srcProxy->instantiate(context->resourceProvider())) { return; } GrTexture* tex = srcProxy->priv().peekTexture(); diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp index 0bbb0718dc..2968c76d15 100644 --- a/tests/IntTextureTest.cpp +++ b/tests/IntTextureTest.cpp @@ -41,8 +41,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { } GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - auto resourceProvider = context->contextPriv().resourceProvider(); - static const int kS = UINT8_MAX + 1; static const size_t kRowBytes = kS * sizeof(int32_t); @@ -280,7 +278,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { // No rendering to integer textures. GrSurfaceDesc intRTDesc = desc; intRTDesc.fFlags = kRenderTarget_GrSurfaceFlag; - sk_sp<GrTexture> temp(resourceProvider->createTexture(intRTDesc, SkBudgeted::kYes)); + sk_sp<GrTexture> temp(context->resourceProvider()->createTexture(intRTDesc, + SkBudgeted::kYes)); REPORTER_ASSERT(reporter, !temp); } } diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp index cc645827d9..a3e272c81b 100644 --- a/tests/PathRendererCacheTests.cpp +++ b/tests/PathRendererCacheTests.cpp @@ -77,7 +77,7 @@ static void test_path(skiatest::Reporter* reporter, sk_sp<GrContext> ctx = GrContext::MakeMock(nullptr); // The cache needs to be big enough that nothing gets flushed, or our expectations can be wrong ctx->setResourceCacheLimits(100, 1000000); - GrResourceCache* cache = ctx->contextPriv().getResourceCache(); + GrResourceCache* cache = ctx->getResourceCache(); sk_sp<GrRenderTargetContext> rtc(ctx->makeDeferredRenderTargetContext( SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 0, diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index 26f10a383a..e675335118 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -158,7 +158,6 @@ void testingOnly_getIORefCnts(GrTextureProxy* proxy, int* refCnt, int* readCnt, DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider(); GrSurfaceDesc desc; desc.fOrigin = kTopLeft_GrSurfaceOrigin; @@ -182,7 +181,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { sk_sp<GrTextureProxy> proxy4 = proxyProvider->createProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes); sk_sp<GrBuffer> buffer(texelBufferSupport - ? resourceProvider->createBuffer( + ? context->resourceProvider()->createBuffer( 1024, GrBufferType::kTexel_GrBufferType, GrAccessPattern::kStatic_GrAccessPattern, 0) : nullptr); @@ -353,7 +352,6 @@ sk_sp<GrTextureProxy> make_input_texture(GrProxyProvider* proxyProvider, int wid DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - auto resourceProvider = context->contextPriv().resourceProvider(); using FPFactory = GrFragmentProcessorTestFactory; uint32_t seed = 0; @@ -393,7 +391,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor } for (int j = 0; j < timesToInvokeFactory; ++j) { fp = FPFactory::MakeIdx(i, &testData); - if (!fp->instantiate(resourceProvider)) { + if (!fp->instantiate(context->resourceProvider())) { continue; } @@ -492,7 +490,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - auto resourceProvider = context->contextPriv().resourceProvider(); SkRandom random; @@ -525,7 +522,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) { continue; } const char* name = fp->name(); - if (!fp->instantiate(resourceProvider) || !clone->instantiate(resourceProvider)) { + if (!fp->instantiate(context->resourceProvider()) || + !clone->instantiate(context->resourceProvider())) { continue; } REPORTER_ASSERT(reporter, !strcmp(fp->name(), clone->name())); diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp index e84e6e7585..acd17be790 100644 --- a/tests/ProxyRefTest.cpp +++ b/tests/ProxyRefTest.cpp @@ -91,7 +91,7 @@ static sk_sp<GrTextureProxy> make_wrapped(GrProxyProvider* proxyProvider) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider(); - GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider(); + GrResourceProvider* resourceProvider = ctxInfo.grContext()->resourceProvider(); for (auto make : { make_deferred, make_wrapped }) { // A single write diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index 0636ed4ce4..077045f5db 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -107,7 +107,7 @@ static void check_texture(skiatest::Reporter* reporter, DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider(); - GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider(); + GrResourceProvider* resourceProvider = ctxInfo.grContext()->resourceProvider(); const GrCaps& caps = *ctxInfo.grContext()->caps(); int attempt = 0; // useful for debugging @@ -196,7 +196,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider(); - GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider(); + GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider(); const GrCaps& caps = *ctxInfo.grContext()->caps(); static const int kWidthHeight = 100; @@ -227,8 +227,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { backendRT, origin)); check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight, config, SkBudgeted::kNo); - check_rendertarget(reporter, caps, resourceProvider, - sProxy->asRenderTargetProxy(), + check_rendertarget(reporter, caps, provider, sProxy->asRenderTargetProxy(), supportedNumSamples, SkBackingFit::kExact, 0, true); } @@ -244,8 +243,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight, config, budgeted); - check_rendertarget(reporter, caps, resourceProvider, - sProxy->asRenderTargetProxy(), + check_rendertarget(reporter, caps, provider, sProxy->asRenderTargetProxy(), supportedNumSamples, SkBackingFit::kExact, caps.maxWindowRectangles(), true); } else { @@ -261,7 +259,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight, config, budgeted); - check_texture(reporter, resourceProvider, sProxy->asTextureProxy(), + check_texture(reporter, provider, sProxy->asTextureProxy(), SkBackingFit::kExact, true); } } diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp index 55a7766944..6ca4b0cf5c 100644 --- a/tests/ResourceAllocatorTest.cpp +++ b/tests/ResourceAllocatorTest.cpp @@ -101,7 +101,7 @@ static void non_overlap_test(skiatest::Reporter* reporter, GrResourceProvider* r DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorTest, reporter, ctxInfo) { GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider(); - GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider(); + GrResourceProvider* resourceProvider = ctxInfo.grContext()->resourceProvider(); struct TestCase { ProxyParams fP1; diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index dd122a0dea..96cda795df 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -127,15 +127,14 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl return; } - GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider(); + GrResourceProvider* provider = context->resourceProvider(); - sk_sp<GrRenderTarget> smallRT0 = create_RT_with_SB(resourceProvider, 4, 0, SkBudgeted::kYes); + sk_sp<GrRenderTarget> smallRT0 = create_RT_with_SB(provider, 4, 0, SkBudgeted::kYes); REPORTER_ASSERT(reporter, smallRT0); { // Two budgeted RTs with the same desc should share a stencil buffer. - sk_sp<GrRenderTarget> smallRT1 = create_RT_with_SB(resourceProvider, 4, 0, - SkBudgeted::kYes); + sk_sp<GrRenderTarget> smallRT1 = create_RT_with_SB(provider, 4, 0, SkBudgeted::kYes); REPORTER_ASSERT(reporter, smallRT1); REPORTER_ASSERT(reporter, get_SB(smallRT0.get()) == get_SB(smallRT1.get())); @@ -143,7 +142,7 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl { // An unbudgeted RT with the same desc should also share. - sk_sp<GrRenderTarget> smallRT2 = create_RT_with_SB(resourceProvider, 4, 0, SkBudgeted::kNo); + sk_sp<GrRenderTarget> smallRT2 = create_RT_with_SB(provider, 4, 0, SkBudgeted::kNo); REPORTER_ASSERT(reporter, smallRT2); REPORTER_ASSERT(reporter, get_SB(smallRT0.get()) == get_SB(smallRT2.get())); @@ -151,7 +150,7 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl { // An RT with a much larger size should not share. - sk_sp<GrRenderTarget> bigRT = create_RT_with_SB(resourceProvider, 400, 0, SkBudgeted::kNo); + sk_sp<GrRenderTarget> bigRT = create_RT_with_SB(provider, 400, 0, SkBudgeted::kNo); REPORTER_ASSERT(reporter, bigRT); REPORTER_ASSERT(reporter, get_SB(smallRT0.get()) != get_SB(bigRT.get())); @@ -160,8 +159,8 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl int smallSampleCount = context->caps()->getSampleCount(4, kRGBA_8888_GrPixelConfig); if (smallSampleCount > 0) { // An RT with a different sample count should not share. - sk_sp<GrRenderTarget> smallMSAART0 = create_RT_with_SB(resourceProvider, 4, - smallSampleCount, SkBudgeted::kNo); + sk_sp<GrRenderTarget> smallMSAART0 = create_RT_with_SB(provider, 4, smallSampleCount, + SkBudgeted::kNo); #ifdef SK_BUILD_FOR_ANDROID if (!smallMSAART0) { // The nexus player seems to fail to create MSAA textures. @@ -175,8 +174,7 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl { // A second MSAA RT should share with the first MSAA RT. - sk_sp<GrRenderTarget> smallMSAART1 = create_RT_with_SB(resourceProvider, 4, - smallSampleCount, + sk_sp<GrRenderTarget> smallMSAART1 = create_RT_with_SB(provider, 4, smallSampleCount, SkBudgeted::kNo); REPORTER_ASSERT(reporter, smallMSAART1); @@ -187,8 +185,7 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl // samples didn't get rounded up to >= 8 or else they could share.). int bigSampleCount = context->caps()->getSampleCount(8, kRGBA_8888_GrPixelConfig); if (bigSampleCount != smallSampleCount) { - sk_sp<GrRenderTarget> smallMSAART2 = create_RT_with_SB(resourceProvider, 4, - bigSampleCount, + sk_sp<GrRenderTarget> smallMSAART2 = create_RT_with_SB(provider, 4, bigSampleCount, SkBudgeted::kNo); REPORTER_ASSERT(reporter, smallMSAART2); @@ -199,7 +196,6 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); - GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider(); GrGpu* gpu = context->getGpu(); // this test is only valid for GL if (!gpu || !gpu->glContextForTesting()) { @@ -224,10 +220,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI context->resetContext(); - sk_sp<GrTexture> borrowed(resourceProvider->wrapBackendTexture( + sk_sp<GrTexture> borrowed(context->resourceProvider()->wrapBackendTexture( backendTextures[0], kBorrow_GrWrapOwnership)); - sk_sp<GrTexture> adopted(resourceProvider->wrapBackendTexture( + sk_sp<GrTexture> adopted(context->resourceProvider()->wrapBackendTexture( backendTextures[1], kAdopt_GrWrapOwnership)); REPORTER_ASSERT(reporter, borrowed != nullptr && adopted != nullptr); @@ -353,12 +349,12 @@ public: fContext = GrContext::MakeMock(nullptr); SkASSERT(fContext); fContext->setResourceCacheLimits(maxCnt, maxBytes); - GrResourceCache* cache = fContext->contextPriv().getResourceCache(); + GrResourceCache* cache = fContext->getResourceCache(); cache->purgeAllUnlocked(); SkASSERT(0 == cache->getResourceCount() && 0 == cache->getResourceBytes()); } - GrResourceCache* cache() { return fContext->contextPriv().getResourceCache(); } + GrResourceCache* cache() { return fContext->getResourceCache(); } GrContext* context() { return fContext.get(); } @@ -1681,7 +1677,7 @@ static sk_sp<GrTextureProxy> make_mipmap_proxy(GrProxyProvider* proxyProvider, DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GPUMemorySize, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider(); + GrResourceProvider* resourceProvider = context->resourceProvider(); static const int kSize = 64; diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp index 7f0d9973b5..a07b3361ef 100644 --- a/tests/SurfaceTest.cpp +++ b/tests/SurfaceTest.cpp @@ -783,8 +783,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInf } static const uint32_t kOrigColor = 0xFFAABBCC; - auto resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider(); - for (auto& surfaceFunc : {&create_gpu_surface_backend_texture, &create_gpu_surface_backend_texture_as_render_target}) { for (int sampleCnt : {0, 4, 8}) { @@ -800,7 +798,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInf // our surface functions. GrRenderTarget* rt = surface->getCanvas() ->internal_private_accessTopLayerRenderTargetContext()->accessRenderTarget(); - REPORTER_ASSERT(reporter, resourceProvider->attachStencilAttachment(rt)); + REPORTER_ASSERT(reporter, + ctxInfo.grContext()->resourceProvider()->attachStencilAttachment(rt)); gpu->deleteTestingOnlyBackendTexture(&backendTex); } } diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp index 914e83e7df..82a726db99 100644 --- a/tests/TextureProxyTest.cpp +++ b/tests/TextureProxyTest.cpp @@ -78,7 +78,7 @@ static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, GrContext* context, SkBackingFit fit) { - GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider(); + GrResourceProvider* resourceProvider = context->resourceProvider(); static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain(); static int kUniqueKeyData = 0; @@ -110,7 +110,7 @@ static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackingFit fit, sk_sp<GrTexture>* backingSurface) { GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider(); + GrResourceProvider* resourceProvider = context->resourceProvider(); const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags); @@ -132,9 +132,9 @@ static void basic_test(GrContext* context, sk_sp<GrTextureProxy> proxy, bool proxyIsCached) { static int id = 1; - GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider(); + GrResourceProvider* resourceProvider = context->resourceProvider(); GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - GrResourceCache* cache = context->contextPriv().getResourceCache(); + GrResourceCache* cache = context->getResourceCache(); int startCacheCount = cache->getResourceCount(); @@ -212,7 +212,7 @@ static void basic_test(GrContext* context, static void invalidation_test(GrContext* context, skiatest::Reporter* reporter) { GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - GrResourceCache* cache = context->contextPriv().getResourceCache(); + GrResourceCache* cache = context->getResourceCache(); REPORTER_ASSERT(reporter, 0 == cache->getResourceCount()); sk_sp<SkImage> rasterImg; @@ -254,8 +254,8 @@ static void invalidation_test(GrContext* context, skiatest::Reporter* reporter) // Test if invalidating unique ids prior to instantiating operates as expected static void invalidation_and_instantiation_test(GrContext* context, skiatest::Reporter* reporter) { GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider(); - GrResourceCache* cache = context->contextPriv().getResourceCache(); + GrResourceProvider* resourceProvider = context->resourceProvider(); + GrResourceCache* cache = context->getResourceCache(); REPORTER_ASSERT(reporter, 0 == cache->getResourceCount()); static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain(); @@ -294,7 +294,7 @@ static void invalidation_and_instantiation_test(GrContext* context, skiatest::Re DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureProxyTest, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - GrResourceCache* cache = context->contextPriv().getResourceCache(); + GrResourceCache* cache = context->getResourceCache(); REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly()); REPORTER_ASSERT(reporter, 0 == cache->getResourceCount()); diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp index ee1a233d63..b59495f0f5 100755 --- a/tests/TransferPixelsTest.cpp +++ b/tests/TransferPixelsTest.cpp @@ -68,8 +68,6 @@ void basic_transfer_test(skiatest::Reporter* reporter, GrContext* context, GrPix return; } - auto resourceProvider = context->contextPriv().resourceProvider(); - // set up the data const int kTextureWidth = 16; const int kTextureHeight = 16; @@ -84,10 +82,10 @@ void basic_transfer_test(skiatest::Reporter* reporter, GrContext* context, GrPix // create and fill transfer buffer size_t size = rowBytes*kBufferHeight; uint32_t bufferFlags = GrResourceProvider::kNoPendingIO_Flag; - sk_sp<GrBuffer> buffer(resourceProvider->createBuffer(size, - kXferCpuToGpu_GrBufferType, - kDynamic_GrAccessPattern, - bufferFlags)); + sk_sp<GrBuffer> buffer(context->resourceProvider()->createBuffer(size, + kXferCpuToGpu_GrBufferType, + kDynamic_GrAccessPattern, + bufferFlags)); if (!buffer) { return; } @@ -104,7 +102,7 @@ void basic_transfer_test(skiatest::Reporter* reporter, GrContext* context, GrPix desc.fHeight = kTextureHeight; desc.fConfig = config; desc.fSampleCnt = 0; - sk_sp<GrTexture> tex = resourceProvider->createTexture(desc, SkBudgeted::kNo); + sk_sp<GrTexture> tex = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo); ////////////////////////// // transfer full data diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp index a41e8f4071..b3da67bb96 100644 --- a/tests/WritePixelsTest.cpp +++ b/tests/WritePixelsTest.cpp @@ -504,7 +504,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixelsPendingIO, reporter, ctxInfo) { sk_sp<GrTextureProxy> temp = proxyProvider->createProxy(desc, SkBackingFit::kApprox, SkBudgeted::kYes); - temp->instantiate(context->contextPriv().resourceProvider()); + temp->instantiate(context->resourceProvider()); } // Create the surfaces and flush them to ensure there is no lingering pendingIO diff --git a/tools/fiddle/fiddle_main.cpp b/tools/fiddle/fiddle_main.cpp index 4ba84f38ca..b22ec55d03 100644 --- a/tools/fiddle/fiddle_main.cpp +++ b/tools/fiddle/fiddle_main.cpp @@ -124,8 +124,6 @@ static bool setup_backend_objects(GrContext* context, return false; } - auto resourceProvider = context->contextPriv().resourceProvider(); - GrSurfaceDesc backingDesc; backingDesc.fFlags = kNone_GrSurfaceFlags; backingDesc.fOrigin = kTopLeft_GrSurfaceOrigin; @@ -165,9 +163,10 @@ static bool setup_backend_objects(GrContext* context, texels[i].fRowBytes = 0; } - backingTexture = resourceProvider->createTexture(backingDesc, SkBudgeted::kNo, - texels.get(), mipLevelCount, - SkDestinationSurfaceColorMode::kLegacy); + backingTexture = context->resourceProvider()->createTexture( + backingDesc, SkBudgeted::kNo, + texels.get(), mipLevelCount, + SkDestinationSurfaceColorMode::kLegacy); if (!backingTexture) { return false; } @@ -193,7 +192,7 @@ static bool setup_backend_objects(GrContext* context, // We use this fact to initialize it with data but don't allow mipmaps GrMipLevel level0 = { data.get(), backingDesc.fWidth*sizeof(uint32_t) }; - sk_sp<GrTexture> tmp = resourceProvider->createTexture( + sk_sp<GrTexture> tmp = context->resourceProvider()->createTexture( backingDesc, SkBudgeted::kNo, &level0, 1, SkDestinationSurfaceColorMode::kLegacy); @@ -223,7 +222,7 @@ static bool setup_backend_objects(GrContext* context, texels[i].fRowBytes = 0; } - backingTextureRenderTarget = resourceProvider->createTexture( + backingTextureRenderTarget = context->resourceProvider()->createTexture( backingDesc, SkBudgeted::kNo, texels.get(), mipLevelCount, SkDestinationSurfaceColorMode::kLegacy); |