summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/renderer_host/gpu_view_host.cc10
-rw-r--r--chrome/browser/renderer_host/gpu_view_host.h5
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_gtk.cc7
-rw-r--r--chrome/browser/renderer_host/video_layer_proxy.cc59
-rw-r--r--chrome/browser/renderer_host/video_layer_proxy.h43
-rw-r--r--chrome/browser/renderer_host/video_layer_x.h1
-rwxr-xr-xchrome/chrome.gyp2
-rwxr-xr-xchrome/chrome_browser.gypi4
-rw-r--r--chrome/common/gpu_messages_internal.h21
-rw-r--r--chrome/gpu/gpu_video_layer_glx.cc48
-rw-r--r--chrome/gpu/gpu_video_layer_glx.h46
-rw-r--r--chrome/gpu/gpu_view_x.cc7
-rw-r--r--chrome/gpu/gpu_view_x.h4
13 files changed, 252 insertions, 5 deletions
diff --git a/chrome/browser/renderer_host/gpu_view_host.cc b/chrome/browser/renderer_host/gpu_view_host.cc
index 8fcb288..a81db6b 100644
--- a/chrome/browser/renderer_host/gpu_view_host.cc
+++ b/chrome/browser/renderer_host/gpu_view_host.cc
@@ -6,6 +6,7 @@
#include "chrome/browser/gpu_process_host.h"
#include "chrome/browser/renderer_host/backing_store_proxy.h"
+#include "chrome/browser/renderer_host/video_layer_proxy.h"
#include "chrome/common/gpu_messages.h"
GpuViewHost::GpuViewHost(RenderWidgetHost* widget, GpuNativeWindowHandle parent)
@@ -31,6 +32,15 @@ BackingStore* GpuViewHost::CreateBackingStore(const gfx::Size& size) {
process_, backing_store_routing_id);
}
+VideoLayer* GpuViewHost::CreateVideoLayer(const gfx::Size& size) {
+ int32 video_layer_routing_id = process_->GetNextRoutingId();
+ process_->Send(new GpuMsg_NewVideoLayer(routing_id_,
+ video_layer_routing_id,
+ size));
+ return new VideoLayerProxy(widget_, size,
+ process_, video_layer_routing_id);
+}
+
void GpuViewHost::OnWindowPainted() {
process_->Send(new GpuMsg_WindowPainted(routing_id_));
}
diff --git a/chrome/browser/renderer_host/gpu_view_host.h b/chrome/browser/renderer_host/gpu_view_host.h
index c6aa2d2..910c978 100644
--- a/chrome/browser/renderer_host/gpu_view_host.h
+++ b/chrome/browser/renderer_host/gpu_view_host.h
@@ -11,6 +11,7 @@
class BackingStore;
class GpuProcessHost;
class RenderWidgetHost;
+class VideoLayer;
namespace gfx {
class Size;
@@ -26,6 +27,10 @@ class GpuViewHost {
// the new pointer to the caller.
BackingStore* CreateBackingStore(const gfx::Size& size);
+ // Creates a new video layer in the GPU process and returns ownership of the
+ // new pointer to the caller.
+ VideoLayer* CreateVideoLayer(const gfx::Size& size);
+
// Notification that the RenderWidgetHost has been asked to paint the window.
// Depending on the backing store, the GPU backing store may have to repaint
// at this time. On Linux this is needed because the GPU process paints
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
index c3f860b..30df540 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
@@ -642,8 +642,11 @@ BackingStore* RenderWidgetHostViewGtk::AllocBackingStore(
VideoLayer* RenderWidgetHostViewGtk::AllocVideoLayer(const gfx::Size& size) {
if (enable_gpu_rendering_) {
- NOTIMPLEMENTED();
- return NULL;
+ // TODO(scherkus): is it possible for a video layer to be allocated before a
+ // backing store?
+ DCHECK(gpu_view_host_.get())
+ << "AllocVideoLayer() called before AllocBackingStore()";
+ return gpu_view_host_->CreateVideoLayer(size);
}
return new VideoLayerX(host_, size,
diff --git a/chrome/browser/renderer_host/video_layer_proxy.cc b/chrome/browser/renderer_host/video_layer_proxy.cc
new file mode 100644
index 0000000..0280def
--- /dev/null
+++ b/chrome/browser/renderer_host/video_layer_proxy.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2010 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 "chrome/browser/renderer_host/video_layer_proxy.h"
+
+#include "base/gfx/rect.h"
+#include "chrome/browser/gpu_process_host.h"
+#include "chrome/browser/renderer_host/render_process_host.h"
+#include "chrome/common/gpu_messages.h"
+
+VideoLayerProxy::VideoLayerProxy(RenderWidgetHost* widget,
+ const gfx::Size& size,
+ GpuProcessHost* process,
+ int32 routing_id)
+ : VideoLayer(widget, size),
+ process_(process),
+ routing_id_(routing_id) {
+ process_->AddRoute(routing_id_, this);
+}
+
+VideoLayerProxy::~VideoLayerProxy() {
+ process_->RemoveRoute(routing_id_);
+}
+
+void VideoLayerProxy::CopyTransportDIB(RenderProcessHost* process,
+ TransportDIB::Id bitmap,
+ const gfx::Rect& bitmap_rect) {
+ base::ProcessId process_id;
+#if defined(OS_WIN)
+ process_id = ::GetProcessId(process->GetHandle());
+#elif defined(OS_POSIX)
+ process_id = process->GetHandle();
+#endif
+
+ if (process_->Send(new GpuMsg_PaintToVideoLayer(
+ routing_id_, process_id, bitmap, bitmap_rect))) {
+ } else {
+ // TODO(scherkus): what to do ?!?!
+ }
+}
+
+void VideoLayerProxy::OnMessageReceived(const IPC::Message& msg) {
+ IPC_BEGIN_MESSAGE_MAP(VideoLayerProxy, msg)
+ IPC_MESSAGE_HANDLER(GpuHostMsg_PaintToVideoLayer_ACK,
+ OnPaintToVideoLayerACK)
+ IPC_END_MESSAGE_MAP_EX()
+}
+
+void VideoLayerProxy::OnChannelConnected(int32 peer_pid) {
+}
+
+void VideoLayerProxy::OnChannelError() {
+}
+
+void VideoLayerProxy::OnPaintToVideoLayerACK() {
+ // TODO(scherkus): we may not need to ACK video layer updates at all.
+ NOTIMPLEMENTED();
+}
diff --git a/chrome/browser/renderer_host/video_layer_proxy.h b/chrome/browser/renderer_host/video_layer_proxy.h
new file mode 100644
index 0000000..637525e
--- /dev/null
+++ b/chrome/browser/renderer_host/video_layer_proxy.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2010 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 CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_PROXY_H_
+#define CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_PROXY_H_
+
+#include "chrome/browser/renderer_host/video_layer.h"
+#include "ipc/ipc_channel.h"
+
+class GpuProcessHost;
+
+// Proxies YUV video layer data to the GPU process for rendering.
+class VideoLayerProxy : public VideoLayer, public IPC::Channel::Listener {
+ public:
+ VideoLayerProxy(RenderWidgetHost* widget, const gfx::Size& size,
+ GpuProcessHost* process, int32 routing_id);
+ virtual ~VideoLayerProxy();
+
+ // VideoLayer implementation.
+ virtual void CopyTransportDIB(RenderProcessHost* process,
+ TransportDIB::Id bitmap,
+ const gfx::Rect& bitmap_rect);
+
+ // IPC::Channel::Listener implementation.
+ virtual void OnMessageReceived(const IPC::Message& message);
+ virtual void OnChannelConnected(int32 peer_pid);
+ virtual void OnChannelError();
+
+ private:
+ // Called when GPU process has finished painting the video layer.
+ void OnPaintToVideoLayerACK();
+
+ // GPU process receiving our proxied requests.
+ GpuProcessHost* process_;
+
+ // IPC routing ID to use when communicating with the GPU process.
+ int32 routing_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(VideoLayerProxy);
+};
+
+#endif // CHROME_BROWSER_RENDERER_HOST_VIDEO_LAYER_PROXY_H_
diff --git a/chrome/browser/renderer_host/video_layer_x.h b/chrome/browser/renderer_host/video_layer_x.h
index fbe45cc..ef97f30 100644
--- a/chrome/browser/renderer_host/video_layer_x.h
+++ b/chrome/browser/renderer_host/video_layer_x.h
@@ -15,6 +15,7 @@ class VideoLayerX : public VideoLayer {
int depth);
virtual ~VideoLayerX();
+ // VideoLayer implementation.
virtual void CopyTransportDIB(RenderProcessHost* process,
TransportDIB::Id bitmap,
const gfx::Rect& bitmap_rect);
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index fa209a7..7efea0c 100755
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -615,6 +615,8 @@
'gpu/gpu_view_x.h',
'gpu/x_util.cc',
'gpu/x_util.h',
+ 'gpu/gpu_video_layer_glx.cc',
+ 'gpu/gpu_video_layer_glx.h',
],
'dependencies': [
'../gpu/gpu.gyp:gl_libs',
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 8aef43c..dc114ce 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1663,6 +1663,8 @@
'browser/renderer_host/translation_service.h',
'browser/renderer_host/video_layer.cc',
'browser/renderer_host/video_layer.h',
+ 'browser/renderer_host/video_layer_proxy.cc',
+ 'browser/renderer_host/video_layer_proxy.h',
'browser/renderer_host/video_layer_x.cc',
'browser/renderer_host/video_layer_x.h',
'browser/renderer_host/web_cache_manager.cc',
@@ -2326,6 +2328,8 @@
'browser/renderer_host/backing_store_proxy.h',
'browser/renderer_host/gpu_view_host.cc',
'browser/renderer_host/gpu_view_host.h',
+ 'browser/renderer_host/video_layer_proxy.cc',
+ 'browser/renderer_host/video_layer_proxy.h',
'browser/views/extensions/extension_shelf.cc',
'browser/views/extensions/extension_shelf.h',
'browser/views/extensions/extension_view.cc',
diff --git a/chrome/common/gpu_messages_internal.h b/chrome/common/gpu_messages_internal.h
index 76f264f..0581e4c 100644
--- a/chrome/common/gpu_messages_internal.h
+++ b/chrome/common/gpu_messages_internal.h
@@ -21,7 +21,12 @@ IPC_BEGIN_MESSAGES(Gpu)
// Creates a new backing store.
IPC_MESSAGE_ROUTED2(GpuMsg_NewBackingStore,
- int32, /* backing_store_id */
+ int32, /* backing_store_routing_id */
+ gfx::Size /* size */)
+
+ // Creates a new video layer.
+ IPC_MESSAGE_ROUTED2(GpuMsg_NewVideoLayer,
+ int32, /* video_layer_routing_id */
gfx::Size /* size */)
// Updates the backing store with the given bitmap. The GPU process will send
@@ -45,6 +50,14 @@ IPC_BEGIN_MESSAGES(Gpu)
// over the top.
IPC_MESSAGE_ROUTED0(GpuMsg_WindowPainted)
+ // Updates the video layer with the given YUV data. The GPU process will send
+ // back a GpuHostMsg_PaintToVideoLayer_ACK after the paint is complete to
+ // let the caller know the TransportDIB can be freed or reused.
+ IPC_MESSAGE_ROUTED3(GpuMsg_PaintToVideoLayer,
+ base::ProcessId, /* process */
+ TransportDIB::Id, /* bitmap */
+ gfx::Rect) /* bitmap_rect */
+
IPC_END_MESSAGES(Gpu)
//------------------------------------------------------------------------------
@@ -57,8 +70,10 @@ IPC_BEGIN_MESSAGES(GpuHost)
IPC_MESSAGE_ROUTED1(GpuHostMsg_CreatedRenderWidgetHostView,
gfx::NativeViewId)
- // Send in response to GpuMsg_PaintToBackingStore, see that for more.
+ // Sent in response to GpuMsg_PaintToBackingStore, see that for more.
IPC_MESSAGE_ROUTED0(GpuHostMsg_PaintToBackingStore_ACK)
-IPC_END_MESSAGES(GpuHost)
+ // Sent in response to GpuMsg_PaintToVideoLayer, see that for more.
+ IPC_MESSAGE_ROUTED0(GpuHostMsg_PaintToVideoLayer_ACK)
+IPC_END_MESSAGES(GpuHost)
diff --git a/chrome/gpu/gpu_video_layer_glx.cc b/chrome/gpu/gpu_video_layer_glx.cc
new file mode 100644
index 0000000..99b4ac6
--- /dev/null
+++ b/chrome/gpu/gpu_video_layer_glx.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2010 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 "chrome/gpu/gpu_video_layer_glx.h"
+
+#include "chrome/common/gpu_messages.h"
+#include "chrome/gpu/gpu_thread.h"
+
+GpuVideoLayerGLX::GpuVideoLayerGLX(GpuViewX* view,
+ GpuThread* gpu_thread,
+ int32 routing_id,
+ const gfx::Size& size)
+ : view_(view),
+ gpu_thread_(gpu_thread),
+ routing_id_(routing_id),
+ size_(size) {
+ gpu_thread_->AddRoute(routing_id_, this);
+}
+
+GpuVideoLayerGLX::~GpuVideoLayerGLX() {
+ gpu_thread_->RemoveRoute(routing_id_);
+}
+
+void GpuVideoLayerGLX::OnMessageReceived(const IPC::Message& msg) {
+ IPC_BEGIN_MESSAGE_MAP(GpuVideoLayerGLX, msg)
+ IPC_MESSAGE_HANDLER(GpuMsg_PaintToVideoLayer, OnPaintToVideoLayer)
+ IPC_END_MESSAGE_MAP_EX()
+}
+
+void GpuVideoLayerGLX::OnChannelConnected(int32 peer_pid) {
+}
+
+void GpuVideoLayerGLX::OnChannelError() {
+ // FIXME(brettw) does this mean we aren't getting any more messages and we
+ // should delete outselves?
+ NOTIMPLEMENTED();
+}
+
+void GpuVideoLayerGLX::OnPaintToVideoLayer(base::ProcessId source_process_id,
+ TransportDIB::Id id,
+ const gfx::Rect& bitmap_rect) {
+ // TODO(scherkus): implement GPU video layer.
+ NOTIMPLEMENTED();
+
+ // TODO(scherkus): we may not need to ACK video layer updates at all.
+ gpu_thread_->Send(new GpuHostMsg_PaintToVideoLayer_ACK(routing_id_));
+}
diff --git a/chrome/gpu/gpu_video_layer_glx.h b/chrome/gpu/gpu_video_layer_glx.h
new file mode 100644
index 0000000..772ff6f
--- /dev/null
+++ b/chrome/gpu/gpu_video_layer_glx.h
@@ -0,0 +1,46 @@
+// Copyright (c) 2010 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 CHROME_GPU_GPU_VIDEO_LAYER_GLX_H_
+#define CHROME_GPU_GPU_VIDEO_LAYER_GLX_H_
+
+#include "base/basictypes.h"
+#include "base/process.h"
+#include "chrome/common/transport_dib.h"
+#include "chrome/common/x11_util.h"
+#include "ipc/ipc_channel.h"
+
+class GpuViewX;
+class GpuThread;
+
+class GpuVideoLayerGLX : public IPC::Channel::Listener {
+ public:
+ GpuVideoLayerGLX(GpuViewX* view,
+ GpuThread* gpu_thread,
+ int32 routing_id,
+ const gfx::Size& size);
+ virtual ~GpuVideoLayerGLX();
+
+ const gfx::Size& size() const { return size_; }
+
+ // IPC::Channel::Listener implementation.
+ virtual void OnMessageReceived(const IPC::Message& message);
+ virtual void OnChannelConnected(int32 peer_pid);
+ virtual void OnChannelError();
+
+ private:
+ // Message handlers.
+ void OnPaintToVideoLayer(base::ProcessId source_process_id,
+ TransportDIB::Id id,
+ const gfx::Rect& bitmap_rect);
+
+ GpuViewX* view_;
+ GpuThread* gpu_thread_;
+ int32 routing_id_;
+ gfx::Size size_;
+
+ DISALLOW_COPY_AND_ASSIGN(GpuVideoLayerGLX);
+};
+
+#endif // CHROME_GPU_GPU_VIDEO_LAYER_GLX_H_
diff --git a/chrome/gpu/gpu_view_x.cc b/chrome/gpu/gpu_view_x.cc
index d52154a..3f698f4 100644
--- a/chrome/gpu/gpu_view_x.cc
+++ b/chrome/gpu/gpu_view_x.cc
@@ -9,6 +9,7 @@
#include "chrome/gpu/gpu_backing_store_glx.h"
#include "chrome/gpu/gpu_backing_store_glx_context.h"
#include "chrome/gpu/gpu_thread.h"
+#include "chrome/gpu/gpu_video_layer_glx.h"
// X stuff must be last since it does "#define Status int" which messes up some
// of the header files we indirectly pull in.
@@ -39,6 +40,7 @@ GLXContext GpuViewX::BindContext() {
void GpuViewX::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(GpuViewX, msg)
IPC_MESSAGE_HANDLER(GpuMsg_NewBackingStore, OnNewBackingStore)
+ IPC_MESSAGE_HANDLER(GpuMsg_NewVideoLayer, OnNewVideoLayer)
IPC_MESSAGE_HANDLER(GpuMsg_WindowPainted, OnWindowPainted)
IPC_END_MESSAGE_MAP_EX()
}
@@ -96,6 +98,11 @@ void GpuViewX::OnNewBackingStore(int32 routing_id, const gfx::Size& size) {
new GpuBackingStoreGLX(this, gpu_thread_, routing_id, size));
}
+void GpuViewX::OnNewVideoLayer(int32 routing_id, const gfx::Size& size) {
+ video_layer_.reset(
+ new GpuVideoLayerGLX(this, gpu_thread_, routing_id, size));
+}
+
void GpuViewX::OnWindowPainted() {
Repaint();
}
diff --git a/chrome/gpu/gpu_view_x.h b/chrome/gpu/gpu_view_x.h
index 4274f82..413548f 100644
--- a/chrome/gpu/gpu_view_x.h
+++ b/chrome/gpu/gpu_view_x.h
@@ -13,6 +13,7 @@
class GpuBackingStoreGLX;
class GpuThread;
+class GpuVideoLayerGLX;
namespace gfx {
class Rect;
@@ -45,6 +46,7 @@ class GpuViewX
private:
// IPC message handlers.
void OnNewBackingStore(int32 routing_id, const gfx::Size& size);
+ void OnNewVideoLayer(int32 routing_id, const gfx::Size& size);
void OnWindowPainted();
GpuThread* gpu_thread_;
@@ -54,6 +56,8 @@ class GpuViewX
scoped_ptr<GpuBackingStoreGLX> backing_store_;
+ scoped_ptr<GpuVideoLayerGLX> video_layer_;
+
DISALLOW_COPY_AND_ASSIGN(GpuViewX);
};