| 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 "components/view_manager/gles2/command_buffer_impl.h" | 5 #include "components/view_manager/gles2/command_buffer_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "components/view_manager/gles2/command_buffer_driver.h" | 9 #include "components/view_manager/gles2/command_buffer_driver.h" |
| 10 #include "components/view_manager/gles2/command_buffer_impl_observer.h" | 10 #include "components/view_manager/gles2/command_buffer_impl_observer.h" |
| 11 #include "components/view_manager/gles2/gpu_state.h" | 11 #include "components/view_manager/gles2/gpu_state.h" |
| 12 #include "gpu/command_buffer/service/sync_point_manager.h" | 12 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 13 | 13 |
| 14 namespace gles2 { | 14 namespace gles2 { |
| 15 namespace { | 15 namespace { |
| 16 void RunCallback(const mojo::Callback<void()>& callback) { | 16 void RunCallback(const mojo::Callback<void()>& callback) { |
| 17 callback.Run(); | 17 callback.Run(); |
| 18 } | 18 } |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 class CommandBufferImpl::CommandBufferDriverClientImpl | 21 class CommandBufferImpl::CommandBufferDriverClientImpl |
| 22 : public CommandBufferDriver::Client { | 22 : public CommandBufferDriver::Client { |
| 23 public: | 23 public: |
| 24 explicit CommandBufferDriverClientImpl(CommandBufferImpl* command_buffer) | 24 explicit CommandBufferDriverClientImpl(CommandBufferImpl* command_buffer) |
| 25 : command_buffer_(command_buffer) {} | 25 : command_buffer_(command_buffer) {} |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 void UpdateVSyncParameters(base::TimeTicks timebase, | |
| 29 base::TimeDelta interval) override { | |
| 30 command_buffer_->UpdateVSyncParameters(timebase, interval); | |
| 31 } | |
| 32 | |
| 33 void DidLoseContext() override { command_buffer_->DidLoseContext(); } | 28 void DidLoseContext() override { command_buffer_->DidLoseContext(); } |
| 34 | 29 |
| 35 CommandBufferImpl* command_buffer_; | 30 CommandBufferImpl* command_buffer_; |
| 36 | 31 |
| 37 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriverClientImpl); | 32 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriverClientImpl); |
| 38 }; | 33 }; |
| 39 | 34 |
| 40 CommandBufferImpl::CommandBufferImpl( | 35 CommandBufferImpl::CommandBufferImpl( |
| 41 mojo::InterfaceRequest<mojo::CommandBuffer> request, | 36 mojo::InterfaceRequest<mojo::CommandBuffer> request, |
| 42 mojo::ViewportParameterListenerPtr listener, | |
| 43 scoped_refptr<GpuState> gpu_state, | 37 scoped_refptr<GpuState> gpu_state, |
| 44 scoped_ptr<CommandBufferDriver> driver) | 38 scoped_ptr<CommandBufferDriver> driver) |
| 45 : gpu_state_(gpu_state), | 39 : gpu_state_(gpu_state), |
| 46 driver_task_runner_(base::MessageLoop::current()->task_runner()), | 40 driver_task_runner_(base::MessageLoop::current()->task_runner()), |
| 47 driver_(driver.Pass()), | 41 driver_(driver.Pass()), |
| 48 viewport_parameter_listener_(listener.Pass()), | |
| 49 binding_(this), | 42 binding_(this), |
| 50 observer_(nullptr), | 43 observer_(nullptr), |
| 51 weak_ptr_factory_(this) { | 44 weak_ptr_factory_(this) { |
| 52 driver_->set_client(make_scoped_ptr(new CommandBufferDriverClientImpl(this))); | 45 driver_->set_client(make_scoped_ptr(new CommandBufferDriverClientImpl(this))); |
| 53 | 46 |
| 54 gpu_state_->control_task_runner()->PostTask( | 47 gpu_state_->control_task_runner()->PostTask( |
| 55 FROM_HERE, | 48 FROM_HERE, |
| 56 base::Bind(&CommandBufferImpl::BindToRequest, | 49 base::Bind(&CommandBufferImpl::BindToRequest, |
| 57 weak_ptr_factory_.GetWeakPtr(), base::Passed(&request))); | 50 weak_ptr_factory_.GetWeakPtr(), base::Passed(&request))); |
| 58 } | 51 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 161 |
| 169 // Objects we own (such as CommandBufferDriver) need to be destroyed on the | 162 // Objects we own (such as CommandBufferDriver) need to be destroyed on the |
| 170 // thread we were created on. | 163 // thread we were created on. |
| 171 driver_task_runner_->DeleteSoon(FROM_HERE, this); | 164 driver_task_runner_->DeleteSoon(FROM_HERE, this); |
| 172 } | 165 } |
| 173 | 166 |
| 174 void CommandBufferImpl::DidLoseContext() { | 167 void CommandBufferImpl::DidLoseContext() { |
| 175 OnConnectionError(); | 168 OnConnectionError(); |
| 176 } | 169 } |
| 177 | 170 |
| 178 void CommandBufferImpl::UpdateVSyncParameters(base::TimeTicks timebase, | |
| 179 base::TimeDelta interval) { | |
| 180 if (!viewport_parameter_listener_) | |
| 181 return; | |
| 182 viewport_parameter_listener_->OnVSyncParametersUpdated( | |
| 183 timebase.ToInternalValue(), interval.ToInternalValue()); | |
| 184 } | |
| 185 | |
| 186 } // namespace gles2 | 171 } // namespace gles2 |
| OLD | NEW |