diff options
author | Chris Dalton <csmartdalton@google.com> | 2018-09-27 09:28:03 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-09-27 23:40:23 +0000 |
commit | d004e0b55c4a1e375af39c09d0f96628252b797d (patch) | |
tree | 429e220d92eba76661e434781812d7fc671573b8 | |
parent | b726c89ff8a84c1da1784c0c8172e9f59ddf757a (diff) | |
download | skqp-d004e0b55c4a1e375af39c09d0f96628252b797d.tar.gz |
Cleanup resource flags
Converts GrResourceProvider::Flags and GrResourceCache::ScratchFlags
to "enum class" and fixes a case where we were accidentally using the
wrong type of flag. Makes sure to allocate GrSWMaskHelper proxies with
kNoPendingIO.
Bug: skia:8351
Change-Id: Ibcaa26314a53d0cb31ae22915ab94ab0fc07e76d
Reviewed-on: https://skia-review.googlesource.com/157280
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
-rw-r--r-- | gm/clockwise.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleCCPRGeometry.cpp | 8 | ||||
-rw-r--r-- | src/gpu/GrBufferAllocPool.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrOnFlushResourceProvider.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrProxyProvider.cpp | 32 | ||||
-rw-r--r-- | src/gpu/GrProxyProvider.h | 25 | ||||
-rw-r--r-- | src/gpu/GrResourceCache.cpp | 6 | ||||
-rw-r--r-- | src/gpu/GrResourceCache.h | 14 | ||||
-rw-r--r-- | src/gpu/GrResourceProvider.cpp | 51 | ||||
-rw-r--r-- | src/gpu/GrResourceProvider.h | 50 | ||||
-rw-r--r-- | src/gpu/GrSWMaskHelper.cpp | 14 | ||||
-rw-r--r-- | src/gpu/GrSurfaceProxy.cpp | 6 | ||||
-rw-r--r-- | src/gpu/ops/GrDrawVerticesOp.cpp | 4 | ||||
-rw-r--r-- | src/gpu/ops/GrTessellatingPathRenderer.cpp | 2 | ||||
-rw-r--r-- | tests/GrMeshTest.cpp | 4 | ||||
-rw-r--r-- | tests/GrPipelineDynamicStateTest.cpp | 4 | ||||
-rw-r--r-- | tests/GrSurfaceTest.cpp | 2 | ||||
-rw-r--r-- | tests/OnFlushCallbackTest.cpp | 2 | ||||
-rw-r--r-- | tests/ProxyConversionTest.cpp | 6 | ||||
-rw-r--r-- | tests/ProxyRefTest.cpp | 4 | ||||
-rw-r--r-- | tests/ProxyTest.cpp | 6 | ||||
-rw-r--r-- | tests/ResourceCacheTest.cpp | 24 | ||||
-rw-r--r-- | tests/TextureProxyTest.cpp | 4 | ||||
-rw-r--r-- | tests/TransferPixelsTest.cpp | 2 | ||||
-rw-r--r-- | tools/gpu/GrTest.cpp | 18 |
25 files changed, 157 insertions, 137 deletions
diff --git a/gm/clockwise.cpp b/gm/clockwise.cpp index 4f47b860dd..58283a9655 100644 --- a/gm/clockwise.cpp +++ b/gm/clockwise.cpp @@ -119,7 +119,7 @@ private: }; sk_sp<GrBuffer> vertexBuffer(flushState->resourceProvider()->createBuffer( sizeof(vertices), kVertex_GrBufferType, kStatic_GrAccessPattern, - GrResourceProvider::kNone_Flag, vertices)); + GrResourceProvider::Flags::kNone, vertices)); if (!vertexBuffer) { return; } diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp index 4193a0c022..1d9bc2bfcf 100644 --- a/samplecode/SampleCCPRGeometry.cpp +++ b/samplecode/SampleCCPRGeometry.cpp @@ -341,8 +341,8 @@ void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state) { sk_sp<GrBuffer> instBuff(rp->createBuffer( fView->fQuadPointInstances.count() * sizeof(QuadPointInstance), kVertex_GrBufferType, kDynamic_GrAccessPattern, - GrResourceProvider::kNoPendingIO_Flag | - GrResourceProvider::kRequireGpuMemory_Flag, + GrResourceProvider::Flags::kNoPendingIO | + GrResourceProvider::Flags::kRequireGpuMemory, fView->fQuadPointInstances.begin())); if (!fView->fQuadPointInstances.empty() && instBuff) { proc.appendMesh(instBuff.get(), fView->fQuadPointInstances.count(), 0, &mesh); @@ -351,8 +351,8 @@ void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state) { sk_sp<GrBuffer> instBuff(rp->createBuffer( fView->fTriPointInstances.count() * sizeof(TriPointInstance), kVertex_GrBufferType, kDynamic_GrAccessPattern, - GrResourceProvider::kNoPendingIO_Flag | - GrResourceProvider::kRequireGpuMemory_Flag, fView->fTriPointInstances.begin())); + GrResourceProvider::Flags::kNoPendingIO | + GrResourceProvider::Flags::kRequireGpuMemory, fView->fTriPointInstances.begin())); if (!fView->fTriPointInstances.empty() && instBuff) { proc.appendMesh(instBuff.get(), fView->fTriPointInstances.count(), 0, &mesh); } diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp index c47881c6c5..1f16c69052 100644 --- a/src/gpu/GrBufferAllocPool.cpp +++ b/src/gpu/GrBufferAllocPool.cpp @@ -373,7 +373,7 @@ GrBuffer* GrBufferAllocPool::getBuffer(size_t size) { 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; + static const auto kFlags = GrResourceProvider::Flags::kNoPendingIO; return resourceProvider->createBuffer(size, fBufferType, kDynamic_GrAccessPattern, kFlags); } diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp index 26b59f93b9..d63c5ac0d5 100644 --- a/src/gpu/GrOnFlushResourceProvider.cpp +++ b/src/gpu/GrOnFlushResourceProvider.cpp @@ -115,7 +115,7 @@ sk_sp<GrBuffer> GrOnFlushResourceProvider::makeBuffer(GrBufferType intendedType, auto resourceProvider = fDrawingMgr->getContext()->contextPriv().resourceProvider(); return sk_sp<GrBuffer>(resourceProvider->createBuffer(size, intendedType, kDynamic_GrAccessPattern, - GrResourceProvider::kNoPendingIO_Flag, + GrResourceProvider::Flags::kNoPendingIO, data)); } diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp index 9f9de9652d..c1f8fad9e8 100644 --- a/src/gpu/GrProxyProvider.cpp +++ b/src/gpu/GrProxyProvider.cpp @@ -174,30 +174,12 @@ sk_sp<GrTextureProxy> GrProxyProvider::findOrCreateProxyByUniqueKey(const GrUniq return result; } -sk_sp<GrTextureProxy> GrProxyProvider::createInstantiatedProxy(const GrSurfaceDesc& desc, - GrSurfaceOrigin origin, - SkBackingFit fit, - SkBudgeted budgeted, - GrSurfaceDescFlags descFlags) { - sk_sp<GrTexture> tex; - - if (SkBackingFit::kApprox == fit) { - tex = fResourceProvider->createApproxTexture(desc, descFlags); - } else { - tex = fResourceProvider->createTexture(desc, budgeted, descFlags); - } - if (!tex) { - return nullptr; - } - - return this->createWrapped(std::move(tex), origin); -} - sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(sk_sp<SkImage> srcImage, GrSurfaceDescFlags descFlags, int sampleCnt, SkBudgeted budgeted, - SkBackingFit fit) { + SkBackingFit fit, + GrInternalSurfaceFlags surfaceFlags) { ASSERT_SINGLE_OWNER SkASSERT(srcImage); @@ -230,7 +212,6 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(sk_sp<SkImage> srcImag } } - GrInternalSurfaceFlags surfaceFlags = GrInternalSurfaceFlags::kNone; if (SkToBool(descFlags & kRenderTarget_GrSurfaceFlag)) { if (fCaps->usesMixedSamples() && sampleCnt > 1) { surfaceFlags |= GrInternalSurfaceFlags::kMixedSampled; @@ -248,7 +229,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(sk_sp<SkImage> srcImag desc.fConfig = config; sk_sp<GrTextureProxy> proxy = this->createLazyProxy( - [desc, budgeted, srcImage, fit](GrResourceProvider* resourceProvider) { + [desc, budgeted, srcImage, fit, surfaceFlags](GrResourceProvider* resourceProvider) { if (!resourceProvider) { // Nothing to clean up here. Once the proxy (and thus lambda) is deleted the ref // on srcImage will be released. @@ -258,7 +239,12 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(sk_sp<SkImage> srcImag SkAssertResult(srcImage->peekPixels(&pixMap)); GrMipLevel mipLevel = { pixMap.addr(), pixMap.rowBytes() }; - return resourceProvider->createTexture(desc, budgeted, fit, mipLevel); + auto resourceProviderFlags = GrResourceProvider::Flags::kNone; + if (surfaceFlags & GrInternalSurfaceFlags::kNoPendingIO) { + resourceProviderFlags |= GrResourceProvider::Flags::kNoPendingIO; + } + return resourceProvider->createTexture(desc, budgeted, fit, mipLevel, + resourceProviderFlags); }, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, GrTextureType::k2D, surfaceFlags, fit, budgeted); diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h index df6903b735..26dc6e9682 100644 --- a/src/gpu/GrProxyProvider.h +++ b/src/gpu/GrProxyProvider.h @@ -61,25 +61,13 @@ public: sk_sp<GrTextureProxy> findOrCreateProxyByUniqueKey(const GrUniqueKey&, GrSurfaceOrigin); /* - * Create a texture proxy that is backed by an instantiated GrSurface. This is almost entirely - * used by Skia's testing code. - * DDL TODO: remove the remaining Skia-internal use of this method and make it truly - * testing-only. - */ - sk_sp<GrTextureProxy> createInstantiatedProxy(const GrSurfaceDesc&, GrSurfaceOrigin, - SkBackingFit, SkBudgeted, - GrSurfaceDescFlags = kNone_GrSurfaceFlags); - - /* * Create an un-mipmapped texture proxy with data. The SkImage must be a raster backend image. * Since the SkImage is ref counted, we simply take a ref on it to keep the data alive until we * actually upload the data to the gpu. */ - sk_sp<GrTextureProxy> createTextureProxy(sk_sp<SkImage> srcImage, - GrSurfaceDescFlags descFlags, - int sampleCnt, - SkBudgeted budgeted, - SkBackingFit fit); + sk_sp<GrTextureProxy> createTextureProxy( + sk_sp<SkImage> srcImage, GrSurfaceDescFlags, int sampleCnt, SkBudgeted, SkBackingFit, + GrInternalSurfaceFlags = GrInternalSurfaceFlags::kNone); /* * Create a mipmapped texture proxy without any data. @@ -244,8 +232,15 @@ public: */ bool recordingDDL() const { return !SkToBool(fResourceProvider); } + /* + * Create a texture proxy that is backed by an instantiated GrSurface. + */ + sk_sp<GrTextureProxy> testingOnly_createInstantiatedProxy(const GrSurfaceDesc&, GrSurfaceOrigin, + SkBackingFit, SkBudgeted); + private: friend class GrAHardwareBufferImageGenerator; // for createWrapped + friend class GrResourceProvider; // for createWrapped sk_sp<GrTextureProxy> createWrapped(sk_sp<GrTexture> tex, GrSurfaceOrigin origin); diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp index e6f59949b0..26ec881140 100644 --- a/src/gpu/GrResourceCache.cpp +++ b/src/gpu/GrResourceCache.cpp @@ -256,17 +256,17 @@ private: GrGpuResource* GrResourceCache::findAndRefScratchResource(const GrScratchKey& scratchKey, size_t resourceSize, - uint32_t flags) { + ScratchFlags flags) { SkASSERT(scratchKey.isValid()); GrGpuResource* resource; - if (flags & (kPreferNoPendingIO_ScratchFlag | kRequireNoPendingIO_ScratchFlag)) { + if (flags & (ScratchFlags::kPreferNoPendingIO | ScratchFlags::kRequireNoPendingIO)) { resource = fScratchMap.find(scratchKey, AvailableForScratchUse(true)); if (resource) { this->refAndMakeResourceMRU(resource); this->validate(); return resource; - } else if (flags & kRequireNoPendingIO_ScratchFlag) { + } else if (flags & ScratchFlags::kRequireNoPendingIO) { return nullptr; } // We would prefer to consume more available VRAM rather than flushing diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h index 3cc6665590..1d3598e90b 100644 --- a/src/gpu/GrResourceCache.h +++ b/src/gpu/GrResourceCache.h @@ -119,19 +119,19 @@ public: */ void releaseAll(); - enum { + enum class ScratchFlags { + kNone = 0, /** Preferentially returns scratch resources with no pending IO. */ - kPreferNoPendingIO_ScratchFlag = 0x1, + kPreferNoPendingIO = 0x1, /** Will not return any resources that match but have pending IO. */ - kRequireNoPendingIO_ScratchFlag = 0x2, + kRequireNoPendingIO = 0x2, }; /** * Find a resource that matches a scratch key. */ - GrGpuResource* findAndRefScratchResource(const GrScratchKey& scratchKey, - size_t resourceSize, - uint32_t flags); + GrGpuResource* findAndRefScratchResource(const GrScratchKey& scratchKey, size_t resourceSize, + ScratchFlags); #ifdef SK_DEBUG // This is not particularly fast and only used for validation, so debug only. @@ -360,6 +360,8 @@ private: bool fPreferVRAMUseOverFlushes; }; +GR_MAKE_BITFIELD_CLASS_OPS(GrResourceCache::ScratchFlags); + class GrResourceCache::ResourceAccess { private: ResourceAccess(GrResourceCache* cache) : fCache(cache) { } diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp index 12bc5ab1f4..593910131c 100644 --- a/src/gpu/GrResourceProvider.cpp +++ b/src/gpu/GrResourceProvider.cpp @@ -80,7 +80,7 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, Sk } sk_sp<GrTexture> GrResourceProvider::getExactScratch(const GrSurfaceDesc& desc, - SkBudgeted budgeted, uint32_t flags) { + SkBudgeted budgeted, Flags flags) { sk_sp<GrTexture> tex(this->refScratchTexture(desc, flags)); if (tex && SkBudgeted::kNo == budgeted) { tex->resourcePriv().makeUnbudgeted(); @@ -92,7 +92,8 @@ sk_sp<GrTexture> GrResourceProvider::getExactScratch(const GrSurfaceDesc& desc, sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, SkBackingFit fit, - const GrMipLevel& mipLevel) { + const GrMipLevel& mipLevel, + Flags flags) { ASSERT_SINGLE_OWNER if (this->isAbandoned()) { @@ -112,10 +113,15 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkColorType colorType; if (GrPixelConfigToColorType(desc.fConfig, &colorType)) { - // DDL TODO: remove this use of createInstantiatedProxy and convert it to a testing-only - // method. - sk_sp<GrTextureProxy> proxy = proxyProvider->createInstantiatedProxy( - desc, kTopLeft_GrSurfaceOrigin, fit, budgeted); + sk_sp<GrTexture> tex = (SkBackingFit::kApprox == fit) + ? this->createApproxTexture(desc, flags) + : this->createTexture(desc, budgeted, flags); + if (!tex) { + return nullptr; + } + + sk_sp<GrTextureProxy> proxy = proxyProvider->createWrapped(std::move(tex), + kTopLeft_GrSurfaceOrigin); if (!proxy) { return nullptr; } @@ -134,7 +140,7 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, } sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, - uint32_t flags) { + Flags flags) { ASSERT_SINGLE_OWNER if (this->isAbandoned()) { return nullptr; @@ -153,9 +159,9 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, Sk } sk_sp<GrTexture> GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc, - uint32_t flags) { + Flags flags) { ASSERT_SINGLE_OWNER - SkASSERT(0 == flags || kNoPendingIO_Flag == flags); + SkASSERT(Flags::kNone == flags || Flags::kNoPendingIO == flags); if (this->isAbandoned()) { return nullptr; @@ -186,8 +192,7 @@ sk_sp<GrTexture> GrResourceProvider::createApproxTexture(const GrSurfaceDesc& de return fGpu->createTexture(*copyDesc, SkBudgeted::kYes); } -sk_sp<GrTexture> GrResourceProvider::refScratchTexture(const GrSurfaceDesc& desc, - uint32_t flags) { +sk_sp<GrTexture> GrResourceProvider::refScratchTexture(const GrSurfaceDesc& desc, Flags flags) { ASSERT_SINGLE_OWNER SkASSERT(!this->isAbandoned()); SkASSERT(fCaps->validateSurfaceDesc(desc, GrMipMapped::kNo)); @@ -199,13 +204,13 @@ sk_sp<GrTexture> GrResourceProvider::refScratchTexture(const GrSurfaceDesc& desc GrScratchKey key; GrTexturePriv::ComputeScratchKey(desc, &key); - uint32_t scratchFlags = 0; - if (kNoPendingIO_Flag & flags) { - scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; + auto scratchFlags = GrResourceCache::ScratchFlags::kNone; + if (Flags::kNoPendingIO & flags) { + scratchFlags |= GrResourceCache::ScratchFlags::kRequireNoPendingIO; } else if (!(desc.fFlags & kRenderTarget_GrSurfaceFlag)) { // If it is not a render target then it will most likely be populated by // writePixels() which will trigger a flush if the texture has pending IO. - scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; + scratchFlags |= GrResourceCache::ScratchFlags::kPreferNoPendingIO; } GrGpuResource* resource = fCache->findAndRefScratchResource(key, GrSurface::WorstCaseSize(desc), @@ -267,7 +272,7 @@ sk_sp<const GrBuffer> GrResourceProvider::findOrMakeStaticBuffer(GrBufferType in if (auto buffer = this->findByUniqueKey<GrBuffer>(key)) { return std::move(buffer); } - if (auto buffer = this->createBuffer(size, intendedType, kStatic_GrAccessPattern, 0, + if (auto buffer = this->createBuffer(size, intendedType, kStatic_GrAccessPattern, Flags::kNone, data)) { // We shouldn't bin and/or cachestatic buffers. SkASSERT(buffer->sizeInBytes() == size); @@ -288,7 +293,7 @@ sk_sp<const GrBuffer> GrResourceProvider::createPatternedIndexBuffer(const uint1 // This is typically used in GrMeshDrawOps, so we assume kNoPendingIO. sk_sp<GrBuffer> buffer(this->createBuffer(bufferSize, kIndex_GrBufferType, - kStatic_GrAccessPattern, kNoPendingIO_Flag)); + kStatic_GrAccessPattern, Flags::kNoPendingIO)); if (!buffer) { return nullptr; } @@ -336,7 +341,7 @@ sk_sp<GrPath> GrResourceProvider::createPath(const SkPath& path, const GrStyle& } GrBuffer* GrResourceProvider::createBuffer(size_t size, GrBufferType intendedType, - GrAccessPattern accessPattern, uint32_t flags, + GrAccessPattern accessPattern, Flags flags, const void* data) { if (this->isAbandoned()) { return nullptr; @@ -344,7 +349,7 @@ GrBuffer* GrResourceProvider::createBuffer(size_t size, GrBufferType intendedTyp if (kDynamic_GrAccessPattern != accessPattern) { return this->gpu()->createBuffer(size, intendedType, accessPattern, data); } - if (!(flags & kRequireGpuMemory_Flag) && + if (!(flags & Flags::kRequireGpuMemory) && this->gpu()->caps()->preferClientSideDynamicBuffers() && GrBufferTypeIsVertexOrIndex(intendedType) && kDynamic_GrAccessPattern == accessPattern) { @@ -357,11 +362,11 @@ GrBuffer* GrResourceProvider::createBuffer(size_t size, GrBufferType intendedTyp GrScratchKey key; GrBuffer::ComputeScratchKeyForDynamicVBO(allocSize, intendedType, &key); - uint32_t scratchFlags = 0; - if (flags & kNoPendingIO_Flag) { - scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag; + auto scratchFlags = GrResourceCache::ScratchFlags::kNone; + if (flags & Flags::kNoPendingIO) { + scratchFlags = GrResourceCache::ScratchFlags::kRequireNoPendingIO; } else { - scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag; + scratchFlags = GrResourceCache::ScratchFlags::kPreferNoPendingIO; } GrBuffer* buffer = static_cast<GrBuffer*>( this->cache()->findAndRefScratchResource(key, allocSize, scratchFlags)); diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h index d1c6aa38fe..491d67d1cf 100644 --- a/src/gpu/GrResourceProvider.h +++ b/src/gpu/GrResourceProvider.h @@ -39,6 +39,24 @@ class SkTypeface; */ class GrResourceProvider { public: + /** These flags govern which scratch resources we are allowed to return */ + enum class Flags { + kNone = 0x0, + + /** If the caller intends to do direct reads/writes to/from the CPU then this flag must be + * set when accessing resources during a GrOpList flush. This includes the execution of + * GrOp objects. The reason is that these memory operations are done immediately and + * will occur out of order WRT the operations being flushed. + * Make this automatic: https://bug.skia.org/4156 + */ + kNoPendingIO = 0x1, + + /** Normally the caps may indicate a preference for client-side buffers. Set this flag when + * creating a buffer to guarantee it resides in GPU memory. + */ + kRequireGpuMemory = 0x2, + }; + GrResourceProvider(GrGpu*, GrResourceCache*, GrSingleOwner*, GrContextOptions::Enable explicitlyAllocateGPUResources); @@ -61,18 +79,18 @@ public: * then result will be a render target. Format and sample count will always match the request. * The contents of the texture are undefined. */ - sk_sp<GrTexture> createApproxTexture(const GrSurfaceDesc&, uint32_t flags); + sk_sp<GrTexture> createApproxTexture(const GrSurfaceDesc&, Flags); /** Create an exact fit texture with no initial data to upload. */ - sk_sp<GrTexture> createTexture(const GrSurfaceDesc&, SkBudgeted, uint32_t flags = 0); + sk_sp<GrTexture> createTexture(const GrSurfaceDesc&, SkBudgeted, Flags = Flags::kNone); sk_sp<GrTexture> createTexture(const GrSurfaceDesc&, SkBudgeted, const GrMipLevel texels[], int mipLevelCount); // Create a potentially loose fit texture with the provided data sk_sp<GrTexture> createTexture(const GrSurfaceDesc&, SkBudgeted, SkBackingFit, - const GrMipLevel&); + const GrMipLevel&, Flags); /////////////////////////////////////////////////////////////////////////// // Wrapped Backend Surfaces @@ -169,24 +187,6 @@ public: */ sk_sp<GrPath> createPath(const SkPath&, const GrStyle&); - /** These flags govern which scratch resources we are allowed to return */ - enum Flags { - kNone_Flag = 0x0, - - /** If the caller intends to do direct reads/writes to/from the CPU then this flag must be - * set when accessing resources during a GrOpList flush. This includes the execution of - * GrOp objects. The reason is that these memory operations are done immediately and - * will occur out of order WRT the operations being flushed. - * Make this automatic: https://bug.skia.org/4156 - */ - kNoPendingIO_Flag = 0x1, - - /** Normally the caps may indicate a preference for client-side buffers. Set this flag when - * creating a buffer to guarantee it resides in GPU memory. - */ - kRequireGpuMemory_Flag = 0x2, - }; - /** * Returns a buffer. * @@ -198,7 +198,7 @@ public: * * @return the buffer if successful, otherwise nullptr. */ - GrBuffer* createBuffer(size_t size, GrBufferType intendedType, GrAccessPattern, uint32_t flags, + GrBuffer* createBuffer(size_t size, GrBufferType intendedType, GrAccessPattern, Flags, const void* data = nullptr); @@ -258,13 +258,13 @@ private: // Attempts to find a resource in the cache that exactly matches the GrSurfaceDesc. Failing that // it returns null. If non-null, the resulting texture is always budgeted. - sk_sp<GrTexture> refScratchTexture(const GrSurfaceDesc&, uint32_t scratchTextureFlags); + sk_sp<GrTexture> refScratchTexture(const GrSurfaceDesc&, Flags); /* * Try to find an existing scratch texture that exactly matches 'desc'. If successful * update the budgeting accordingly. */ - sk_sp<GrTexture> getExactScratch(const GrSurfaceDesc&, SkBudgeted, uint32_t flags); + sk_sp<GrTexture> getExactScratch(const GrSurfaceDesc&, SkBudgeted, Flags); GrResourceCache* cache() { return fCache; } const GrResourceCache* cache() const { return fCache; } @@ -298,4 +298,6 @@ private: SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) }; +GR_MAKE_BITFIELD_CLASS_OPS(GrResourceProvider::Flags); + #endif diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index 0fbf9dcfe4..852a04099e 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -106,7 +106,15 @@ sk_sp<GrTextureProxy> GrSWMaskHelper::toTextureProxy(GrContext* context, SkBacki return nullptr; } - return context->contextPriv().proxyProvider()->createTextureProxy(std::move(img), - kNone_GrSurfaceFlags, 1, - SkBudgeted::kYes, fit); + // TODO: http://skbug.com/8422: Although this fixes http://skbug.com/8351, it seems like these + // should just participate in the normal allocation process and not need the pending IO flag. + auto surfaceFlags = GrInternalSurfaceFlags::kNone; + if (!context->contextPriv().resourceProvider()) { + // In DDL mode, this texture proxy will be instantiated at flush time, therfore it cannot + // have pending IO. + surfaceFlags |= GrInternalSurfaceFlags::kNoPendingIO; + } + + return context->contextPriv().proxyProvider()->createTextureProxy( + std::move(img), kNone_GrSurfaceFlags, 1, SkBudgeted::kYes, fit, surfaceFlags); } diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index f14a436aba..d46480a1d5 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -131,12 +131,12 @@ sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl(GrResourceProvider* resourceP desc.fConfig = fConfig; desc.fSampleCnt = sampleCnt; - GrResourceProvider::Flags resourceProviderFlags = GrResourceProvider::kNone_Flag; - if (fSurfaceFlags & GrInternalSurfaceFlags::kNoPendingIO || + GrResourceProvider::Flags resourceProviderFlags = GrResourceProvider::Flags::kNone; + if ((fSurfaceFlags & GrInternalSurfaceFlags::kNoPendingIO) || resourceProvider->explicitlyAllocateGPUResources()) { // The explicit resource allocator requires that any resources it pulls out of the // cache have no pending IO. - resourceProviderFlags = GrResourceProvider::kNoPendingIO_Flag; + resourceProviderFlags = GrResourceProvider::Flags::kNoPendingIO; } sk_sp<GrSurface> surface; diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp index 04b537f82b..b4aa61906a 100644 --- a/src/gpu/ops/GrDrawVerticesOp.cpp +++ b/src/gpu/ops/GrDrawVerticesOp.cpp @@ -312,7 +312,7 @@ void GrDrawVerticesOp::drawNonVolatile(Target* target) { vertexBuffer.reset(rp->createBuffer(fVertexCount * vertexStride, kVertex_GrBufferType, kStatic_GrAccessPattern, - 0)); + GrResourceProvider::Flags::kNone)); void* verts = vertexBuffer ? vertexBuffer->map() : nullptr; if (!verts) { SkDebugf("Could not allocate vertices\n"); @@ -325,7 +325,7 @@ void GrDrawVerticesOp::drawNonVolatile(Target* target) { indexBuffer.reset(rp->createBuffer(fIndexCount * sizeof(uint16_t), kIndex_GrBufferType, kStatic_GrAccessPattern, - 0)); + GrResourceProvider::Flags::kNone)); indices = indexBuffer ? static_cast<uint16_t*>(indexBuffer->map()) : nullptr; if (!indices) { SkDebugf("Could not allocate indices\n"); diff --git a/src/gpu/ops/GrTessellatingPathRenderer.cpp b/src/gpu/ops/GrTessellatingPathRenderer.cpp index f7228683ef..75620d3d6a 100644 --- a/src/gpu/ops/GrTessellatingPathRenderer.cpp +++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp @@ -78,7 +78,7 @@ public: void* lock(int vertexCount) override { size_t size = vertexCount * stride(); fVertexBuffer.reset(fResourceProvider->createBuffer( - size, kVertex_GrBufferType, kStatic_GrAccessPattern, 0)); + size, kVertex_GrBufferType, kStatic_GrAccessPattern, GrResourceProvider::Flags::kNone)); if (!fVertexBuffer.get()) { return nullptr; } diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp index 3997dc4b5f..762430ffab 100644 --- a/tests/GrMeshTest.cpp +++ b/tests/GrMeshTest.cpp @@ -378,8 +378,8 @@ sk_sp<const GrBuffer> DrawMeshHelper::makeVertexBuffer(const T* data, int count) return sk_sp<const GrBuffer>( fState->resourceProvider()->createBuffer( count * sizeof(T), kVertex_GrBufferType, kDynamic_GrAccessPattern, - GrResourceProvider::kNoPendingIO_Flag | - GrResourceProvider::kRequireGpuMemory_Flag, data)); + GrResourceProvider::Flags::kNoPendingIO | + GrResourceProvider::Flags::kRequireGpuMemory, data)); } sk_sp<const GrBuffer> DrawMeshHelper::getIndexBuffer() { diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp index 81bd8824d4..3840dc6724 100644 --- a/tests/GrPipelineDynamicStateTest.cpp +++ b/tests/GrPipelineDynamicStateTest.cpp @@ -196,8 +196,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo sk_sp<const GrBuffer> vbuff(rp->createBuffer(sizeof(vdata), kVertex_GrBufferType, kDynamic_GrAccessPattern, - GrResourceProvider::kNoPendingIO_Flag | - GrResourceProvider::kRequireGpuMemory_Flag, + GrResourceProvider::Flags::kNoPendingIO | + GrResourceProvider::Flags::kRequireGpuMemory, vdata)); if (!vbuff) { ERRORF(reporter, "vbuff is null."); diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index f7961875db..bdec795a43 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -165,7 +165,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(InitialTextureClear, reporter, context_info) // Try directly creating the texture. // Do this twice in an attempt to hit the cache on the second time through. for (int i = 0; i < 2; ++i) { - sk_sp<GrTextureProxy> proxy = proxyProvider->createInstantiatedProxy( + auto proxy = proxyProvider->testingOnly_createInstantiatedProxy( desc, origin, fit, SkBudgeted::kYes); if (!proxy) { continue; diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp index 9eb2dcab58..c96f197098 100644 --- a/tests/OnFlushCallbackTest.cpp +++ b/tests/OnFlushCallbackTest.cpp @@ -313,7 +313,7 @@ public: desc.fConfig = kRGBA_8888_GrPixelConfig; return resourceProvider->createTexture(desc, SkBudgeted::kYes, - GrResourceProvider::kNoPendingIO_Flag); + GrResourceProvider::Flags::kNoPendingIO); }, GrProxyProvider::Renderable::kYes, kBottomLeft_GrSurfaceOrigin, diff --git a/tests/ProxyConversionTest.cpp b/tests/ProxyConversionTest.cpp index def9a7084f..e316da7a20 100644 --- a/tests/ProxyConversionTest.cpp +++ b/tests/ProxyConversionTest.cpp @@ -45,13 +45,15 @@ static sk_sp<GrSurfaceProxy> make_offscreen_rt(GrProxyProvider* provider, GrSurfaceOrigin origin) { SkASSERT(kRenderTarget_GrSurfaceFlag == desc.fFlags); - return provider->createInstantiatedProxy(desc, origin, SkBackingFit::kExact, SkBudgeted::kYes); + return provider->testingOnly_createInstantiatedProxy(desc, origin, SkBackingFit::kExact, + SkBudgeted::kYes); } static sk_sp<GrSurfaceProxy> make_texture(GrProxyProvider* provider, const GrSurfaceDesc& desc, GrSurfaceOrigin origin) { - return provider->createInstantiatedProxy(desc, origin, SkBackingFit::kExact, SkBudgeted::kYes); + return provider->testingOnly_createInstantiatedProxy(desc, origin, SkBackingFit::kExact, + SkBudgeted::kYes); } // Test converting between RenderTargetProxies and TextureProxies for preinstantiated Proxies diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp index 914bf283e4..288085f998 100644 --- a/tests/ProxyRefTest.cpp +++ b/tests/ProxyRefTest.cpp @@ -79,8 +79,8 @@ static sk_sp<GrTextureProxy> make_wrapped(GrProxyProvider* proxyProvider) { desc.fHeight = kWidthHeight; desc.fConfig = kRGBA_8888_GrPixelConfig; - return proxyProvider->createInstantiatedProxy(desc, kBottomLeft_GrSurfaceOrigin, - SkBackingFit::kExact, SkBudgeted::kNo); + return proxyProvider->testingOnly_createInstantiatedProxy( + desc, kBottomLeft_GrSurfaceOrigin, SkBackingFit::kExact, SkBudgeted::kNo); } DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp index 694adf4efc..5e050a371c 100644 --- a/tests/ProxyTest.cpp +++ b/tests/ProxyTest.cpp @@ -127,7 +127,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { { sk_sp<GrTexture> tex; if (SkBackingFit::kApprox == fit) { - tex = resourceProvider->createApproxTexture(desc, 0); + tex = resourceProvider->createApproxTexture( + desc, GrResourceProvider::Flags::kNone); } else { tex = resourceProvider->createTexture(desc, budgeted); } @@ -160,7 +161,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) { { sk_sp<GrTexture> tex; if (SkBackingFit::kApprox == fit) { - tex = resourceProvider->createApproxTexture(desc, 0); + tex = resourceProvider->createApproxTexture( + desc, GrResourceProvider::Flags::kNone); } else { tex = resourceProvider->createTexture(desc, budgeted); } diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp index 3dcf194d4a..fa09db31d4 100644 --- a/tests/ResourceCacheTest.cpp +++ b/tests/ResourceCacheTest.cpp @@ -671,7 +671,7 @@ void test_unbudgeted_to_scratch(skiatest::Reporter* reporter); REPORTER_ASSERT(reporter, resource->resourcePriv().getScratchKey() == key); REPORTER_ASSERT(reporter, !resource->cacheAccess().isScratch()); REPORTER_ASSERT(reporter, SkBudgeted::kNo == resource->resourcePriv().isBudgeted()); - REPORTER_ASSERT(reporter, nullptr == cache->findAndRefScratchResource(key, TestResource::kDefaultSize, 0)); + REPORTER_ASSERT(reporter, nullptr == cache->findAndRefScratchResource(key, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone)); REPORTER_ASSERT(reporter, 1 == cache->getResourceCount()); REPORTER_ASSERT(reporter, size == cache->getResourceBytes()); REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount()); @@ -685,7 +685,7 @@ void test_unbudgeted_to_scratch(skiatest::Reporter* reporter); REPORTER_ASSERT(reporter, 1 == cache->getBudgetedResourceCount()); REPORTER_ASSERT(reporter, size == cache->getBudgetedResourceBytes()); REPORTER_ASSERT(reporter, size == cache->getPurgeableBytes()); - resource = static_cast<TestResource*>(cache->findAndRefScratchResource(key, TestResource::kDefaultSize, 0)); + resource = static_cast<TestResource*>(cache->findAndRefScratchResource(key, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone)); REPORTER_ASSERT(reporter, resource); REPORTER_ASSERT(reporter, resource->resourcePriv().getScratchKey() == key); REPORTER_ASSERT(reporter, resource->cacheAccess().isScratch()); @@ -734,7 +734,7 @@ static void test_duplicate_scratch_key(skiatest::Reporter* reporter) { GrScratchKey scratchKey1; TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey1); // Check for negative case consistency. (leaks upon test failure.) - REPORTER_ASSERT(reporter, nullptr == cache->findAndRefScratchResource(scratchKey1, TestResource::kDefaultSize, 0)); + REPORTER_ASSERT(reporter, nullptr == cache->findAndRefScratchResource(scratchKey1, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone)); GrScratchKey scratchKey; TestResource::ComputeScratchKey(TestResource::kB_SimulatedProperty, &scratchKey); @@ -782,7 +782,7 @@ static void test_remove_scratch_key(skiatest::Reporter* reporter) { // Ensure that scratch key lookup is correct for negative case. TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey); // (following leaks upon test failure). - REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0) == nullptr); + REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone) == nullptr); // Scratch resources are registered with GrResourceCache just by existing. There are 2. TestResource::ComputeScratchKey(TestResource::kB_SimulatedProperty, &scratchKey); @@ -792,7 +792,7 @@ static void test_remove_scratch_key(skiatest::Reporter* reporter) { // Find the first resource and remove its scratch key GrGpuResource* find; - find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0); + find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone); find->resourcePriv().removeScratchKey(); // It's still alive, but not cached by scratch key anymore REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive()); @@ -806,7 +806,7 @@ static void test_remove_scratch_key(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, 1 == cache->getResourceCount()); // Repeat for the second resource. - find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0); + find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone); find->resourcePriv().removeScratchKey(); REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive()); SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache->countScratchEntriesForKey(scratchKey));) @@ -863,20 +863,20 @@ static void test_scratch_key_consistency(skiatest::Reporter* reporter) { // Ensure that scratch key lookup is correct for negative case. TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey); // (following leaks upon test failure). - REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0) == nullptr); + REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone) == nullptr); // Find the first resource with a scratch key and a copy of a scratch key. TestResource::ComputeScratchKey(TestResource::kB_SimulatedProperty, &scratchKey); - GrGpuResource* find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0); + GrGpuResource* find = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone); REPORTER_ASSERT(reporter, find != nullptr); find->unref(); scratchKey2 = scratchKey; - find = cache->findAndRefScratchResource(scratchKey2, TestResource::kDefaultSize, 0); + find = cache->findAndRefScratchResource(scratchKey2, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone); REPORTER_ASSERT(reporter, find != nullptr); REPORTER_ASSERT(reporter, find == a || find == b); - GrGpuResource* find2 = cache->findAndRefScratchResource(scratchKey2, TestResource::kDefaultSize, 0); + GrGpuResource* find2 = cache->findAndRefScratchResource(scratchKey2, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone); REPORTER_ASSERT(reporter, find2 != nullptr); REPORTER_ASSERT(reporter, find2 == a || find2 == b); REPORTER_ASSERT(reporter, find2 != find); @@ -1032,13 +1032,13 @@ static void test_purge_invalidated(skiatest::Reporter* reporter) { // Make sure we actually get to c via it's scratch key, before we say goodbye. GrScratchKey scratchKey; TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey); - GrGpuResource* scratch = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0); + GrGpuResource* scratch = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone); REPORTER_ASSERT(reporter, scratch == c); SkSafeUnref(scratch); // Get rid of c. cache->purgeAllUnlocked(); - scratch = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, 0); + scratch = cache->findAndRefScratchResource(scratchKey, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone); REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive()); REPORTER_ASSERT(reporter, 0 == cache->getResourceCount()); REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes()); diff --git a/tests/TextureProxyTest.cpp b/tests/TextureProxyTest.cpp index 32b1c86965..334863118d 100644 --- a/tests/TextureProxyTest.cpp +++ b/tests/TextureProxyTest.cpp @@ -64,7 +64,7 @@ static sk_sp<GrTextureProxy> wrapped(skiatest::Reporter* reporter, GrProxyProvider* proxyProvider, SkBackingFit fit) { const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags); - sk_sp<GrTextureProxy> proxy = proxyProvider->createInstantiatedProxy( + sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy( desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes); // Only budgeted & wrapped external proxies get to carry uniqueKeys REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid()); @@ -85,7 +85,7 @@ static sk_sp<GrTextureProxy> wrapped_with_key(skiatest::Reporter* reporter, const GrSurfaceDesc desc = make_desc(kNone_GrSurfaceFlags); // Only budgeted & wrapped external proxies get to carry uniqueKeys - sk_sp<GrTextureProxy> proxy = proxyProvider->createInstantiatedProxy( + sk_sp<GrTextureProxy> proxy = proxyProvider->testingOnly_createInstantiatedProxy( desc, kBottomLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes); SkAssertResult(proxyProvider->assignUniqueKeyToProxy(key, proxy.get())); REPORTER_ASSERT(reporter, proxy->getUniqueKey().isValid()); diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp index 677420da3b..537b5fe3fa 100644 --- a/tests/TransferPixelsTest.cpp +++ b/tests/TransferPixelsTest.cpp @@ -78,7 +78,7 @@ void basic_transfer_test(skiatest::Reporter* reporter, GrContext* context, GrCol // create and fill transfer buffer size_t size = rowBytes*kBufferHeight; - uint32_t bufferFlags = GrResourceProvider::kNoPendingIO_Flag; + auto bufferFlags = GrResourceProvider::Flags::kNoPendingIO; sk_sp<GrBuffer> buffer(resourceProvider->createBuffer(size, kXferCpuToGpu_GrBufferType, kDynamic_GrAccessPattern, diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp index 4afb07a760..c0ca8ff39a 100644 --- a/tools/gpu/GrTest.cpp +++ b/tools/gpu/GrTest.cpp @@ -203,6 +203,24 @@ int GrResourceCache::countUniqueKeysWithTag(const char* tag) const { /////////////////////////////////////////////////////////////////////////////// +sk_sp<GrTextureProxy> GrProxyProvider::testingOnly_createInstantiatedProxy( + const GrSurfaceDesc& desc, GrSurfaceOrigin origin, SkBackingFit fit, SkBudgeted budgeted) { + sk_sp<GrTexture> tex; + + if (SkBackingFit::kApprox == fit) { + tex = fResourceProvider->createApproxTexture(desc, GrResourceProvider::Flags::kNone); + } else { + tex = fResourceProvider->createTexture(desc, budgeted, GrResourceProvider::Flags::kNone); + } + if (!tex) { + return nullptr; + } + + return this->createWrapped(std::move(tex), origin); +} + +/////////////////////////////////////////////////////////////////////////////// + #define ASSERT_SINGLE_OWNER \ SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fRenderTargetContext->singleOwner());) |