Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Unified Diff: src/gpu/GrTextureProvider.cpp

Issue 1567983002: Add guards to GrTextureProvider (Closed) Base URL: https://skia.googlesource.com/skia.git@gpudeviceguards
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/gpu/GrTextureProvider.h ('K') | « src/gpu/GrResourceProvider.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrTextureProvider.cpp
diff --git a/src/gpu/GrTextureProvider.cpp b/src/gpu/GrTextureProvider.cpp
index cb652f7a7fd8c2e27b46fb7a4c802a4031b900e1..b2d172f36f1407292f19317e782e6190935ac540 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,
@@ -19,6 +23,7 @@ enum ScratchTextureFlags {
GrTexture* GrTextureProvider::createTexture(const GrSurfaceDesc& desc, bool budgeted,
const void* srcData, size_t rowBytes) {
+ ASSERT_SINGLE_OWNER
if (this->isAbandoned()) {
return nullptr;
}
@@ -44,11 +49,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 +69,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 +116,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 +124,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 +138,11 @@ 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);
}
« include/gpu/GrTextureProvider.h ('K') | « src/gpu/GrResourceProvider.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698