summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gpu_process_host.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-13 00:55:37 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-13 00:55:37 +0000
commitc0fc094f4b95fc55baace5d1452b6110f68cf167 (patch)
tree16dc1253142393c4325055ef69971fa4f91187f0 /chrome/browser/gpu_process_host.cc
parentf0c7a263de099efa75d9f4122c16c0c0fcaa9677 (diff)
downloadchromium_src-c0fc094f4b95fc55baace5d1452b6110f68cf167.zip
chromium_src-c0fc094f4b95fc55baace5d1452b6110f68cf167.tar.gz
chromium_src-c0fc094f4b95fc55baace5d1452b6110f68cf167.tar.bz2
Add the ability for the GPU process to be used to paint the backing store of a
tab. This is the first pass and is currently a bit buggy and incomplete. This patch refactors the backing store to make it a virtual interface which is then implemented by the platform-specific backing stores. This cleans up the multi-platform aspects of the old code, and also makes it possible to create different backing stores (such as ones in another process). This renames the BackingStore::PaintRect function to PaintToBackingStore which clears up what it does. I would often get confused and think that it paints the backing store to the screen. This makes a common way to capture backing store information and adds it to the backing store API. This removed a bunch of ugly ifdefs. This adds the ability for a backing store to specify that the TransportDIB should not be freed by RenderWidgetHost when painting is complete. This is necessary since the out-of-process version needs to use it after the RenderWidget paint function has returned. This pushes up the vector of copy_rect from RenderWidgetHost to the actual BackingStores. This prevents us from sending duplicate data over IPC. It also makes the common non-IPC case more efficient, since we end up setting up various surfaces only once when there are multiple update rects. BUG=none TEST=none Review URL: http://codereview.chromium.org/523028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gpu_process_host.cc')
-rw-r--r--chrome/browser/gpu_process_host.cc113
1 files changed, 113 insertions, 0 deletions
diff --git a/chrome/browser/gpu_process_host.cc b/chrome/browser/gpu_process_host.cc
new file mode 100644
index 0000000..905f5c7
--- /dev/null
+++ b/chrome/browser/gpu_process_host.cc
@@ -0,0 +1,113 @@
+// 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/gpu_process_host.h"
+
+#include "base/command_line.h"
+#include "base/singleton.h"
+#include "base/thread.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/child_process_launcher.h"
+#include "chrome/common/child_process_host.h"
+#include "chrome/common/child_process_info.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/gpu_messages.h"
+#include "ipc/ipc_switches.h"
+
+GpuProcessHost::GpuProcessHost() : last_routing_id_(1) {
+ FilePath exe_path = ChildProcessHost::GetChildPath();
+ if (exe_path.empty())
+ return;
+
+ std::string channel_id = ChildProcessInfo::GenerateRandomChannelID(this);
+ channel_.reset(new IPC::ChannelProxy(
+ channel_id,
+ IPC::Channel::MODE_SERVER,
+ this,
+ NULL, // No filter (for now).
+ g_browser_process->io_thread()->message_loop()));
+
+ CommandLine* cmd_line = new CommandLine(exe_path);
+ cmd_line->AppendSwitchWithValue(switches::kProcessType,
+ switches::kGpuProcess);
+ cmd_line->AppendSwitchWithValue(switches::kProcessChannelID,
+ ASCIIToWide(channel_id));
+
+ // Spawn the child process asynchronously to avoid blocking the UI thread.
+ child_process_.reset(new ChildProcessLauncher(
+#if defined(OS_WIN)
+ FilePath(),
+#elif defined(POSIX)
+ base::environment_vector(),
+ channel_->GetClientFileDescriptor(),
+#endif
+ cmd_line,
+ this));
+}
+
+GpuProcessHost::~GpuProcessHost() {
+}
+
+// static
+GpuProcessHost* GpuProcessHost::Get() {
+ GpuProcessHost* host = Singleton<GpuProcessHost>::get();
+ if (!host->child_process_.get())
+ return NULL; // Failed to init.
+ return host;
+}
+
+int32 GpuProcessHost::GetNextRoutingId() {
+ return ++last_routing_id_;
+}
+
+int32 GpuProcessHost::NewRenderWidgetHostView(gfx::NativeViewId parent) {
+ int32 routing_id = GetNextRoutingId();
+ Send(new GpuMsg_NewRenderWidgetHostView(parent, routing_id));
+ return routing_id;
+}
+
+bool GpuProcessHost::Send(IPC::Message* msg) {
+ if (!channel_.get()) {
+ delete msg;
+ return false;
+ }
+
+ if (child_process_.get() && child_process_->IsStarting()) {
+ queued_messages_.push(msg);
+ return true;
+ }
+
+ return channel_->Send(msg);
+}
+
+void GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
+ if (message.routing_id() == MSG_ROUTING_CONTROL) {
+ // We don't currently have any control messages.
+ // OnControlMessageReceived(message);
+ } else {
+ router_.OnMessageReceived(message);
+ }
+}
+
+void GpuProcessHost::OnChannelConnected(int32 peer_pid) {
+}
+
+void GpuProcessHost::OnChannelError() {
+}
+
+void GpuProcessHost::OnProcessLaunched() {
+ while (!queued_messages_.empty()) {
+ Send(queued_messages_.front());
+ queued_messages_.pop();
+ }
+}
+
+void GpuProcessHost::AddRoute(int32 routing_id,
+ IPC::Channel::Listener* listener) {
+ router_.AddRoute(routing_id, listener);
+}
+
+void GpuProcessHost::RemoveRoute(int32 routing_id) {
+ router_.RemoveRoute(routing_id);
+}