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

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"
(...skipping 198 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