OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ |
| 6 #define SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 11 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
| 12 #include "third_party/mojo_services/src/gpu/public/interfaces/command_buffer.moj
om.h" |
| 13 #include "third_party/mojo_services/src/gpu/public/interfaces/viewport_parameter
_listener.mojom.h" |
| 14 |
| 15 namespace gpu { |
| 16 class SyncPointManager; |
| 17 } |
| 18 |
| 19 namespace gles2 { |
| 20 class CommandBufferDriver; |
| 21 |
| 22 // This class listens to the CommandBuffer message pipe on a low-latency thread |
| 23 // so that we can insert sync points without blocking on the GL driver. It |
| 24 // forwards most method calls to the CommandBufferDriver, which runs on the |
| 25 // same thread as the native viewport. |
| 26 class CommandBufferImpl : public mojo::CommandBuffer { |
| 27 public: |
| 28 CommandBufferImpl( |
| 29 mojo::InterfaceRequest<CommandBuffer> request, |
| 30 mojo::ViewportParameterListenerPtr listener, |
| 31 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner, |
| 32 gpu::SyncPointManager* sync_point_manager, |
| 33 scoped_ptr<CommandBufferDriver> driver); |
| 34 ~CommandBufferImpl() override; |
| 35 |
| 36 void Initialize(mojo::CommandBufferSyncClientPtr sync_client, |
| 37 mojo::CommandBufferSyncPointClientPtr sync_point_client, |
| 38 mojo::CommandBufferLostContextObserverPtr loss_observer, |
| 39 mojo::ScopedSharedBufferHandle shared_state) override; |
| 40 void SetGetBuffer(int32_t buffer) override; |
| 41 void Flush(int32_t put_offset) override; |
| 42 void MakeProgress(int32_t last_get_offset) override; |
| 43 void RegisterTransferBuffer(int32_t id, |
| 44 mojo::ScopedSharedBufferHandle transfer_buffer, |
| 45 uint32_t size) override; |
| 46 void DestroyTransferBuffer(int32_t id) override; |
| 47 void InsertSyncPoint(bool retire) override; |
| 48 void RetireSyncPoint(uint32_t sync_point) override; |
| 49 void Echo(const mojo::Callback<void()>& callback) override; |
| 50 |
| 51 void DidLoseContext(); |
| 52 void UpdateVSyncParameters(base::TimeTicks timebase, |
| 53 base::TimeDelta interval); |
| 54 |
| 55 private: |
| 56 void BindToRequest(mojo::InterfaceRequest<CommandBuffer> request); |
| 57 |
| 58 scoped_refptr<gpu::SyncPointManager> sync_point_manager_; |
| 59 scoped_refptr<base::SingleThreadTaskRunner> driver_task_runner_; |
| 60 scoped_ptr<CommandBufferDriver> driver_; |
| 61 mojo::CommandBufferSyncPointClientPtr sync_point_client_; |
| 62 mojo::ViewportParameterListenerPtr viewport_parameter_listener_; |
| 63 mojo::StrongBinding<CommandBuffer> binding_; |
| 64 |
| 65 base::WeakPtrFactory<CommandBufferImpl> weak_factory_; |
| 66 DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); |
| 67 }; |
| 68 |
| 69 } // namespace gles2 |
| 70 |
| 71 #endif // SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ |
OLD | NEW |