Index: gpu/command_buffer/client/cmd_buffer_helper.cc |
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.cc b/gpu/command_buffer/client/cmd_buffer_helper.cc |
index 632892313f2f9f55b36f1fc825dcde8cbf0ced85..d43efc343cbea3fcd4a8348c11d57cb097a7bc65 100644 |
--- a/gpu/command_buffer/client/cmd_buffer_helper.cc |
+++ b/gpu/command_buffer/client/cmd_buffer_helper.cc |
@@ -17,6 +17,8 @@ const double kFlushDelay = 1.0 / (5.0 * 60.0); |
CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) |
: command_buffer_(command_buffer), |
+ ring_buffer_id_(-1), |
+ ring_buffer_size_(0), |
entries_(NULL), |
total_entry_count_(0), |
usable_entry_count_(0), |
@@ -27,14 +29,25 @@ CommandBufferHelper::CommandBufferHelper(CommandBuffer* command_buffer) |
last_flush_time_(0) { |
} |
-bool CommandBufferHelper::Initialize(int32 ring_buffer_size) { |
- ring_buffer_ = command_buffer_->GetRingBuffer(); |
+bool CommandBufferHelper::AllocateRingBuffer() { |
+ int32 id = command_buffer_->CreateTransferBuffer(ring_buffer_size_, -1); |
+ if (id < 0) { |
+ return false; |
+ } |
+ |
+ ring_buffer_ = command_buffer_->GetTransferBuffer(id); |
if (!ring_buffer_.ptr) |
return false; |
+ ring_buffer_id_ = id; |
+ command_buffer_->SetGetBuffer(id); |
+ |
+ // TODO(gman): Do we really need to call GetState here? We know get & put = 0 |
+ // Also do we need to check state.num_entries? |
CommandBuffer::State state = command_buffer_->GetState(); |
entries_ = static_cast<CommandBufferEntry*>(ring_buffer_.ptr); |
- int32 num_ring_buffer_entries = ring_buffer_size / sizeof(CommandBufferEntry); |
+ int32 num_ring_buffer_entries = |
+ ring_buffer_size_ / sizeof(CommandBufferEntry); |
if (num_ring_buffer_entries > state.num_entries) { |
return false; |
} |
@@ -48,6 +61,11 @@ bool CommandBufferHelper::Initialize(int32 ring_buffer_size) { |
return true; |
} |
+bool CommandBufferHelper::Initialize(int32 ring_buffer_size) { |
+ ring_buffer_size_ = ring_buffer_size; |
+ return AllocateRingBuffer(); |
+} |
+ |
CommandBufferHelper::~CommandBufferHelper() { |
} |