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