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