OLD | NEW |
---|---|
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_driver.h" | 5 #include "mojo/services/gles2/command_buffer_driver.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "gpu/command_buffer/common/constants.h" | 10 #include "gpu/command_buffer/common/constants.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 DVLOG(0) << "Failed to map shared memory."; | 174 DVLOG(0) << "Failed to map shared memory."; |
175 return; | 175 return; |
176 } | 176 } |
177 command_buffer_->RegisterTransferBuffer(id, backing.Pass()); | 177 command_buffer_->RegisterTransferBuffer(id, backing.Pass()); |
178 } | 178 } |
179 | 179 |
180 void CommandBufferDriver::DestroyTransferBuffer(int32_t id) { | 180 void CommandBufferDriver::DestroyTransferBuffer(int32_t id) { |
181 command_buffer_->DestroyTransferBuffer(id); | 181 command_buffer_->DestroyTransferBuffer(id); |
182 } | 182 } |
183 | 183 |
184 void CommandBufferDriver::Echo(const Callback<void()>& callback) { | |
185 callback.Run(); | |
jamesr
2014/11/19 20:57:17
i'm not sure if this works (i.e. if the callback b
| |
186 } | |
187 | |
184 void CommandBufferDriver::SetContextLostCallback( | 188 void CommandBufferDriver::SetContextLostCallback( |
189 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
185 const base::Callback<void(int32_t)>& callback) { | 190 const base::Callback<void(int32_t)>& callback) { |
191 context_lost_task_runner_ = task_runner; | |
186 context_lost_callback_ = callback; | 192 context_lost_callback_ = callback; |
187 } | 193 } |
188 | 194 |
189 void CommandBufferDriver::OnParseError() { | 195 void CommandBufferDriver::OnParseError() { |
190 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 196 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
191 OnContextLost(state.context_lost_reason); | 197 OnContextLost(state.context_lost_reason); |
192 } | 198 } |
193 | 199 |
194 void CommandBufferDriver::OnResize(gfx::Size size, float scale_factor) { | 200 void CommandBufferDriver::OnResize(gfx::Size size, float scale_factor) { |
195 surface_->Resize(size); | 201 surface_->Resize(size); |
196 } | 202 } |
197 | 203 |
198 void CommandBufferDriver::OnContextLost(uint32_t reason) { | 204 void CommandBufferDriver::OnContextLost(uint32_t reason) { |
199 if (!context_lost_callback_.is_null()) | 205 if (!context_lost_callback_.is_null()) { |
200 context_lost_callback_.Run(reason); | 206 context_lost_task_runner_->PostTask( |
207 FROM_HERE, base::Bind(context_lost_callback_, reason)); | |
208 } | |
201 } | 209 } |
202 | 210 |
203 } // namespace mojo | 211 } // namespace mojo |
OLD | NEW |