| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_GPU_GPU_RENDER_THREAD_H_ | |
| 6 #define CONTENT_GPU_GPU_RENDER_THREAD_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/hash_tables.h" | |
| 13 #include "base/command_line.h" | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/time.h" | |
| 17 #include "build/build_config.h" | |
| 18 #include "content/common/child_thread.h" | |
| 19 #include "content/common/gpu_info.h" | |
| 20 #include "content/gpu/gpu_channel.h" | |
| 21 #include "content/gpu/gpu_config.h" | |
| 22 #include "content/gpu/x_util.h" | |
| 23 #include "ipc/ipc_channel.h" | |
| 24 #include "ipc/ipc_message.h" | |
| 25 #include "ui/gfx/native_widget_types.h" | |
| 26 | |
| 27 namespace IPC { | |
| 28 struct ChannelHandle; | |
| 29 } | |
| 30 | |
| 31 // A GpuRenderThread is a thread responsible for issuing rendering commands to | |
| 32 // a GPU. There is currently only one per GPU process. This might change. Assume | |
| 33 // there are many, all running on different threads. | |
| 34 // | |
| 35 // A GpuRenderThread can also be hosted in the browser process in single process | |
| 36 // or in-process GPU modes. In this case there is no corresponding | |
| 37 // GpuChildThread and this is the reason the GpuChildThread is referenced via | |
| 38 // a pointer to IPC::Message::Sender, which can be implemented by other hosts | |
| 39 // to send IPC messages to the browser process IO thread on the | |
| 40 // GpuRenderThread's behalf. | |
| 41 class GpuRenderThread : public IPC::Channel::Listener, | |
| 42 public IPC::Message::Sender { | |
| 43 public: | |
| 44 GpuRenderThread(IPC::Message::Sender* browser_channel, | |
| 45 GpuWatchdogThread* gpu_watchdog_thread, | |
| 46 MessageLoop* io_message_loop, | |
| 47 base::WaitableEvent* shutdown_event); | |
| 48 ~GpuRenderThread(); | |
| 49 | |
| 50 // Remove the channel for a particular renderer. | |
| 51 void RemoveChannel(int renderer_id); | |
| 52 | |
| 53 // Listener overrides. | |
| 54 virtual bool OnMessageReceived(const IPC::Message& msg); | |
| 55 | |
| 56 // Sender overrides. | |
| 57 virtual bool Send(IPC::Message* msg); | |
| 58 | |
| 59 private: | |
| 60 // Message handlers. | |
| 61 void OnEstablishChannel(int renderer_id); | |
| 62 void OnCloseChannel(const IPC::ChannelHandle& channel_handle); | |
| 63 void OnSynchronize(); | |
| 64 void OnCreateViewCommandBuffer( | |
| 65 gfx::PluginWindowHandle window, | |
| 66 int32 render_view_id, | |
| 67 int32 renderer_id, | |
| 68 const GPUCreateCommandBufferConfig& init_params); | |
| 69 #if defined(OS_MACOSX) | |
| 70 void OnAcceleratedSurfaceBuffersSwappedACK( | |
| 71 int renderer_id, int32 route_id, uint64 swap_buffers_count); | |
| 72 void OnDestroyCommandBuffer(int renderer_id, int32 renderer_view_id); | |
| 73 #endif | |
| 74 | |
| 75 MessageLoop* io_message_loop_; | |
| 76 base::WaitableEvent* shutdown_event_; | |
| 77 | |
| 78 // Either an IPC channel to the browser or, if the GpuRenderThread is | |
| 79 // running in the browser process, a Sender implementation that will post | |
| 80 // IPC messages to the UI thread. | |
| 81 IPC::Message::Sender* browser_channel_; | |
| 82 | |
| 83 // These objects manage channels to individual renderer processes there is | |
| 84 // one channel for each renderer process that has connected to this GPU | |
| 85 // process. | |
| 86 typedef base::hash_map<int, scoped_refptr<GpuChannel> > GpuChannelMap; | |
| 87 GpuChannelMap gpu_channels_; | |
| 88 GpuWatchdogThread* watchdog_thread_; | |
| 89 | |
| 90 DISALLOW_COPY_AND_ASSIGN(GpuRenderThread); | |
| 91 }; | |
| 92 | |
| 93 #endif // CONTENT_GPU_GPU_RENDER_THREAD_H_ | |
| OLD | NEW |