OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DRIVER_H_ | 5 #ifndef COMPONENTS_MUS_GLES2_COMMAND_BUFFER_DRIVER_H_ |
6 #define COMPONENTS_MUS_GLES2_COMMAND_BUFFER_DRIVER_H_ | 6 #define COMPONENTS_MUS_GLES2_COMMAND_BUFFER_DRIVER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "gpu/command_buffer/common/capabilities.h" | 17 #include "gpu/command_buffer/common/capabilities.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/constants.h" | 20 #include "gpu/command_buffer/common/constants.h" |
20 #include "mojo/public/cpp/bindings/array.h" | 21 #include "mojo/public/cpp/bindings/array.h" |
21 #include "mojo/public/cpp/system/buffer.h" | 22 #include "mojo/public/cpp/system/buffer.h" |
22 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
23 #include "ui/mojo/geometry/geometry.mojom.h" | 24 #include "ui/mojo/geometry/geometry.mojom.h" |
24 | 25 |
25 namespace gpu { | 26 namespace gpu { |
26 class CommandBufferService; | 27 class CommandBufferService; |
27 class GpuScheduler; | 28 class GpuScheduler; |
28 class SyncPointClient; | 29 class SyncPointClient; |
(...skipping 16 matching lines...) Expand all Loading... |
45 // viewport. | 46 // viewport. |
46 class CommandBufferDriver : base::NonThreadSafe { | 47 class CommandBufferDriver : base::NonThreadSafe { |
47 public: | 48 public: |
48 class Client { | 49 class Client { |
49 public: | 50 public: |
50 virtual ~Client(); | 51 virtual ~Client(); |
51 virtual void DidLoseContext(uint32_t reason) = 0; | 52 virtual void DidLoseContext(uint32_t reason) = 0; |
52 virtual void UpdateVSyncParameters(int64_t timebase, int64_t interval) = 0; | 53 virtual void UpdateVSyncParameters(int64_t timebase, int64_t interval) = 0; |
53 }; | 54 }; |
54 CommandBufferDriver(gpu::CommandBufferNamespace command_buffer_namespace, | 55 CommandBufferDriver(gpu::CommandBufferNamespace command_buffer_namespace, |
55 uint64_t command_buffer_id, | 56 gpu::CommandBufferId command_buffer_id, |
56 gfx::AcceleratedWidget widget, | 57 gfx::AcceleratedWidget widget, |
57 scoped_refptr<GpuState> gpu_state); | 58 scoped_refptr<GpuState> gpu_state); |
58 ~CommandBufferDriver(); | 59 ~CommandBufferDriver(); |
59 | 60 |
60 void set_client(scoped_ptr<Client> client) { client_ = std::move(client); } | 61 void set_client(scoped_ptr<Client> client) { client_ = std::move(client); } |
61 | 62 |
62 bool Initialize(mojo::ScopedSharedBufferHandle shared_state, | 63 bool Initialize(mojo::ScopedSharedBufferHandle shared_state, |
63 mojo::Array<int32_t> attribs); | 64 mojo::Array<int32_t> attribs); |
64 void SetGetBuffer(int32_t buffer); | 65 void SetGetBuffer(int32_t buffer); |
65 void Flush(int32_t put_offset); | 66 void Flush(int32_t put_offset); |
66 void RegisterTransferBuffer(int32_t id, | 67 void RegisterTransferBuffer(int32_t id, |
67 mojo::ScopedSharedBufferHandle transfer_buffer, | 68 mojo::ScopedSharedBufferHandle transfer_buffer, |
68 uint32_t size); | 69 uint32_t size); |
69 void DestroyTransferBuffer(int32_t id); | 70 void DestroyTransferBuffer(int32_t id); |
70 void CreateImage(int32_t id, | 71 void CreateImage(int32_t id, |
71 mojo::ScopedHandle memory_handle, | 72 mojo::ScopedHandle memory_handle, |
72 int32_t type, | 73 int32_t type, |
73 mojo::SizePtr size, | 74 mojo::SizePtr size, |
74 int32_t format, | 75 int32_t format, |
75 int32_t internal_format); | 76 int32_t internal_format); |
76 void DestroyImage(int32_t id); | 77 void DestroyImage(int32_t id); |
77 bool IsScheduled() const; | 78 bool IsScheduled() const; |
78 bool HasUnprocessedCommands() const; | 79 bool HasUnprocessedCommands() const; |
79 gpu::Capabilities GetCapabilities() const; | 80 gpu::Capabilities GetCapabilities() const; |
80 gpu::CommandBuffer::State GetLastState() const; | 81 gpu::CommandBuffer::State GetLastState() const; |
81 gpu::CommandBufferNamespace GetNamespaceID() const { | 82 gpu::CommandBufferNamespace GetNamespaceID() const { |
82 return command_buffer_namespace_; | 83 return command_buffer_namespace_; |
83 } | 84 } |
84 uint64_t GetCommandBufferID() const { return command_buffer_id_; } | 85 gpu::CommandBufferId GetCommandBufferID() const { return command_buffer_id_; } |
85 gpu::SyncPointOrderData* sync_point_order_data() { | 86 gpu::SyncPointOrderData* sync_point_order_data() { |
86 return sync_point_order_data_.get(); | 87 return sync_point_order_data_.get(); |
87 } | 88 } |
88 uint32_t GetUnprocessedOrderNum() const; | 89 uint32_t GetUnprocessedOrderNum() const; |
89 uint32_t GetProcessedOrderNum() const; | 90 uint32_t GetProcessedOrderNum() const; |
90 void SignalQuery(uint32_t query_id, const base::Closure& callback); | 91 void SignalQuery(uint32_t query_id, const base::Closure& callback); |
91 | 92 |
92 private: | 93 private: |
93 bool MakeCurrent(); | 94 bool MakeCurrent(); |
94 | 95 |
(...skipping 11 matching lines...) Expand all Loading... |
106 void PollWork(); | 107 void PollWork(); |
107 void PerformWork(); | 108 void PerformWork(); |
108 | 109 |
109 void DestroyDecoder(); | 110 void DestroyDecoder(); |
110 | 111 |
111 // Callbacks: | 112 // Callbacks: |
112 void OnUpdateVSyncParameters(const base::TimeTicks timebase, | 113 void OnUpdateVSyncParameters(const base::TimeTicks timebase, |
113 const base::TimeDelta interval); | 114 const base::TimeDelta interval); |
114 void OnFenceSyncRelease(uint64_t release); | 115 void OnFenceSyncRelease(uint64_t release); |
115 bool OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id, | 116 bool OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id, |
116 uint64_t command_buffer_id, | 117 gpu::CommandBufferId command_buffer_id, |
117 uint64_t release); | 118 uint64_t release); |
118 void OnParseError(); | 119 void OnParseError(); |
119 void OnContextLost(uint32_t reason); | 120 void OnContextLost(uint32_t reason); |
120 | 121 |
121 const gpu::CommandBufferNamespace command_buffer_namespace_; | 122 const gpu::CommandBufferNamespace command_buffer_namespace_; |
122 const uint64_t command_buffer_id_; | 123 const gpu::CommandBufferId command_buffer_id_; |
123 gfx::AcceleratedWidget widget_; | 124 gfx::AcceleratedWidget widget_; |
124 scoped_ptr<Client> client_; | 125 scoped_ptr<Client> client_; |
125 scoped_ptr<gpu::CommandBufferService> command_buffer_; | 126 scoped_ptr<gpu::CommandBufferService> command_buffer_; |
126 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | 127 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; |
127 scoped_ptr<gpu::GpuScheduler> scheduler_; | 128 scoped_ptr<gpu::GpuScheduler> scheduler_; |
128 scoped_refptr<gpu::SyncPointOrderData> sync_point_order_data_; | 129 scoped_refptr<gpu::SyncPointOrderData> sync_point_order_data_; |
129 scoped_ptr<gpu::SyncPointClient> sync_point_client_; | 130 scoped_ptr<gpu::SyncPointClient> sync_point_client_; |
130 scoped_refptr<gfx::GLContext> context_; | 131 scoped_refptr<gfx::GLContext> context_; |
131 scoped_refptr<gfx::GLSurface> surface_; | 132 scoped_refptr<gfx::GLSurface> surface_; |
132 scoped_refptr<GpuState> gpu_state_; | 133 scoped_refptr<GpuState> gpu_state_; |
133 | 134 |
134 scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_; | 135 scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_; |
135 base::Callback<void(int32_t)> context_lost_callback_; | 136 base::Callback<void(int32_t)> context_lost_callback_; |
136 | 137 |
137 base::TimeTicks process_delayed_work_time_; | 138 base::TimeTicks process_delayed_work_time_; |
138 uint32_t previous_processed_num_; | 139 uint32_t previous_processed_num_; |
139 base::TimeTicks last_idle_time_; | 140 base::TimeTicks last_idle_time_; |
140 | 141 |
141 base::WeakPtrFactory<CommandBufferDriver> weak_factory_; | 142 base::WeakPtrFactory<CommandBufferDriver> weak_factory_; |
142 | 143 |
143 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver); | 144 DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver); |
144 }; | 145 }; |
145 | 146 |
146 } // namespace mus | 147 } // namespace mus |
147 | 148 |
148 #endif // COMPONENTS_GLES2_COMMAND_BUFFER_DRIVER_H_ | 149 #endif // COMPONENTS_GLES2_COMMAND_BUFFER_DRIVER_H_ |
OLD | NEW |