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

Side by Side Diff: content/common/gpu/gpu_channel_manager.cc

Issue 1716813002: Use GpuPreferences to avoid directly accessing switches in gpu related code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 9 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 | « content/common/gpu/gpu_channel_manager.h ('k') | content/common/gpu/gpu_channel_test_common.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 "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"
12 #include "base/location.h" 11 #include "base/location.h"
13 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
14 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
15 #include "build/build_config.h" 14 #include "build/build_config.h"
16 #include "content/common/gpu/establish_channel_params.h" 15 #include "content/common/gpu/establish_channel_params.h"
17 #include "content/common/gpu/gpu_channel.h" 16 #include "content/common/gpu/gpu_channel.h"
18 #include "content/common/gpu/gpu_channel_manager_delegate.h" 17 #include "content/common/gpu/gpu_channel_manager_delegate.h"
19 #include "content/common/gpu/gpu_memory_buffer_factory.h" 18 #include "content/common/gpu/gpu_memory_buffer_factory.h"
20 #include "content/common/gpu/gpu_memory_manager.h" 19 #include "content/common/gpu/gpu_memory_manager.h"
21 #include "content/common/gpu/gpu_messages.h" 20 #include "content/common/gpu/gpu_messages.h"
22 #include "content/common/gpu/image_transport_surface.h" 21 #include "content/common/gpu/image_transport_surface.h"
23 #include "content/public/common/content_switches.h"
24 #include "gpu/command_buffer/common/sync_token.h" 22 #include "gpu/command_buffer/common/sync_token.h"
25 #include "gpu/command_buffer/common/value_state.h" 23 #include "gpu/command_buffer/common/value_state.h"
26 #include "gpu/command_buffer/service/feature_info.h" 24 #include "gpu/command_buffer/service/feature_info.h"
27 #include "gpu/command_buffer/service/gpu_switches.h"
28 #include "gpu/command_buffer/service/mailbox_manager.h" 25 #include "gpu/command_buffer/service/mailbox_manager.h"
29 #include "gpu/command_buffer/service/memory_program_cache.h" 26 #include "gpu/command_buffer/service/memory_program_cache.h"
30 #include "gpu/command_buffer/service/shader_translator_cache.h" 27 #include "gpu/command_buffer/service/shader_translator_cache.h"
31 #include "gpu/command_buffer/service/sync_point_manager.h" 28 #include "gpu/command_buffer/service/sync_point_manager.h"
32 #include "ipc/message_filter.h"
33 #include "ipc/message_router.h"
34 #include "ui/gl/gl_bindings.h" 29 #include "ui/gl/gl_bindings.h"
35 #include "ui/gl/gl_share_group.h" 30 #include "ui/gl/gl_share_group.h"
36 31
37 #if defined(OS_MACOSX) 32 #if defined(OS_MACOSX)
38 #include "content/common/gpu/buffer_presented_params_mac.h" 33 #include "content/common/gpu/buffer_presented_params_mac.h"
39 #endif 34 #endif
40 35
41 namespace content { 36 namespace content {
42 37
43 namespace { 38 namespace {
44 #if defined(OS_ANDROID) 39 #if defined(OS_ANDROID)
45 // Amount of time we expect the GPU to stay powered up without being used. 40 // Amount of time we expect the GPU to stay powered up without being used.
46 const int kMaxGpuIdleTimeMs = 40; 41 const int kMaxGpuIdleTimeMs = 40;
47 // Maximum amount of time we keep pinging the GPU waiting for the client to 42 // Maximum amount of time we keep pinging the GPU waiting for the client to
48 // draw. 43 // draw.
49 const int kMaxKeepAliveTimeMs = 200; 44 const int kMaxKeepAliveTimeMs = 200;
50 #endif 45 #endif
51 46
52 } 47 }
53 48
54 GpuChannelManager::GpuChannelManager( 49 GpuChannelManager::GpuChannelManager(
50 const gpu::GpuPreferences& gpu_preferences,
55 GpuChannelManagerDelegate* delegate, 51 GpuChannelManagerDelegate* delegate,
56 GpuWatchdog* watchdog, 52 GpuWatchdog* watchdog,
57 base::SingleThreadTaskRunner* task_runner, 53 base::SingleThreadTaskRunner* task_runner,
58 base::SingleThreadTaskRunner* io_task_runner, 54 base::SingleThreadTaskRunner* io_task_runner,
59 base::WaitableEvent* shutdown_event, 55 base::WaitableEvent* shutdown_event,
60 gpu::SyncPointManager* sync_point_manager, 56 gpu::SyncPointManager* sync_point_manager,
61 GpuMemoryBufferFactory* gpu_memory_buffer_factory) 57 GpuMemoryBufferFactory* gpu_memory_buffer_factory)
62 : task_runner_(task_runner), 58 : task_runner_(task_runner),
63 io_task_runner_(io_task_runner), 59 io_task_runner_(io_task_runner),
60 gpu_preferences_(gpu_preferences),
64 delegate_(delegate), 61 delegate_(delegate),
65 watchdog_(watchdog), 62 watchdog_(watchdog),
66 shutdown_event_(shutdown_event), 63 shutdown_event_(shutdown_event),
67 share_group_(new gfx::GLShareGroup), 64 share_group_(new gfx::GLShareGroup),
68 mailbox_manager_(gpu::gles2::MailboxManager::Create()), 65 mailbox_manager_(gpu::gles2::MailboxManager::Create(gpu_preferences)),
69 gpu_memory_manager_(this), 66 gpu_memory_manager_(this),
70 sync_point_manager_(sync_point_manager), 67 sync_point_manager_(sync_point_manager),
71 sync_point_client_waiter_( 68 sync_point_client_waiter_(
72 sync_point_manager->CreateSyncPointClientWaiter()), 69 sync_point_manager->CreateSyncPointClientWaiter()),
73 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), 70 gpu_memory_buffer_factory_(gpu_memory_buffer_factory),
74 weak_factory_(this) { 71 weak_factory_(this) {
75 DCHECK(task_runner); 72 DCHECK(task_runner);
76 DCHECK(io_task_runner); 73 DCHECK(io_task_runner);
77 const base::CommandLine* command_line = 74 if (gpu_preferences_.ui_prioritize_in_gpu_process)
78 base::CommandLine::ForCurrentProcess();
79 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess))
80 preemption_flag_ = new gpu::PreemptionFlag; 75 preemption_flag_ = new gpu::PreemptionFlag;
81 } 76 }
82 77
83 GpuChannelManager::~GpuChannelManager() { 78 GpuChannelManager::~GpuChannelManager() {
84 // Destroy channels before anything else because of dependencies. 79 // Destroy channels before anything else because of dependencies.
85 gpu_channels_.clear(); 80 gpu_channels_.clear();
86 if (default_offscreen_surface_.get()) { 81 if (default_offscreen_surface_.get()) {
87 default_offscreen_surface_->Destroy(); 82 default_offscreen_surface_->Destroy();
88 default_offscreen_surface_ = NULL; 83 default_offscreen_surface_ = NULL;
89 } 84 }
90 } 85 }
91 86
92 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { 87 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() {
93 if (!program_cache_.get() && 88 if (!program_cache_.get() &&
94 (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary || 89 (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary ||
95 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) && 90 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) &&
96 !base::CommandLine::ForCurrentProcess()->HasSwitch( 91 !gpu_preferences_.disable_gpu_program_cache) {
97 switches::kDisableGpuProgramCache)) { 92 program_cache_.reset(new gpu::gles2::MemoryProgramCache(
98 program_cache_.reset(new gpu::gles2::MemoryProgramCache()); 93 gpu_preferences_.gpu_program_cache_size,
94 gpu_preferences_.disable_gpu_shader_disk_cache));
99 } 95 }
100 return program_cache_.get(); 96 return program_cache_.get();
101 } 97 }
102 98
103 gpu::gles2::ShaderTranslatorCache* 99 gpu::gles2::ShaderTranslatorCache*
104 GpuChannelManager::shader_translator_cache() { 100 GpuChannelManager::shader_translator_cache() {
105 if (!shader_translator_cache_.get()) 101 if (!shader_translator_cache_.get()) {
106 shader_translator_cache_ = new gpu::gles2::ShaderTranslatorCache; 102 shader_translator_cache_ =
103 new gpu::gles2::ShaderTranslatorCache(gpu_preferences_);
104 }
107 return shader_translator_cache_.get(); 105 return shader_translator_cache_.get();
108 } 106 }
109 107
110 gpu::gles2::FramebufferCompletenessCache* 108 gpu::gles2::FramebufferCompletenessCache*
111 GpuChannelManager::framebuffer_completeness_cache() { 109 GpuChannelManager::framebuffer_completeness_cache() {
112 if (!framebuffer_completeness_cache_.get()) 110 if (!framebuffer_completeness_cache_.get())
113 framebuffer_completeness_cache_ = 111 framebuffer_completeness_cache_ =
114 new gpu::gles2::FramebufferCompletenessCache; 112 new gpu::gles2::FramebufferCompletenessCache;
115 return framebuffer_completeness_cache_.get(); 113 return framebuffer_completeness_cache_.get();
116 } 114 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 306 }
309 } 307 }
310 if (!stub || !stub->decoder()->MakeCurrent()) 308 if (!stub || !stub->decoder()->MakeCurrent())
311 return; 309 return;
312 glFinish(); 310 glFinish();
313 DidAccessGpu(); 311 DidAccessGpu();
314 } 312 }
315 #endif 313 #endif
316 314
317 } // namespace content 315 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | content/common/gpu/gpu_channel_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698