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 MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ | 5 #ifndef MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ |
6 #define MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ | 6 #define MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "components/mus/public/interfaces/command_buffer.mojom.h" | 16 #include "components/mus/public/interfaces/command_buffer.mojom.h" |
17 #include "gpu/command_buffer/client/gpu_control.h" | 17 #include "gpu/command_buffer/client/gpu_control.h" |
18 #include "gpu/command_buffer/common/command_buffer.h" | 18 #include "gpu/command_buffer/common/command_buffer.h" |
19 #include "gpu/command_buffer/common/command_buffer_id.h" | 19 #include "gpu/command_buffer/common/command_buffer_id.h" |
20 #include "gpu/command_buffer/common/command_buffer_shared.h" | 20 #include "gpu/command_buffer/common/command_buffer_shared.h" |
21 #include "mojo/public/cpp/bindings/binding.h" | 21 #include "mojo/public/cpp/bindings/binding.h" |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class RunLoop; | 24 class RunLoop; |
25 } | 25 } |
26 | 26 |
27 namespace gles2 { | 27 namespace gles2 { |
28 class CommandBufferClientImpl; | 28 class CommandBufferClientImpl; |
29 | 29 |
30 class CommandBufferDelegate { | |
31 public: | |
32 virtual ~CommandBufferDelegate(); | |
33 virtual void ContextLost(); | |
34 }; | |
35 | |
36 class CommandBufferClientImpl | 30 class CommandBufferClientImpl |
37 : public mus::mojom::CommandBufferClient, | 31 : public mus::mojom::CommandBufferClient, |
38 public gpu::CommandBuffer, | 32 public gpu::CommandBuffer, |
39 public gpu::GpuControl { | 33 public gpu::GpuControl { |
40 public: | 34 public: |
41 explicit CommandBufferClientImpl( | 35 explicit CommandBufferClientImpl( |
42 CommandBufferDelegate* delegate, | |
43 const std::vector<int32_t>& attribs, | 36 const std::vector<int32_t>& attribs, |
44 mojo::ScopedMessagePipeHandle command_buffer_handle); | 37 mojo::ScopedMessagePipeHandle command_buffer_handle); |
45 ~CommandBufferClientImpl() override; | 38 ~CommandBufferClientImpl() override; |
46 | 39 |
47 // CommandBuffer implementation: | 40 // CommandBuffer implementation: |
48 bool Initialize() override; | 41 bool Initialize() override; |
49 State GetLastState() override; | 42 State GetLastState() override; |
50 int32_t GetLastToken() override; | 43 int32_t GetLastToken() override; |
51 void Flush(int32_t put_offset) override; | 44 void Flush(int32_t put_offset) override; |
52 void OrderingBarrier(int32_t put_offset) override; | 45 void OrderingBarrier(int32_t put_offset) override; |
53 void WaitForTokenInRange(int32_t start, int32_t end) override; | 46 void WaitForTokenInRange(int32_t start, int32_t end) override; |
54 void WaitForGetOffsetInRange(int32_t start, int32_t end) override; | 47 void WaitForGetOffsetInRange(int32_t start, int32_t end) override; |
55 void SetGetBuffer(int32_t shm_id) override; | 48 void SetGetBuffer(int32_t shm_id) override; |
56 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, | 49 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, |
57 int32_t* id) override; | 50 int32_t* id) override; |
58 void DestroyTransferBuffer(int32_t id) override; | 51 void DestroyTransferBuffer(int32_t id) override; |
59 | 52 |
60 // gpu::GpuControl implementation: | 53 // gpu::GpuControl implementation: |
| 54 void SetGpuControlClient(gpu::GpuControlClient*) override; |
61 gpu::Capabilities GetCapabilities() override; | 55 gpu::Capabilities GetCapabilities() override; |
62 int32_t CreateImage(ClientBuffer buffer, | 56 int32_t CreateImage(ClientBuffer buffer, |
63 size_t width, | 57 size_t width, |
64 size_t height, | 58 size_t height, |
65 unsigned internalformat) override; | 59 unsigned internalformat) override; |
66 void DestroyImage(int32_t id) override; | 60 void DestroyImage(int32_t id) override; |
67 int32_t CreateGpuMemoryBufferImage(size_t width, | 61 int32_t CreateGpuMemoryBufferImage(size_t width, |
68 size_t height, | 62 size_t height, |
69 unsigned internalformat, | 63 unsigned internalformat, |
70 unsigned usage) override; | 64 unsigned usage) override; |
(...skipping 18 matching lines...) Expand all Loading... |
89 void SignalAck(uint32_t id) override; | 83 void SignalAck(uint32_t id) override; |
90 void SwapBuffersCompleted(int32_t result) override; | 84 void SwapBuffersCompleted(int32_t result) override; |
91 void UpdateState(const gpu::CommandBuffer::State& state) override; | 85 void UpdateState(const gpu::CommandBuffer::State& state) override; |
92 void UpdateVSyncParameters(int64_t timebase, int64_t interval) override; | 86 void UpdateVSyncParameters(int64_t timebase, int64_t interval) override; |
93 | 87 |
94 void TryUpdateState(); | 88 void TryUpdateState(); |
95 void MakeProgressAndUpdateState(); | 89 void MakeProgressAndUpdateState(); |
96 | 90 |
97 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; } | 91 gpu::CommandBufferSharedState* shared_state() const { return shared_state_; } |
98 | 92 |
99 CommandBufferDelegate* delegate_; | 93 gpu::GpuControlClient* gpu_control_client_; |
| 94 bool destroyed_; |
100 std::vector<int32_t> attribs_; | 95 std::vector<int32_t> attribs_; |
101 mojo::Binding<mus::mojom::CommandBufferClient> client_binding_; | 96 mojo::Binding<mus::mojom::CommandBufferClient> client_binding_; |
102 mus::mojom::CommandBufferPtr command_buffer_; | 97 mus::mojom::CommandBufferPtr command_buffer_; |
103 | 98 |
104 gpu::CommandBufferId command_buffer_id_; | 99 gpu::CommandBufferId command_buffer_id_; |
105 gpu::Capabilities capabilities_; | 100 gpu::Capabilities capabilities_; |
106 State last_state_; | 101 State last_state_; |
107 mojo::ScopedSharedBufferHandle shared_state_handle_; | 102 mojo::ScopedSharedBufferHandle shared_state_handle_; |
108 gpu::CommandBufferSharedState* shared_state_; | 103 gpu::CommandBufferSharedState* shared_state_; |
109 int32_t last_put_offset_; | 104 int32_t last_put_offset_; |
110 int32_t next_transfer_buffer_id_; | 105 int32_t next_transfer_buffer_id_; |
111 | 106 |
112 // Image IDs are allocated in sequence. | 107 // Image IDs are allocated in sequence. |
113 int next_image_id_; | 108 int next_image_id_; |
114 | 109 |
115 uint64_t next_fence_sync_release_; | 110 uint64_t next_fence_sync_release_; |
116 uint64_t flushed_fence_sync_release_; | 111 uint64_t flushed_fence_sync_release_; |
117 }; | 112 }; |
118 | 113 |
119 } // gles2 | 114 } // gles2 |
120 | 115 |
121 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ | 116 #endif // MOJO_GLES2_COMMAND_BUFFER_CLIENT_IMPL_H_ |
OLD | NEW |