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 COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ | 5 #ifndef COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ |
6 #define COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ | 6 #define COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "components/mus/public/interfaces/command_buffer.mojom.h" | 14 #include "components/mus/public/interfaces/command_buffer.mojom.h" |
15 #include "gpu/command_buffer/common/command_buffer.h" | 15 #include "gpu/command_buffer/common/command_buffer.h" |
16 #include "mojo/public/cpp/bindings/binding.h" | 16 #include "mojo/public/cpp/bindings/binding.h" |
17 | 17 |
18 namespace mus { | 18 namespace mus { |
19 | 19 |
20 class CommandBufferDriver; | 20 class CommandBufferDriver; |
21 class CommandBufferImplObserver; | |
22 class GpuState; | 21 class GpuState; |
23 | 22 |
24 // This class listens to the CommandBuffer message pipe on a low-latency thread | 23 // This class listens to the CommandBuffer message pipe on a low-latency thread |
25 // so that we can insert sync points without blocking on the GL driver. It | 24 // so that we can insert sync points without blocking on the GL driver. It |
26 // forwards most method calls to the CommandBufferDriver, which runs on the | 25 // forwards most method calls to the CommandBufferDriver, which runs on the |
27 // same thread as the native viewport. | 26 // same thread as the native viewport. |
28 class CommandBufferImpl : public mojom::CommandBuffer { | 27 class CommandBufferImpl : public mojom::CommandBuffer { |
29 public: | 28 public: |
30 CommandBufferImpl(mojo::InterfaceRequest<CommandBuffer> request, | 29 CommandBufferImpl(mojo::InterfaceRequest<CommandBuffer> request, |
31 scoped_refptr<GpuState> gpu_state); | 30 scoped_refptr<GpuState> gpu_state); |
32 void DidLoseContext(uint32_t reason); | 31 void DidLoseContext(uint32_t reason); |
33 | 32 |
34 void set_observer(CommandBufferImplObserver* observer) { | |
35 observer_ = observer; | |
36 } | |
37 | |
38 private: | 33 private: |
39 class CommandBufferDriverClientImpl; | 34 class CommandBufferDriverClientImpl; |
40 ~CommandBufferImpl() override; | 35 ~CommandBufferImpl() override; |
41 | 36 |
42 // mojom::CommandBuffer: | 37 // mojom::CommandBuffer: |
43 void Initialize( | 38 void Initialize( |
44 mojom::CommandBufferLostContextObserverPtr loss_observer, | 39 mojom::CommandBufferClientPtr client, |
45 mojo::ScopedSharedBufferHandle shared_state, | 40 mojo::ScopedSharedBufferHandle shared_state, |
46 mojo::Array<int32_t> attribs, | 41 mojo::Array<int32_t> attribs, |
47 const mojom::CommandBuffer::InitializeCallback& callback) override; | 42 const mojom::CommandBuffer::InitializeCallback& callback) override; |
48 void SetGetBuffer(int32_t buffer) override; | 43 void SetGetBuffer(int32_t buffer) override; |
49 void Flush(int32_t put_offset) override; | 44 void Flush(int32_t put_offset) override; |
50 void MakeProgress( | 45 void MakeProgress( |
51 int32_t last_get_offset, | 46 int32_t last_get_offset, |
52 const mojom::CommandBuffer::MakeProgressCallback& callback) override; | 47 const mojom::CommandBuffer::MakeProgressCallback& callback) override; |
53 void RegisterTransferBuffer(int32_t id, | 48 void RegisterTransferBuffer(int32_t id, |
54 mojo::ScopedSharedBufferHandle transfer_buffer, | 49 mojo::ScopedSharedBufferHandle transfer_buffer, |
55 uint32_t size) override; | 50 uint32_t size) override; |
56 void DestroyTransferBuffer(int32_t id) override; | 51 void DestroyTransferBuffer(int32_t id) override; |
57 void CreateImage(int32_t id, | 52 void CreateImage(int32_t id, |
58 mojo::ScopedHandle memory_handle, | 53 mojo::ScopedHandle memory_handle, |
59 int32_t type, | 54 int32_t type, |
60 mojo::SizePtr size, | 55 mojo::SizePtr size, |
61 int32_t format, | 56 int32_t format, |
62 int32_t internal_format) override; | 57 int32_t internal_format) override; |
63 void DestroyImage(int32_t id) override; | 58 void DestroyImage(int32_t id) override; |
| 59 void CreateStreamTexture( |
| 60 uint32_t client_texture_id, |
| 61 const mojom::CommandBuffer::CreateStreamTextureCallback& callback |
| 62 ) override; |
| 63 void ProduceFrontBuffer(const gpu::Mailbox& mailbox) override; |
| 64 void SignalQuery(uint32_t query, uint32_t signal_id) override; |
| 65 void SignalSyncToken(const gpu::SyncToken& sync_token, |
| 66 uint32_t signal_id) override; |
| 67 void WaitForGetOffsetInRange( |
| 68 int32_t start, int32_t end, |
| 69 const mojom::CommandBuffer::WaitForGetOffsetInRangeCallback& callback |
| 70 ) override; |
| 71 void WaitForTokenInRange( |
| 72 int32_t start, int32_t end, |
| 73 const mojom::CommandBuffer::WaitForGetOffsetInRangeCallback& callback |
| 74 ) override; |
64 | 75 |
65 // All helper functions are called in the GPU therad. | 76 // All helper functions are called in the GPU therad. |
66 void InitializeOnGpuThread( | 77 void InitializeOnGpuThread( |
67 mojom::CommandBufferLostContextObserverPtr loss_observer, | 78 mojom::CommandBufferClientPtr client, |
68 mojo::ScopedSharedBufferHandle shared_state, | 79 mojo::ScopedSharedBufferHandle shared_state, |
69 mojo::Array<int32_t> attribs, | 80 mojo::Array<int32_t> attribs, |
70 const base::Callback< | 81 const base::Callback< |
71 void(mojom::CommandBufferInitializeResultPtr)>& callback); | 82 void(mojom::CommandBufferInitializeResultPtr)>& callback); |
72 bool SetGetBufferOnGpuThread(int32_t buffer); | 83 bool SetGetBufferOnGpuThread(int32_t buffer); |
73 bool FlushOnGpuThread(int32_t put_offset, uint32_t order_num); | 84 bool FlushOnGpuThread(int32_t put_offset, uint32_t order_num); |
74 bool MakeProgressOnGpuThread( | 85 bool MakeProgressOnGpuThread( |
75 int32_t last_get_offset, | 86 int32_t last_get_offset, |
76 const base::Callback<void(const gpu::CommandBuffer::State&)>& callback); | 87 const base::Callback<void(const gpu::CommandBuffer::State&)>& callback); |
77 bool RegisterTransferBufferOnGpuThread( | 88 bool RegisterTransferBufferOnGpuThread( |
(...skipping 10 matching lines...) Expand all Loading... |
88 bool DestroyImageOnGpuThread(int32_t id); | 99 bool DestroyImageOnGpuThread(int32_t id); |
89 | 100 |
90 void BindToRequest(mojo::InterfaceRequest<CommandBuffer> request); | 101 void BindToRequest(mojo::InterfaceRequest<CommandBuffer> request); |
91 | 102 |
92 void OnConnectionError(); | 103 void OnConnectionError(); |
93 bool DeleteOnGpuThread(); | 104 bool DeleteOnGpuThread(); |
94 | 105 |
95 scoped_refptr<GpuState> gpu_state_; | 106 scoped_refptr<GpuState> gpu_state_; |
96 scoped_ptr<CommandBufferDriver> driver_; | 107 scoped_ptr<CommandBufferDriver> driver_; |
97 scoped_ptr<mojo::Binding<CommandBuffer>> binding_; | 108 scoped_ptr<mojo::Binding<CommandBuffer>> binding_; |
98 CommandBufferImplObserver* observer_; | 109 mojom::CommandBufferClientPtr client_; |
99 mojom::CommandBufferLostContextObserverPtr loss_observer_; | |
100 | 110 |
101 DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); | 111 DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); |
102 }; | 112 }; |
103 | 113 |
104 } // namespace mus | 114 } // namespace mus |
105 | 115 |
106 #endif // COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ | 116 #endif // COMPONENTS_MUS_GLES2_COMMAND_BUFFER_IMPL_H_ |
OLD | NEW |