Revert of Add guards to GrTextureProvider (patchset #5 id:80001 of https://codereview.chromium.org/1567983002/ )

Reason for revert:
breaking asan bot

Original issue's description:
> Add guards to GrTextureProvider
>
> TBR=bsalomon@google.com
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1567983002
>
> Committed: https://skia.googlesource.com/skia/+/b30dd1db1d914b85a691b4724713ba1b0f16cd6c

TBR=robertphillips@google.com,joshualitt@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/1565313003
This commit is contained in:
joshualitt 2016-01-07 13:17:38 -08:00 committed by Commit bot
parent 1a46467b69
commit 9a9515e081
7 changed files with 16 additions and 51 deletions

View File

@ -310,7 +310,7 @@ private:
SkSurfaceProps fSurfaceProps; SkSurfaceProps fSurfaceProps;
// In debug builds we guard against improper thread handling // In debug builds we guard against improper thread handling
SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) mutable GrSingleOwner* fSingleOwner;
}; };
#endif #endif

View File

@ -11,8 +11,6 @@
#include "GrTexture.h" #include "GrTexture.h"
#include "SkImageFilter.h" #include "SkImageFilter.h"
class GrSingleOwner;
class SK_API GrTextureProvider { class SK_API GrTextureProvider {
public: public:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -44,7 +42,15 @@ public:
} }
/** Finds a texture by unique key. If the texture is found it is ref'ed and returned. */ /** Finds a texture by unique key. If the texture is found it is ref'ed and returned. */
GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key); GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key) {
GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key);
if (resource) {
GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture();
SkASSERT(texture);
return texture;
}
return NULL;
}
/** /**
* Determines whether a texture is associated with the unique key. If the texture is found it * Determines whether a texture is associated with the unique key. If the texture is found it
@ -128,7 +134,7 @@ public:
GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc); GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc);
protected: protected:
GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* singleOwner); GrTextureProvider(GrGpu* gpu, GrResourceCache* cache) : fCache(cache), fGpu(gpu) {}
/** /**
* Assigns a unique key to a resource. If the key is associated with another resource that * Assigns a unique key to a resource. If the key is associated with another resource that
@ -180,9 +186,6 @@ protected:
private: private:
GrResourceCache* fCache; GrResourceCache* fCache;
GrGpu* fGpu; GrGpu* fGpu;
// In debug builds we guard against improper thread handling
SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;)
}; };
#endif #endif

View File

@ -85,7 +85,7 @@ void GrContext::initCommon(const GrContextOptions& options) {
fCaps = SkRef(fGpu->caps()); fCaps = SkRef(fGpu->caps());
fResourceCache = new GrResourceCache(fCaps); fResourceCache = new GrResourceCache(fCaps);
fResourceCache->setOverBudgetCallback(OverBudgetCB, this); fResourceCache->setOverBudgetCallback(OverBudgetCB, this);
fResourceProvider = new GrResourceProvider(fGpu, fResourceCache, &fSingleOwner); fResourceProvider = new GrResourceProvider(fGpu, fResourceCache);
fLayerCache.reset(new GrLayerCache(this)); fLayerCache.reset(new GrLayerCache(this));

View File

@ -57,10 +57,7 @@ GrDrawContext::GrDrawContext(GrDrawingManager* drawingMgr,
, fDrawTarget(SkSafeRef(rt->getLastDrawTarget())) , fDrawTarget(SkSafeRef(rt->getLastDrawTarget()))
, fTextContext(nullptr) , fTextContext(nullptr)
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
#ifdef SK_DEBUG , fSingleOwner(singleOwner) {
, fSingleOwner(singleOwner)
#endif
{
SkDEBUGCODE(this->validate();) SkDEBUGCODE(this->validate();)
} }

View File

@ -19,8 +19,7 @@
GR_DECLARE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey); GR_DECLARE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey);
GrResourceProvider::GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* owner) GrResourceProvider::GrResourceProvider(GrGpu* gpu, GrResourceCache* cache) : INHERITED(gpu, cache) {
: INHERITED(gpu, cache, owner) {
GR_DEFINE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey); GR_DEFINE_STATIC_UNIQUE_KEY(gQuadIndexBufferKey);
fQuadIndexBufferKey = gQuadIndexBufferKey; fQuadIndexBufferKey = gQuadIndexBufferKey;
} }

View File

@ -17,7 +17,6 @@ class GrBatchAtlas;
class GrIndexBuffer; class GrIndexBuffer;
class GrPath; class GrPath;
class GrRenderTarget; class GrRenderTarget;
class GrSingleOwner;
class GrStencilAttachment; class GrStencilAttachment;
class GrStrokeInfo; class GrStrokeInfo;
class GrVertexBuffer; class GrVertexBuffer;
@ -36,7 +35,7 @@ class SkTypeface;
*/ */
class GrResourceProvider : protected GrTextureProvider { class GrResourceProvider : protected GrTextureProvider {
public: public:
GrResourceProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* owner); GrResourceProvider(GrGpu* gpu, GrResourceCache* cache);
template <typename T> T* findAndRefTByUniqueKey(const GrUniqueKey& key) { template <typename T> T* findAndRefTByUniqueKey(const GrUniqueKey& key) {
return static_cast<T*>(this->findAndRefResourceByUniqueKey(key)); return static_cast<T*>(this->findAndRefResourceByUniqueKey(key));

View File

@ -10,10 +10,6 @@
#include "GrTexturePriv.h" #include "GrTexturePriv.h"
#include "GrResourceCache.h" #include "GrResourceCache.h"
#include "GrGpu.h" #include "GrGpu.h"
#include "../private/GrSingleOwner.h"
#define ASSERT_SINGLE_OWNER \
SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);)
enum ScratchTextureFlags { enum ScratchTextureFlags {
kExact_ScratchTextureFlag = 0x1, kExact_ScratchTextureFlag = 0x1,
@ -21,18 +17,8 @@ enum ScratchTextureFlags {
kNoCreate_ScratchTextureFlag = 0x4, kNoCreate_ScratchTextureFlag = 0x4,
}; };
GrTextureProvider::GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* singleOwner)
: fCache(cache)
, fGpu(gpu)
#ifdef SK_DEBUG
, fSingleOwner(singleOwner)
#endif
{
}
GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budgeted, GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budgeted,
const void* srcData, size_t rowBytes) { const void* srcData, size_t rowBytes) {
ASSERT_SINGLE_OWNER
if (this->isAbandoned()) { if (this->isAbandoned()) {
return nullptr; return nullptr;
} }
@ -58,13 +44,11 @@ GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg
} }
GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) { GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) {
ASSERT_SINGLE_OWNER
return this->internalCreateApproxTexture(desc, 0); return this->internalCreateApproxTexture(desc, 0);
} }
GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& desc, GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& desc,
uint32_t scratchFlags) { uint32_t scratchFlags) {
ASSERT_SINGLE_OWNER
if (this->isAbandoned()) { if (this->isAbandoned()) {
return nullptr; return nullptr;
} }
@ -78,7 +62,6 @@ GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& d
GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc, GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc,
uint32_t flags) { uint32_t flags) {
ASSERT_SINGLE_OWNER
SkASSERT(!this->isAbandoned()); SkASSERT(!this->isAbandoned());
SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig)); SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig));
@ -125,7 +108,6 @@ GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc,
GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& desc, GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& desc,
GrWrapOwnership ownership) { GrWrapOwnership ownership) {
ASSERT_SINGLE_OWNER
if (this->isAbandoned()) { if (this->isAbandoned()) {
return nullptr; return nullptr;
} }
@ -133,13 +115,11 @@ GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& des
} }
GrRenderTarget* GrTextureProvider::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc) { GrRenderTarget* GrTextureProvider::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc) {
ASSERT_SINGLE_OWNER
return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(desc, return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(desc,
kBorrow_GrWrapOwnership); kBorrow_GrWrapOwnership);
} }
void GrTextureProvider::assignUniqueKeyToResource(const GrUniqueKey& key, GrGpuResource* resource) { void GrTextureProvider::assignUniqueKeyToResource(const GrUniqueKey& key, GrGpuResource* resource) {
ASSERT_SINGLE_OWNER
if (this->isAbandoned() || !resource) { if (this->isAbandoned() || !resource) {
return; return;
} }
@ -147,22 +127,9 @@ void GrTextureProvider::assignUniqueKeyToResource(const GrUniqueKey& key, GrGpuR
} }
bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) const { bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) const {
ASSERT_SINGLE_OWNER
return this->isAbandoned() ? false : fCache->hasUniqueKey(key); return this->isAbandoned() ? false : fCache->hasUniqueKey(key);
} }
GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKey& key) { GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKey& key) {
ASSERT_SINGLE_OWNER
return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key); return this->isAbandoned() ? nullptr : fCache->findAndRefUniqueResource(key);
} }
GrTexture* GrTextureProvider::findAndRefTextureByUniqueKey(const GrUniqueKey& key) {
ASSERT_SINGLE_OWNER
GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key);
if (resource) {
GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture();
SkASSERT(texture);
return texture;
}
return NULL;
}