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

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

Issue 213353005: Refactor gpu::Buffer to allow different types of backing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix pointer alignment in tests Created 6 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 | Annotate | Revision Log
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/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 scheduler_->SetSchedulingChangedCallback( 535 scheduler_->SetSchedulingChangedCallback(
536 base::Bind(&GpuChannel::StubSchedulingChanged, 536 base::Bind(&GpuChannel::StubSchedulingChanged,
537 base::Unretained(channel_))); 537 base::Unretained(channel_)));
538 538
539 if (watchdog_) { 539 if (watchdog_) {
540 scheduler_->SetCommandProcessedCallback( 540 scheduler_->SetCommandProcessedCallback(
541 base::Bind(&GpuCommandBufferStub::OnCommandProcessed, 541 base::Bind(&GpuCommandBufferStub::OnCommandProcessed,
542 base::Unretained(this))); 542 base::Unretained(this)));
543 } 543 }
544 544
545 if (!command_buffer_->SetSharedStateBuffer(shared_state_shm.Pass())) { 545 const size_t kSharedStateSize = sizeof(gpu::CommandBufferSharedState);
546 DLOG(ERROR) << "Failed to map shared stae buffer."; 546 if (!shared_state_shm->Map(kSharedStateSize)) {
547 DLOG(ERROR) << "Failed to map shared state buffer.";
547 OnInitializeFailed(reply_message); 548 OnInitializeFailed(reply_message);
548 return; 549 return;
549 } 550 }
551 command_buffer_->SetSharedStateBuffer(gpu::MakeBackingFromSharedMemory(
552 shared_state_shm.Pass(), kSharedStateSize));
550 553
551 GpuCommandBufferMsg_Initialize::WriteReplyParams( 554 GpuCommandBufferMsg_Initialize::WriteReplyParams(
552 reply_message, true, gpu_control_->GetCapabilities()); 555 reply_message, true, gpu_control_->GetCapabilities());
553 Send(reply_message); 556 Send(reply_message);
554 557
555 if (handle_.is_null() && !active_url_.is_empty()) { 558 if (handle_.is_null() && !active_url_.is_empty()) {
556 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); 559 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
557 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( 560 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext(
558 active_url_)); 561 active_url_));
559 } 562 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 690
688 // Take ownership of the memory and map it into this process. 691 // Take ownership of the memory and map it into this process.
689 // This validates the size. 692 // This validates the size.
690 scoped_ptr<base::SharedMemory> shared_memory( 693 scoped_ptr<base::SharedMemory> shared_memory(
691 new base::SharedMemory(transfer_buffer, false)); 694 new base::SharedMemory(transfer_buffer, false));
692 if (!shared_memory->Map(size)) { 695 if (!shared_memory->Map(size)) {
693 DVLOG(0) << "Failed to map shared memory."; 696 DVLOG(0) << "Failed to map shared memory.";
694 return; 697 return;
695 } 698 }
696 699
697 if (command_buffer_) 700 if (command_buffer_) {
698 command_buffer_->RegisterTransferBuffer(id, shared_memory.Pass(), size); 701 command_buffer_->RegisterTransferBuffer(
702 id, gpu::MakeBackingFromSharedMemory(shared_memory.Pass(), size));
703 }
699 } 704 }
700 705
701 void GpuCommandBufferStub::OnDestroyTransferBuffer(int32 id) { 706 void GpuCommandBufferStub::OnDestroyTransferBuffer(int32 id) {
702 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyTransferBuffer"); 707 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnDestroyTransferBuffer");
703 708
704 if (command_buffer_) 709 if (command_buffer_)
705 command_buffer_->DestroyTransferBuffer(id); 710 command_buffer_->DestroyTransferBuffer(id);
706 } 711 }
707 712
708 void GpuCommandBufferStub::OnCommandProcessed() { 713 void GpuCommandBufferStub::OnCommandProcessed() {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 if (decoder_) 964 if (decoder_)
960 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB); 965 decoder_->LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB);
961 command_buffer_->SetParseError(gpu::error::kLostContext); 966 command_buffer_->SetParseError(gpu::error::kLostContext);
962 } 967 }
963 968
964 uint64 GpuCommandBufferStub::GetMemoryUsage() const { 969 uint64 GpuCommandBufferStub::GetMemoryUsage() const {
965 return GetMemoryManager()->GetClientMemoryUsage(this); 970 return GetMemoryManager()->GetClientMemoryUsage(this);
966 } 971 }
967 972
968 } // namespace content 973 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/command_buffer_proxy_impl.cc ('k') | gpu/command_buffer/client/client_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698