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

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.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, 10 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
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_command_buffer_stub.h" 5 #include "content/common/gpu/gpu_command_buffer_stub.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/hash.h" 12 #include "base/hash.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/shared_memory.h" 15 #include "base/memory/shared_memory.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "content/common/gpu/gpu_channel.h" 19 #include "content/common/gpu/gpu_channel.h"
20 #include "content/common/gpu/gpu_channel_manager.h" 20 #include "content/common/gpu/gpu_channel_manager.h"
21 #include "content/common/gpu/gpu_channel_manager_delegate.h" 21 #include "content/common/gpu/gpu_channel_manager_delegate.h"
22 #include "content/common/gpu/gpu_memory_manager.h" 22 #include "content/common/gpu/gpu_memory_manager.h"
23 #include "content/common/gpu/gpu_memory_tracking.h" 23 #include "content/common/gpu/gpu_memory_tracking.h"
24 #include "content/common/gpu/gpu_messages.h" 24 #include "content/common/gpu/gpu_messages.h"
25 #include "content/common/gpu/gpu_watchdog.h" 25 #include "content/common/gpu/gpu_watchdog.h"
26 #include "content/common/gpu/image_transport_surface.h" 26 #include "content/common/gpu/image_transport_surface.h"
27 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" 27 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
28 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" 28 #include "content/common/gpu/media/gpu_video_encode_accelerator.h"
29 #include "content/public/common/content_client.h" 29 #include "content/public/common/content_client.h"
30 #include "content/public/common/content_switches.h" 30 #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.
31 #include "gpu/command_buffer/common/constants.h" 31 #include "gpu/command_buffer/common/constants.h"
32 #include "gpu/command_buffer/common/mailbox.h" 32 #include "gpu/command_buffer/common/mailbox.h"
33 #include "gpu/command_buffer/common/sync_token.h" 33 #include "gpu/command_buffer/common/sync_token.h"
34 #include "gpu/command_buffer/service/gl_context_virtual.h" 34 #include "gpu/command_buffer/service/gl_context_virtual.h"
35 #include "gpu/command_buffer/service/gl_state_restorer_impl.h" 35 #include "gpu/command_buffer/service/gl_state_restorer_impl.h"
36 #include "gpu/command_buffer/service/image_factory.h" 36 #include "gpu/command_buffer/service/image_factory.h"
37 #include "gpu/command_buffer/service/image_manager.h" 37 #include "gpu/command_buffer/service/image_manager.h"
38 #include "gpu/command_buffer/service/logger.h" 38 #include "gpu/command_buffer/service/logger.h"
39 #include "gpu/command_buffer/service/mailbox_manager.h" 39 #include "gpu/command_buffer/service/mailbox_manager.h"
40 #include "gpu/command_buffer/service/memory_tracking.h" 40 #include "gpu/command_buffer/service/memory_tracking.h"
41 #include "gpu/command_buffer/service/query_manager.h" 41 #include "gpu/command_buffer/service/query_manager.h"
42 #include "gpu/command_buffer/service/sync_point_manager.h" 42 #include "gpu/command_buffer/service/sync_point_manager.h"
43 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 43 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
44 #include "gpu/command_buffer/service/valuebuffer_manager.h" 44 #include "gpu/command_buffer/service/valuebuffer_manager.h"
45 #include "ui/gl/gl_bindings.h" 45 #include "ui/gl/gl_bindings.h"
46 #include "ui/gl/gl_switches.h" 46 #include "ui/gl/gl_switches.h"
Fady Samuel 2016/02/25 16:26:33 Delete this?
Peng 2016/02/25 17:13:22 Done.
47 47
48 #if defined(OS_WIN) 48 #if defined(OS_WIN)
49 #include "base/win/win_util.h" 49 #include "base/win/win_util.h"
50 #include "content/public/common/sandbox_init.h" 50 #include "content/public/common/sandbox_init.h"
51 #endif 51 #endif
52 52
53 #if defined(OS_ANDROID) 53 #if defined(OS_ANDROID)
54 #include "content/common/gpu/stream_texture_android.h" 54 #include "content/common/gpu/stream_texture_android.h"
55 #endif 55 #endif
56 56
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 gpu::gles2::ContextCreationAttribHelper attrib_parser; 210 gpu::gles2::ContextCreationAttribHelper attrib_parser;
211 attrib_parser.Parse(requested_attribs_); 211 attrib_parser.Parse(requested_attribs_);
212 212
213 if (share_group) { 213 if (share_group) {
214 context_group_ = share_group->context_group_; 214 context_group_ = share_group->context_group_;
215 DCHECK(context_group_->bind_generates_resource() == 215 DCHECK(context_group_->bind_generates_resource() ==
216 attrib_parser.bind_generates_resource); 216 attrib_parser.bind_generates_resource);
217 } else { 217 } else {
218 context_group_ = new gpu::gles2::ContextGroup( 218 context_group_ = new gpu::gles2::ContextGroup(
219 mailbox_manager, new GpuCommandBufferMemoryTracker( 219 channel_->gpu_channel_manager()->gpu_preferences(), mailbox_manager,
220 channel, command_buffer_id_.GetUnsafeValue()), 220 new GpuCommandBufferMemoryTracker(channel,
221 command_buffer_id_.GetUnsafeValue()),
221 channel_->gpu_channel_manager()->shader_translator_cache(), 222 channel_->gpu_channel_manager()->shader_translator_cache(),
222 channel_->gpu_channel_manager()->framebuffer_completeness_cache(), NULL, 223 channel_->gpu_channel_manager()->framebuffer_completeness_cache(), NULL,
223 subscription_ref_set, pending_valuebuffer_state, 224 subscription_ref_set, pending_valuebuffer_state,
224 attrib_parser.bind_generates_resource); 225 attrib_parser.bind_generates_resource);
225 } 226 }
226 227
227 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent 228 // Virtualize PreferIntegratedGpu contexts by default on OS X to prevent
228 // performance regressions when enabling FCM. 229 // performance regressions when enabling FCM.
229 // http://crbug.com/180463 230 // http://crbug.com/180463
230 #if defined(OS_MACOSX) 231 #if defined(OS_MACOSX)
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 } 615 }
615 616
616 // Initialize the decoder with either the view or pbuffer GLContext. 617 // Initialize the decoder with either the view or pbuffer GLContext.
617 if (!decoder_->Initialize(surface_, context, offscreen_, initial_size_, 618 if (!decoder_->Initialize(surface_, context, offscreen_, initial_size_,
618 disallowed_features_, requested_attribs_)) { 619 disallowed_features_, requested_attribs_)) {
619 DLOG(ERROR) << "Failed to initialize decoder."; 620 DLOG(ERROR) << "Failed to initialize decoder.";
620 OnInitializeFailed(reply_message); 621 OnInitializeFailed(reply_message);
621 return; 622 return;
622 } 623 }
623 624
624 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 625 if (channel_->gpu_channel_manager()->
625 switches::kEnableGPUServiceLogging)) { 626 gpu_preferences().enable_gpu_service_logging) {
626 decoder_->set_log_commands(true); 627 decoder_->set_log_commands(true);
627 } 628 }
628 629
629 decoder_->GetLogger()->SetMsgCallback( 630 decoder_->GetLogger()->SetMsgCallback(
630 base::Bind(&GpuCommandBufferStub::SendConsoleMessage, 631 base::Bind(&GpuCommandBufferStub::SendConsoleMessage,
631 base::Unretained(this))); 632 base::Unretained(this)));
632 decoder_->SetShaderCacheCallback( 633 decoder_->SetShaderCacheCallback(
633 base::Bind(&GpuCommandBufferStub::SendCachedShader, 634 base::Bind(&GpuCommandBufferStub::SendCachedShader,
634 base::Unretained(this))); 635 base::Unretained(this)));
635 decoder_->SetFenceSyncReleaseCallback(base::Bind( 636 decoder_->SetFenceSyncReleaseCallback(base::Bind(
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 1123 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
1123 bool was_lost = state.error == gpu::error::kLostContext; 1124 bool was_lost = state.error == gpu::error::kLostContext;
1124 1125
1125 if (was_lost) { 1126 if (was_lost) {
1126 bool was_lost_by_robustness = 1127 bool was_lost_by_robustness =
1127 decoder_ && decoder_->WasContextLostByRobustnessExtension(); 1128 decoder_ && decoder_->WasContextLostByRobustnessExtension();
1128 1129
1129 // Work around issues with recovery by allowing a new GPU process to launch. 1130 // Work around issues with recovery by allowing a new GPU process to launch.
1130 if ((was_lost_by_robustness || 1131 if ((was_lost_by_robustness ||
1131 context_group_->feature_info()->workarounds().exit_on_context_lost) && 1132 context_group_->feature_info()->workarounds().exit_on_context_lost) &&
1132 !base::CommandLine::ForCurrentProcess()->HasSwitch( 1133 !channel_->gpu_channel_manager()->gpu_preferences().single_process &&
1133 switches::kSingleProcess) && 1134 !channel_->gpu_channel_manager()->gpu_preferences().in_process_gpu) {
1134 !base::CommandLine::ForCurrentProcess()->HasSwitch(
1135 switches::kInProcessGPU)) {
1136 LOG(ERROR) << "Exiting GPU process because some drivers cannot recover" 1135 LOG(ERROR) << "Exiting GPU process because some drivers cannot recover"
1137 << " from problems."; 1136 << " from problems.";
1138 // Signal the message loop to quit to shut down other threads 1137 // Signal the message loop to quit to shut down other threads
1139 // gracefully. 1138 // gracefully.
1140 base::MessageLoop::current()->QuitNow(); 1139 base::MessageLoop::current()->QuitNow();
1141 } 1140 }
1142 1141
1143 // Lose all other contexts if the reset was triggered by the robustness 1142 // Lose all other contexts if the reset was triggered by the robustness
1144 // extension instead of being synthetic. 1143 // extension instead of being synthetic.
1145 if (was_lost_by_robustness && 1144 if (was_lost_by_robustness &&
(...skipping 25 matching lines...) Expand all
1171 result)); 1170 result));
1172 } 1171 }
1173 1172
1174 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, 1173 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase,
1175 base::TimeDelta interval) { 1174 base::TimeDelta interval) {
1176 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, 1175 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase,
1177 interval)); 1176 interval));
1178 } 1177 }
1179 1178
1180 } // namespace content 1179 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698