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

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

Issue 8919014: Revert "Revert 113479 - Revert "Revert 113250 - Add CommandBuffer::SetGetBuffer"" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | « gpu/command_buffer/client/cmd_buffer_helper.h ('k') | gpu/command_buffer/client/cmd_buffer_helper_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
}
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper.h ('k') | gpu/command_buffer/client/cmd_buffer_helper_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698