OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ | 5 #ifndef GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ |
6 #define GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ | 6 #define GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <deque> | 11 #include <deque> |
12 #include <memory> | 12 #include <memory> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 19 #include "base/synchronization/lock.h" |
19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
20 #include "gpu/command_buffer/common/command_buffer_id.h" | 21 #include "gpu/command_buffer/common/command_buffer_id.h" |
21 #include "gpu/command_buffer/common/constants.h" | 22 #include "gpu/command_buffer/common/constants.h" |
22 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 23 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
23 #include "gpu/command_buffer/service/command_buffer_service.h" | 24 #include "gpu/command_buffer/service/command_buffer_service.h" |
24 #include "gpu/command_buffer/service/command_executor.h" | 25 #include "gpu/command_buffer/service/command_executor.h" |
25 #include "gpu/command_buffer/service/context_group.h" | 26 #include "gpu/command_buffer/service/context_group.h" |
26 #include "gpu/gpu_export.h" | 27 #include "gpu/gpu_export.h" |
27 #include "gpu/ipc/common/surface_handle.h" | 28 #include "gpu/ipc/common/surface_handle.h" |
28 #include "gpu/ipc/service/gpu_memory_manager.h" | 29 #include "gpu/ipc/service/gpu_memory_manager.h" |
(...skipping 14 matching lines...) Expand all Loading... |
43 class SyncPointClient; | 44 class SyncPointClient; |
44 } | 45 } |
45 | 46 |
46 struct GPUCreateCommandBufferConfig; | 47 struct GPUCreateCommandBufferConfig; |
47 struct GpuCommandBufferMsg_CreateImage_Params; | 48 struct GpuCommandBufferMsg_CreateImage_Params; |
48 | 49 |
49 namespace gpu { | 50 namespace gpu { |
50 | 51 |
51 class GpuChannel; | 52 class GpuChannel; |
52 struct WaitForCommandState; | 53 struct WaitForCommandState; |
| 54 class GpuVSyncProvider; |
53 | 55 |
54 class GPU_EXPORT GpuCommandBufferStub | 56 class GPU_EXPORT GpuCommandBufferStub |
55 : public IPC::Listener, | 57 : public IPC::Listener, |
56 public IPC::Sender, | 58 public IPC::Sender, |
57 public ImageTransportSurfaceDelegate, | 59 public ImageTransportSurfaceDelegate, |
58 public base::SupportsWeakPtr<GpuCommandBufferStub> { | 60 public base::SupportsWeakPtr<GpuCommandBufferStub> { |
59 public: | 61 public: |
60 class DestructionObserver { | 62 class DestructionObserver { |
61 public: | 63 public: |
62 // Called in Destroy(), before the context/surface are released. | 64 // Called in Destroy(), before the context/surface are released. |
(...skipping 23 matching lines...) Expand all Loading... |
86 | 88 |
87 // ImageTransportSurfaceDelegate implementation: | 89 // ImageTransportSurfaceDelegate implementation: |
88 #if defined(OS_WIN) | 90 #if defined(OS_WIN) |
89 void DidCreateAcceleratedSurfaceChildWindow( | 91 void DidCreateAcceleratedSurfaceChildWindow( |
90 SurfaceHandle parent_window, | 92 SurfaceHandle parent_window, |
91 SurfaceHandle child_window) override; | 93 SurfaceHandle child_window) override; |
92 #endif | 94 #endif |
93 void DidSwapBuffersComplete(SwapBuffersCompleteParams params) override; | 95 void DidSwapBuffersComplete(SwapBuffersCompleteParams params) override; |
94 const gles2::FeatureInfo* GetFeatureInfo() const override; | 96 const gles2::FeatureInfo* GetFeatureInfo() const override; |
95 void SetLatencyInfoCallback(const LatencyInfoCallback& callback) override; | 97 void SetLatencyInfoCallback(const LatencyInfoCallback& callback) override; |
| 98 // This is called from VSyncProvider to update parameters for generating |
| 99 // timer-based VSync signals on the browser side. |
96 void UpdateVSyncParameters(base::TimeTicks timebase, | 100 void UpdateVSyncParameters(base::TimeTicks timebase, |
97 base::TimeDelta interval) override; | 101 base::TimeDelta interval) override; |
98 | 102 |
| 103 // This is called from GpuVSyncProvider with actual GPU VSync signals. |
| 104 void UpdateGpuVSync(base::TimeTicks timestamp); |
| 105 |
| 106 // Send VSync signals or VSync parameters over IPC. |
| 107 void SendUpdatedVSyncParameters(base::TimeTicks timebase, |
| 108 base::TimeDelta interval); |
| 109 |
99 gles2::MemoryTracker* GetMemoryTracker() const; | 110 gles2::MemoryTracker* GetMemoryTracker() const; |
100 | 111 |
101 // Whether this command buffer can currently handle IPC messages. | 112 // Whether this command buffer can currently handle IPC messages. |
102 bool IsScheduled(); | 113 bool IsScheduled(); |
103 | 114 |
104 // Whether there are commands in the buffer that haven't been processed. | 115 // Whether there are commands in the buffer that haven't been processed. |
105 bool HasUnprocessedCommands(); | 116 bool HasUnprocessedCommands(); |
106 | 117 |
107 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } | 118 gles2::GLES2Decoder* decoder() const { return decoder_.get(); } |
108 CommandExecutor* scheduler() const { return executor_.get(); } | 119 CommandExecutor* scheduler() const { return executor_.get(); } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 uint64_t release); | 192 uint64_t release); |
182 | 193 |
183 void OnDescheduleUntilFinished(); | 194 void OnDescheduleUntilFinished(); |
184 void OnRescheduleAfterFinished(); | 195 void OnRescheduleAfterFinished(); |
185 | 196 |
186 void OnCreateImage(const GpuCommandBufferMsg_CreateImage_Params& params); | 197 void OnCreateImage(const GpuCommandBufferMsg_CreateImage_Params& params); |
187 void OnDestroyImage(int32_t id); | 198 void OnDestroyImage(int32_t id); |
188 void OnCreateStreamTexture(uint32_t texture_id, | 199 void OnCreateStreamTexture(uint32_t texture_id, |
189 int32_t stream_id, | 200 int32_t stream_id, |
190 bool* succeeded); | 201 bool* succeeded); |
| 202 void OnEnableVSync(bool enabled); |
191 void OnCommandProcessed(); | 203 void OnCommandProcessed(); |
192 void OnParseError(); | 204 void OnParseError(); |
193 | 205 |
194 void ReportState(); | 206 void ReportState(); |
195 | 207 |
196 // Wrapper for CommandExecutor::PutChanged that sets the crash report URL. | 208 // Wrapper for CommandExecutor::PutChanged that sets the crash report URL. |
197 void PutChanged(); | 209 void PutChanged(); |
198 | 210 |
199 // Poll the command buffer to execute work. | 211 // Poll the command buffer to execute work. |
200 void PollWork(); | 212 void PollWork(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 base::TimeTicks last_idle_time_; | 255 base::TimeTicks last_idle_time_; |
244 | 256 |
245 LatencyInfoCallback latency_info_callback_; | 257 LatencyInfoCallback latency_info_callback_; |
246 | 258 |
247 GURL active_url_; | 259 GURL active_url_; |
248 size_t active_url_hash_; | 260 size_t active_url_hash_; |
249 | 261 |
250 std::unique_ptr<WaitForCommandState> wait_for_token_; | 262 std::unique_ptr<WaitForCommandState> wait_for_token_; |
251 std::unique_ptr<WaitForCommandState> wait_for_get_offset_; | 263 std::unique_ptr<WaitForCommandState> wait_for_get_offset_; |
252 | 264 |
| 265 bool gpu_vsync_signal_supported_; |
| 266 std::unique_ptr<GpuVSyncProvider> vsync_provider_; |
| 267 |
| 268 #if defined(OS_WIN) |
| 269 // TODO: This isn't ideal, but for now VSync interval is still |
| 270 // provided via UpdateVSyncParameters on the main thread, but |
| 271 // it needs to be passed along with VSync signal when VSync becomes |
| 272 // available on background thread. |
| 273 // The current solution is to temporarily store vsync_interval_. |
| 274 // Perhaps this could be avoided by calculating the interval from |
| 275 // consecutive VSync signals. |
| 276 base::TimeDelta vsync_interval_; |
| 277 base::Lock vsync_lock_; |
| 278 #endif // defined(OS_WIN) |
| 279 |
253 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); | 280 DISALLOW_COPY_AND_ASSIGN(GpuCommandBufferStub); |
254 }; | 281 }; |
255 | 282 |
256 } // namespace gpu | 283 } // namespace gpu |
257 | 284 |
258 #endif // GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ | 285 #endif // GPU_IPC_SERVICE_GPU_COMMAND_BUFFER_STUB_H_ |
OLD | NEW |