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

Side by Side Diff: mojo/services/gles2/command_buffer_impl.cc

Issue 211703003: GPU: 'Pass' SharedMemory when possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@GPU_ref_count_buffer
Patch Set: Rebase. Created 6 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 | « gpu/command_buffer/service/transfer_buffer_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/services/gles2/command_buffer_impl.h" 5 #include "mojo/services/gles2/command_buffer_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 9
10 #include "gpu/command_buffer/common/constants.h" 10 #include "gpu/command_buffer/common/constants.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 void CommandBufferImpl::MakeProgress(int32_t last_get_offset) { 137 void CommandBufferImpl::MakeProgress(int32_t last_get_offset) {
138 // TODO(piman): handle out-of-order. 138 // TODO(piman): handle out-of-order.
139 AllocationScope scope; 139 AllocationScope scope;
140 sync_client_->DidMakeProgress(command_buffer_->GetState()); 140 sync_client_->DidMakeProgress(command_buffer_->GetState());
141 } 141 }
142 142
143 void CommandBufferImpl::RegisterTransferBuffer(int32_t id, 143 void CommandBufferImpl::RegisterTransferBuffer(int32_t id,
144 const ShmHandle& transfer_buffer, 144 const ShmHandle& transfer_buffer,
145 uint32_t size) { 145 uint32_t size) {
146 bool read_only = false; 146 // Take ownership of the memory and map it into this process.
147 base::SharedMemory shared_memory(transfer_buffer, read_only); 147 // This validates the size.
148 command_buffer_->RegisterTransferBuffer(id, &shared_memory, size); 148 scoped_ptr<base::SharedMemory> shared_memory(
149 new base::SharedMemory(transfer_buffer, false));
150 if (!shared_memory->Map(size)) {
151 DVLOG(0) << "Failed to map shared memory.";
152 return;
153 }
154
155 command_buffer_->RegisterTransferBuffer(id, shared_memory.Pass(), size);
149 } 156 }
150 157
151 void CommandBufferImpl::DestroyTransferBuffer(int32_t id) { 158 void CommandBufferImpl::DestroyTransferBuffer(int32_t id) {
152 command_buffer_->DestroyTransferBuffer(id); 159 command_buffer_->DestroyTransferBuffer(id);
153 } 160 }
154 161
155 void CommandBufferImpl::Echo(const Callback<void()>& callback) { 162 void CommandBufferImpl::Echo(const Callback<void()>& callback) {
156 callback.Run(); 163 callback.Run();
157 } 164 }
158 165
159 void CommandBufferImpl::RequestAnimationFrames() { 166 void CommandBufferImpl::RequestAnimationFrames() {
160 timer_.Start(FROM_HERE, 167 timer_.Start(FROM_HERE,
161 base::TimeDelta::FromMilliseconds(16), 168 base::TimeDelta::FromMilliseconds(16),
162 this, 169 this,
163 &CommandBufferImpl::DrawAnimationFrame); 170 &CommandBufferImpl::DrawAnimationFrame);
164 } 171 }
165 172
166 void CommandBufferImpl::CancelAnimationFrames() { timer_.Stop(); } 173 void CommandBufferImpl::CancelAnimationFrames() { timer_.Stop(); }
167 174
168 void CommandBufferImpl::OnParseError() { 175 void CommandBufferImpl::OnParseError() {
169 gpu::CommandBuffer::State state = command_buffer_->GetState(); 176 gpu::CommandBuffer::State state = command_buffer_->GetState();
170 client_->LostContext(state.context_lost_reason); 177 client_->LostContext(state.context_lost_reason);
171 } 178 }
172 179
173 void CommandBufferImpl::DrawAnimationFrame() { client_->DrawAnimationFrame(); } 180 void CommandBufferImpl::DrawAnimationFrame() { client_->DrawAnimationFrame(); }
174 181
175 } // namespace services 182 } // namespace services
176 } // namespace mojo 183 } // namespace mojo
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/transfer_buffer_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698