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

Unified Diff: gpu/command_buffer/client/buffer_tracker.cc

Issue 11415223: gpu: Allow BufferData size=0 for pixel transfer buffer objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Allow BufferTracker::Buffer to be created with zero size. Created 8 years, 1 month 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 | gpu/command_buffer/client/buffer_tracker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/client/buffer_tracker.cc
diff --git a/gpu/command_buffer/client/buffer_tracker.cc b/gpu/command_buffer/client/buffer_tracker.cc
index 3e4e087ed364e72628de47bc9d211e120ce6c4c7..c99afe3343425d1bafbffa6ac14b3f3cc2582b34 100644
--- a/gpu/command_buffer/client/buffer_tracker.cc
+++ b/gpu/command_buffer/client/buffer_tracker.cc
@@ -24,12 +24,15 @@ BufferTracker::~BufferTracker() {
BufferTracker::Buffer* BufferTracker::CreateBuffer(
GLuint id, GLsizeiptr size) {
GPU_DCHECK_NE(0u, id);
- GPU_DCHECK_LT(0, size);
- int32 shm_id;
- uint32 shm_offset;
- void* address = mapped_memory_->Alloc(size, &shm_id, &shm_offset);
- if (!address) {
- return NULL;
+ GPU_DCHECK_LE(0, size);
+ int32 shm_id = -1;
+ uint32 shm_offset = 0;
+ void* address = NULL;
+ if (size) {
+ address = mapped_memory_->Alloc(size, &shm_id, &shm_offset);
+ if (!address) {
+ return NULL;
+ }
}
Buffer* buffer = new Buffer(id, size, shm_id, shm_offset, address);
@@ -56,8 +59,8 @@ void BufferTracker::RemoveBuffer(GLuint client_id) {
}
void BufferTracker::FreePendingToken(Buffer* buffer, int32 token) {
- GPU_DCHECK(buffer->address_);
- mapped_memory_->FreePendingToken(buffer->address_, token);
+ if (buffer->address_)
+ mapped_memory_->FreePendingToken(buffer->address_, token);
buffer->size_ = 0;
buffer->shm_id_ = 0;
buffer->shm_offset_ = 0;
« no previous file with comments | « no previous file | gpu/command_buffer/client/buffer_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698