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_child_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_child_thread.h')
-rw-r--r-- | content/gpu/gpu_child_thread.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/content/gpu/gpu_child_thread.h b/content/gpu/gpu_child_thread.h new file mode 100644 index 0000000..7f1350f --- /dev/null +++ b/content/gpu/gpu_child_thread.h @@ -0,0 +1,90 @@ +// 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_CHILD_THREAD_H_ +#define CONTENT_GPU_GPU_CHILD_THREAD_H_ +#pragma once + +#include <string> + +#include "base/basictypes.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/gpu_render_thread.h" +#include "content/gpu/x_util.h" +#include "ui/gfx/native_widget_types.h" + +namespace IPC { +struct ChannelHandle; +} + +namespace sandbox { +class TargetServices; +} + +class GpuWatchdogThread; + +// The main thread of the GPU child process. There will only ever be one of +// these per process. It does process initialization and shutdown. It forwards +// IPC messages to GpuRenderThread, which is responsible for issuing rendering +// commands to the GPU. +class GpuChildThread : public ChildThread { + public: +#if defined(OS_WIN) + explicit GpuChildThread(sandbox::TargetServices* target_services); +#else + GpuChildThread(); +#endif + + // For single-process mode. + explicit GpuChildThread(const std::string& channel_id); + + ~GpuChildThread(); + + void Init(const base::Time& process_start_time); + void StopWatchdog(); + + // ChildThread overrides. + virtual bool Send(IPC::Message* msg); + virtual bool OnControlMessageReceived(const IPC::Message& msg); + + private: + // Message handlers. + void OnInitialize(); + void OnCollectGraphicsInfo(); + void OnCrash(); + void OnHang(); + +#if defined(OS_WIN) + static void CollectDxDiagnostics(GpuChildThread* thread); + static void SetDxDiagnostics(GpuChildThread* thread, const DxDiagNode& node); +#endif + + base::Time process_start_time_; + scoped_refptr<GpuWatchdogThread> watchdog_thread_; + +#if defined(OS_WIN) + // Windows specific client sandbox interface. + sandbox::TargetServices* target_services_; + + // Indicates whether DirectX Diagnostics collection is ongoing. + bool collecting_dx_diagnostics_; +#endif + + scoped_ptr<GpuRenderThread> render_thread_; + + // Information about the GPU, such as device and vendor ID. + GPUInfo gpu_info_; + + DISALLOW_COPY_AND_ASSIGN(GpuChildThread); +}; + +#endif // CONTENT_GPU_GPU_CHILD_THREAD_H_ |