summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-06 04:38:55 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-06 04:38:55 +0000
commitbe4f188066196d7bd0a4a7a62254bb603e566f74 (patch)
treea493671ea3e09fec3d20c86a0e452d509e7c9954 /gpu/command_buffer/service
parentee3cd175f8592b2b1f2ccd14b071d56ca733a5c6 (diff)
downloadchromium_src-be4f188066196d7bd0a4a7a62254bb603e566f74.zip
chromium_src-be4f188066196d7bd0a4a7a62254bb603e566f74.tar.gz
chromium_src-be4f188066196d7bd0a4a7a62254bb603e566f74.tar.bz2
linux: implement gpu plugin
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=35509 Review URL: http://codereview.chromium.org/500132 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35612 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc5
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.h8
-rw-r--r--gpu/command_buffer/service/gpu_processor.cc21
-rw-r--r--gpu/command_buffer/service/gpu_processor_linux.cc50
-rw-r--r--gpu/command_buffer/service/gpu_processor_win.cc19
5 files changed, 79 insertions, 24 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index a1ca73b..8b1fcf5 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -14,6 +14,9 @@
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/gles2_cmd_validation.h"
+#if defined(OS_LINUX)
+#include "gpu/command_buffer/service/x_utils.h"
+#endif
namespace gpu {
namespace gles2 {
@@ -982,7 +985,6 @@ parse_error::ParseError GLES2DecoderImpl::DoCommand(
parse_error::ParseError result = parse_error::kParseNoError;
if (debug()) {
// TODO(gman): Change output to something useful for NaCl.
- const char* f = GetCommandName(command);
printf("cmd: %s\n", GetCommandName(command));
}
unsigned int command_index = command - kStartPoint - 1;
@@ -1757,4 +1759,3 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetActiveAttrib(
} // namespace gles2
} // namespace gpu
-
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h
index 646fbcc..09d00f4 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.h
@@ -8,14 +8,16 @@
#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_H_
#include <build/build_config.h>
-#if defined(OS_LINUX)
-#include "gpu/command_buffer/service/x_utils.h"
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
#include <windows.h>
#endif
#include "gpu/command_buffer/service/common_decoder.h"
namespace gpu {
+// Forward-declared instead of including x_utils.h, because including glx.h
+// causes havok.
+class XWindowWrapper;
+
namespace gles2 {
// This class implements the AsyncAPIInterface interface, decoding GLES2
diff --git a/gpu/command_buffer/service/gpu_processor.cc b/gpu/command_buffer/service/gpu_processor.cc
index 0968215..c095341 100644
--- a/gpu/command_buffer/service/gpu_processor.cc
+++ b/gpu/command_buffer/service/gpu_processor.cc
@@ -9,6 +9,25 @@ using ::base::SharedMemory;
namespace gpu {
+GPUProcessor::GPUProcessor(CommandBuffer* command_buffer)
+ : command_buffer_(command_buffer),
+ commands_per_update_(100) {
+ DCHECK(command_buffer);
+ decoder_.reset(gles2::GLES2Decoder::Create());
+ decoder_->set_engine(this);
+}
+
+GPUProcessor::GPUProcessor(CommandBuffer* command_buffer,
+ gles2::GLES2Decoder* decoder,
+ CommandParser* parser,
+ int commands_per_update)
+ : command_buffer_(command_buffer),
+ commands_per_update_(commands_per_update) {
+ DCHECK(command_buffer);
+ decoder_.reset(decoder);
+ parser_.reset(parser);
+}
+
GPUProcessor::~GPUProcessor() {
}
@@ -32,6 +51,8 @@ void GPUProcessor::ProcessCommands() {
command_buffer_->SetParseError(parse_error);
command_buffer_->RaiseErrorStatus();
return;
+ case gpu::parse_error::kParseNoError:
+ break;
}
++commands_processed;
diff --git a/gpu/command_buffer/service/gpu_processor_linux.cc b/gpu/command_buffer/service/gpu_processor_linux.cc
new file mode 100644
index 0000000..205cceb
--- /dev/null
+++ b/gpu/command_buffer/service/gpu_processor_linux.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2009 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 <gdk/gdkx.h>
+#include "gpu/command_buffer/service/gpu_processor.h"
+#include "gpu/command_buffer/service/x_utils.h"
+
+using ::base::SharedMemory;
+
+namespace gpu {
+
+bool GPUProcessor::Initialize(gfx::PluginWindowHandle handle) {
+ DCHECK(handle);
+
+ // Cannot reinitialize.
+ if (decoder_->window() != NULL)
+ return false;
+
+ // Map the ring buffer and create the parser.
+ Buffer ring_buffer = command_buffer_->GetRingBuffer();
+ if (ring_buffer.ptr) {
+ parser_.reset(new CommandParser(ring_buffer.ptr,
+ ring_buffer.size,
+ 0,
+ ring_buffer.size,
+ 0,
+ decoder_.get()));
+ } else {
+ parser_.reset(new CommandParser(NULL, 0, 0, 0, 0,
+ decoder_.get()));
+ }
+
+ // Initialize GAPI immediately if the window handle is valid.
+ XWindowWrapper *window = new XWindowWrapper(GDK_DISPLAY(), handle);
+ decoder_->set_window_wrapper(window);
+ return decoder_->Initialize();
+}
+
+void GPUProcessor::Destroy() {
+ // Destroy GAPI if window handle has not already become invalid.
+ XWindowWrapper *window = decoder_->window();
+ if (window) {
+ decoder_->Destroy();
+ decoder_->set_window_wrapper(NULL);
+ delete window;
+ }
+}
+
+} // namespace gpu
diff --git a/gpu/command_buffer/service/gpu_processor_win.cc b/gpu/command_buffer/service/gpu_processor_win.cc
index 6a05845..bef34d8 100644
--- a/gpu/command_buffer/service/gpu_processor_win.cc
+++ b/gpu/command_buffer/service/gpu_processor_win.cc
@@ -10,25 +10,6 @@ using ::base::SharedMemory;
namespace gpu {
-GPUProcessor::GPUProcessor(CommandBuffer* command_buffer)
- : command_buffer_(command_buffer),
- commands_per_update_(100) {
- DCHECK(command_buffer);
- decoder_.reset(gles2::GLES2Decoder::Create());
- decoder_->set_engine(this);
-}
-
-GPUProcessor::GPUProcessor(CommandBuffer* command_buffer,
- gles2::GLES2Decoder* decoder,
- CommandParser* parser,
- int commands_per_update)
- : command_buffer_(command_buffer),
- commands_per_update_(commands_per_update) {
- DCHECK(command_buffer);
- decoder_.reset(decoder);
- parser_.reset(parser);
-}
-
bool GPUProcessor::Initialize(gfx::PluginWindowHandle handle) {
DCHECK(handle);