diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-21 23:22:04 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-21 23:22:04 +0000 |
commit | 7a31f7c62d9998d28e79bb86f3805f3fe64205f0 (patch) | |
tree | 3faa940b7b51357549fceaf666f26606ced0cff9 /content/gpu/gpu_render_thread.h | |
parent | 53c607c59c37f81db4611d0fdd42b0f2d8869e86 (diff) | |
download | chromium_src-7a31f7c62d9998d28e79bb86f3805f3fe64205f0.zip chromium_src-7a31f7c62d9998d28e79bb86f3805f3fe64205f0.tar.gz chromium_src-7a31f7c62d9998d28e79bb86f3805f3fe64205f0.tar.bz2 |
This is a thread that runs in the browser process that can issue GL calls without going via a command buffer. It is for rendering the browser's chrome, basic compositing, etc. It is not for rendering arbitrary content from, for example, WebGL.
It is only enabled with --single-process or --in-process-gpu, the latter only running the GPU "process" as a thread inside the browser process.
Eventually, the plan is to add strict validation to ensure it can only run basic white-listed shaders and other restrictions so that the browser's GPU thread can be made available to the renderers' compositors without a command line switch.
I split GpuThread into two new classes. GpuChildThread derives from ChildThread and contains stuff that should only happen in a standalone process. I included GPUInfo collection here because if the browser should never need to run that.
GpuRenderThread contains stuff that is also needed in the browser process.
The GPU thread does not use an IPC channel within the browser process. It still uses IPC messages but posts them directly between message loops.
I changed the EstablishGpuChannel messages between the browser and GPU process to not deal with returning the GPUInfo. Now the GPU process just sends it as the first thing it does after handling its Init message. This was to allow the separation of GPUInfo collection (in GpuChildThread) and channel establishment (in GpuRenderThread).
TEST=trybots, run webgl with no switches, --single-process and --in-process-gpu, check browser terminates cleanly in all cases.
BUG=none
Review URL: http://codereview.chromium.org/6677055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78945 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/gpu/gpu_render_thread.h')
-rw-r--r-- | content/gpu/gpu_render_thread.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/content/gpu/gpu_render_thread.h b/content/gpu/gpu_render_thread.h new file mode 100644 index 0000000..9f6287e --- /dev/null +++ b/content/gpu/gpu_render_thread.h @@ -0,0 +1,91 @@ +// 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_GPU_GPU_RENDER_THREAD_H_ +#define CONTENT_GPU_GPU_RENDER_THREAD_H_ +#pragma once + +#include <string> + +#include "base/basictypes.h" +#include "base/hash_tables.h" +#include "base/command_line.h" +#include "base/ref_counted.h" +#include "base/scoped_ptr.h" +#include "base/time.h" +#include "build/build_config.h" +#include "content/common/child_thread.h" +#include "content/common/gpu_info.h" +#include "content/gpu/gpu_channel.h" +#include "content/gpu/gpu_config.h" +#include "content/gpu/x_util.h" +#include "ipc/ipc_channel.h" +#include "ipc/ipc_message.h" +#include "ui/gfx/native_widget_types.h" + +namespace IPC { +struct ChannelHandle; +} + +// A GpuRenderThread is a thread responsible for issuing rendering commands to +// a GPU. There is currently only one per GPU process. This might change. Assume +// there are many, all running on different threads. +// +// A GpuRenderThread can also be hosted in the browser process in single process +// or in-process GPU modes. In this case there is no corresponding +// GpuChildThread and this is the reason the GpuChildThread is referenced via +// a pointer to IPC::Message::Sender, which can be implemented by other hosts +// to send IPC messages to the browser process IO thread on the +// GpuRenderThread's behalf. +class GpuRenderThread : public IPC::Channel::Listener, + public IPC::Message::Sender { + public: + GpuRenderThread(IPC::Message::Sender* browser_channel, + MessageLoop* io_message_loop, + base::WaitableEvent* shutdown_event); + ~GpuRenderThread(); + + // Remove the channel for a particular renderer. + void RemoveChannel(int renderer_id); + + // Listener overrides. + virtual bool OnMessageReceived(const IPC::Message& msg); + + // Sender overrides. + virtual bool Send(IPC::Message* msg); + + private: + // Message handlers. + void OnEstablishChannel(int renderer_id); + void OnCloseChannel(const IPC::ChannelHandle& channel_handle); + void OnSynchronize(); + void OnCreateViewCommandBuffer( + gfx::PluginWindowHandle window, + int32 render_view_id, + int32 renderer_id, + const GPUCreateCommandBufferConfig& init_params); +#if defined(OS_MACOSX) + void OnAcceleratedSurfaceBuffersSwappedACK( + int renderer_id, int32 route_id, uint64 swap_buffers_count); + void OnDestroyCommandBuffer(int renderer_id, int32 renderer_view_id); +#endif + + MessageLoop* io_message_loop_; + base::WaitableEvent* shutdown_event_; + + // Either an IPC channel to the browser or, if the GpuRenderThread is + // running in the browser process, a Sender implementation that will post + // IPC messages to the UI thread. + IPC::Message::Sender* browser_channel_; + + // These objects manage channels to individual renderer processes there is + // one channel for each renderer process that has connected to this GPU + // process. + typedef base::hash_map<int, scoped_refptr<GpuChannel> > GpuChannelMap; + GpuChannelMap gpu_channels_; + + DISALLOW_COPY_AND_ASSIGN(GpuRenderThread); +}; + +#endif // CONTENT_GPU_GPU_RENDER_THREAD_H_ |