Revert "Allow GrSurfaceProxy-derived classes to use flags when instantiating"

This reverts commit c8f1e3a5c0.

Reason for revert: check on ANGLE failure
Original change's description:
> 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>
> 

TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Change-Id: I157417c443028b2148ee355ce69c946a96bb9407
Reviewed-on: https://skia-review.googlesource.com/9066
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2017-02-28 15:05:52 +00:00 committed by Skia Commit-Bot
parent e30cf80c88
commit 2411c1112e
12 changed files with 45 additions and 59 deletions

View File

@ -28,8 +28,7 @@ public:
* @param mipLevelCount The amount of elements in the texels array
*/
GrTexture* createMipMappedTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
const GrMipLevel* texels, int mipLevelCount,
uint32_t flags = 0);
const GrMipLevel* texels, int mipLevelCount);
/**
* This function is a shim which creates a SkTArray<GrMipLevel> of size 1.
@ -41,11 +40,11 @@ public:
* field is ignored.
*/
GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, const void* srcData,
size_t rowBytes, uint32_t flags = 0);
size_t rowBytes);
/** Shortcut for creating a texture with no initial data to upload. */
GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, uint32_t flags = 0) {
return this->createTexture(desc, budgeted, nullptr, 0, flags);
GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted) {
return this->createTexture(desc, budgeted, nullptr, 0);
}
/** Assigns a unique key to the texture. The texture will be findable via this key using
@ -73,18 +72,18 @@ public:
* The contents of the texture are undefined. The caller owns a ref on the returned texture and
* must balance with a call to unref.
*/
GrTexture* createApproxTexture(const GrSurfaceDesc&, uint32_t flags = 0);
GrTexture* createApproxTexture(const GrSurfaceDesc&);
/** Legacy function that no longer should be used. */
enum ScratchTexMatch {
kExact_ScratchTexMatch,
kApprox_ScratchTexMatch
};
GrTexture* refScratchTexture(const GrSurfaceDesc& desc, ScratchTexMatch match, uint32_t flags) {
GrTexture* refScratchTexture(const GrSurfaceDesc& desc, ScratchTexMatch match) {
if (kApprox_ScratchTexMatch == match) {
return this->createApproxTexture(desc, flags);
return this->createApproxTexture(desc);
} else {
return this->createTexture(desc, SkBudgeted::kYes, flags);
return this->createTexture(desc, SkBudgeted::kYes);
}
}

View File

@ -60,8 +60,7 @@ protected:
friend class GrSurfaceProxy; // for ctors
// Deferred version
GrRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&,
SkBackingFit, SkBudgeted, uint32_t flags);
GrRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, SkBackingFit, SkBudgeted);
// Wrapped version
GrRenderTargetProxy(sk_sp<GrSurface>);

View File

@ -171,7 +171,7 @@ public:
static sk_sp<GrTextureProxy> MakeWrapped(sk_sp<GrTexture>);
static sk_sp<GrSurfaceProxy> MakeDeferred(const GrCaps&, const GrSurfaceDesc&,
SkBackingFit, SkBudgeted, uint32_t flags = 0);
SkBackingFit, SkBudgeted);
// TODO: need to refine ownership semantics of 'srcData' if we're in completely
// deferred mode
@ -304,11 +304,10 @@ public:
protected:
// Deferred version
GrSurfaceProxy(const GrSurfaceDesc& desc, SkBackingFit fit, SkBudgeted budgeted, uint32_t flags)
GrSurfaceProxy(const GrSurfaceDesc& desc, SkBackingFit fit, SkBudgeted budgeted)
: fDesc(desc)
, fFit(fit)
, fBudgeted(budgeted)
, fFlags(flags)
, fGpuMemorySize(kInvalidGpuMemorySize)
, fLastOpList(nullptr) {
// Note: this ctor pulls a new uniqueID from the same pool at the GrGpuResources
@ -330,7 +329,6 @@ protected:
const GrSurfaceDesc fDesc;
const SkBackingFit fFit; // always exact for wrapped resources
const SkBudgeted fBudgeted; // set from the backing resource for wrapped resources
const uint32_t fFlags;
const UniqueID fUniqueID; // set from the backing resource for wrapped resources
static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0);

View File

@ -29,7 +29,7 @@ protected:
// Deferred version
GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
const void* srcData, size_t srcRowBytes, uint32_t flags);
const void* srcData, size_t srcRowBytes);
// Wrapped version
GrTextureProxy(sk_sp<GrSurface>);

View File

@ -26,8 +26,7 @@ private:
friend class GrSurfaceProxy; // for ctors
// Deferred version
GrTextureRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&,
SkBackingFit, SkBudgeted, uint32_t flags);
GrTextureRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, SkBackingFit, SkBudgeted);
// Wrapped version
GrTextureRenderTargetProxy(sk_sp<GrSurface>);

View File

@ -334,7 +334,7 @@ void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize,
SkASSERT(buffer);
SkASSERT(startVertex);
size_t offset SK_INIT_TO_AVOID_WARNING;
size_t offset = 0; // assign to suppress 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 SK_INIT_TO_AVOID_WARNING;
size_t offset = 0; // assign to suppress warning
void* ptr = INHERITED::makeSpace(indexCount * sizeof(uint16_t),
sizeof(uint16_t),
buffer,

View File

@ -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, uint32_t flags)
: INHERITED(desc, fit, budgeted, flags)
SkBackingFit fit, SkBudgeted budgeted)
: INHERITED(desc, fit, budgeted)
, 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.

View File

@ -23,7 +23,6 @@ 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) {
@ -42,9 +41,9 @@ GrSurface* GrSurfaceProxy::instantiate(GrTextureProvider* texProvider) {
}
if (SkBackingFit::kApprox == fFit) {
fTarget = texProvider->createApproxTexture(fDesc, fFlags);
fTarget = texProvider->createApproxTexture(fDesc);
} else {
fTarget = texProvider->createTexture(fDesc, fBudgeted, fFlags);
fTarget = texProvider->createTexture(fDesc, fBudgeted);
}
if (!fTarget) {
return nullptr;
@ -144,15 +143,10 @@ 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,
uint32_t flags) {
SkASSERT(0 == flags || GrResourceProvider::kNoPendingIO_Flag == flags);
SkBudgeted budgeted) {
// TODO: share this testing code with check_texture_creation_params
if (GrPixelConfigIsCompressed(desc.fConfig)) {
if (SkBackingFit::kApprox == fit || kBottomLeft_GrSurfaceOrigin == desc.fOrigin) {
@ -197,11 +191,10 @@ 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, flags));
return sk_sp<GrSurfaceProxy>(new GrTextureRenderTargetProxy(caps, copyDesc, fit, budgeted));
}
return sk_sp<GrSurfaceProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0, flags));
return sk_sp<GrSurfaceProxy>(new GrTextureProxy(copyDesc, fit, budgeted, nullptr, 0));
}
sk_sp<GrSurfaceProxy> GrSurfaceProxy::MakeDeferred(const GrCaps& caps,
@ -212,8 +205,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<GrTexture> tex(texProvider->createTexture(desc, budgeted, srcData, rowBytes));
return GrSurfaceProxy::MakeWrapped(std::move(tex));
sk_sp<GrSurface> surf(texProvider->createTexture(desc, budgeted, srcData, rowBytes));
return GrSurfaceProxy::MakeWrapped(std::move(surf));
}
return GrSurfaceProxy::MakeDeferred(caps, desc, SkBackingFit::kExact, budgeted);

View File

@ -31,8 +31,7 @@ GrTextureProvider::GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingl
}
GrTexture* GrTextureProvider::createMipMappedTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
const GrMipLevel* texels, int mipLevelCount,
uint32_t flags) {
const GrMipLevel* texels, int mipLevelCount) {
ASSERT_SINGLE_OWNER
if (this->isAbandoned()) {
@ -55,8 +54,9 @@ GrTexture* GrTextureProvider::createMipMappedTexture(const GrSurfaceDesc& desc,
}
if (!GrPixelConfigIsCompressed(desc.fConfig)) {
if (mipLevelCount < 2) {
flags |= kExact_ScratchTextureFlag | kNoCreate_ScratchTextureFlag;
if (GrTexture* texture = this->refScratchTexture(desc, flags)) {
static const uint32_t kFlags = kExact_ScratchTextureFlag |
kNoCreate_ScratchTextureFlag;
if (GrTexture* texture = this->refScratchTexture(desc, kFlags)) {
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, uint32_t flags) {
const void* srcData, size_t rowBytes) {
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, flags);
return this->createMipMappedTexture(desc, budgeted, texels, levelCount);
}
GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc, uint32_t flags) {
GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) {
ASSERT_SINGLE_OWNER
return this->internalCreateApproxTexture(desc, flags);
return this->internalCreateApproxTexture(desc, 0);
}
GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& desc,

View File

@ -10,8 +10,8 @@
#include "GrTextureProvider.h"
GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, SkBudgeted budgeted,
const void* srcData, size_t /*rowBytes*/, uint32_t flags)
: INHERITED(srcDesc, fit, budgeted, flags) {
const void* srcData, size_t /*rowBytes*/)
: INHERITED(srcDesc, fit, budgeted) {
SkASSERT(!srcData); // currently handled in Make()
}

View File

@ -13,12 +13,10 @@
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
const GrSurfaceDesc& desc,
SkBackingFit fit,
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) {
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) {
}
// Wrapped version

View File

@ -8,7 +8,6 @@
#include "GrTextureStripAtlas.h"
#include "GrContext.h"
#include "GrContextPriv.h"
#include "GrResourceProvider.h"
#include "GrSurfaceContext.h"
#include "SkGr.h"
#include "SkPixelRef.h"
@ -210,14 +209,15 @@ 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,
GrResourceProvider::kNoPendingIO_Flag));
texture.reset(fDesc.fContext->textureProvider()->createTexture(texDesc, SkBudgeted::kYes,
nullptr, 0));
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();