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 "services/gles2/command_buffer_driver.h" | 5 #include "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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 mailbox_manager_(mailbox_manager), | 74 mailbox_manager_(mailbox_manager), |
75 sync_point_manager_(sync_point_manager), | 75 sync_point_manager_(sync_point_manager), |
76 weak_factory_(this) { | 76 weak_factory_(this) { |
77 } | 77 } |
78 | 78 |
79 CommandBufferDriver::~CommandBufferDriver() { | 79 CommandBufferDriver::~CommandBufferDriver() { |
80 if (decoder_) { | 80 if (decoder_) { |
81 bool have_context = decoder_->MakeCurrent(); | 81 bool have_context = decoder_->MakeCurrent(); |
82 decoder_->Destroy(have_context); | 82 decoder_->Destroy(have_context); |
83 } | 83 } |
84 client_->DidDestroy(); | |
85 } | 84 } |
86 | 85 |
87 void CommandBufferDriver::Initialize( | 86 void CommandBufferDriver::Initialize( |
88 mojo::CommandBufferSyncClientPtr sync_client, | 87 mojo::CommandBufferSyncClientPtr sync_client, |
| 88 mojo::CommandBufferLostContextObserverPtr loss_observer, |
89 mojo::ScopedSharedBufferHandle shared_state) { | 89 mojo::ScopedSharedBufferHandle shared_state) { |
90 sync_client_ = sync_client.Pass(); | 90 sync_client_ = sync_client.Pass(); |
| 91 loss_observer_ = loss_observer.Pass(); |
91 bool success = DoInitialize(shared_state.Pass()); | 92 bool success = DoInitialize(shared_state.Pass()); |
92 mojo::GpuCapabilitiesPtr capabilities = | 93 mojo::GpuCapabilitiesPtr capabilities = |
93 success ? mojo::GpuCapabilities::From(decoder_->GetCapabilities()) | 94 success ? mojo::GpuCapabilities::From(decoder_->GetCapabilities()) |
94 : mojo::GpuCapabilities::New(); | 95 : mojo::GpuCapabilities::New(); |
95 sync_client_->DidInitialize(success, capabilities.Pass()); | 96 sync_client_->DidInitialize(success, capabilities.Pass()); |
96 } | 97 } |
97 | 98 |
98 bool CommandBufferDriver::DoInitialize( | 99 bool CommandBufferDriver::DoInitialize( |
99 mojo::ScopedSharedBufferHandle shared_state) { | 100 mojo::ScopedSharedBufferHandle shared_state) { |
100 if (widget_ == gfx::kNullAcceleratedWidget) | 101 if (widget_ == gfx::kNullAcceleratedWidget) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 sync_point, base::Bind(&CommandBufferDriver::OnSyncPointRetired, | 232 sync_point, base::Bind(&CommandBufferDriver::OnSyncPointRetired, |
232 weak_factory_.GetWeakPtr())); | 233 weak_factory_.GetWeakPtr())); |
233 return scheduler_->IsScheduled(); | 234 return scheduler_->IsScheduled(); |
234 } | 235 } |
235 | 236 |
236 void CommandBufferDriver::OnSyncPointRetired() { | 237 void CommandBufferDriver::OnSyncPointRetired() { |
237 scheduler_->SetScheduled(true); | 238 scheduler_->SetScheduled(true); |
238 } | 239 } |
239 | 240 |
240 void CommandBufferDriver::OnContextLost(uint32_t reason) { | 241 void CommandBufferDriver::OnContextLost(uint32_t reason) { |
241 client_->LostContext(reason); | 242 loss_observer_->DidLoseContext(reason); |
| 243 client_->DidLoseContext(); |
242 } | 244 } |
243 | 245 |
244 void CommandBufferDriver::OnUpdateVSyncParameters( | 246 void CommandBufferDriver::OnUpdateVSyncParameters( |
245 const base::TimeTicks timebase, | 247 const base::TimeTicks timebase, |
246 const base::TimeDelta interval) { | 248 const base::TimeDelta interval) { |
247 client_->UpdateVSyncParameters(timebase, interval); | 249 client_->UpdateVSyncParameters(timebase, interval); |
248 } | 250 } |
249 | 251 |
250 } // namespace gles2 | 252 } // namespace gles2 |
OLD | NEW |