diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 21:53:50 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 21:53:50 +0000 |
commit | 246a7045b9c45620fd725210aac51322e611c83f (patch) | |
tree | 6bdce605ae758c282a2b27e92a6b223d98b8d46a /chrome/renderer/gpu_channel_host.h | |
parent | c3240722a63ff142684575e3ea4eb89915edae72 (diff) | |
download | chromium_src-246a7045b9c45620fd725210aac51322e611c83f.zip chromium_src-246a7045b9c45620fd725210aac51322e611c83f.tar.gz chromium_src-246a7045b9c45620fd725210aac51322e611c83f.tar.bz2 |
Added support for opening a GPU command buffer from a renderer processes through a GPU channel.
Probably only works in windows only so far.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/657046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40783 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/gpu_channel_host.h')
-rw-r--r-- | chrome/renderer/gpu_channel_host.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/chrome/renderer/gpu_channel_host.h b/chrome/renderer/gpu_channel_host.h new file mode 100644 index 0000000..00a6129 --- /dev/null +++ b/chrome/renderer/gpu_channel_host.h @@ -0,0 +1,77 @@ +// 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_RENDERER_GPU_CHANNEL_HOST_H_ +#define CHROME_RENDERER_GPU_CHANNEL_HOST_H_ + +#include <string> + +#include "base/hash_tables.h" +#include "chrome/common/message_router.h" +#include "ipc/ipc_channel.h" +#include "ipc/ipc_message.h" +#include "ipc/ipc_sync_channel.h" + +class CommandBufferProxy; + +// Encapsulates an IPC channel between the renderer and one plugin process. +// On the plugin side there's a corresponding GpuChannel. +class GpuChannelHost : public IPC::Channel::Listener, + public IPC::Message::Sender, + public base::RefCountedThreadSafe<GpuChannelHost> { + public: + enum State { + // Not yet connected. + UNCONNECTED, + // Ready to use. + CONNECTED, + // An error caused the host to become disconnected. Recreate channel to + // reestablish connection. + LOST + }; + + // Called on the render thread + GpuChannelHost(); + ~GpuChannelHost(); + + // Connect to GPU process channel. + void Connect(const std::string& channel_name); + + State state() const { return state_; } + + // Returns whether the channel to the GPU process is ready. + bool ready() const { return channel_.get() != NULL; } + + // IPC::Channel::Listener implementation: + virtual void OnMessageReceived(const IPC::Message& msg); + virtual void OnChannelConnected(int32 peer_pid); + virtual void OnChannelError(); + + // IPC::Message::Sender implementation: + virtual bool Send(IPC::Message* msg); + + // Create and connect to a command buffer in the GPU process. + CommandBufferProxy* CreateCommandBuffer(); + + // Destroy a command buffer created by this channel. + void DestroyCommandBuffer(CommandBufferProxy* command_buffer); + + private: + State state_; + + scoped_ptr<IPC::SyncChannel> channel_; + + // Used to implement message routing functionality to CommandBufferProxy + // objects + MessageRouter router_; + + // Keep track of all the registered CommandBufferProxies to + // inform about OnChannelError + typedef base::hash_map<int, IPC::Channel::Listener*> ProxyMap; + ProxyMap proxies_; + + DISALLOW_COPY_AND_ASSIGN(GpuChannelHost); +}; + +#endif // CHROME_RENDERER_GPU_CHANNEL_HOST_H_ |