diff options
author | 2016-01-11 08:27:48 -0800 | |
---|---|---|
committer | 2016-01-11 08:27:48 -0800 | |
commit | 6d0872d9bd97de5301214a258e141dd5fbeecffc (patch) | |
tree | 5fd61d616d646098dfacfaef56c5c5f70c74f32b /src/gpu/GrTextureProvider.cpp | |
parent | 7cf12ddb8c1c2cf7a0eec63439148cc6b2bc104a (diff) |
Reland of Add guards to GrTextureProvider (patchset #1 id:1 of https://codereview.chromium.org/1565313003/ )
Reason for revert:
should be fixed
Original issue's description:
> 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:
>
> Committed: https://skia.googlesource.com/skia/+/9a9515e081c54efdd5a0b0
f662c013cbeef6d63f
TBR=bsalomon@google.com
TBR=robertphillips@google.com,joshualitt@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=skia:
Review URL: https://codereview.chromium.org/1575093002
Diffstat (limited to 'src/gpu/GrTextureProvider.cpp')
-rw-r--r-- | src/gpu/GrTextureProvider.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp index cb652f7a7f..1c2f36535a 100644 --- a/src/gpu/GrTextureProvider.cpp +++ b/src/gpu/GrTextureProvider.cpp @@ -10,6 +10,10 @@ #include "GrTexturePriv.h" #include "GrResourceCache.h" #include "GrGpu.h" +#include "../private/GrSingleOwner.h" + +#define ASSERT_SINGLE_OWNER \ + SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) enum ScratchTextureFlags { kExact_ScratchTextureFlag = 0x1, @@ -17,8 +21,18 @@ enum ScratchTextureFlags { 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, const void* srcData, size_t rowBytes) { + ASSERT_SINGLE_OWNER if (this->isAbandoned()) { return nullptr; } @@ -44,11 +58,13 @@ GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budg } GrTexture* GrTextureProvider::createApproxTexture(const GrSurfaceDesc& desc) { + ASSERT_SINGLE_OWNER return this->internalCreateApproxTexture(desc, 0); } GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& desc, uint32_t scratchFlags) { + ASSERT_SINGLE_OWNER if (this->isAbandoned()) { return nullptr; } @@ -62,6 +78,7 @@ GrTexture* GrTextureProvider::internalCreateApproxTexture(const GrSurfaceDesc& d GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc, uint32_t flags) { + ASSERT_SINGLE_OWNER SkASSERT(!this->isAbandoned()); SkASSERT(!GrPixelConfigIsCompressed(inDesc.fConfig)); @@ -108,6 +125,7 @@ GrTexture* GrTextureProvider::refScratchTexture(const GrSurfaceDesc& inDesc, GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwnership ownership) { + ASSERT_SINGLE_OWNER if (this->isAbandoned()) { return nullptr; } @@ -115,11 +133,13 @@ GrTexture* GrTextureProvider::wrapBackendTexture(const GrBackendTextureDesc& des } GrRenderTarget* GrTextureProvider::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc) { + ASSERT_SINGLE_OWNER return this->isAbandoned() ? nullptr : fGpu->wrapBackendRenderTarget(desc, - kBorrow_GrWrapOwnership); + kBorrow_GrWrapOwnership); } void GrTextureProvider::assignUniqueKeyToResource(const GrUniqueKey& key, GrGpuResource* resource) { + ASSERT_SINGLE_OWNER if (this->isAbandoned() || !resource) { return; } @@ -127,9 +147,22 @@ void GrTextureProvider::assignUniqueKeyToResource(const GrUniqueKey& key, GrGpuR } bool GrTextureProvider::existsResourceWithUniqueKey(const GrUniqueKey& key) const { + ASSERT_SINGLE_OWNER return this->isAbandoned() ? false : fCache->hasUniqueKey(key); } GrGpuResource* GrTextureProvider::findAndRefResourceByUniqueKey(const GrUniqueKey& key) { + ASSERT_SINGLE_OWNER 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; +} |