OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gles2/command_buffer_client_impl.h" | 5 #include "mojo/gles2/command_buffer_client_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 DCHECK(*memory); | 37 DCHECK(*memory); |
38 | 38 |
39 return true; | 39 return true; |
40 } | 40 } |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 CommandBufferDelegate::~CommandBufferDelegate() {} | 44 CommandBufferDelegate::~CommandBufferDelegate() {} |
45 | 45 |
46 void CommandBufferDelegate::ContextLost() {} | 46 void CommandBufferDelegate::ContextLost() {} |
47 void CommandBufferDelegate::DrawAnimationFrame() {} | |
48 | 47 |
49 class CommandBufferClientImpl::SyncClientImpl | 48 class CommandBufferClientImpl::SyncClientImpl |
50 : public InterfaceImpl<CommandBufferSyncClient> { | 49 : public InterfaceImpl<CommandBufferSyncClient> { |
51 public: | 50 public: |
52 SyncClientImpl() : initialized_successfully_(false) {} | 51 SyncClientImpl() : initialized_successfully_(false) {} |
53 | 52 |
54 bool WaitForInitialization() { | 53 bool WaitForInitialization() { |
55 if (!WaitForIncomingMethodCall()) | 54 if (!WaitForIncomingMethodCall()) |
56 return false; | 55 return false; |
57 return initialized_successfully_; | 56 return initialized_successfully_; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 void CommandBufferClientImpl::Echo(const base::Closure& callback) { | 244 void CommandBufferClientImpl::Echo(const base::Closure& callback) { |
246 command_buffer_->Echo(callback); | 245 command_buffer_->Echo(callback); |
247 } | 246 } |
248 | 247 |
249 uint32 CommandBufferClientImpl::CreateStreamTexture(uint32 texture_id) { | 248 uint32 CommandBufferClientImpl::CreateStreamTexture(uint32 texture_id) { |
250 // TODO(piman) | 249 // TODO(piman) |
251 NOTIMPLEMENTED(); | 250 NOTIMPLEMENTED(); |
252 return 0; | 251 return 0; |
253 } | 252 } |
254 | 253 |
255 void CommandBufferClientImpl::RequestAnimationFrames() { | |
256 command_buffer_->RequestAnimationFrames(); | |
257 } | |
258 | |
259 void CommandBufferClientImpl::CancelAnimationFrames() { | |
260 command_buffer_->CancelAnimationFrames(); | |
261 } | |
262 | |
263 void CommandBufferClientImpl::DidDestroy() { | 254 void CommandBufferClientImpl::DidDestroy() { |
264 LostContext(gpu::error::kUnknown); | 255 LostContext(gpu::error::kUnknown); |
265 } | 256 } |
266 | 257 |
267 void CommandBufferClientImpl::LostContext(int32_t lost_reason) { | 258 void CommandBufferClientImpl::LostContext(int32_t lost_reason) { |
268 last_state_.error = gpu::error::kLostContext; | 259 last_state_.error = gpu::error::kLostContext; |
269 last_state_.context_lost_reason = | 260 last_state_.context_lost_reason = |
270 static_cast<gpu::error::ContextLostReason>(lost_reason); | 261 static_cast<gpu::error::ContextLostReason>(lost_reason); |
271 delegate_->ContextLost(); | 262 delegate_->ContextLost(); |
272 } | 263 } |
273 | 264 |
274 void CommandBufferClientImpl::DrawAnimationFrame() { | |
275 delegate_->DrawAnimationFrame(); | |
276 } | |
277 | |
278 void CommandBufferClientImpl::OnConnectionError() { | 265 void CommandBufferClientImpl::OnConnectionError() { |
279 LostContext(gpu::error::kUnknown); | 266 LostContext(gpu::error::kUnknown); |
280 } | 267 } |
281 | 268 |
282 void CommandBufferClientImpl::TryUpdateState() { | 269 void CommandBufferClientImpl::TryUpdateState() { |
283 if (last_state_.error == gpu::error::kNoError) | 270 if (last_state_.error == gpu::error::kNoError) |
284 shared_state()->Read(&last_state_); | 271 shared_state()->Read(&last_state_); |
285 } | 272 } |
286 | 273 |
287 void CommandBufferClientImpl::MakeProgressAndUpdateState() { | 274 void CommandBufferClientImpl::MakeProgressAndUpdateState() { |
288 command_buffer_->MakeProgress(last_state_.get_offset); | 275 command_buffer_->MakeProgress(last_state_.get_offset); |
289 | 276 |
290 CommandBufferStatePtr state = sync_client_impl_->WaitForProgress(); | 277 CommandBufferStatePtr state = sync_client_impl_->WaitForProgress(); |
291 if (!state) { | 278 if (!state) { |
292 VLOG(1) << "Channel encountered error while waiting for command buffer"; | 279 VLOG(1) << "Channel encountered error while waiting for command buffer"; |
293 // TODO(piman): is it ok for this to re-enter? | 280 // TODO(piman): is it ok for this to re-enter? |
294 DidDestroy(); | 281 DidDestroy(); |
295 return; | 282 return; |
296 } | 283 } |
297 | 284 |
298 if (state->generation - last_state_.generation < 0x80000000U) | 285 if (state->generation - last_state_.generation < 0x80000000U) |
299 last_state_ = state.To<State>(); | 286 last_state_ = state.To<State>(); |
300 } | 287 } |
301 | 288 |
302 } // namespace gles2 | 289 } // namespace gles2 |
303 } // namespace mojo | 290 } // namespace mojo |
OLD | NEW |