OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CC_OUTPUT_OUTPUT_SURFACE_H_ | 5 #ifndef CC_OUTPUT_OUTPUT_SURFACE_H_ |
6 #define CC_OUTPUT_OUTPUT_SURFACE_H_ | 6 #define CC_OUTPUT_OUTPUT_SURFACE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.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 "cc/base/cc_export.h" | 14 #include "cc/base/cc_export.h" |
| 15 #include "cc/base/rolling_time_delta_history.h" |
15 #include "cc/output/context_provider.h" | 16 #include "cc/output/context_provider.h" |
16 #include "cc/output/overlay_candidate_validator.h" | 17 #include "cc/output/overlay_candidate_validator.h" |
17 #include "cc/output/software_output_device.h" | 18 #include "cc/output/software_output_device.h" |
18 | 19 |
19 namespace base { class SingleThreadTaskRunner; } | 20 namespace base { class SingleThreadTaskRunner; } |
20 | 21 |
21 namespace ui { struct LatencyInfo; } | 22 namespace ui { struct LatencyInfo; } |
22 | 23 |
23 namespace gfx { | 24 namespace gfx { |
24 class Rect; | 25 class Rect; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // processing should be stopped, or lowered in priority. | 121 // processing should be stopped, or lowered in priority. |
121 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} | 122 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} |
122 | 123 |
123 // Requests a BeginFrame notification from the output surface. The | 124 // Requests a BeginFrame notification from the output surface. The |
124 // notification will be delivered by calling | 125 // notification will be delivered by calling |
125 // OutputSurfaceClient::BeginFrame until the callback is disabled. | 126 // OutputSurfaceClient::BeginFrame until the callback is disabled. |
126 virtual void SetNeedsBeginFrame(bool enable) {} | 127 virtual void SetNeedsBeginFrame(bool enable) {} |
127 | 128 |
128 bool HasClient() { return !!client_; } | 129 bool HasClient() { return !!client_; } |
129 | 130 |
| 131 // Returns an estimate of the current GPU latency. When only a software |
| 132 // device is present, returns 0. |
| 133 base::TimeDelta GpuLatencyEstimate(); |
| 134 |
130 // Get the class capable of informing cc of hardware overlay capability. | 135 // Get the class capable of informing cc of hardware overlay capability. |
131 OverlayCandidateValidator* overlay_candidate_validator() const { | 136 OverlayCandidateValidator* overlay_candidate_validator() const { |
132 return overlay_candidate_validator_.get(); | 137 return overlay_candidate_validator_.get(); |
133 } | 138 } |
134 | 139 |
135 protected: | 140 protected: |
136 OutputSurfaceClient* client_; | 141 OutputSurfaceClient* client_; |
137 | 142 |
138 // Synchronously initialize context3d and enter hardware mode. | 143 // Synchronously initialize context3d and enter hardware mode. |
139 // This can only supported in threaded compositing mode. | 144 // This can only supported in threaded compositing mode. |
(...skipping 22 matching lines...) Expand all Loading... |
162 const gfx::Rect& viewport, | 167 const gfx::Rect& viewport, |
163 const gfx::Rect& clip, | 168 const gfx::Rect& clip, |
164 const gfx::Rect& viewport_rect_for_tile_priority, | 169 const gfx::Rect& viewport_rect_for_tile_priority, |
165 const gfx::Transform& transform_for_tile_priority, | 170 const gfx::Transform& transform_for_tile_priority, |
166 bool resourceless_software_draw); | 171 bool resourceless_software_draw); |
167 | 172 |
168 private: | 173 private: |
169 void SetUpContext3d(); | 174 void SetUpContext3d(); |
170 void ResetContext3d(); | 175 void ResetContext3d(); |
171 void SetMemoryPolicy(const ManagedMemoryPolicy& policy); | 176 void SetMemoryPolicy(const ManagedMemoryPolicy& policy); |
| 177 void UpdateAndMeasureGpuLatency(); |
172 | 178 |
173 bool external_stencil_test_enabled_; | 179 bool external_stencil_test_enabled_; |
174 | 180 |
175 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; | 181 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; |
176 | 182 |
| 183 std::deque<unsigned> available_gpu_latency_query_ids_; |
| 184 std::deque<unsigned> pending_gpu_latency_query_ids_; |
| 185 RollingTimeDeltaHistory gpu_latency_history_; |
| 186 |
177 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 187 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
178 }; | 188 }; |
179 | 189 |
180 } // namespace cc | 190 } // namespace cc |
181 | 191 |
182 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 192 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
OLD | NEW |