Move resourceProvider accessor to GrContextPriv (take 2)
TBR=bsalomon@google.com
Change-Id: I3fd46ebfad0d04b8a2bfa6190f81308f3a6be620
Reviewed-on: https://skia-review.googlesource.com/95121
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/bench/GrResourceCacheBench.cpp b/bench/GrResourceCacheBench.cpp
index d78af0a..c48aed5 100644
--- a/bench/GrResourceCacheBench.cpp
+++ b/bench/GrResourceCacheBench.cpp
@@ -9,10 +9,11 @@
#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"
@@ -76,7 +77,7 @@
// Set the cache budget to be very large so no purging occurs.
context->setResourceCacheLimits(CACHE_SIZE_COUNT, 1 << 30);
- GrResourceCache* cache = context->getResourceCache();
+ GrResourceCache* cache = context->contextPriv().getResourceCache();
// Make sure the cache is empty.
cache->purgeAllUnlocked();
@@ -122,7 +123,7 @@
// Set the cache budget to be very large so no purging occurs.
fContext->setResourceCacheLimits(CACHE_SIZE_COUNT, 1 << 30);
- GrResourceCache* cache = fContext->getResourceCache();
+ GrResourceCache* cache = fContext->contextPriv().getResourceCache();
// Make sure the cache is empty.
cache->purgeAllUnlocked();
@@ -137,7 +138,7 @@
if (!fContext) {
return;
}
- GrResourceCache* cache = fContext->getResourceCache();
+ GrResourceCache* cache = fContext->contextPriv().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 84c71f8..6b5d750 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -305,9 +305,6 @@
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/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index bdfdbd0..66ba484 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -136,7 +136,7 @@
this->clear();
// We need to get the actual GrTexture so force instantiation of the GrTextureProxy
- texProxy->instantiate(context->resourceProvider());
+ texProxy->instantiate(context->contextPriv().resourceProvider());
GrTexture* texture = texProxy->priv().peekTexture();
SkASSERT(texture);
fOriginalTexture = texture;
@@ -218,8 +218,8 @@
eglDestroyImageKHR(display, image);
return nullptr;
}
- sk_sp<GrTexture> tex = context->resourceProvider()->wrapBackendTexture(backendTex,
- kAdopt_GrWrapOwnership);
+ sk_sp<GrTexture> tex = context->contextPriv().resourceProvider()->wrapBackendTexture(
+ backendTex, kAdopt_GrWrapOwnership);
if (!tex) {
glDeleteTextures(1, &texID);
eglDestroyImageKHR(display, image);
@@ -240,7 +240,7 @@
// makeProxy when it is invoked with a different context.
//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);
+ context->contextPriv().getResourceCache()->insertCrossContextGpuResource(fOriginalTexture);
return GrSurfaceProxy::MakeWrapped(std::move(tex), kTopLeft_GrSurfaceOrigin);
}
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 5dc2396..36dc139 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -43,7 +43,7 @@
// 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->getResourceCache()->insertCrossContextGpuResource(texture.get());
+ context->contextPriv().getResourceCache()->insertCrossContextGpuResource(texture.get());
GrBackendTexture backendTexture = texture->getBackendTexture();
@@ -115,8 +115,8 @@
// 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->resourceProvider()->wrapBackendTexture(fBackendTexture,
- kBorrow_GrWrapOwnership);
+ tex = context->contextPriv().resourceProvider()->wrapBackendTexture(
+ fBackendTexture, kBorrow_GrWrapOwnership);
if (!tex) {
return nullptr;
}
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp
index 13ae404..fc5fb66 100644
--- a/src/gpu/GrBufferAllocPool.cpp
+++ b/src/gpu/GrBufferAllocPool.cpp
@@ -10,6 +10,7 @@
#include "GrBuffer.h"
#include "GrCaps.h"
#include "GrContext.h"
+#include "GrContextPriv.h"
#include "GrGpu.h"
#include "GrResourceProvider.h"
#include "GrTypes.h"
@@ -368,11 +369,11 @@
GrBuffer* GrBufferAllocPool::getBuffer(size_t size) {
- GrResourceProvider* rp = fGpu->getContext()->resourceProvider();
+ auto resourceProvider = fGpu->getContext()->contextPriv().resourceProvider();
// Shouldn't have to use this flag (https://bug.skia.org/4156)
static const uint32_t kFlags = GrResourceProvider::kNoPendingIO_Flag;
- return rp->createBuffer(size, fBufferType, kDynamic_GrAccessPattern, kFlags);
+ return resourceProvider->createBuffer(size, fBufferType, kDynamic_GrAccessPattern, kFlags);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 95d2344..c13cd53 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -484,7 +484,7 @@
ASSERT_OWNED_PROXY_PRIV(dst->asSurfaceProxy());
GR_CREATE_TRACE_MARKER_CONTEXT("GrContextPriv", "writeSurfacePixels", fContext);
- if (!dst->asSurfaceProxy()->instantiate(fContext->resourceProvider())) {
+ if (!dst->asSurfaceProxy()->instantiate(this->resourceProvider())) {
return false;
}
@@ -563,7 +563,7 @@
return false;
}
- if (!tempProxy->instantiate(fContext->resourceProvider())) {
+ if (!tempProxy->instantiate(this->resourceProvider())) {
return false;
}
GrTexture* texture = tempProxy->priv().peekTexture();
@@ -616,7 +616,7 @@
GR_CREATE_TRACE_MARKER_CONTEXT("GrContextPriv", "readSurfacePixels", fContext);
// MDB TODO: delay this instantiation until later in the method
- if (!src->asSurfaceProxy()->instantiate(fContext->resourceProvider())) {
+ if (!src->asSurfaceProxy()->instantiate(this->resourceProvider())) {
return false;
}
@@ -724,7 +724,7 @@
configToRead = tempDrawInfo.fReadConfig;
}
- if (!proxyToRead->instantiate(fContext->resourceProvider())) {
+ if (!proxyToRead->instantiate(this->resourceProvider())) {
return false;
}
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 2da8f34..bbf67a5 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -170,6 +170,11 @@
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 0ba9dec..24e19f5 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -188,7 +188,7 @@
// 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->resourceProvider())) {
+ if (!fProxies[pageIdx]->instantiate(fContext->contextPriv().resourceProvider())) {
return false;
}
@@ -309,7 +309,7 @@
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->resourceProvider())) {
+ if (!fProxies[pageIdx]->instantiate(fContext->contextPriv().resourceProvider())) {
return false;
}
GrTextureProxy* proxy = fProxies[pageIdx].get();
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 7a7e0a3..e60468b 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -168,7 +168,7 @@
bool flushed = false;
{
- GrResourceAllocator alloc(fContext->resourceProvider());
+ GrResourceAllocator alloc(fContext->contextPriv().resourceProvider());
for (int i = 0; i < fOpLists.count(); ++i) {
fOpLists[i]->gatherProxyIntervals(&alloc);
alloc.markEndOfOpList(i);
@@ -194,7 +194,7 @@
// 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->getResourceCache()->notifyFlushOccurred(type);
+ fContext->contextPriv().getResourceCache()->notifyFlushOccurred(type);
}
for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) {
onFlushCBObject->postFlush(fFlushState.nextTokenToFlush(), fFlushingOpListIDs.begin(),
@@ -217,7 +217,7 @@
}
#ifdef SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION
- if (!fOpLists[i]->instantiate(fContext->resourceProvider())) {
+ if (!fOpLists[i]->instantiate(fContext->contextPriv().resourceProvider())) {
SkDebugf("OpList failed to instantiate.\n");
fOpLists[i] = nullptr;
continue;
@@ -228,7 +228,7 @@
// 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->resourceProvider());
+ fOpLists[i]->instantiateDeferredProxies(fContext->contextPriv().resourceProvider());
fOpLists[i]->prepare(flushState);
}
@@ -291,7 +291,7 @@
result = this->flush(proxy, numSemaphores, backendSemaphores);
}
- if (!proxy->instantiate(fContext->resourceProvider())) {
+ if (!proxy->instantiate(fContext->contextPriv().resourceProvider())) {
return result;
}
@@ -340,7 +340,7 @@
fOpLists.back()->makeClosed(*fContext->caps());
}
- sk_sp<GrTextureOpList> opList(new GrTextureOpList(fContext->resourceProvider(),
+ sk_sp<GrTextureOpList> opList(new GrTextureOpList(fContext->contextPriv().resourceProvider(),
textureProxy,
fContext->getAuditTrail()));
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index cbb28c4..0162b4b 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -65,7 +65,7 @@
GrCoverageCountingPathRenderer* getCoverageCountingPathRenderer();
void flushIfNecessary() {
- if (fContext->getResourceCache()->requestsFlush()) {
+ if (fContext->contextPriv().getResourceCache()->requestsFlush()) {
this->internalFlush(nullptr, GrResourceCache::kCacheRequested, 0, nullptr);
}
}
@@ -92,7 +92,7 @@
, fAtlasTextContext(nullptr)
, fPathRendererChain(nullptr)
, fSoftwarePathRenderer(nullptr)
- , fFlushState(context->getGpu(), context->resourceProvider())
+ , fFlushState(context->getGpu(), context->contextPriv().resourceProvider())
, fFlushing(false) {}
void abandon();
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 3a09551..93f719a 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -13,6 +13,7 @@
#include "GrBuffer.h"
#include "GrCaps.h"
#include "GrContext.h"
+#include "GrContextPriv.h"
#include "GrGpuResourcePriv.h"
#include "GrMesh.h"
#include "GrPathRendering.h"
@@ -483,15 +484,17 @@
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 = fContext->resourceProvider()->wrapBackendSemaphore(
+ semaphore = resourceProvider->wrapBackendSemaphore(
backendSemaphores[i], GrResourceProvider::SemaphoreWrapType::kWillSignal,
kBorrow_GrWrapOwnership);
} else {
- semaphore = fContext->resourceProvider()->makeSemaphore(false);
+ semaphore = resourceProvider->makeSemaphore(false);
}
this->insertSemaphore(semaphore, false);
diff --git a/src/gpu/GrGpuCommandBuffer.cpp b/src/gpu/GrGpuCommandBuffer.cpp
index 1dc16c1..096c3c4 100644
--- a/src/gpu/GrGpuCommandBuffer.cpp
+++ b/src/gpu/GrGpuCommandBuffer.cpp
@@ -46,8 +46,9 @@
SkASSERT(primProc.hasInstanceAttribs() == meshes[i].isInstanced());
}
#endif
+ auto resourceProvider = this->gpu()->getContext()->contextPriv().resourceProvider();
- if (pipeline.isBad() || !primProc.instantiate(this->gpu()->getContext()->resourceProvider())) {
+ if (pipeline.isBad() || !primProc.instantiate(resourceProvider)) {
return false;
}
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index df8e72c..3d3c88b 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -7,6 +7,7 @@
#include "GrGpuResource.h"
#include "GrContext.h"
+#include "GrContextPriv.h"
#include "GrResourceCache.h"
#include "GrGpu.h"
#include "GrGpuResourcePriv.h"
@@ -15,8 +16,8 @@
static inline GrResourceCache* get_resource_cache(GrGpu* gpu) {
SkASSERT(gpu);
SkASSERT(gpu->getContext());
- SkASSERT(gpu->getContext()->getResourceCache());
- return gpu->getContext()->getResourceCache();
+ SkASSERT(gpu->getContext()->contextPriv().getResourceCache());
+ return gpu->getContext()->contextPriv().getResourceCache();
}
GrGpuResource::GrGpuResource(GrGpu* gpu)
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index 7fcd30f..8de827c 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -19,10 +19,12 @@
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);
@@ -42,8 +44,7 @@
// 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(
- fDrawingMgr->getContext()->resourceProvider())) {
+ if (!renderTargetContext->asSurfaceProxy()->instantiate(resourceProvider)) {
return nullptr;
}
@@ -67,11 +68,12 @@
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(
- fDrawingMgr->getContext()->resourceProvider())) {
+ if (!renderTargetContext->asSurfaceProxy()->instantiate(resourceProvider)) {
return nullptr;
}
@@ -82,18 +84,20 @@
sk_sp<GrBuffer> GrOnFlushResourceProvider::makeBuffer(GrBufferType intendedType, size_t size,
const void* data) {
- GrResourceProvider* rp = fDrawingMgr->getContext()->resourceProvider();
- return sk_sp<GrBuffer>(rp->createBuffer(size, intendedType, kDynamic_GrAccessPattern,
- GrResourceProvider::kNoPendingIO_Flag,
- data));
+ auto resourceProvider = fDrawingMgr->getContext()->contextPriv().resourceProvider();
+ return sk_sp<GrBuffer>(resourceProvider->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) {
- GrResourceProvider* rp = fDrawingMgr->getContext()->resourceProvider();
- sk_sp<const GrBuffer> buffer = rp->findOrMakeStaticBuffer(intendedType, size, data, key);
+ auto resourceProvider = fDrawingMgr->getContext()->contextPriv().resourceProvider();
+ sk_sp<const GrBuffer> buffer = resourceProvider->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 393823c..1e1d87a 100644
--- a/src/gpu/GrPathRendererChain.cpp
+++ b/src/gpu/GrPathRendererChain.cpp
@@ -34,7 +34,7 @@
}
if (options.fGpuPathRenderers & GpuPathRenderers::kStencilAndCover) {
sk_sp<GrPathRenderer> pr(
- GrStencilAndCoverPathRenderer::Create(context->resourceProvider(), caps));
+ GrStencilAndCoverPathRenderer::Create(context->contextPriv().resourceProvider(), caps));
if (pr) {
fChain.push_back(std::move(pr));
}
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 96cbca4..2b02b8d 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -18,7 +18,7 @@
#if GR_TEST_UTILS
GrResourceProvider* GrProcessorTestData::resourceProvider() {
- return fContext->resourceProvider();
+ return fContext->contextPriv().resourceProvider();
}
GrProxyProvider* GrProcessorTestData::proxyProvider() {
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 19540eb..42a4fdd 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1425,9 +1425,11 @@
return false;
}
+ auto resourceProvider = fContext->contextPriv().resourceProvider();
+
SkTArray<sk_sp<GrSemaphore>> semaphores(numSemaphores);
for (int i = 0; i < numSemaphores; ++i) {
- sk_sp<GrSemaphore> sema = fContext->resourceProvider()->wrapBackendSemaphore(
+ sk_sp<GrSemaphore> sema = 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 2ae52b9..47cd922 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -11,6 +11,7 @@
#include "../private/GrRenderTargetProxy.h"
#include "GrColor.h"
#include "GrContext.h"
+#include "GrContextPriv.h"
#include "GrPaint.h"
#include "GrSurfaceContext.h"
#include "GrTypesPriv.h"
@@ -349,7 +350,7 @@
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->resourceProvider())) {
+ if (!fRenderTargetProxy->instantiate(fContext->contextPriv().resourceProvider())) {
return nullptr;
}
return fRenderTargetProxy->priv().peekRenderTarget();
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 09ce760..0f62bc6 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -26,7 +26,7 @@
GrRenderTargetOpList::GrRenderTargetOpList(GrRenderTargetProxy* proxy, GrGpu* gpu,
GrAuditTrail* auditTrail)
- : INHERITED(gpu->getContext()->resourceProvider(), proxy, auditTrail)
+ : INHERITED(gpu->getContext()->contextPriv().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 0e6eee4..f906773 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -9,6 +9,7 @@
#include "GrAutoLocaleSetter.h"
#include "GrContext.h"
+#include "GrContextPriv.h"
#include "GrCoordTransform.h"
#include "GrGLProgramBuilder.h"
#include "GrProgramDesc.h"
@@ -32,7 +33,11 @@
const GrPrimitiveProcessor& primProc,
GrProgramDesc* desc,
GrGLGpu* gpu) {
- SkASSERT(!pipeline.isBad() && primProc.instantiate(gpu->getContext()->resourceProvider()));
+#ifdef SK_DEBUG
+ GrResourceProvider* resourceProvider = gpu->getContext()->contextPriv().resourceProvider();
+
+ SkASSERT(!pipeline.isBad() && primProc.instantiate(resourceProvider));
+#endif
ATRACE_ANDROID_FRAMEWORK("Shader Compile");
GrAutoLocaleSetter als("C");
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index 86e5732..b2dfa6c 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -560,7 +560,7 @@
SkASSERT(fInstanceData);
if (fInstanceData->count()) {
- sk_sp<GrPathRange> glyphs(this->createGlyphs(ctx->resourceProvider()));
+ sk_sp<GrPathRange> glyphs(this->createGlyphs(ctx->contextPriv().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 1dbc490..10e757e 100644
--- a/src/gpu/vk/GrVkPipelineState.cpp
+++ b/src/gpu/vk/GrVkPipelineState.cpp
@@ -8,6 +8,7 @@
#include "GrVkPipelineState.h"
#include "GrContext.h"
+#include "GrContextPriv.h"
#include "GrPipeline.h"
#include "GrTexturePriv.h"
#include "GrVkBufferView.h"
@@ -263,10 +264,12 @@
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(gpu->getContext()->resourceProvider()));
+ SkAssertResult(dstTextureSampler.instantiate(resourceProvider));
textureBindings.push_back(&dstTextureSampler);
}
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 20e8349..d08f0a4 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -156,7 +156,7 @@
GrSurfaceOrigin* origin) const {
SkASSERT(fProxy);
- if (!fProxy->instantiate(fContext->resourceProvider())) {
+ if (!fProxy->instantiate(fContext->contextPriv().resourceProvider())) {
return 0;
}
@@ -180,7 +180,7 @@
return nullptr;
}
- if (!proxy->instantiate(fContext->resourceProvider())) {
+ if (!proxy->instantiate(fContext->contextPriv().resourceProvider())) {
return nullptr;
}
@@ -284,7 +284,9 @@
return nullptr;
}
- sk_sp<GrTexture> tex = ctx->resourceProvider()->wrapBackendTexture(backendTex, ownership);
+ GrResourceProvider* resourceProvider = ctx->contextPriv().resourceProvider();
+
+ sk_sp<GrTexture> tex = resourceProvider->wrapBackendTexture(backendTex, ownership);
if (!tex) {
return nullptr;
}
@@ -585,7 +587,7 @@
return codecImage;
}
- if (!proxy->instantiate(context->resourceProvider())) {
+ if (!proxy->instantiate(context->contextPriv().resourceProvider())) {
return codecImage;
}
sk_sp<GrTexture> texture = sk_ref_sp(proxy->priv().peekTexture());
diff --git a/tests/BlendTest.cpp b/tests/BlendTest.cpp
index bf985aa..b17b9f1 100644
--- a/tests/BlendTest.cpp
+++ b/tests/BlendTest.cpp
@@ -95,7 +95,9 @@
backingDesc.fConfig = config;
backingDesc.fSampleCnt = sampleCnt;
- *backingSurface = context->resourceProvider()->createTexture(backingDesc, SkBudgeted::kNo);
+ auto resourceProvider = context->contextPriv().resourceProvider();
+
+ *backingSurface = resourceProvider->createTexture(backingDesc, SkBudgeted::kNo);
if (!(*backingSurface)) {
return nullptr;
}
diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp
index fe24bc1..c078422 100644
--- a/tests/ClipStackTest.cpp
+++ b/tests/ClipStackTest.cpp
@@ -1486,7 +1486,7 @@
path.setFillType(SkPath::kEvenOdd_FillType);
static const char* kTag = GrClipStackClip::kMaskTestTag;
- GrResourceCache* cache = context->getResourceCache();
+ GrResourceCache* cache = context->contextPriv().getResourceCache();
static constexpr int kN = 5;
@@ -1496,7 +1496,7 @@
stack.save();
stack.clipPath(path, m, SkClipOp::kIntersect, true);
sk_sp<GrTextureProxy> mask = GrClipStackClip(&stack).testingOnly_createClipMask(context);
- mask->instantiate(context->resourceProvider());
+ mask->instantiate(context->contextPriv().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 0ff0d2c..04bcca7 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -211,6 +211,8 @@
return;
}
+ auto resourceProvider = context->contextPriv().resourceProvider();
+
for (auto willUseMips : {false, true}) {
for (auto isWrapped : {false, true}) {
GrMipMapped mipMapped = willUseMips ? GrMipMapped::kYes : GrMipMapped::kNo;
@@ -240,7 +242,7 @@
GrTextureProxy* texProxy = device->accessRenderTargetContext()->asTextureProxy();
REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped());
- texProxy->instantiate(context->resourceProvider());
+ texProxy->instantiate(resourceProvider);
GrTexture* texture = texProxy->priv().peekTexture();
REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped());
@@ -252,7 +254,7 @@
texProxy = as_IB(image)->peekProxy();
REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped());
- texProxy->instantiate(context->resourceProvider());
+ texProxy->instantiate(resourceProvider);
texture = texProxy->priv().peekTexture();
REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped());
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index f65744a..cd1ce1e 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -146,7 +146,7 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo) {
GrContext* const context = ctxInfo.grContext();
- GrResourceProvider* rp = context->resourceProvider();
+ GrResourceProvider* rp = context->contextPriv().resourceProvider();
sk_sp<GrRenderTargetContext> rtc(
context->makeDeferredRenderTargetContext(SkBackingFit::kExact, kScreenSize, kScreenSize,
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 582510c..eab9301 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -24,6 +24,8 @@
// 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;
@@ -31,7 +33,7 @@
desc.fHeight = 256;
desc.fConfig = kRGBA_8888_GrPixelConfig;
desc.fSampleCnt = 0;
- sk_sp<GrSurface> texRT1 = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
+ sk_sp<GrSurface> texRT1 = resourceProvider->createTexture(desc, SkBudgeted::kNo);
REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asRenderTarget());
REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asTexture());
@@ -44,7 +46,7 @@
desc.fFlags = kNone_GrSurfaceFlags;
desc.fOrigin = kTopLeft_GrSurfaceOrigin;
- sk_sp<GrTexture> tex1 = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
+ sk_sp<GrTexture> tex1 = 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());
@@ -52,8 +54,8 @@
GrBackendTexture backendTex = context->getGpu()->createTestingOnlyBackendTexture(
nullptr, 256, 256, kRGBA_8888_GrPixelConfig, false, GrMipMapped::kNo);
- sk_sp<GrSurface> texRT2 = context->resourceProvider()->wrapRenderableBackendTexture(
- backendTex, 0, kBorrow_GrWrapOwnership);
+ sk_sp<GrSurface> texRT2 = resourceProvider->wrapRenderableBackendTexture(
+ backendTex, 0, kBorrow_GrWrapOwnership);
REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asRenderTarget());
REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asTexture());
@@ -72,7 +74,7 @@
DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- GrResourceProvider* resourceProvider = context->resourceProvider();
+ GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider();
const GrCaps* caps = context->caps();
GrPixelConfig configs[] = {
diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp
index c330808..3105e9b 100644
--- a/tests/ImageFilterCacheTest.cpp
+++ b/tests/ImageFilterCacheTest.cpp
@@ -209,7 +209,7 @@
return;
}
- if (!srcProxy->instantiate(context->resourceProvider())) {
+ if (!srcProxy->instantiate(context->contextPriv().resourceProvider())) {
return;
}
GrTexture* tex = srcProxy->priv().peekTexture();
diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp
index 2968c76..0bbb071 100644
--- a/tests/IntTextureTest.cpp
+++ b/tests/IntTextureTest.cpp
@@ -41,6 +41,8 @@
}
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);
@@ -278,8 +280,7 @@
// No rendering to integer textures.
GrSurfaceDesc intRTDesc = desc;
intRTDesc.fFlags = kRenderTarget_GrSurfaceFlag;
- sk_sp<GrTexture> temp(context->resourceProvider()->createTexture(intRTDesc,
- SkBudgeted::kYes));
+ sk_sp<GrTexture> temp(resourceProvider->createTexture(intRTDesc, SkBudgeted::kYes));
REPORTER_ASSERT(reporter, !temp);
}
}
diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp
index a3e272c..cc64582 100644
--- a/tests/PathRendererCacheTests.cpp
+++ b/tests/PathRendererCacheTests.cpp
@@ -77,7 +77,7 @@
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->getResourceCache();
+ GrResourceCache* cache = ctx->contextPriv().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 e675335..26f10a3 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -158,6 +158,7 @@
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;
@@ -181,7 +182,7 @@
sk_sp<GrTextureProxy> proxy4 =
proxyProvider->createProxy(desc, SkBackingFit::kExact, SkBudgeted::kYes);
sk_sp<GrBuffer> buffer(texelBufferSupport
- ? context->resourceProvider()->createBuffer(
+ ? resourceProvider->createBuffer(
1024, GrBufferType::kTexel_GrBufferType,
GrAccessPattern::kStatic_GrAccessPattern, 0)
: nullptr);
@@ -352,6 +353,7 @@
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;
@@ -391,7 +393,7 @@
}
for (int j = 0; j < timesToInvokeFactory; ++j) {
fp = FPFactory::MakeIdx(i, &testData);
- if (!fp->instantiate(context->resourceProvider())) {
+ if (!fp->instantiate(resourceProvider)) {
continue;
}
@@ -490,6 +492,7 @@
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;
@@ -522,8 +525,7 @@
continue;
}
const char* name = fp->name();
- if (!fp->instantiate(context->resourceProvider()) ||
- !clone->instantiate(context->resourceProvider())) {
+ if (!fp->instantiate(resourceProvider) || !clone->instantiate(resourceProvider)) {
continue;
}
REPORTER_ASSERT(reporter, !strcmp(fp->name(), clone->name()));
diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp
index acd17be..e84e6e7 100644
--- a/tests/ProxyRefTest.cpp
+++ b/tests/ProxyRefTest.cpp
@@ -91,7 +91,7 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) {
GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
- GrResourceProvider* resourceProvider = ctxInfo.grContext()->resourceProvider();
+ GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
for (auto make : { make_deferred, make_wrapped }) {
// A single write
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index 077045f..0636ed4 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -107,7 +107,7 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
- GrResourceProvider* resourceProvider = ctxInfo.grContext()->resourceProvider();
+ GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
const GrCaps& caps = *ctxInfo.grContext()->caps();
int attempt = 0; // useful for debugging
@@ -196,7 +196,7 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
- GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider();
+ GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
const GrCaps& caps = *ctxInfo.grContext()->caps();
static const int kWidthHeight = 100;
@@ -227,7 +227,8 @@
backendRT, origin));
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight, config, SkBudgeted::kNo);
- check_rendertarget(reporter, caps, provider, sProxy->asRenderTargetProxy(),
+ check_rendertarget(reporter, caps, resourceProvider,
+ sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact, 0, true);
}
@@ -243,7 +244,8 @@
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight, config, budgeted);
- check_rendertarget(reporter, caps, provider, sProxy->asRenderTargetProxy(),
+ check_rendertarget(reporter, caps, resourceProvider,
+ sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
caps.maxWindowRectangles(), true);
} else {
@@ -259,7 +261,7 @@
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight, config, budgeted);
- check_texture(reporter, provider, sProxy->asTextureProxy(),
+ check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
SkBackingFit::kExact, true);
}
}
diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp
index 6ca4b0c..55a7766 100644
--- a/tests/ResourceAllocatorTest.cpp
+++ b/tests/ResourceAllocatorTest.cpp
@@ -101,7 +101,7 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorTest, reporter, ctxInfo) {
GrProxyProvider* proxyProvider = ctxInfo.grContext()->contextPriv().proxyProvider();
- GrResourceProvider* resourceProvider = ctxInfo.grContext()->resourceProvider();
+ GrResourceProvider* resourceProvider = ctxInfo.grContext()->contextPriv().resourceProvider();
struct TestCase {
ProxyParams fP1;
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 96cda79..dd122a0 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -127,14 +127,15 @@
return;
}
- GrResourceProvider* provider = context->resourceProvider();
+ GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider();
- sk_sp<GrRenderTarget> smallRT0 = create_RT_with_SB(provider, 4, 0, SkBudgeted::kYes);
+ sk_sp<GrRenderTarget> smallRT0 = create_RT_with_SB(resourceProvider, 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(provider, 4, 0, SkBudgeted::kYes);
+ sk_sp<GrRenderTarget> smallRT1 = create_RT_with_SB(resourceProvider, 4, 0,
+ SkBudgeted::kYes);
REPORTER_ASSERT(reporter, smallRT1);
REPORTER_ASSERT(reporter, get_SB(smallRT0.get()) == get_SB(smallRT1.get()));
@@ -142,7 +143,7 @@
{
// An unbudgeted RT with the same desc should also share.
- sk_sp<GrRenderTarget> smallRT2 = create_RT_with_SB(provider, 4, 0, SkBudgeted::kNo);
+ sk_sp<GrRenderTarget> smallRT2 = create_RT_with_SB(resourceProvider, 4, 0, SkBudgeted::kNo);
REPORTER_ASSERT(reporter, smallRT2);
REPORTER_ASSERT(reporter, get_SB(smallRT0.get()) == get_SB(smallRT2.get()));
@@ -150,7 +151,7 @@
{
// An RT with a much larger size should not share.
- sk_sp<GrRenderTarget> bigRT = create_RT_with_SB(provider, 400, 0, SkBudgeted::kNo);
+ sk_sp<GrRenderTarget> bigRT = create_RT_with_SB(resourceProvider, 400, 0, SkBudgeted::kNo);
REPORTER_ASSERT(reporter, bigRT);
REPORTER_ASSERT(reporter, get_SB(smallRT0.get()) != get_SB(bigRT.get()));
@@ -159,8 +160,8 @@
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(provider, 4, smallSampleCount,
- SkBudgeted::kNo);
+ sk_sp<GrRenderTarget> smallMSAART0 = create_RT_with_SB(resourceProvider, 4,
+ smallSampleCount, SkBudgeted::kNo);
#ifdef SK_BUILD_FOR_ANDROID
if (!smallMSAART0) {
// The nexus player seems to fail to create MSAA textures.
@@ -174,7 +175,8 @@
{
// A second MSAA RT should share with the first MSAA RT.
- sk_sp<GrRenderTarget> smallMSAART1 = create_RT_with_SB(provider, 4, smallSampleCount,
+ sk_sp<GrRenderTarget> smallMSAART1 = create_RT_with_SB(resourceProvider, 4,
+ smallSampleCount,
SkBudgeted::kNo);
REPORTER_ASSERT(reporter, smallMSAART1);
@@ -185,7 +187,8 @@
// 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(provider, 4, bigSampleCount,
+ sk_sp<GrRenderTarget> smallMSAART2 = create_RT_with_SB(resourceProvider, 4,
+ bigSampleCount,
SkBudgeted::kNo);
REPORTER_ASSERT(reporter, smallMSAART2);
@@ -196,6 +199,7 @@
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()) {
@@ -220,10 +224,10 @@
context->resetContext();
- sk_sp<GrTexture> borrowed(context->resourceProvider()->wrapBackendTexture(
+ sk_sp<GrTexture> borrowed(resourceProvider->wrapBackendTexture(
backendTextures[0], kBorrow_GrWrapOwnership));
- sk_sp<GrTexture> adopted(context->resourceProvider()->wrapBackendTexture(
+ sk_sp<GrTexture> adopted(resourceProvider->wrapBackendTexture(
backendTextures[1], kAdopt_GrWrapOwnership));
REPORTER_ASSERT(reporter, borrowed != nullptr && adopted != nullptr);
@@ -349,12 +353,12 @@
fContext = GrContext::MakeMock(nullptr);
SkASSERT(fContext);
fContext->setResourceCacheLimits(maxCnt, maxBytes);
- GrResourceCache* cache = fContext->getResourceCache();
+ GrResourceCache* cache = fContext->contextPriv().getResourceCache();
cache->purgeAllUnlocked();
SkASSERT(0 == cache->getResourceCount() && 0 == cache->getResourceBytes());
}
- GrResourceCache* cache() { return fContext->getResourceCache(); }
+ GrResourceCache* cache() { return fContext->contextPriv().getResourceCache(); }
GrContext* context() { return fContext.get(); }
@@ -1677,7 +1681,7 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GPUMemorySize, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- GrResourceProvider* resourceProvider = context->resourceProvider();
+ GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider();
static const int kSize = 64;
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index a07b336..7f0d997 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -783,6 +783,8 @@
}
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}) {
@@ -798,8 +800,7 @@
// our surface functions.
GrRenderTarget* rt = surface->getCanvas()
->internal_private_accessTopLayerRenderTargetContext()->accessRenderTarget();
- REPORTER_ASSERT(reporter,
- ctxInfo.grContext()->resourceProvider()->attachStencilAttachment(rt));
+ REPORTER_ASSERT(reporter, resourceProvider->attachStencilAttachment(rt));
gpu->deleteTestingOnlyBackendTexture(&backendTex);
}
}
diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp
index 82a726d..914e83e 100644
--- a/tests/TextureProxyTest.cpp
+++ b/tests/TextureProxyTest.cpp
@@ -78,7 +78,7 @@
static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter,
GrContext* context, SkBackingFit fit) {
- GrResourceProvider* resourceProvider = context->resourceProvider();
+ GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider();
static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
static int kUniqueKeyData = 0;
@@ -110,7 +110,7 @@
static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackingFit fit,
sk_sp<GrTexture>* backingSurface) {
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- GrResourceProvider* resourceProvider = context->resourceProvider();
+ GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider();
const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags);
@@ -132,9 +132,9 @@
sk_sp<GrTextureProxy> proxy, bool proxyIsCached) {
static int id = 1;
- GrResourceProvider* resourceProvider = context->resourceProvider();
+ GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider();
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- GrResourceCache* cache = context->getResourceCache();
+ GrResourceCache* cache = context->contextPriv().getResourceCache();
int startCacheCount = cache->getResourceCount();
@@ -212,7 +212,7 @@
static void invalidation_test(GrContext* context, skiatest::Reporter* reporter) {
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- GrResourceCache* cache = context->getResourceCache();
+ GrResourceCache* cache = context->contextPriv().getResourceCache();
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
sk_sp<SkImage> rasterImg;
@@ -254,8 +254,8 @@
// 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->resourceProvider();
- GrResourceCache* cache = context->getResourceCache();
+ GrResourceProvider* resourceProvider = context->contextPriv().resourceProvider();
+ GrResourceCache* cache = context->contextPriv().getResourceCache();
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
static GrUniqueKey::Domain d = GrUniqueKey::GenerateDomain();
@@ -294,7 +294,7 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TextureProxyTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- GrResourceCache* cache = context->getResourceCache();
+ GrResourceCache* cache = context->contextPriv().getResourceCache();
REPORTER_ASSERT(reporter, !proxyProvider->numUniqueKeyProxies_TestOnly());
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp
index b59495f..ee1a233 100755
--- a/tests/TransferPixelsTest.cpp
+++ b/tests/TransferPixelsTest.cpp
@@ -68,6 +68,8 @@
return;
}
+ auto resourceProvider = context->contextPriv().resourceProvider();
+
// set up the data
const int kTextureWidth = 16;
const int kTextureHeight = 16;
@@ -82,10 +84,10 @@
// create and fill transfer buffer
size_t size = rowBytes*kBufferHeight;
uint32_t bufferFlags = GrResourceProvider::kNoPendingIO_Flag;
- sk_sp<GrBuffer> buffer(context->resourceProvider()->createBuffer(size,
- kXferCpuToGpu_GrBufferType,
- kDynamic_GrAccessPattern,
- bufferFlags));
+ sk_sp<GrBuffer> buffer(resourceProvider->createBuffer(size,
+ kXferCpuToGpu_GrBufferType,
+ kDynamic_GrAccessPattern,
+ bufferFlags));
if (!buffer) {
return;
}
@@ -102,7 +104,7 @@
desc.fHeight = kTextureHeight;
desc.fConfig = config;
desc.fSampleCnt = 0;
- sk_sp<GrTexture> tex = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
+ sk_sp<GrTexture> tex = resourceProvider->createTexture(desc, SkBudgeted::kNo);
//////////////////////////
// transfer full data
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index b3da67b..a41e8f4 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -504,7 +504,7 @@
sk_sp<GrTextureProxy> temp = proxyProvider->createProxy(desc, SkBackingFit::kApprox,
SkBudgeted::kYes);
- temp->instantiate(context->resourceProvider());
+ temp->instantiate(context->contextPriv().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 b22ec55..4ba84f3 100644
--- a/tools/fiddle/fiddle_main.cpp
+++ b/tools/fiddle/fiddle_main.cpp
@@ -124,6 +124,8 @@
return false;
}
+ auto resourceProvider = context->contextPriv().resourceProvider();
+
GrSurfaceDesc backingDesc;
backingDesc.fFlags = kNone_GrSurfaceFlags;
backingDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
@@ -163,10 +165,9 @@
texels[i].fRowBytes = 0;
}
- backingTexture = context->resourceProvider()->createTexture(
- backingDesc, SkBudgeted::kNo,
- texels.get(), mipLevelCount,
- SkDestinationSurfaceColorMode::kLegacy);
+ backingTexture = resourceProvider->createTexture(backingDesc, SkBudgeted::kNo,
+ texels.get(), mipLevelCount,
+ SkDestinationSurfaceColorMode::kLegacy);
if (!backingTexture) {
return false;
}
@@ -192,7 +193,7 @@
// 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 = context->resourceProvider()->createTexture(
+ sk_sp<GrTexture> tmp = resourceProvider->createTexture(
backingDesc, SkBudgeted::kNo,
&level0, 1,
SkDestinationSurfaceColorMode::kLegacy);
@@ -222,7 +223,7 @@
texels[i].fRowBytes = 0;
}
- backingTextureRenderTarget = context->resourceProvider()->createTexture(
+ backingTextureRenderTarget = resourceProvider->createTexture(
backingDesc, SkBudgeted::kNo,
texels.get(), mipLevelCount,
SkDestinationSurfaceColorMode::kLegacy);