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

Unified Diff: src/gpu/GrGpu.cpp

Issue 477323006: Revert of Add GrResourceCache2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrGpuResource.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrGpu.cpp
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index bdf67727c3f41f70eb515492e01fbb5e7ac23bbb..0b49e7445ab897b8709406ec988bf1d6d5067043 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -49,9 +49,62 @@
#endif
}
-GrGpu::~GrGpu() {}
-
-void GrGpu::contextAbandonded() {}
+GrGpu::~GrGpu() {
+ this->releaseResources();
+}
+
+void GrGpu::abandonResources() {
+
+ fClipMaskManager.releaseResources();
+
+ while (NULL != fObjectList.head()) {
+ fObjectList.head()->abandon();
+ }
+
+ SkASSERT(NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed());
+ SkSafeSetNull(fQuadIndexBuffer);
+ delete fVertexPool;
+ fVertexPool = NULL;
+ delete fIndexPool;
+ fIndexPool = NULL;
+}
+
+void GrGpu::releaseResources() {
+
+ fClipMaskManager.releaseResources();
+
+ while (NULL != fObjectList.head()) {
+ fObjectList.head()->release();
+ }
+
+ SkASSERT(NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed());
+ SkSafeSetNull(fQuadIndexBuffer);
+ delete fVertexPool;
+ fVertexPool = NULL;
+ delete fIndexPool;
+ fIndexPool = NULL;
+}
+
+void GrGpu::insertObject(GrGpuResource* object) {
+ SkASSERT(NULL != object);
+ SkASSERT(this == object->getGpu());
+
+ fObjectList.addToHead(object);
+}
+
+void GrGpu::removeObject(GrGpuResource* object) {
+ SkASSERT(NULL != object);
+ SkASSERT(this == object->getGpu());
+
+ fObjectList.remove(object);
+}
+
+
+void GrGpu::unimpl(const char msg[]) {
+#ifdef SK_DEBUG
+ GrPrintf("--- GrGpu unimplemented(\"%s\")\n", msg);
+#endif
+}
////////////////////////////////////////////////////////////////////////////////
@@ -266,8 +319,7 @@
}
const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
- if (NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()) {
- SkSafeUnref(fQuadIndexBuffer);
+ if (NULL == fQuadIndexBuffer) {
static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS;
GrGpu* me = const_cast<GrGpu*>(this);
fQuadIndexBuffer = me->createIndexBuffer(SIZE, false);
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrGpuResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698