Add GrResourceCache2.
Currently it just replaces GrGpu as the owner of the linked list of resources.
Committed: https://skia.googlesource.com/skia/+/94ce9ac8624dbb45656b8f5c992fad9c9ff3ee5f
R=mtklein@google.com, robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/481443002
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 74df260..6ada03b 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -50,18 +50,6 @@
}
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;
@@ -69,42 +57,7 @@
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
-}
+void GrGpu::contextAbandonded() {}
////////////////////////////////////////////////////////////////////////////////
@@ -318,7 +271,8 @@
}
const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
- if (NULL == fQuadIndexBuffer) {
+ if (NULL == fQuadIndexBuffer || fQuadIndexBuffer->wasDestroyed()) {
+ SkSafeUnref(fQuadIndexBuffer);
static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS;
GrGpu* me = const_cast<GrGpu*>(this);
fQuadIndexBuffer = me->createIndexBuffer(SIZE, false);