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 #ifndef SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ | 5 #ifndef SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ |
6 #define SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ | 6 #define SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "mojo/public/cpp/bindings/strong_binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
12 #include "mojo/services/gpu/public/interfaces/command_buffer.mojom.h" | 12 #include "mojo/services/gpu/public/interfaces/command_buffer.mojom.h" |
13 #include "mojo/services/gpu/public/interfaces/viewport_parameter_listener.mojom.
h" | 13 #include "mojo/services/gpu/public/interfaces/viewport_parameter_listener.mojom.
h" |
14 | 14 |
15 namespace gpu { | 15 namespace gpu { |
16 class SyncPointManager; | 16 class SyncPointManager; |
17 } | 17 } |
18 | 18 |
19 namespace gles2 { | 19 namespace gles2 { |
20 class CommandBufferDriver; | 20 class CommandBufferDriver; |
21 | 21 |
22 // This class listens to the CommandBuffer message pipe on a low-latency thread | 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 | 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 | 24 // forwards most method calls to the CommandBufferDriver, which runs on the |
25 // same thread as the native viewport. | 25 // same thread as the native viewport. |
26 class CommandBufferImpl : public mojo::CommandBuffer { | 26 class CommandBufferImpl : public mojo::CommandBuffer, mojo::ErrorHandler { |
27 public: | 27 public: |
28 class Observer { | 28 class Observer { |
29 public: | 29 public: |
30 virtual void OnCommandBufferImplDestroyed() = 0; | 30 virtual void OnCommandBufferImplDestroyed() = 0; |
31 }; | 31 }; |
32 | 32 |
33 CommandBufferImpl( | 33 CommandBufferImpl( |
34 mojo::InterfaceRequest<CommandBuffer> request, | 34 mojo::InterfaceRequest<CommandBuffer> request, |
35 mojo::ViewportParameterListenerPtr listener, | 35 mojo::ViewportParameterListenerPtr listener, |
36 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner, | 36 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner, |
(...skipping 13 matching lines...) Expand all Loading... |
50 uint32_t size) override; | 50 uint32_t size) override; |
51 void DestroyTransferBuffer(int32_t id) override; | 51 void DestroyTransferBuffer(int32_t id) override; |
52 void InsertSyncPoint(bool retire) override; | 52 void InsertSyncPoint(bool retire) override; |
53 void RetireSyncPoint(uint32_t sync_point) override; | 53 void RetireSyncPoint(uint32_t sync_point) override; |
54 void Echo(const mojo::Callback<void()>& callback) override; | 54 void Echo(const mojo::Callback<void()>& callback) override; |
55 | 55 |
56 void DidLoseContext(); | 56 void DidLoseContext(); |
57 void UpdateVSyncParameters(base::TimeTicks timebase, | 57 void UpdateVSyncParameters(base::TimeTicks timebase, |
58 base::TimeDelta interval); | 58 base::TimeDelta interval); |
59 | 59 |
| 60 // Sets an observer for CommandBufferImpl destruction. An observer registered |
| 61 // here will be notified of the destruction of this object on the thread used |
| 62 // to create it, before the destruction happens. |
60 void set_observer(Observer* observer) { observer_ = observer; } | 63 void set_observer(Observer* observer) { observer_ = observer; } |
61 | 64 |
| 65 // mojo::ErrorHandler implementation |
| 66 void OnConnectionError() override; |
| 67 |
62 private: | 68 private: |
63 void BindToRequest(mojo::InterfaceRequest<CommandBuffer> request); | 69 void BindToRequest(mojo::InterfaceRequest<CommandBuffer> request); |
| 70 void NotifyAndDestroy(); |
| 71 void Destroy(); |
64 | 72 |
65 scoped_refptr<gpu::SyncPointManager> sync_point_manager_; | 73 scoped_refptr<gpu::SyncPointManager> sync_point_manager_; |
| 74 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; |
66 scoped_refptr<base::SingleThreadTaskRunner> driver_task_runner_; | 75 scoped_refptr<base::SingleThreadTaskRunner> driver_task_runner_; |
67 scoped_ptr<CommandBufferDriver> driver_; | 76 scoped_ptr<CommandBufferDriver> driver_; |
68 mojo::CommandBufferSyncPointClientPtr sync_point_client_; | 77 mojo::CommandBufferSyncPointClientPtr sync_point_client_; |
69 mojo::ViewportParameterListenerPtr viewport_parameter_listener_; | 78 mojo::ViewportParameterListenerPtr viewport_parameter_listener_; |
70 mojo::StrongBinding<CommandBuffer> binding_; | 79 mojo::Binding<CommandBuffer> binding_; |
71 Observer* observer_; | 80 Observer* observer_; |
72 | 81 |
73 base::WeakPtrFactory<CommandBufferImpl> weak_factory_; | 82 base::WeakPtrFactory<CommandBufferImpl> weak_factory_; |
74 DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); | 83 DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); |
75 }; | 84 }; |
76 | 85 |
77 } // namespace gles2 | 86 } // namespace gles2 |
78 | 87 |
79 #endif // SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ | 88 #endif // SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ |
OLD | NEW |