summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/gpu_processor.cc
diff options
context:
space:
mode:
authorapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-24 19:34:24 +0000
committerapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-24 19:34:24 +0000
commit97632e2039e3ec0b9342f5e7c074bf631c738a9f (patch)
tree71e51bad650961671a0aa96b433403fc5a8ff544 /gpu/command_buffer/service/gpu_processor.cc
parentd4edbe5e406c5773d66d65214b963ed474b34cf4 (diff)
downloadchromium_src-97632e2039e3ec0b9342f5e7c074bf631c738a9f.zip
chromium_src-97632e2039e3ec0b9342f5e7c074bf631c738a9f.tar.gz
chromium_src-97632e2039e3ec0b9342f5e7c074bf631c738a9f.tar.bz2
Branched gpu process and command buffer code into Chrome tree. Fixed up paths and other minor changes to make it work in the Chrome tree. Will remove copy from O3D tree shortly. Only works in Windows currently.
TEST=none BUG=none Review URL: http://codereview.chromium.org/436017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/gpu_processor.cc')
-rw-r--r--gpu/command_buffer/service/gpu_processor.cc84
1 files changed, 84 insertions, 0 deletions
diff --git a/gpu/command_buffer/service/gpu_processor.cc b/gpu/command_buffer/service/gpu_processor.cc
new file mode 100644
index 0000000..845d5b6
--- /dev/null
+++ b/gpu/command_buffer/service/gpu_processor.cc
@@ -0,0 +1,84 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/command_buffer/service/gpu_processor.h"
+#include "gpu/np_utils/np_browser.h"
+
+using ::base::SharedMemory;
+using np_utils::NPBrowser;
+
+namespace command_buffer {
+
+GPUProcessor::~GPUProcessor() {
+}
+
+namespace {
+void InvokeProcessCommands(void* data) {
+ static_cast<GPUProcessor*>(data)->ProcessCommands();
+}
+} // namespace anonymous
+
+void GPUProcessor::ProcessCommands() {
+ if (command_buffer_->GetErrorStatus())
+ return;
+
+ parser_->set_put(command_buffer_->GetPutOffset());
+
+ int commands_processed = 0;
+ while (commands_processed < commands_per_update_ && !parser_->IsEmpty()) {
+ command_buffer::parse_error::ParseError parse_error =
+ parser_->ProcessCommand();
+ switch (parse_error) {
+ case command_buffer::parse_error::kParseUnknownCommand:
+ case command_buffer::parse_error::kParseInvalidArguments:
+ command_buffer_->SetParseError(parse_error);
+ break;
+
+ case command_buffer::parse_error::kParseInvalidSize:
+ case command_buffer::parse_error::kParseOutOfBounds:
+ command_buffer_->SetParseError(parse_error);
+ command_buffer_->RaiseErrorStatus();
+ return;
+ }
+
+ ++commands_processed;
+ }
+
+ command_buffer_->SetGetOffset(static_cast<int32>(parser_->get()));
+
+ if (!parser_->IsEmpty()) {
+ NPBrowser::get()->PluginThreadAsyncCall(npp_, InvokeProcessCommands, this);
+ }
+}
+
+void *GPUProcessor::GetSharedMemoryAddress(int32 shm_id) {
+ ::base::SharedMemory* shared_memory =
+ command_buffer_->GetTransferBuffer(shm_id);
+ if (!shared_memory)
+ return NULL;
+
+ if (!shared_memory->memory()) {
+ if (!shared_memory->Map(shared_memory->max_size()))
+ return NULL;
+ }
+
+ return shared_memory->memory();
+}
+
+// TODO(apatrick): Consolidate this with the above and return both the address
+// and size.
+size_t GPUProcessor::GetSharedMemorySize(int32 shm_id) {
+ ::base::SharedMemory* shared_memory =
+ command_buffer_->GetTransferBuffer(shm_id);
+ if (!shared_memory)
+ return 0;
+
+ return shared_memory->max_size();
+}
+
+void GPUProcessor::set_token(int32 token) {
+ command_buffer_->SetToken(token);
+}
+
+} // namespace command_buffer