summaryrefslogtreecommitdiffstats
path: root/content/common/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'content/common/gpu')
-rw-r--r--content/common/gpu/gpu_channel.cc34
-rw-r--r--content/common/gpu/gpu_channel.h9
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc4
-rw-r--r--content/common/gpu/gpu_messages.h9
-rw-r--r--content/common/gpu/gpu_surface_stub.cc37
-rw-r--r--content/common/gpu/gpu_surface_stub.h49
6 files changed, 138 insertions, 4 deletions
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc
index 94c2c06..338d426 100644
--- a/content/common/gpu/gpu_channel.cc
+++ b/content/common/gpu/gpu_channel.cc
@@ -18,6 +18,7 @@
#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/gpu_video_service.h"
#include "content/common/gpu/transport_texture.h"
+#include "ui/gfx/gl/gl_surface.h"
#if defined(OS_POSIX)
#include "ipc/ipc_channel_posix.h"
@@ -184,6 +185,9 @@ bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) {
OnCreateOffscreenCommandBuffer)
IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer,
OnDestroyCommandBuffer)
+ IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenSurface,
+ OnCreateOffscreenSurface)
+ IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroySurface, OnDestroySurface)
IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateVideoDecoder,
OnCreateVideoDecoder)
IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyVideoDecoder,
@@ -250,6 +254,36 @@ void GpuChannel::OnDestroyCommandBuffer(int32 route_id) {
#endif
}
+void GpuChannel::OnCreateOffscreenSurface(const gfx::Size& size,
+ int* route_id) {
+ *route_id = MSG_ROUTING_NONE;
+
+#if defined(ENABLE_GPU)
+ scoped_ptr<gfx::GLSurface> surface(
+ gfx::GLSurface::CreateOffscreenGLSurface(size));
+ if (!surface.get())
+ return;
+
+ *route_id = GenerateRouteID();
+
+ scoped_ptr<GpuSurfaceStub> stub (new GpuSurfaceStub(this,
+ *route_id,
+ surface.release()));
+
+ router_.AddRoute(*route_id, stub.get());
+ surfaces_.AddWithID(stub.release(), *route_id);
+#endif
+}
+
+void GpuChannel::OnDestroySurface(int route_id) {
+#if defined(ENABLE_GPU)
+ if (router_.ResolveRoute(route_id)) {
+ router_.RemoveRoute(route_id);
+ surfaces_.Remove(route_id);
+ }
+#endif
+}
+
void GpuChannel::OnCreateVideoDecoder(
int32 decoder_host_id, const std::vector<uint32>& configs) {
// TODO(cevans): do NOT re-enable this until GpuVideoService has been checked
diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h
index d4025ae..da12ecd 100644
--- a/content/common/gpu/gpu_channel.h
+++ b/content/common/gpu/gpu_channel.h
@@ -15,6 +15,7 @@
#include "base/process.h"
#include "build/build_config.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
+#include "content/common/gpu/gpu_surface_stub.h"
#include "content/common/message_router.h"
#include "ipc/ipc_sync_channel.h"
#include "ui/gfx/native_widget_types.h"
@@ -112,6 +113,10 @@ class GpuChannel : public IPC::Channel::Listener,
int32* route_id);
void OnDestroyCommandBuffer(int32 route_id);
+ void OnCreateOffscreenSurface(const gfx::Size& size,
+ int* route_id);
+ void OnDestroySurface(int route_id);
+
void OnCreateVideoDecoder(int32 decoder_host_id,
const std::vector<uint32>& configs);
void OnDestroyVideoDecoder(int32 decoder_id);
@@ -139,6 +144,10 @@ class GpuChannel : public IPC::Channel::Listener,
#if defined(ENABLE_GPU)
typedef IDMap<GpuCommandBufferStub, IDMapOwnPointer> StubMap;
StubMap stubs_;
+
+ typedef IDMap<GpuSurfaceStub, IDMapOwnPointer> SurfaceMap;
+ SurfaceMap surfaces_;
+
std::set<int32> latched_routes_;
#endif // defined (ENABLE_GPU)
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index 0c852ad..e207372 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -25,10 +25,6 @@
using gpu::Buffer;
-#if defined(OS_WIN)
-#define kCompositorWindowOwner L"CompositorWindowOwner"
-#endif // defined(OS_WIN)
-
GpuCommandBufferStub::GpuCommandBufferStub(
GpuChannel* channel,
gfx::PluginWindowHandle handle,
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index 9c31376..c4db8f1 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -307,6 +307,15 @@ IPC_SYNC_MESSAGE_CONTROL4_1(GpuChannelMsg_CreateOffscreenCommandBuffer,
IPC_SYNC_MESSAGE_CONTROL1_0(GpuChannelMsg_DestroyCommandBuffer,
int32 /* instance_id */)
+// Create a surface for offscreen rendering.
+IPC_SYNC_MESSAGE_CONTROL1_1(GpuChannelMsg_CreateOffscreenSurface,
+ gfx::Size, /* size */
+ int /* route_id */)
+
+// Destroy a surface by routing id.
+IPC_MESSAGE_CONTROL1(GpuChannelMsg_DestroySurface,
+ int /* route_id */)
+
// Create hardware video decoder && associate it with the output |decoder_id|;
// We need this to be control message because we had to map the GpuChannel and
// |decoder_id|.
diff --git a/content/common/gpu/gpu_surface_stub.cc b/content/common/gpu/gpu_surface_stub.cc
new file mode 100644
index 0000000..389c624
--- /dev/null
+++ b/content/common/gpu/gpu_surface_stub.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2011 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.
+
+#if defined(ENABLE_GPU)
+
+#include "content/common/gpu/gpu_surface_stub.h"
+
+#include "content/common/gpu/gpu_channel.h"
+#include "ipc/ipc_message_macros.h"
+
+GpuSurfaceStub::GpuSurfaceStub(GpuChannel* channel,
+ int route_id,
+ gfx::GLSurface* surface)
+ : channel_(channel),
+ route_id_(route_id),
+ surface_(surface) {
+}
+
+GpuSurfaceStub::~GpuSurfaceStub() {
+}
+
+bool GpuSurfaceStub::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ //IPC_BEGIN_MESSAGE_MAP(GpuSurfaceStub, message)
+ // IPC_MESSAGE_UNHANDLED(handled = false)
+ //IPC_END_MESSAGE_MAP()
+ DCHECK(handled);
+ return handled;
+}
+
+bool GpuSurfaceStub::Send(IPC::Message* message) {
+ return channel_->Send(message);
+}
+
+
+#endif // defined(ENABLE_GPU)
diff --git a/content/common/gpu/gpu_surface_stub.h b/content/common/gpu/gpu_surface_stub.h
new file mode 100644
index 0000000..1a9deb6
--- /dev/null
+++ b/content/common/gpu/gpu_surface_stub.h
@@ -0,0 +1,49 @@
+// Copyright (c) 2011 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.
+
+#ifndef CONTENT_COMMON_GPU_GPU_SURFACE_STUB_H_
+#define CONTENT_COMMON_GPU_GPU_SURFACE_STUB_H_
+#pragma once
+
+#if defined(ENABLE_GPU)
+
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "ipc/ipc_channel.h"
+#include "ipc/ipc_message.h"
+#include "ui/gfx/gl/gl_surface.h"
+
+class GpuChannel;
+
+class GpuSurfaceStub
+ : public IPC::Channel::Listener,
+ public IPC::Message::Sender,
+ public base::SupportsWeakPtr<GpuSurfaceStub> {
+ public:
+ // Takes ownership of surface.
+ GpuSurfaceStub(GpuChannel* channel, int route_id, gfx::GLSurface* surface);
+ virtual ~GpuSurfaceStub();
+
+ // IPC::Channel::Listener implementation:
+ virtual bool OnMessageReceived(const IPC::Message& message);
+
+ // IPC::Message::Sender implementation:
+ virtual bool Send(IPC::Message* msg);
+
+ private:
+ // Message handlers.
+ // None yet.
+
+ // This is a weak pointer. The GpuChannel controls the lifetime of the
+ // GpuSurfaceStub and always outlives it.
+ GpuChannel* channel_;
+
+ int route_id_;
+ scoped_ptr<gfx::GLSurface> surface_;
+ DISALLOW_COPY_AND_ASSIGN(GpuSurfaceStub);
+};
+
+#endif // defined(ENABLE_GPU)
+
+#endif // CONTENT_COMMON_GPU_GPU_SURFACE_STUB_H_