summaryrefslogtreecommitdiffstats
path: root/chrome/gpu/gpu_command_buffer_stub.cc
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-25 22:08:35 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-25 22:08:35 +0000
commit6217d397bf501ec1ec5b7270d493006badd4d87a (patch)
treefce6c8e9c15b79bab29a9535ce9929dd9d53735b /chrome/gpu/gpu_command_buffer_stub.cc
parent21dedcc12d21ccb288244249522d77bc074c501e (diff)
downloadchromium_src-6217d397bf501ec1ec5b7270d493006badd4d87a.zip
chromium_src-6217d397bf501ec1ec5b7270d493006badd4d87a.tar.gz
chromium_src-6217d397bf501ec1ec5b7270d493006badd4d87a.tar.bz2
Calling OpenGL from the renderer process
- Added ability for renderer processes to render to a real window (Windows only so far). - Added ability to create offscreen frame buffer objects that can be resized later. - OpenGL context can have a "parent" context that can access its last swapped back buffer through a texture ID. - Moved code to establish GPU channel from RenderWidget to RenderThread. - Changed way service size command buffer object lifetimes are managed. TEST=trybot and visual verification that OpenGL can clear the browser window to magenta. BUG=none Review URL: http://codereview.chromium.org/1136006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42679 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu/gpu_command_buffer_stub.cc')
-rw-r--r--chrome/gpu/gpu_command_buffer_stub.cc34
1 files changed, 31 insertions, 3 deletions
diff --git a/chrome/gpu/gpu_command_buffer_stub.cc b/chrome/gpu/gpu_command_buffer_stub.cc
index 6c3f5cc..5d6842d 100644
--- a/chrome/gpu/gpu_command_buffer_stub.cc
+++ b/chrome/gpu/gpu_command_buffer_stub.cc
@@ -6,6 +6,7 @@
#include "base/process_util.h"
#include "base/shared_memory.h"
+#include "build/build_config.h"
#include "chrome/common/gpu_messages.h"
#include "chrome/gpu/gpu_channel.h"
#include "chrome/gpu/gpu_command_buffer_stub.h"
@@ -13,12 +14,23 @@
using gpu::Buffer;
GpuCommandBufferStub::GpuCommandBufferStub(GpuChannel* channel,
+ gfx::NativeView view,
+ GpuCommandBufferStub* parent,
+ const gfx::Size& size,
+ uint32 parent_texture_id,
int32 route_id)
: channel_(channel),
+ view_(view),
+ parent_(parent),
+ initial_size_(size),
+ parent_texture_id_(parent_texture_id),
route_id_(route_id) {
}
GpuCommandBufferStub::~GpuCommandBufferStub() {
+ if (processor_.get()) {
+ processor_->Destroy();
+ }
}
void GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
@@ -34,6 +46,8 @@ void GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
OnDestroyTransferBuffer);
IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_GetTransferBuffer,
OnGetTransferBuffer);
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ResizeOffscreenFrameBuffer,
+ OnResizeOffscreenFrameBuffer);
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
}
@@ -55,8 +69,18 @@ void GpuCommandBufferStub::OnInitialize(
if (command_buffer_->Initialize(size)) {
Buffer buffer = command_buffer_->GetRingBuffer();
if (buffer.shared_memory) {
- processor_ = new gpu::GPUProcessor(command_buffer_.get());
- if (processor_->Initialize(gfx::kNullPluginWindow)) {
+ gpu::GPUProcessor* parent_processor =
+ parent_ ? parent_->processor_.get() : NULL;
+ processor_.reset(new gpu::GPUProcessor(command_buffer_.get()));
+ // TODO(apatrick): The reinterpret_cast below is only valid on windows.
+#if !defined(OS_WIN)
+ DCHECK_EQ(view_, static_cast<gfx::NativeView>(0));
+#endif
+ if (processor_->Initialize(
+ reinterpret_cast<gfx::PluginWindowHandle>(view_),
+ parent_processor,
+ initial_size_,
+ parent_texture_id_)) {
command_buffer_->SetPutOffsetChangeCallback(
NewCallback(processor_.get(),
&gpu::GPUProcessor::ProcessCommands));
@@ -66,7 +90,7 @@ void GpuCommandBufferStub::OnInitialize(
buffer.shared_memory->ShareToProcess(channel_->renderer_handle(),
ring_buffer);
} else {
- processor_ = NULL;
+ processor_.reset();
command_buffer_.reset();
}
}
@@ -117,4 +141,8 @@ void GpuCommandBufferStub::OnGetTransferBuffer(
}
}
+void GpuCommandBufferStub::OnResizeOffscreenFrameBuffer(const gfx::Size& size) {
+ processor_->ResizeOffscreenFrameBuffer(size);
+}
+
#endif // ENABLE_GPU