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 #include "content/common/gpu/gpu_channel_manager.h" | 5 #include "content/common/gpu/gpu_channel_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "content/common/gpu/establish_channel_params.h" | 16 #include "content/common/gpu/establish_channel_params.h" |
17 #include "content/common/gpu/gpu_channel.h" | 17 #include "content/common/gpu/gpu_channel.h" |
18 #include "content/common/gpu/gpu_channel_manager_delegate.h" | 18 #include "content/common/gpu/gpu_channel_manager_delegate.h" |
19 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 19 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
20 #include "content/common/gpu/gpu_memory_manager.h" | 20 #include "content/common/gpu/gpu_memory_manager.h" |
21 #include "content/common/gpu/gpu_messages.h" | 21 #include "content/common/gpu/gpu_messages.h" |
Fady Samuel
2016/02/25 16:26:33
You can probably delete this. I missed it in my pa
Peng
2016/02/25 17:13:22
Done.
| |
22 #include "content/common/gpu/image_transport_surface.h" | 22 #include "content/common/gpu/image_transport_surface.h" |
23 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
Fady Samuel
2016/02/25 16:26:33
Delete this.
Peng
2016/02/25 17:13:22
Done.
| |
24 #include "gpu/command_buffer/common/sync_token.h" | 24 #include "gpu/command_buffer/common/sync_token.h" |
25 #include "gpu/command_buffer/common/value_state.h" | 25 #include "gpu/command_buffer/common/value_state.h" |
26 #include "gpu/command_buffer/service/feature_info.h" | 26 #include "gpu/command_buffer/service/feature_info.h" |
27 #include "gpu/command_buffer/service/gpu_switches.h" | 27 #include "gpu/command_buffer/service/gpu_switches.h" |
28 #include "gpu/command_buffer/service/mailbox_manager.h" | 28 #include "gpu/command_buffer/service/mailbox_manager.h" |
29 #include "gpu/command_buffer/service/memory_program_cache.h" | 29 #include "gpu/command_buffer/service/memory_program_cache.h" |
30 #include "gpu/command_buffer/service/shader_translator_cache.h" | 30 #include "gpu/command_buffer/service/shader_translator_cache.h" |
31 #include "gpu/command_buffer/service/sync_point_manager.h" | 31 #include "gpu/command_buffer/service/sync_point_manager.h" |
32 #include "ipc/message_filter.h" | 32 #include "ipc/message_filter.h" |
33 #include "ipc/message_router.h" | 33 #include "ipc/message_router.h" |
Fady Samuel
2016/02/25 16:26:33
nit: you can probably delete these ipc includes. I
Peng
2016/02/25 17:13:22
Done.
| |
34 #include "ui/gl/gl_bindings.h" | 34 #include "ui/gl/gl_bindings.h" |
35 #include "ui/gl/gl_share_group.h" | 35 #include "ui/gl/gl_share_group.h" |
36 | 36 |
37 #if defined(OS_MACOSX) | 37 #if defined(OS_MACOSX) |
38 #include "content/common/gpu/buffer_presented_params_mac.h" | 38 #include "content/common/gpu/buffer_presented_params_mac.h" |
39 #endif | 39 #endif |
40 | 40 |
41 namespace content { | 41 namespace content { |
42 | 42 |
43 namespace { | 43 namespace { |
44 #if defined(OS_ANDROID) | 44 #if defined(OS_ANDROID) |
45 // Amount of time we expect the GPU to stay powered up without being used. | 45 // Amount of time we expect the GPU to stay powered up without being used. |
46 const int kMaxGpuIdleTimeMs = 40; | 46 const int kMaxGpuIdleTimeMs = 40; |
47 // Maximum amount of time we keep pinging the GPU waiting for the client to | 47 // Maximum amount of time we keep pinging the GPU waiting for the client to |
48 // draw. | 48 // draw. |
49 const int kMaxKeepAliveTimeMs = 200; | 49 const int kMaxKeepAliveTimeMs = 200; |
50 #endif | 50 #endif |
51 | 51 |
52 } | 52 } |
53 | 53 |
54 GpuChannelManager::GpuChannelManager( | 54 GpuChannelManager::GpuChannelManager( |
55 const gpu::GpuPreferences& gpu_preferences, | |
55 GpuChannelManagerDelegate* delegate, | 56 GpuChannelManagerDelegate* delegate, |
56 GpuWatchdog* watchdog, | 57 GpuWatchdog* watchdog, |
57 base::SingleThreadTaskRunner* task_runner, | 58 base::SingleThreadTaskRunner* task_runner, |
58 base::SingleThreadTaskRunner* io_task_runner, | 59 base::SingleThreadTaskRunner* io_task_runner, |
59 base::WaitableEvent* shutdown_event, | 60 base::WaitableEvent* shutdown_event, |
60 gpu::SyncPointManager* sync_point_manager, | 61 gpu::SyncPointManager* sync_point_manager, |
61 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 62 GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
62 : task_runner_(task_runner), | 63 : task_runner_(task_runner), |
63 io_task_runner_(io_task_runner), | 64 io_task_runner_(io_task_runner), |
65 gpu_preferences_(gpu_preferences), | |
64 delegate_(delegate), | 66 delegate_(delegate), |
65 watchdog_(watchdog), | 67 watchdog_(watchdog), |
66 shutdown_event_(shutdown_event), | 68 shutdown_event_(shutdown_event), |
67 share_group_(new gfx::GLShareGroup), | 69 share_group_(new gfx::GLShareGroup), |
68 mailbox_manager_(gpu::gles2::MailboxManager::Create()), | 70 mailbox_manager_(gpu::gles2::MailboxManager::Create(gpu_preferences)), |
69 gpu_memory_manager_(this), | 71 gpu_memory_manager_(this), |
70 sync_point_manager_(sync_point_manager), | 72 sync_point_manager_(sync_point_manager), |
71 sync_point_client_waiter_( | 73 sync_point_client_waiter_( |
72 sync_point_manager->CreateSyncPointClientWaiter()), | 74 sync_point_manager->CreateSyncPointClientWaiter()), |
73 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), | 75 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), |
74 weak_factory_(this) { | 76 weak_factory_(this) { |
75 DCHECK(task_runner); | 77 DCHECK(task_runner); |
76 DCHECK(io_task_runner); | 78 DCHECK(io_task_runner); |
77 const base::CommandLine* command_line = | 79 const base::CommandLine* command_line = |
78 base::CommandLine::ForCurrentProcess(); | 80 base::CommandLine::ForCurrentProcess(); |
79 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) | 81 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess)) |
80 preemption_flag_ = new gpu::PreemptionFlag; | 82 preemption_flag_ = new gpu::PreemptionFlag; |
81 } | 83 } |
82 | 84 |
83 GpuChannelManager::~GpuChannelManager() { | 85 GpuChannelManager::~GpuChannelManager() { |
84 // Destroy channels before anything else because of dependencies. | 86 // Destroy channels before anything else because of dependencies. |
85 gpu_channels_.clear(); | 87 gpu_channels_.clear(); |
86 if (default_offscreen_surface_.get()) { | 88 if (default_offscreen_surface_.get()) { |
87 default_offscreen_surface_->Destroy(); | 89 default_offscreen_surface_->Destroy(); |
88 default_offscreen_surface_ = NULL; | 90 default_offscreen_surface_ = NULL; |
89 } | 91 } |
90 } | 92 } |
91 | 93 |
92 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { | 94 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { |
93 if (!program_cache_.get() && | 95 if (!program_cache_.get() && |
94 (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary || | 96 (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary || |
95 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) && | 97 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) && |
96 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 98 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
97 switches::kDisableGpuProgramCache)) { | 99 switches::kDisableGpuProgramCache)) { |
98 program_cache_.reset(new gpu::gles2::MemoryProgramCache()); | 100 program_cache_.reset(new gpu::gles2::MemoryProgramCache( |
101 gpu_preferences_.gpu_program_cache_size, | |
102 gpu_preferences_.disable_gpu_shader_disk_cache)); | |
99 } | 103 } |
100 return program_cache_.get(); | 104 return program_cache_.get(); |
101 } | 105 } |
102 | 106 |
103 gpu::gles2::ShaderTranslatorCache* | 107 gpu::gles2::ShaderTranslatorCache* |
104 GpuChannelManager::shader_translator_cache() { | 108 GpuChannelManager::shader_translator_cache() { |
105 if (!shader_translator_cache_.get()) | 109 if (!shader_translator_cache_.get()) { |
106 shader_translator_cache_ = new gpu::gles2::ShaderTranslatorCache; | 110 shader_translator_cache_ = |
111 new gpu::gles2::ShaderTranslatorCache(gpu_preferences_); | |
112 } | |
107 return shader_translator_cache_.get(); | 113 return shader_translator_cache_.get(); |
108 } | 114 } |
109 | 115 |
110 gpu::gles2::FramebufferCompletenessCache* | 116 gpu::gles2::FramebufferCompletenessCache* |
111 GpuChannelManager::framebuffer_completeness_cache() { | 117 GpuChannelManager::framebuffer_completeness_cache() { |
112 if (!framebuffer_completeness_cache_.get()) | 118 if (!framebuffer_completeness_cache_.get()) |
113 framebuffer_completeness_cache_ = | 119 framebuffer_completeness_cache_ = |
114 new gpu::gles2::FramebufferCompletenessCache; | 120 new gpu::gles2::FramebufferCompletenessCache; |
115 return framebuffer_completeness_cache_.get(); | 121 return framebuffer_completeness_cache_.get(); |
116 } | 122 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 } | 314 } |
309 } | 315 } |
310 if (!stub || !stub->decoder()->MakeCurrent()) | 316 if (!stub || !stub->decoder()->MakeCurrent()) |
311 return; | 317 return; |
312 glFinish(); | 318 glFinish(); |
313 DidAccessGpu(); | 319 DidAccessGpu(); |
314 } | 320 } |
315 #endif | 321 #endif |
316 | 322 |
317 } // namespace content | 323 } // namespace content |
OLD | NEW |