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 MOJO_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ | |
6 #define MOJO_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 "mojo/public/cpp/bindings/strong_binding.h" | |
12 #include "mojo/services/public/interfaces/gpu/command_buffer.mojom.h" | |
13 #include "mojo/services/public/interfaces/gpu/viewport_parameter_listener.mojom.
h" | |
14 | |
15 namespace gpu { | |
16 class SyncPointManager; | |
17 } | |
18 | |
19 namespace mojo { | |
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 CommandBuffer { | |
27 public: | |
28 CommandBufferImpl( | |
29 InterfaceRequest<CommandBuffer> request, | |
30 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(CommandBufferSyncClientPtr sync_client, | |
37 CommandBufferSyncPointClientPtr sync_point_client, | |
38 ScopedSharedBufferHandle shared_state) override; | |
39 void SetGetBuffer(int32_t buffer) override; | |
40 void Flush(int32_t put_offset) override; | |
41 void MakeProgress(int32_t last_get_offset) override; | |
42 void RegisterTransferBuffer(int32_t id, | |
43 ScopedSharedBufferHandle transfer_buffer, | |
44 uint32_t size) override; | |
45 void DestroyTransferBuffer(int32_t id) override; | |
46 void InsertSyncPoint(bool retire) override; | |
47 void RetireSyncPoint(uint32_t sync_point) override; | |
48 void Echo(const Callback<void()>& callback) override; | |
49 | |
50 void LostContext(int32_t reason); | |
51 void UpdateVSyncParameters(base::TimeTicks timebase, | |
52 base::TimeDelta interval); | |
53 | |
54 private: | |
55 void BindToRequest(InterfaceRequest<CommandBuffer> request); | |
56 | |
57 scoped_refptr<gpu::SyncPointManager> sync_point_manager_; | |
58 scoped_refptr<base::SingleThreadTaskRunner> driver_task_runner_; | |
59 scoped_ptr<CommandBufferDriver> driver_; | |
60 CommandBufferSyncPointClientPtr sync_point_client_; | |
61 ViewportParameterListenerPtr viewport_parameter_listener_; | |
62 StrongBinding<CommandBuffer> binding_; | |
63 | |
64 base::WeakPtrFactory<CommandBufferImpl> weak_factory_; | |
65 DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); | |
66 }; | |
67 | |
68 } // namespace mojo | |
69 | |
70 #endif // MOJO_SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ | |
OLD | NEW |