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

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

Issue 649533003: C++11 declares a type safe null pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Presubmit errors Created 6 years, 2 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/hash.h" 9 #include "base/hash.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 if (share_group) { 186 if (share_group) {
187 context_group_ = share_group->context_group_; 187 context_group_ = share_group->context_group_;
188 DCHECK(context_group_->bind_generates_resource() == 188 DCHECK(context_group_->bind_generates_resource() ==
189 attrib_parser.bind_generates_resource); 189 attrib_parser.bind_generates_resource);
190 } else { 190 } else {
191 context_group_ = new gpu::gles2::ContextGroup( 191 context_group_ = new gpu::gles2::ContextGroup(
192 mailbox_manager, 192 mailbox_manager,
193 new GpuCommandBufferMemoryTracker(channel), 193 new GpuCommandBufferMemoryTracker(channel),
194 channel_->gpu_channel_manager()->shader_translator_cache(), 194 channel_->gpu_channel_manager()->shader_translator_cache(),
195 NULL, 195 nullptr,
196 attrib_parser.bind_generates_resource); 196 attrib_parser.bind_generates_resource);
197 } 197 }
198 198
199 use_virtualized_gl_context_ |= 199 use_virtualized_gl_context_ |=
200 context_group_->feature_info()->workarounds().use_virtualized_gl_contexts; 200 context_group_->feature_info()->workarounds().use_virtualized_gl_contexts;
201 } 201 }
202 202
203 GpuCommandBufferStub::~GpuCommandBufferStub() { 203 GpuCommandBufferStub::~GpuCommandBufferStub() {
204 Destroy(); 204 Destroy();
205 205
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 gpu_channel_manager->Send(new GpuHostMsg_DidDestroyOffscreenContext( 408 gpu_channel_manager->Send(new GpuHostMsg_DidDestroyOffscreenContext(
409 active_url_)); 409 active_url_));
410 } 410 }
411 411
412 memory_manager_client_state_.reset(); 412 memory_manager_client_state_.reset();
413 413
414 while (!sync_points_.empty()) 414 while (!sync_points_.empty())
415 OnRetireSyncPoint(sync_points_.front()); 415 OnRetireSyncPoint(sync_points_.front());
416 416
417 if (decoder_) 417 if (decoder_)
418 decoder_->set_engine(NULL); 418 decoder_->set_engine(nullptr);
419 419
420 // The scheduler has raw references to the decoder and the command buffer so 420 // The scheduler has raw references to the decoder and the command buffer so
421 // destroy it before those. 421 // destroy it before those.
422 scheduler_.reset(); 422 scheduler_.reset();
423 423
424 bool have_context = false; 424 bool have_context = false;
425 if (decoder_ && command_buffer_ && 425 if (decoder_ && command_buffer_ &&
426 command_buffer_->GetLastState().error != gpu::error::kLostContext) 426 command_buffer_->GetLastState().error != gpu::error::kLostContext)
427 have_context = decoder_->MakeCurrent(); 427 have_context = decoder_->MakeCurrent();
428 FOR_EACH_OBSERVER(DestructionObserver, 428 FOR_EACH_OBSERVER(DestructionObserver,
429 destruction_observers_, 429 destruction_observers_,
430 OnWillDestroyStub()); 430 OnWillDestroyStub());
431 431
432 if (decoder_) { 432 if (decoder_) {
433 decoder_->Destroy(have_context); 433 decoder_->Destroy(have_context);
434 decoder_.reset(); 434 decoder_.reset();
435 } 435 }
436 436
437 command_buffer_.reset(); 437 command_buffer_.reset();
438 438
439 // Remove this after crbug.com/248395 is sorted out. 439 // Remove this after crbug.com/248395 is sorted out.
440 surface_ = NULL; 440 surface_ = nullptr;
441 } 441 }
442 442
443 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { 443 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) {
444 Destroy(); 444 Destroy();
445 GpuCommandBufferMsg_Initialize::WriteReplyParams( 445 GpuCommandBufferMsg_Initialize::WriteReplyParams(
446 reply_message, false, gpu::Capabilities()); 446 reply_message, false, gpu::Capabilities());
447 Send(reply_message); 447 Send(reply_message);
448 } 448 }
449 449
450 void GpuCommandBufferStub::OnInitialize( 450 void GpuCommandBufferStub::OnInitialize(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } 513 }
514 // This should be a non-virtual GL context. 514 // This should be a non-virtual GL context.
515 DCHECK(context->GetHandle()); 515 DCHECK(context->GetHandle());
516 context = new gpu::GLContextVirtual( 516 context = new gpu::GLContextVirtual(
517 channel_->share_group(), context.get(), decoder_->AsWeakPtr()); 517 channel_->share_group(), context.get(), decoder_->AsWeakPtr());
518 if (!context->Initialize(surface_.get(), gpu_preference_)) { 518 if (!context->Initialize(surface_.get(), gpu_preference_)) {
519 // TODO(sievers): The real context created above for the default 519 // TODO(sievers): The real context created above for the default
520 // offscreen surface might not be compatible with this surface. 520 // offscreen surface might not be compatible with this surface.
521 // Need to adjust at least GLX to be able to create the initial context 521 // Need to adjust at least GLX to be able to create the initial context
522 // with a config that is compatible with onscreen and offscreen surfaces. 522 // with a config that is compatible with onscreen and offscreen surfaces.
523 context = NULL; 523 context = nullptr;
524 524
525 DLOG(ERROR) << "Failed to initialize virtual GL context."; 525 DLOG(ERROR) << "Failed to initialize virtual GL context.";
526 OnInitializeFailed(reply_message); 526 OnInitializeFailed(reply_message);
527 return; 527 return;
528 } 528 }
529 } 529 }
530 if (!context.get()) { 530 if (!context.get()) {
531 context = gfx::GLContext::CreateGLContext( 531 context = gfx::GLContext::CreateGLContext(
532 channel_->share_group(), surface_.get(), gpu_preference_); 532 channel_->share_group(), surface_.get(), gpu_preference_);
533 } 533 }
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 uint64 GpuCommandBufferStub::GetMemoryUsage() const { 1087 uint64 GpuCommandBufferStub::GetMemoryUsage() const {
1088 return GetMemoryManager()->GetClientMemoryUsage(this); 1088 return GetMemoryManager()->GetClientMemoryUsage(this);
1089 } 1089 }
1090 1090
1091 void GpuCommandBufferStub::SwapBuffersCompleted( 1091 void GpuCommandBufferStub::SwapBuffersCompleted(
1092 const std::vector<ui::LatencyInfo>& latency_info) { 1092 const std::vector<ui::LatencyInfo>& latency_info) {
1093 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info)); 1093 Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, latency_info));
1094 } 1094 }
1095 1095
1096 } // namespace content 1096 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_manager.cc ('k') | content/common/gpu/gpu_memory_buffer_factory_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698