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

Side by Side Diff: mojo/services/gles2/command_buffer_impl.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
« no previous file with comments | « mojo/gles2/command_buffer_client_impl.cc ('k') | ppapi/proxy/ppapi_command_buffer_proxy.cc » ('j') | 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 command_buffer_->SetPutOffsetChangeCallback(base::Bind( 112 command_buffer_->SetPutOffsetChangeCallback(base::Bind(
113 &gpu::GpuScheduler::PutChanged, base::Unretained(scheduler_.get()))); 113 &gpu::GpuScheduler::PutChanged, base::Unretained(scheduler_.get())));
114 command_buffer_->SetGetBufferChangeCallback(base::Bind( 114 command_buffer_->SetGetBufferChangeCallback(base::Bind(
115 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get()))); 115 &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get())));
116 command_buffer_->SetParseErrorCallback( 116 command_buffer_->SetParseErrorCallback(
117 base::Bind(&CommandBufferImpl::OnParseError, base::Unretained(this))); 117 base::Bind(&CommandBufferImpl::OnParseError, base::Unretained(this)));
118 118
119 // TODO(piman): other callbacks 119 // TODO(piman): other callbacks
120 120
121 const size_t kSize = sizeof(gpu::CommandBufferSharedState);
121 scoped_ptr<base::SharedMemory> shared_state_shm( 122 scoped_ptr<base::SharedMemory> shared_state_shm(
122 new base::SharedMemory(shared_state, false)); 123 new base::SharedMemory(shared_state, false));
123 if (!command_buffer_->SetSharedStateBuffer(shared_state_shm.Pass())) 124 if (!shared_state_shm->Map(kSize))
124 return false; 125 return false;
125 126
127 command_buffer_->SetSharedStateBuffer(
128 gpu::MakeBackingFromSharedMemory(shared_state_shm.Pass(), kSize));
126 return true; 129 return true;
127 } 130 }
128 131
129 void CommandBufferImpl::SetGetBuffer(int32_t buffer) { 132 void CommandBufferImpl::SetGetBuffer(int32_t buffer) {
130 command_buffer_->SetGetBuffer(buffer); 133 command_buffer_->SetGetBuffer(buffer);
131 } 134 }
132 135
133 void CommandBufferImpl::Flush(int32_t put_offset) { 136 void CommandBufferImpl::Flush(int32_t put_offset) {
134 command_buffer_->Flush(put_offset); 137 command_buffer_->Flush(put_offset);
135 } 138 }
136 139
137 void CommandBufferImpl::MakeProgress(int32_t last_get_offset) { 140 void CommandBufferImpl::MakeProgress(int32_t last_get_offset) {
138 // TODO(piman): handle out-of-order. 141 // TODO(piman): handle out-of-order.
139 AllocationScope scope; 142 AllocationScope scope;
140 sync_client_->DidMakeProgress(command_buffer_->GetState()); 143 sync_client_->DidMakeProgress(command_buffer_->GetState());
141 } 144 }
142 145
143 void CommandBufferImpl::RegisterTransferBuffer(int32_t id, 146 void CommandBufferImpl::RegisterTransferBuffer(int32_t id,
144 const ShmHandle& transfer_buffer, 147 const ShmHandle& transfer_buffer,
145 uint32_t size) { 148 uint32_t size) {
146 // Take ownership of the memory and map it into this process. 149 // Take ownership of the memory and map it into this process.
147 // This validates the size. 150 // This validates the size.
148 scoped_ptr<base::SharedMemory> shared_memory( 151 scoped_ptr<base::SharedMemory> shared_memory(
149 new base::SharedMemory(transfer_buffer, false)); 152 new base::SharedMemory(transfer_buffer, false));
150 if (!shared_memory->Map(size)) { 153 if (!shared_memory->Map(size)) {
151 DVLOG(0) << "Failed to map shared memory."; 154 DVLOG(0) << "Failed to map shared memory.";
152 return; 155 return;
153 } 156 }
154 157
155 command_buffer_->RegisterTransferBuffer(id, shared_memory.Pass(), size); 158 command_buffer_->RegisterTransferBuffer(
159 id, gpu::MakeBackingFromSharedMemory(shared_memory.Pass(), size));
156 } 160 }
157 161
158 void CommandBufferImpl::DestroyTransferBuffer(int32_t id) { 162 void CommandBufferImpl::DestroyTransferBuffer(int32_t id) {
159 command_buffer_->DestroyTransferBuffer(id); 163 command_buffer_->DestroyTransferBuffer(id);
160 } 164 }
161 165
162 void CommandBufferImpl::Echo(const Callback<void()>& callback) { 166 void CommandBufferImpl::Echo(const Callback<void()>& callback) {
163 callback.Run(); 167 callback.Run();
164 } 168 }
165 169
166 void CommandBufferImpl::RequestAnimationFrames() { 170 void CommandBufferImpl::RequestAnimationFrames() {
167 timer_.Start(FROM_HERE, 171 timer_.Start(FROM_HERE,
168 base::TimeDelta::FromMilliseconds(16), 172 base::TimeDelta::FromMilliseconds(16),
169 this, 173 this,
170 &CommandBufferImpl::DrawAnimationFrame); 174 &CommandBufferImpl::DrawAnimationFrame);
171 } 175 }
172 176
173 void CommandBufferImpl::CancelAnimationFrames() { timer_.Stop(); } 177 void CommandBufferImpl::CancelAnimationFrames() { timer_.Stop(); }
174 178
175 void CommandBufferImpl::OnParseError() { 179 void CommandBufferImpl::OnParseError() {
176 gpu::CommandBuffer::State state = command_buffer_->GetState(); 180 gpu::CommandBuffer::State state = command_buffer_->GetState();
177 client_->LostContext(state.context_lost_reason); 181 client_->LostContext(state.context_lost_reason);
178 } 182 }
179 183
180 void CommandBufferImpl::DrawAnimationFrame() { client_->DrawAnimationFrame(); } 184 void CommandBufferImpl::DrawAnimationFrame() { client_->DrawAnimationFrame(); }
181 185
182 } // namespace services 186 } // namespace services
183 } // namespace mojo 187 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/gles2/command_buffer_client_impl.cc ('k') | ppapi/proxy/ppapi_command_buffer_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698