Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: gpu/ipc/service/gpu_channel_manager.cc

Issue 1845563005: Refactor content/common/gpu into gpu/ipc/service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop ref to deleted content_tests_gypi_values.content_unittests_ozone_sources Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/ipc/service/gpu_channel_manager.h ('k') | gpu/ipc/service/gpu_channel_manager_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "gpu/ipc/service/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/location.h" 11 #include "base/location.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "content/common/gpu/gpu_channel.h"
16 #include "content/common/gpu/gpu_channel_manager_delegate.h"
17 #include "content/common/gpu/gpu_memory_buffer_factory.h"
18 #include "content/common/gpu/gpu_memory_manager.h"
19 #include "gpu/command_buffer/common/sync_token.h" 15 #include "gpu/command_buffer/common/sync_token.h"
20 #include "gpu/command_buffer/common/value_state.h" 16 #include "gpu/command_buffer/common/value_state.h"
21 #include "gpu/command_buffer/service/feature_info.h" 17 #include "gpu/command_buffer/service/feature_info.h"
22 #include "gpu/command_buffer/service/mailbox_manager.h" 18 #include "gpu/command_buffer/service/mailbox_manager.h"
23 #include "gpu/command_buffer/service/memory_program_cache.h" 19 #include "gpu/command_buffer/service/memory_program_cache.h"
24 #include "gpu/command_buffer/service/shader_translator_cache.h" 20 #include "gpu/command_buffer/service/shader_translator_cache.h"
25 #include "gpu/command_buffer/service/sync_point_manager.h" 21 #include "gpu/command_buffer/service/sync_point_manager.h"
26 #include "gpu/ipc/common/gpu_messages.h" 22 #include "gpu/ipc/common/gpu_messages.h"
23 #include "gpu/ipc/service/gpu_channel.h"
24 #include "gpu/ipc/service/gpu_channel_manager_delegate.h"
25 #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
26 #include "gpu/ipc/service/gpu_memory_manager.h"
27 #include "ui/gl/gl_bindings.h" 27 #include "ui/gl/gl_bindings.h"
28 #include "ui/gl/gl_share_group.h" 28 #include "ui/gl/gl_share_group.h"
29 29
30 namespace content { 30 namespace gpu {
31 31
32 namespace { 32 namespace {
33 #if defined(OS_ANDROID) 33 #if defined(OS_ANDROID)
34 // Amount of time we expect the GPU to stay powered up without being used. 34 // Amount of time we expect the GPU to stay powered up without being used.
35 const int kMaxGpuIdleTimeMs = 40; 35 const int kMaxGpuIdleTimeMs = 40;
36 // Maximum amount of time we keep pinging the GPU waiting for the client to 36 // Maximum amount of time we keep pinging the GPU waiting for the client to
37 // draw. 37 // draw.
38 const int kMaxKeepAliveTimeMs = 200; 38 const int kMaxKeepAliveTimeMs = 200;
39 #endif 39 #endif
40 40
41 } 41 }
42 42
43 GpuChannelManager::GpuChannelManager( 43 GpuChannelManager::GpuChannelManager(
44 const gpu::GpuPreferences& gpu_preferences, 44 const GpuPreferences& gpu_preferences,
45 GpuChannelManagerDelegate* delegate, 45 GpuChannelManagerDelegate* delegate,
46 GpuWatchdog* watchdog, 46 GpuWatchdog* watchdog,
47 base::SingleThreadTaskRunner* task_runner, 47 base::SingleThreadTaskRunner* task_runner,
48 base::SingleThreadTaskRunner* io_task_runner, 48 base::SingleThreadTaskRunner* io_task_runner,
49 base::WaitableEvent* shutdown_event, 49 base::WaitableEvent* shutdown_event,
50 gpu::SyncPointManager* sync_point_manager, 50 SyncPointManager* sync_point_manager,
51 GpuMemoryBufferFactory* gpu_memory_buffer_factory) 51 GpuMemoryBufferFactory* gpu_memory_buffer_factory)
52 : task_runner_(task_runner), 52 : task_runner_(task_runner),
53 io_task_runner_(io_task_runner), 53 io_task_runner_(io_task_runner),
54 gpu_preferences_(gpu_preferences), 54 gpu_preferences_(gpu_preferences),
55 delegate_(delegate), 55 delegate_(delegate),
56 watchdog_(watchdog), 56 watchdog_(watchdog),
57 shutdown_event_(shutdown_event), 57 shutdown_event_(shutdown_event),
58 share_group_(new gfx::GLShareGroup), 58 share_group_(new gfx::GLShareGroup),
59 mailbox_manager_(gpu::gles2::MailboxManager::Create(gpu_preferences)), 59 mailbox_manager_(gles2::MailboxManager::Create(gpu_preferences)),
60 gpu_memory_manager_(this), 60 gpu_memory_manager_(this),
61 sync_point_manager_(sync_point_manager), 61 sync_point_manager_(sync_point_manager),
62 sync_point_client_waiter_( 62 sync_point_client_waiter_(
63 sync_point_manager->CreateSyncPointClientWaiter()), 63 sync_point_manager->CreateSyncPointClientWaiter()),
64 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), 64 gpu_memory_buffer_factory_(gpu_memory_buffer_factory),
65 weak_factory_(this) { 65 weak_factory_(this) {
66 DCHECK(task_runner); 66 DCHECK(task_runner);
67 DCHECK(io_task_runner); 67 DCHECK(io_task_runner);
68 if (gpu_preferences_.ui_prioritize_in_gpu_process) 68 if (gpu_preferences_.ui_prioritize_in_gpu_process)
69 preemption_flag_ = new gpu::PreemptionFlag; 69 preemption_flag_ = new PreemptionFlag;
70 } 70 }
71 71
72 GpuChannelManager::~GpuChannelManager() { 72 GpuChannelManager::~GpuChannelManager() {
73 // Destroy channels before anything else because of dependencies. 73 // Destroy channels before anything else because of dependencies.
74 gpu_channels_.clear(); 74 gpu_channels_.clear();
75 if (default_offscreen_surface_.get()) { 75 if (default_offscreen_surface_.get()) {
76 default_offscreen_surface_->Destroy(); 76 default_offscreen_surface_->Destroy();
77 default_offscreen_surface_ = NULL; 77 default_offscreen_surface_ = NULL;
78 } 78 }
79 } 79 }
80 80
81 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { 81 gles2::ProgramCache* GpuChannelManager::program_cache() {
82 if (!program_cache_.get() && 82 if (!program_cache_.get() &&
83 (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary || 83 (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary ||
84 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) && 84 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) &&
85 !gpu_preferences_.disable_gpu_program_cache) { 85 !gpu_preferences_.disable_gpu_program_cache) {
86 program_cache_.reset(new gpu::gles2::MemoryProgramCache( 86 program_cache_.reset(new gles2::MemoryProgramCache(
87 gpu_preferences_.gpu_program_cache_size, 87 gpu_preferences_.gpu_program_cache_size,
88 gpu_preferences_.disable_gpu_shader_disk_cache)); 88 gpu_preferences_.disable_gpu_shader_disk_cache));
89 } 89 }
90 return program_cache_.get(); 90 return program_cache_.get();
91 } 91 }
92 92
93 gpu::gles2::ShaderTranslatorCache* 93 gles2::ShaderTranslatorCache*
94 GpuChannelManager::shader_translator_cache() { 94 GpuChannelManager::shader_translator_cache() {
95 if (!shader_translator_cache_.get()) { 95 if (!shader_translator_cache_.get()) {
96 shader_translator_cache_ = 96 shader_translator_cache_ =
97 new gpu::gles2::ShaderTranslatorCache(gpu_preferences_); 97 new gles2::ShaderTranslatorCache(gpu_preferences_);
98 } 98 }
99 return shader_translator_cache_.get(); 99 return shader_translator_cache_.get();
100 } 100 }
101 101
102 gpu::gles2::FramebufferCompletenessCache* 102 gles2::FramebufferCompletenessCache*
103 GpuChannelManager::framebuffer_completeness_cache() { 103 GpuChannelManager::framebuffer_completeness_cache() {
104 if (!framebuffer_completeness_cache_.get()) 104 if (!framebuffer_completeness_cache_.get())
105 framebuffer_completeness_cache_ = 105 framebuffer_completeness_cache_ =
106 new gpu::gles2::FramebufferCompletenessCache; 106 new gles2::FramebufferCompletenessCache;
107 return framebuffer_completeness_cache_.get(); 107 return framebuffer_completeness_cache_.get();
108 } 108 }
109 109
110 void GpuChannelManager::RemoveChannel(int client_id) { 110 void GpuChannelManager::RemoveChannel(int client_id) {
111 delegate_->DidDestroyChannel(client_id); 111 delegate_->DidDestroyChannel(client_id);
112 gpu_channels_.erase(client_id); 112 gpu_channels_.erase(client_id);
113 } 113 }
114 114
115 #if defined(OS_MACOSX) 115 #if defined(OS_MACOSX)
116 void GpuChannelManager::AddBufferPresentedCallback( 116 void GpuChannelManager::AddBufferPresentedCallback(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 void GpuChannelManager::InternalDestroyGpuMemoryBufferOnIO( 181 void GpuChannelManager::InternalDestroyGpuMemoryBufferOnIO(
182 gfx::GpuMemoryBufferId id, 182 gfx::GpuMemoryBufferId id,
183 int client_id) { 183 int client_id) {
184 gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(id, client_id); 184 gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(id, client_id);
185 } 185 }
186 186
187 void GpuChannelManager::DestroyGpuMemoryBuffer( 187 void GpuChannelManager::DestroyGpuMemoryBuffer(
188 gfx::GpuMemoryBufferId id, 188 gfx::GpuMemoryBufferId id,
189 int client_id, 189 int client_id,
190 const gpu::SyncToken& sync_token) { 190 const SyncToken& sync_token) {
191 if (sync_token.HasData()) { 191 if (sync_token.HasData()) {
192 scoped_refptr<gpu::SyncPointClientState> release_state = 192 scoped_refptr<SyncPointClientState> release_state =
193 sync_point_manager()->GetSyncPointClientState( 193 sync_point_manager()->GetSyncPointClientState(
194 sync_token.namespace_id(), sync_token.command_buffer_id()); 194 sync_token.namespace_id(), sync_token.command_buffer_id());
195 if (release_state) { 195 if (release_state) {
196 sync_point_client_waiter_->WaitOutOfOrder( 196 sync_point_client_waiter_->WaitOutOfOrder(
197 release_state.get(), sync_token.release_count(), 197 release_state.get(), sync_token.release_count(),
198 base::Bind(&GpuChannelManager::InternalDestroyGpuMemoryBuffer, 198 base::Bind(&GpuChannelManager::InternalDestroyGpuMemoryBuffer,
199 base::Unretained(this), id, client_id)); 199 base::Unretained(this), id, client_id));
200 return; 200 return;
201 } 201 }
202 } 202 }
203 203
204 // No sync token or invalid sync token, destroy immediately. 204 // No sync token or invalid sync token, destroy immediately.
205 InternalDestroyGpuMemoryBuffer(id, client_id); 205 InternalDestroyGpuMemoryBuffer(id, client_id);
206 } 206 }
207 207
208 void GpuChannelManager::UpdateValueState(int client_id, 208 void GpuChannelManager::UpdateValueState(int client_id,
209 unsigned int target, 209 unsigned int target,
210 const gpu::ValueState& state) { 210 const ValueState& state) {
211 // Only pass updated state to the channel corresponding to the 211 // Only pass updated state to the channel corresponding to the
212 // render_widget_host where the event originated. 212 // render_widget_host where the event originated.
213 auto it = gpu_channels_.find(client_id); 213 auto it = gpu_channels_.find(client_id);
214 if (it != gpu_channels_.end()) 214 if (it != gpu_channels_.end())
215 it->second->HandleUpdateValueState(target, state); 215 it->second->HandleUpdateValueState(target, state);
216 } 216 }
217 217
218 void GpuChannelManager::PopulateShaderCache(const std::string& program_proto) { 218 void GpuChannelManager::PopulateShaderCache(const std::string& program_proto) {
219 if (program_cache()) 219 if (program_cache())
220 program_cache()->LoadProgram(program_proto); 220 program_cache()->LoadProgram(program_proto);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 break; 299 break;
300 } 300 }
301 } 301 }
302 if (!stub || !stub->decoder()->MakeCurrent()) 302 if (!stub || !stub->decoder()->MakeCurrent())
303 return; 303 return;
304 glFinish(); 304 glFinish();
305 DidAccessGpu(); 305 DidAccessGpu();
306 } 306 }
307 #endif 307 #endif
308 308
309 } // namespace content 309 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/service/gpu_channel_manager.h ('k') | gpu/ipc/service/gpu_channel_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698