| 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 GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_ | 5 #ifndef GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_ |
| 6 #define GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_ | 6 #define GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/containers/scoped_ptr_hash_map.h" | 15 #include "base/containers/scoped_ptr_hash_map.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "gpu/command_buffer/common/constants.h" | 20 #include "gpu/command_buffer/common/constants.h" |
| 21 #include "gpu/gpu_export.h" | 21 #include "gpu/gpu_export.h" |
| 22 #include "gpu/ipc/service/gpu_memory_manager.h" | 22 #include "gpu/ipc/service/gpu_memory_manager.h" |
| 23 #include "ui/gfx/gpu_memory_buffer.h" | 23 #include "ui/gfx/gpu_memory_buffer.h" |
| 24 #include "ui/gfx/native_widget_types.h" | 24 #include "ui/gfx/native_widget_types.h" |
| 25 #include "ui/gl/gl_surface.h" | 25 #include "ui/gl/gl_surface.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 #if defined(OS_ANDROID) | 146 #if defined(OS_ANDROID) |
| 147 void DidAccessGpu(); | 147 void DidAccessGpu(); |
| 148 #endif | 148 #endif |
| 149 | 149 |
| 150 bool is_exiting_for_lost_context() { | 150 bool is_exiting_for_lost_context() { |
| 151 return exiting_for_lost_context_; | 151 return exiting_for_lost_context_; |
| 152 } | 152 } |
| 153 | 153 |
| 154 protected: | 154 protected: |
| 155 virtual scoped_ptr<GpuChannel> CreateGpuChannel( | 155 virtual std::unique_ptr<GpuChannel> CreateGpuChannel( |
| 156 int client_id, | 156 int client_id, |
| 157 uint64_t client_tracing_id, | 157 uint64_t client_tracing_id, |
| 158 bool preempts, | 158 bool preempts, |
| 159 bool allow_view_command_buffers, | 159 bool allow_view_command_buffers, |
| 160 bool allow_real_time_streams); | 160 bool allow_real_time_streams); |
| 161 | 161 |
| 162 SyncPointManager* sync_point_manager() const { | 162 SyncPointManager* sync_point_manager() const { |
| 163 return sync_point_manager_; | 163 return sync_point_manager_; |
| 164 } | 164 } |
| 165 | 165 |
| 166 gfx::GLShareGroup* share_group() const { return share_group_.get(); } | 166 gfx::GLShareGroup* share_group() const { return share_group_.get(); } |
| 167 gles2::MailboxManager* mailbox_manager() const { | 167 gles2::MailboxManager* mailbox_manager() const { |
| 168 return mailbox_manager_.get(); | 168 return mailbox_manager_.get(); |
| 169 } | 169 } |
| 170 PreemptionFlag* preemption_flag() const { | 170 PreemptionFlag* preemption_flag() const { |
| 171 return preemption_flag_.get(); | 171 return preemption_flag_.get(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 174 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 175 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 175 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 176 | 176 |
| 177 // These objects manage channels to individual renderer processes there is | 177 // These objects manage channels to individual renderer processes there is |
| 178 // one channel for each renderer process that has connected to this GPU | 178 // one channel for each renderer process that has connected to this GPU |
| 179 // process. | 179 // process. |
| 180 base::ScopedPtrHashMap<int32_t, scoped_ptr<GpuChannel>> gpu_channels_; | 180 base::ScopedPtrHashMap<int32_t, std::unique_ptr<GpuChannel>> gpu_channels_; |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 void InternalDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id); | 183 void InternalDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id); |
| 184 void InternalDestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, | 184 void InternalDestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, |
| 185 int client_id); | 185 int client_id); |
| 186 #if defined(OS_ANDROID) | 186 #if defined(OS_ANDROID) |
| 187 void ScheduleWakeUpGpu(); | 187 void ScheduleWakeUpGpu(); |
| 188 void DoWakeUpGpu(); | 188 void DoWakeUpGpu(); |
| 189 #endif | 189 #endif |
| 190 | 190 |
| 191 const GpuPreferences& gpu_preferences_; | 191 const GpuPreferences& gpu_preferences_; |
| 192 | 192 |
| 193 GpuChannelManagerDelegate* const delegate_; | 193 GpuChannelManagerDelegate* const delegate_; |
| 194 #if defined(OS_MACOSX) | 194 #if defined(OS_MACOSX) |
| 195 base::hash_map<int32_t, BufferPresentedCallback> | 195 base::hash_map<int32_t, BufferPresentedCallback> |
| 196 buffer_presented_callback_map_; | 196 buffer_presented_callback_map_; |
| 197 #endif | 197 #endif |
| 198 | 198 |
| 199 GpuWatchdog* watchdog_; | 199 GpuWatchdog* watchdog_; |
| 200 | 200 |
| 201 base::WaitableEvent* shutdown_event_; | 201 base::WaitableEvent* shutdown_event_; |
| 202 | 202 |
| 203 scoped_refptr<gfx::GLShareGroup> share_group_; | 203 scoped_refptr<gfx::GLShareGroup> share_group_; |
| 204 scoped_refptr<gles2::MailboxManager> mailbox_manager_; | 204 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
| 205 scoped_refptr<PreemptionFlag> preemption_flag_; | 205 scoped_refptr<PreemptionFlag> preemption_flag_; |
| 206 GpuMemoryManager gpu_memory_manager_; | 206 GpuMemoryManager gpu_memory_manager_; |
| 207 // SyncPointManager guaranteed to outlive running MessageLoop. | 207 // SyncPointManager guaranteed to outlive running MessageLoop. |
| 208 SyncPointManager* sync_point_manager_; | 208 SyncPointManager* sync_point_manager_; |
| 209 scoped_ptr<SyncPointClient> sync_point_client_waiter_; | 209 std::unique_ptr<SyncPointClient> sync_point_client_waiter_; |
| 210 scoped_ptr<gles2::ProgramCache> program_cache_; | 210 std::unique_ptr<gles2::ProgramCache> program_cache_; |
| 211 scoped_refptr<gles2::ShaderTranslatorCache> shader_translator_cache_; | 211 scoped_refptr<gles2::ShaderTranslatorCache> shader_translator_cache_; |
| 212 scoped_refptr<gles2::FramebufferCompletenessCache> | 212 scoped_refptr<gles2::FramebufferCompletenessCache> |
| 213 framebuffer_completeness_cache_; | 213 framebuffer_completeness_cache_; |
| 214 scoped_refptr<gfx::GLSurface> default_offscreen_surface_; | 214 scoped_refptr<gfx::GLSurface> default_offscreen_surface_; |
| 215 GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; | 215 GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; |
| 216 #if defined(OS_ANDROID) | 216 #if defined(OS_ANDROID) |
| 217 // Last time we know the GPU was powered on. Global for tracking across all | 217 // Last time we know the GPU was powered on. Global for tracking across all |
| 218 // transport surfaces. | 218 // transport surfaces. |
| 219 base::TimeTicks last_gpu_access_time_; | 219 base::TimeTicks last_gpu_access_time_; |
| 220 base::TimeTicks begin_wake_up_time_; | 220 base::TimeTicks begin_wake_up_time_; |
| 221 #endif | 221 #endif |
| 222 | 222 |
| 223 // Set during intentional GPU process shutdown. | 223 // Set during intentional GPU process shutdown. |
| 224 bool exiting_for_lost_context_; | 224 bool exiting_for_lost_context_; |
| 225 | 225 |
| 226 // Member variables should appear before the WeakPtrFactory, to ensure | 226 // Member variables should appear before the WeakPtrFactory, to ensure |
| 227 // that any WeakPtrs to Controller are invalidated before its members | 227 // that any WeakPtrs to Controller are invalidated before its members |
| 228 // variable's destructors are executed, rendering them invalid. | 228 // variable's destructors are executed, rendering them invalid. |
| 229 base::WeakPtrFactory<GpuChannelManager> weak_factory_; | 229 base::WeakPtrFactory<GpuChannelManager> weak_factory_; |
| 230 | 230 |
| 231 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); | 231 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); |
| 232 }; | 232 }; |
| 233 | 233 |
| 234 } // namespace gpu | 234 } // namespace gpu |
| 235 | 235 |
| 236 #endif // GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_ | 236 #endif // GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_ |
| OLD | NEW |