| 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/base/rolling_time_delta_history.h" |
| 16 #include "cc/output/context_provider.h" | 16 #include "cc/output/context_provider.h" |
| 17 #include "cc/output/overlay_candidate_validator.h" | 17 #include "cc/output/overlay_candidate_validator.h" |
| 18 #include "cc/output/software_output_device.h" | 18 #include "cc/output/software_output_device.h" |
| 19 #include "cc/scheduler/frame_source.h" |
| 20 #include "ui/compositor/compositor_vsync_manager.h" |
| 19 | 21 |
| 20 namespace base { class SingleThreadTaskRunner; } | 22 namespace base { class SingleThreadTaskRunner; } |
| 21 | 23 |
| 22 namespace ui { struct LatencyInfo; } | 24 namespace ui { struct LatencyInfo; } |
| 23 | 25 |
| 24 namespace gfx { | 26 namespace gfx { |
| 25 class Rect; | 27 class Rect; |
| 26 class Size; | 28 class Size; |
| 27 class Transform; | 29 class Transform; |
| 28 } | 30 } |
| 29 | 31 |
| 30 namespace cc { | 32 namespace cc { |
| 31 | 33 |
| 32 class CompositorFrame; | 34 class CompositorFrame; |
| 33 class CompositorFrameAck; | 35 class CompositorFrameAck; |
| 34 struct ManagedMemoryPolicy; | 36 struct ManagedMemoryPolicy; |
| 35 class OutputSurfaceClient; | 37 class OutputSurfaceClient; |
| 36 | 38 |
| 37 // Represents the output surface for a compositor. The compositor owns | 39 // Represents the output surface for a compositor. The compositor owns |
| 38 // and manages its destruction. Its lifetime is: | 40 // and manages its destruction. Its lifetime is: |
| 39 // 1. Created on the main thread by the LayerTreeHost through its client. | 41 // 1. Created on the main thread by the LayerTreeHost through its client. |
| 40 // 2. Passed to the compositor thread and bound to a client via BindToClient. | 42 // 2. Passed to the compositor thread and bound to a client via BindToClient. |
| 41 // From here on, it will only be used on the compositor thread. | 43 // From here on, it will only be used on the compositor thread. |
| 42 // 3. If the 3D context is lost, then the compositor will delete the output | 44 // 3. If the 3D context is lost, then the compositor will delete the output |
| 43 // surface (on the compositor thread) and go back to step 1. | 45 // surface (on the compositor thread) and go back to step 1. |
| 44 class CC_EXPORT OutputSurface { | 46 class CC_EXPORT OutputSurface : public BeginFrameSource { |
| 45 public: | 47 public: |
| 46 enum { | 48 enum { |
| 47 DEFAULT_MAX_FRAMES_PENDING = 2 | 49 DEFAULT_MAX_FRAMES_PENDING = 2 |
| 48 }; | 50 }; |
| 49 | 51 |
| 50 explicit OutputSurface( | 52 explicit OutputSurface( |
| 51 const scoped_refptr<ContextProvider>& context_provider); | 53 const scoped_refptr<ContextProvider>& context_provider); |
| 52 | 54 |
| 53 explicit OutputSurface(scoped_ptr<SoftwareOutputDevice> software_device); | 55 explicit OutputSurface(scoped_ptr<SoftwareOutputDevice> software_device); |
| 54 | 56 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // The implementation may destroy or steal the contents of the CompositorFrame | 116 // The implementation may destroy or steal the contents of the CompositorFrame |
| 115 // passed in (though it will not take ownership of the CompositorFrame | 117 // passed in (though it will not take ownership of the CompositorFrame |
| 116 // itself). | 118 // itself). |
| 117 virtual void SwapBuffers(CompositorFrame* frame); | 119 virtual void SwapBuffers(CompositorFrame* frame); |
| 118 virtual void OnSwapBuffersComplete(); | 120 virtual void OnSwapBuffersComplete(); |
| 119 | 121 |
| 120 // Notifies frame-rate smoothness preference. If true, all non-critical | 122 // Notifies frame-rate smoothness preference. If true, all non-critical |
| 121 // processing should be stopped, or lowered in priority. | 123 // processing should be stopped, or lowered in priority. |
| 122 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} | 124 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} |
| 123 | 125 |
| 124 // Requests a BeginFrame notification from the output surface. The | |
| 125 // notification will be delivered by calling | |
| 126 // OutputSurfaceClient::BeginFrame until the callback is disabled. | |
| 127 virtual void SetNeedsBeginFrame(bool enable) {} | |
| 128 | |
| 129 bool HasClient() { return !!client_; } | 126 bool HasClient() { return !!client_; } |
| 130 | 127 |
| 131 // Returns an estimate of the current GPU latency. When only a software | 128 // Returns an estimate of the current GPU latency. When only a software |
| 132 // device is present, returns 0. | 129 // device is present, returns 0. |
| 133 base::TimeDelta GpuLatencyEstimate(); | 130 base::TimeDelta GpuLatencyEstimate(); |
| 134 | 131 |
| 135 // Get the class capable of informing cc of hardware overlay capability. | 132 // Get the class capable of informing cc of hardware overlay capability. |
| 136 OverlayCandidateValidator* overlay_candidate_validator() const { | 133 OverlayCandidateValidator* overlay_candidate_validator() const { |
| 137 return overlay_candidate_validator_.get(); | 134 return overlay_candidate_validator_.get(); |
| 138 } | 135 } |
| 139 | 136 |
| 137 void AddVSyncObserver(ui::CompositorVSyncManager::Observer* obs) { |
| 138 vsync_observer_ = obs; |
| 139 }; |
| 140 |
| 141 // BeginFrameSource |
| 142 virtual void SetNeedsBeginFrames(bool needs_begin_frames) OVERRIDE; |
| 143 virtual bool NeedsBeginFrames() const OVERRIDE; |
| 144 virtual void DidFinishFrame(size_t remaining_frames) OVERRIDE {} |
| 145 virtual void AsValueInto(base::debug::TracedValue* dict) const OVERRIDE; |
| 146 |
| 140 protected: | 147 protected: |
| 148 bool needs_begin_frames_ = false; |
| 149 |
| 141 OutputSurfaceClient* client_; | 150 OutputSurfaceClient* client_; |
| 151 ui::CompositorVSyncManager::Observer* vsync_observer_; |
| 152 BeginFrameObserver* begin_frame_observer_; |
| 142 | 153 |
| 143 // Synchronously initialize context3d and enter hardware mode. | 154 // Synchronously initialize context3d and enter hardware mode. |
| 144 // This can only supported in threaded compositing mode. | 155 // This can only supported in threaded compositing mode. |
| 145 bool InitializeAndSetContext3d( | 156 bool InitializeAndSetContext3d( |
| 146 scoped_refptr<ContextProvider> context_provider); | 157 scoped_refptr<ContextProvider> context_provider); |
| 147 void ReleaseGL(); | 158 void ReleaseGL(); |
| 148 | 159 |
| 149 void PostSwapBuffersComplete(); | 160 void PostSwapBuffersComplete(); |
| 150 | 161 |
| 151 struct OutputSurface::Capabilities capabilities_; | 162 struct OutputSurface::Capabilities capabilities_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 std::deque<unsigned> available_gpu_latency_query_ids_; | 194 std::deque<unsigned> available_gpu_latency_query_ids_; |
| 184 std::deque<unsigned> pending_gpu_latency_query_ids_; | 195 std::deque<unsigned> pending_gpu_latency_query_ids_; |
| 185 RollingTimeDeltaHistory gpu_latency_history_; | 196 RollingTimeDeltaHistory gpu_latency_history_; |
| 186 | 197 |
| 187 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 198 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
| 188 }; | 199 }; |
| 189 | 200 |
| 190 } // namespace cc | 201 } // namespace cc |
| 191 | 202 |
| 192 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 203 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
| OLD | NEW |