diff options
author | 2017-02-27 11:39:51 -0500 | |
---|---|---|
committer | 2017-02-28 13:40:19 +0000 | |
commit | c8f1e3a5c08d58657dddccdeedbe5d6e8c16d891 (patch) | |
tree | 448ae6f8f46e44f0ded1989e132bd83445d7b448 /src | |
parent | b1305c03c3edc90d22a4a45b773ca895097422a2 (diff) |
Allow GrSurfaceProxy-derived classes to use flags when instantiating
In some instances proxies must be created that, when instantiated, have no pending IO.
This is split out of: (Add per-Flush callback to GrDrawingManager)
https://skia-review.googlesource.com/c/8679/
Change-Id: I68b5504d35ad436a4ae737ac4bb3c171fc9a5826
Reviewed-on: https://skia-review.googlesource.com/8988
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrBufferAllocPool.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetProxy.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrSurfaceProxy.cpp | 21 | ||||
-rw-r--r-- | src/gpu/GrTextureProvider.cpp | 16 | ||||
-rw-r--r-- | src/gpu/GrTextureProxy.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrTextureRenderTargetProxy.cpp | 14 | ||||
-rw-r--r-- | src/gpu/effects/GrTextureStripAtlas.cpp | 10 |
7 files changed, 41 insertions, 32 deletions
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp index e3f30b0c1c..38bde0dc9a 100644 --- a/src/gpu/GrBufferAllocPool.cpp +++ b/src/gpu/GrBufferAllocPool.cpp @@ -334,7 +334,7 @@ void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize, SkASSERT(buffer); SkASSERT(startVertex); - size_t offset = 0; // assign to suppress warning + size_t offset SK_INIT_TO_AVOID_WARNING; void* ptr = INHERITED::makeSpace(vertexSize * vertexCount, vertexSize, buffer, @@ -359,7 +359,7 @@ void* GrIndexBufferAllocPool::makeSpace(int indexCount, SkASSERT(buffer); SkASSERT(startIndex); - size_t offset = 0; // assign to suppress warning + size_t offset SK_INIT_TO_AVOID_WARNING; void* ptr = INHERITED::makeSpace(indexCount * sizeof(uint16_t), sizeof(uint16_t), buffer, diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp index 882acf660c..b3328ab638 100644 --- a/src/gpu/GrRenderTargetProxy.cpp +++ b/src/gpu/GrRenderTargetProxy.cpp @@ -18,8 +18,8 @@ // TODO: we can probably munge the 'desc' in both the wrapped and deferred // cases to make the sampleConfig/numSamples stuff more rational. GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc& desc, - SkBackingFit fit, SkBudgeted budgeted) - : INHERITED(desc, fit, budgeted) + SkBackingFit fit, SkBudgeted budgeted, uint32_t flags) + : INHERITED(desc, fit, budgeted, flags) , fFlags(GrRenderTarget::Flags::kNone) { // Since we know the newly created render target will be internal, we are able to precompute // what the flags will ultimately end up being. diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index bd60aa9fb9..3cac43b65d 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -23,6 +23,7 @@ GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, SkBackingFit fit) , fDesc(fTarget->desc()) , fFit(fit) , fBudgeted(fTarget->resourcePriv().isBudgeted()) + , fFlags(0) , fUniqueID(fTarget->uniqueID()) // Note: converting from unique resource ID to a proxy ID! , fGpuMemorySize(kInvalidGpuMemorySize) , fLastOpList(nullptr) { @@ -41,9 +42,9 @@ GrSurface* GrSurfaceProxy::instantiate(GrTextureProvider* texProvider) { } if (SkBackingFit::kApprox == fFit) { - fTarget = texProvider->createApproxTexture(fDesc); + fTarget = texProvider->createApproxTexture(fDesc, fFlags); } else { - fTarget = texProvider->createTexture(fDesc, fBudgeted); + fTarget = texProvider->createTexture(fDesc, fBudgeted, fFlags); } if (!fTarget) { return nullptr; @@ -143,10 +144,15 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeWrapped(sk_sp<GrTexture> tex) { } } +#include "GrResourceProvider.h" + sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps, const GrSurfaceDesc& desc, SkBackingFit fit, - SkBudgeted budgeted) { + SkBudgeted budgeted, + uint32_t flags) { + SkASSERT(0 == flags || GrResourceProvider::kNoPendingIO_Flag == flags); + // TODO: share this testing code with check_texture_creation_params if (GrPixelConfigIsCompressed(desc.fConfig)) { if (SkBackingFit::kApprox == fit || kBottomLeft_GrSurfaceOrigin == desc.fOrigin) { @@ -191,10 +197,11 @@ sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps, if (willBeRT) { // We know anything we instantiate later from this deferred path will be // both texturable and renderable - return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(caps, copyDesc, fit, budgeted)); + return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(caps, copyDesc, fit, + budgeted, flags)); } - return sk_sp<GrSurfaceProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0)); + return sk_sp<GrSurfaceProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0, flags)); } sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps, @@ -205,8 +212,8 @@ sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps, size_t rowBytes) { if (srcData) { // If we have srcData, for now, we create a wrapped GrTextureProxy - sk_sp<GrSurface> surf(texProvider->createTexture(desc, budgeted, srcData, rowBytes)); - return GrSurfaceProxy::MakeWrapped(std::move(surf)); + sk_sp<GrTexture> tex(texProvider->createTexture(desc, budgeted, srcData, rowBytes)); + return GrSurfaceProxy::MakeWrapped(std::move(tex)); } return GrSurfaceProxy::MakeDeferred(caps, desc, SkBackingFit::kExact, budgeted); diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp index 993f4b8cfa..3790f27fcc 100644 --- a/src/gpu/GrTextureProvider.cpp +++ b/src/gpu/GrTextureProvider.cpp @@ -31,7 +31,8 @@ GrTextureProvider::GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingl } GrTexture* GrTextureProvider::createMipMappedTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, - const GrMipLevel* texels, int mipLevelCount) { + const GrMipLevel* texels, int mipLevelCount, + uint32_t flags) { ASSERT_SINGLE_OWNER if (this->isAbandoned()) { @@ -54,9 +55,8 @@ GrTexture* GrTextureProvider::createMipMappedTexture(const GrSurfaceDesc& desc, } if (!GrPixelConfigIsCompressed(desc.fConfig)) { if (mipLevelCount < 2) { - static const uint32_t kFlags = kExact_ScratchTextureFlag | - kNoCreate_ScratchTextureFlag; - if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) { + flags |= kExact_ScratchTextureFlag | kNoCreate_ScratchTextureFlag; + if (GrTexture* texture = this->refScratchTexture(desc, flags)) { if (!mipLevelCount || texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, texels[0].fPixels, texels[0].fRowBytes)) { @@ -78,7 +78,7 @@ GrTexture* GrTextureProvider::createMipMappedTexture(const GrSurfaceDesc& desc, } GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, - const void* srcData, size_t rowBytes) { + const void* srcData, size_t rowBytes, uint32_t flags) { GrMipLevel tempTexels; GrMipLevel* texels = nullptr; int levelCount = 0; @@ -88,12 +88,12 @@ GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, SkBudgete texels = &tempTexels; levelCount = 1; } - return this->createMipMappedTexture(desc, budgeted, texels, levelCount); + return this->createMipMappedTexture(desc, budgeted, texels, levelCount, flags); } -GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) { +GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc, uint32_t flags) { ASSERT_SINGLE_OWNER - return this->internalCreateApproxTexture(desc, 0); + return this->internalCreateApproxTexture(desc, flags); } GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& desc, diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp index 77a8402dbe..9a65140816 100644 --- a/src/gpu/GrTextureProxy.cpp +++ b/src/gpu/GrTextureProxy.cpp @@ -10,8 +10,8 @@ #include "GrTextureProvider.h" GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, SkBudgeted budgeted, - const void* srcData, size_t /*rowBytes*/) - : INHERITED(srcDesc, fit, budgeted) { + const void* srcData, size_t /*rowBytes*/, uint32_t flags) + : INHERITED(srcDesc, fit, budgeted, flags) { SkASSERT(!srcData); // currently handled in Make() } diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp index 212ea0a049..432d00854f 100644 --- a/src/gpu/GrTextureRenderTargetProxy.cpp +++ b/src/gpu/GrTextureRenderTargetProxy.cpp @@ -8,19 +8,21 @@ #include "GrTextureRenderTargetProxy.h" // Deferred version -// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and +// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and // GrRenderTargetProxy) so its constructor must be explicitly called. GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc& desc, SkBackingFit fit, - SkBudgeted budgeted) - : GrSurfaceProxy(desc, fit, budgeted) - , GrTextureProxy(desc, fit, budgeted, nullptr, 0) // 4 now textures w/ data are always wrapped - , GrRenderTargetProxy(caps, desc, fit, budgeted) { + SkBudgeted budgeted, + uint32_t flags) + : GrSurfaceProxy(desc, fit, budgeted, flags) + // for now textures w/ data are always wrapped + , GrTextureProxy(desc, fit, budgeted, nullptr, 0, flags) + , GrRenderTargetProxy(caps, desc, fit, budgeted, flags) { } // Wrapped version -// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and +// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and // GrRenderTargetProxy) so its constructor must be explicitly called. GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf) : GrSurfaceProxy(surf, SkBackingFit::kExact) diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp index 6bc7ec0480..f49830481b 100644 --- a/src/gpu/effects/GrTextureStripAtlas.cpp +++ b/src/gpu/effects/GrTextureStripAtlas.cpp @@ -8,6 +8,7 @@ #include "GrTextureStripAtlas.h" #include "GrContext.h" #include "GrContextPriv.h" +#include "GrResourceProvider.h" #include "GrSurfaceContext.h" #include "SkGr.h" #include "SkPixelRef.h" @@ -209,15 +210,14 @@ void GrTextureStripAtlas::lockTexture() { // MDB TODO (caching): this side-steps the issue of proxies with unique IDs sk_sp<GrTexture> texture(fDesc.fContext->textureProvider()->findAndRefTextureByUniqueKey(key)); if (!texture) { - texture.reset(fDesc.fContext->textureProvider()->createTexture(texDesc, SkBudgeted::kYes, - nullptr, 0)); + texture.reset(fDesc.fContext->textureProvider()->createTexture( + texDesc, SkBudgeted::kYes, + nullptr, 0, + GrResourceProvider::kNoPendingIO_Flag)); if (!texture) { return; } - // We will be issuing writes to the surface using kDontFlush_PixelOpsFlag, so we - // need to make sure any existing IO is flushed - fDesc.fContext->flushSurfaceIO(texture.get()); fDesc.fContext->textureProvider()->assignUniqueKeyToTexture(key, texture.get()); // This is a new texture, so all of our cache info is now invalid this->initLRU(); |