| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
| 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/id_map.h" | 12 #include "base/id_map.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/process.h" | 16 #include "base/process.h" |
| 16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 17 #include "content/common/gpu/gpu_command_buffer_stub.h" | 18 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 18 #include "content/common/gpu/gpu_memory_manager.h" | 19 #include "content/common/gpu/gpu_memory_manager.h" |
| 19 #include "content/common/message_router.h" | 20 #include "content/common/message_router.h" |
| 20 #include "ipc/ipc_sync_channel.h" | 21 #include "ipc/ipc_sync_channel.h" |
| 21 #include "ui/gfx/native_widget_types.h" | 22 #include "ui/gfx/native_widget_types.h" |
| 22 #include "ui/gfx/size.h" | 23 #include "ui/gfx/size.h" |
| 23 #include "ui/gl/gl_share_group.h" | 24 #include "ui/gl/gl_share_group.h" |
| 24 #include "ui/gl/gpu_preference.h" | 25 #include "ui/gl/gpu_preference.h" |
| 25 | 26 |
| 26 class GpuChannelManager; | 27 class GpuChannelManager; |
| 27 struct GPUCreateCommandBufferConfig; | 28 struct GPUCreateCommandBufferConfig; |
| 28 class GpuWatchdog; | 29 class GpuWatchdog; |
| 29 | 30 |
| 30 namespace base { | 31 namespace base { |
| 31 class MessageLoopProxy; | 32 class MessageLoopProxy; |
| 32 class WaitableEvent; | 33 class WaitableEvent; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace gpu { | 36 namespace gpu { |
| 36 struct RefCountedCounter; | 37 struct RefCountedCounter; |
| 38 namespace gles2 { |
| 39 class ProgramCache; |
| 40 } |
| 37 } | 41 } |
| 38 | 42 |
| 39 // Encapsulates an IPC channel between the GPU process and one renderer | 43 // Encapsulates an IPC channel between the GPU process and one renderer |
| 40 // process. On the renderer side there's a corresponding GpuChannelHost. | 44 // process. On the renderer side there's a corresponding GpuChannelHost. |
| 41 class GpuChannel : public IPC::Listener, | 45 class GpuChannel : public IPC::Listener, |
| 42 public IPC::Sender, | 46 public IPC::Sender, |
| 43 public base::RefCountedThreadSafe<GpuChannel> { | 47 public base::RefCountedThreadSafe<GpuChannel> { |
| 44 public: | 48 public: |
| 45 // Takes ownership of the renderer process handle. | 49 // Takes ownership of the renderer process handle. |
| 46 GpuChannel(GpuChannelManager* gpu_channel_manager, | 50 GpuChannel(GpuChannelManager* gpu_channel_manager, |
| 47 GpuWatchdog* watchdog, | 51 GpuWatchdog* watchdog, |
| 48 gfx::GLShareGroup* share_group, | 52 gfx::GLShareGroup* share_group, |
| 49 gpu::gles2::MailboxManager* mailbox_manager, | 53 gpu::gles2::MailboxManager* mailbox_manager, |
| 50 int client_id, | 54 int client_id, |
| 51 bool software); | 55 bool software, |
| 56 gpu::gles2::ProgramCache* program_cache); |
| 52 | 57 |
| 53 bool Init(base::MessageLoopProxy* io_message_loop, | 58 bool Init(base::MessageLoopProxy* io_message_loop, |
| 54 base::WaitableEvent* shutdown_event); | 59 base::WaitableEvent* shutdown_event); |
| 55 | 60 |
| 56 // Get the GpuChannelManager that owns this channel. | 61 // Get the GpuChannelManager that owns this channel. |
| 57 GpuChannelManager* gpu_channel_manager() const { | 62 GpuChannelManager* gpu_channel_manager() const { |
| 58 return gpu_channel_manager_; | 63 return gpu_channel_manager_; |
| 59 } | 64 } |
| 60 | 65 |
| 61 // Returns the name of the associated IPC channel. | 66 // Returns the name of the associated IPC channel. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 const gfx::Size& size, | 136 const gfx::Size& size, |
| 132 const GPUCreateCommandBufferConfig& init_params, | 137 const GPUCreateCommandBufferConfig& init_params, |
| 133 IPC::Message* reply_message); | 138 IPC::Message* reply_message); |
| 134 void OnDestroyCommandBuffer(int32 route_id, IPC::Message* reply_message); | 139 void OnDestroyCommandBuffer(int32 route_id, IPC::Message* reply_message); |
| 135 | 140 |
| 136 // The lifetime of objects of this class is managed by a GpuChannelManager. | 141 // The lifetime of objects of this class is managed by a GpuChannelManager. |
| 137 // The GpuChannelManager destroy all the GpuChannels that they own when they | 142 // The GpuChannelManager destroy all the GpuChannels that they own when they |
| 138 // are destroyed. So a raw pointer is safe. | 143 // are destroyed. So a raw pointer is safe. |
| 139 GpuChannelManager* gpu_channel_manager_; | 144 GpuChannelManager* gpu_channel_manager_; |
| 140 | 145 |
| 146 gpu::gles2::ProgramCache* program_cache_; |
| 147 |
| 141 scoped_ptr<IPC::SyncChannel> channel_; | 148 scoped_ptr<IPC::SyncChannel> channel_; |
| 142 | 149 |
| 143 // Number of routed messages for pending processing on a stub. | 150 // Number of routed messages for pending processing on a stub. |
| 144 scoped_refptr<gpu::RefCountedCounter> unprocessed_messages_; | 151 scoped_refptr<gpu::RefCountedCounter> unprocessed_messages_; |
| 145 | 152 |
| 146 // If non-NULL, all stubs on this channel should stop processing GL | 153 // If non-NULL, all stubs on this channel should stop processing GL |
| 147 // commands (via their GpuScheduler) when preempt_by_counter_->count | 154 // commands (via their GpuScheduler) when preempt_by_counter_->count |
| 148 // is non-zero. | 155 // is non-zero. |
| 149 scoped_refptr<gpu::RefCountedCounter> preempt_by_counter_; | 156 scoped_refptr<gpu::RefCountedCounter> preempt_by_counter_; |
| 150 | 157 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 176 bool software_; | 183 bool software_; |
| 177 bool handle_messages_scheduled_; | 184 bool handle_messages_scheduled_; |
| 178 bool processed_get_state_fast_; | 185 bool processed_get_state_fast_; |
| 179 | 186 |
| 180 base::WeakPtrFactory<GpuChannel> weak_factory_; | 187 base::WeakPtrFactory<GpuChannel> weak_factory_; |
| 181 | 188 |
| 182 DISALLOW_COPY_AND_ASSIGN(GpuChannel); | 189 DISALLOW_COPY_AND_ASSIGN(GpuChannel); |
| 183 }; | 190 }; |
| 184 | 191 |
| 185 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 192 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
| OLD | NEW |