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

Unified Diff: src/gpu/gl/GrGLCreateNullInterface.cpp

Issue 1863923003: Fix null context GenBuffers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLCreateNullInterface.cpp
diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp
index b9a29fb7421d3a117f3768d0a84b6ea613ae454a..80a7cfbd2cdba26465042be242be89925edf01e0 100644
--- a/src/gpu/gl/GrGLCreateNullInterface.cpp
+++ b/src/gpu/gl/GrGLCreateNullInterface.cpp
@@ -47,7 +47,9 @@ private:
// This class maintains a sparsely populated array of buffer pointers.
class BufferManager {
public:
- BufferManager() : fFreeListHead(kFreeListEnd) {}
+ BufferManager() : fFreeListHead(kFreeListEnd) {
+ *fBuffers.append() = nullptr; // 0 is not a valid GL buffer id.
+ }
~BufferManager() {
// nullptr out the entries that are really free list links rather than ptrs before deleting.
@@ -89,6 +91,7 @@ public:
}
void free(BufferObj* buffer) {
+ SkASSERT(buffer);
SkASSERT(fBuffers.count() > 0);
GrGLuint id = buffer->id();
@@ -201,8 +204,10 @@ public:
fCurrPixelUnpackBuffer = 0;
}
- BufferObj* buffer = fBufferManager.lookUp(ids[i]);
- fBufferManager.free(buffer);
+ if (ids[i] > 0) {
+ BufferObj* buffer = fBufferManager.lookUp(ids[i]);
+ fBufferManager.free(buffer);
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698