| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
| 11 #include "cc/output/software_output_device.h" | 11 #include "cc/output/software_output_device.h" |
| 12 #include "cc/scheduler/frame_rate_controller.h" |
| 12 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 13 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
| 13 | 14 |
| 14 namespace ui { struct LatencyInfo; } | 15 namespace ui { struct LatencyInfo; } |
| 15 | 16 |
| 16 namespace gfx { | 17 namespace gfx { |
| 17 class Rect; | 18 class Rect; |
| 18 class Size; | 19 class Size; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace cc { | 22 namespace cc { |
| 22 | 23 |
| 23 class CompositorFrame; | 24 class CompositorFrame; |
| 25 class CompositorFrameAck; |
| 24 class OutputSurfaceClient; | 26 class OutputSurfaceClient; |
| 25 class OutputSurfaceCallbacks; | 27 class OutputSurfaceCallbacks; |
| 28 class Thread; |
| 26 | 29 |
| 27 // Represents the output surface for a compositor. The compositor owns | 30 // Represents the output surface for a compositor. The compositor owns |
| 28 // and manages its destruction. Its lifetime is: | 31 // and manages its destruction. Its lifetime is: |
| 29 // 1. Created on the main thread by the LayerTreeHost through its client. | 32 // 1. Created on the main thread by the LayerTreeHost through its client. |
| 30 // 2. Passed to the compositor thread and bound to a client via BindToClient. | 33 // 2. Passed to the compositor thread and bound to a client via BindToClient. |
| 31 // From here on, it will only be used on the compositor thread. | 34 // From here on, it will only be used on the compositor thread. |
| 32 // 3. If the 3D context is lost, then the compositor will delete the output | 35 // 3. If the 3D context is lost, then the compositor will delete the output |
| 33 // surface (on the compositor thread) and go back to step 1. | 36 // surface (on the compositor thread) and go back to step 1. |
| 34 class CC_EXPORT OutputSurface { | 37 class CC_EXPORT OutputSurface : public FrameRateControllerClient { |
| 35 public: | 38 public: |
| 36 explicit OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); | 39 explicit OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); |
| 37 | 40 |
| 38 explicit OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); | 41 explicit OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); |
| 39 | 42 |
| 40 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, | 43 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, |
| 41 scoped_ptr<cc::SoftwareOutputDevice> software_device); | 44 scoped_ptr<cc::SoftwareOutputDevice> software_device); |
| 42 | 45 |
| 43 virtual ~OutputSurface(); | 46 virtual ~OutputSurface(); |
| 44 | 47 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 73 // (namely Android WebView), this is called to determine whether the software | 76 // (namely Android WebView), this is called to determine whether the software |
| 74 // device should be used on the current frame. | 77 // device should be used on the current frame. |
| 75 virtual bool ForcedDrawToSoftwareDevice() const; | 78 virtual bool ForcedDrawToSoftwareDevice() const; |
| 76 | 79 |
| 77 // Called by the compositor on the compositor thread. This is a place where | 80 // Called by the compositor on the compositor thread. This is a place where |
| 78 // thread-specific data for the output surface can be initialized, since from | 81 // thread-specific data for the output surface can be initialized, since from |
| 79 // this point on the output surface will only be used on the compositor | 82 // this point on the output surface will only be used on the compositor |
| 80 // thread. | 83 // thread. |
| 81 virtual bool BindToClient(OutputSurfaceClient* client); | 84 virtual bool BindToClient(OutputSurfaceClient* client); |
| 82 | 85 |
| 86 void InitializeBeginFrameEmulation( |
| 87 Thread* thread, |
| 88 bool throttle_frame_production, |
| 89 base::TimeDelta interval, |
| 90 bool swap_buffers_complete_supported); |
| 91 |
| 92 void SetMaxFramesPending(int max_frames_pending); |
| 93 |
| 83 // Sends frame data to the parent compositor. This should only be called when | 94 // Sends frame data to the parent compositor. This should only be called when |
| 84 // capabilities().has_parent_compositor. The implementation may destroy or | 95 // capabilities().has_parent_compositor. The implementation may destroy or |
| 85 // steal the contents of the CompositorFrame passed in. | 96 // steal the contents of the CompositorFrame passed in. |
| 86 virtual void SendFrameToParentCompositor(CompositorFrame* frame); | 97 virtual void SendFrameToParentCompositor(CompositorFrame* frame); |
| 87 | 98 |
| 88 virtual void EnsureBackbuffer(); | 99 virtual void EnsureBackbuffer(); |
| 89 virtual void DiscardBackbuffer(); | 100 virtual void DiscardBackbuffer(); |
| 90 | 101 |
| 91 virtual void Reshape(gfx::Size size, float scale_factor); | 102 virtual void Reshape(gfx::Size size, float scale_factor); |
| 92 | 103 |
| 93 virtual void BindFramebuffer(); | 104 virtual void BindFramebuffer(); |
| 94 | 105 |
| 95 virtual void PostSubBuffer(gfx::Rect rect, const ui::LatencyInfo&); | 106 virtual void PostSubBuffer(gfx::Rect rect, const ui::LatencyInfo&); |
| 96 virtual void SwapBuffers(const ui::LatencyInfo&); | 107 virtual void SwapBuffers(const ui::LatencyInfo&); |
| 97 | 108 |
| 98 // Notifies frame-rate smoothness preference. If true, all non-critical | 109 // Notifies frame-rate smoothness preference. If true, all non-critical |
| 99 // processing should be stopped, or lowered in priority. | 110 // processing should be stopped, or lowered in priority. |
| 100 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} | 111 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} |
| 101 | 112 |
| 102 // Requests a BeginFrame notification from the output surface. The | 113 // Requests a BeginFrame notification from the output surface. The |
| 103 // notification will be delivered by calling | 114 // notification will be delivered by calling |
| 104 // OutputSurfaceClient::BeginFrame until the callback is disabled. | 115 // OutputSurfaceClient::BeginFrame until the callback is disabled. |
| 105 virtual void SetNeedsBeginFrame(bool enable) {} | 116 virtual void SetNeedsBeginFrame(bool enable); |
| 117 |
| 118 private: |
| 119 OutputSurfaceClient* client_; |
| 120 friend class OutputSurfaceCallbacks; |
| 106 | 121 |
| 107 protected: | 122 protected: |
| 108 OutputSurfaceClient* client_; | |
| 109 struct cc::OutputSurface::Capabilities capabilities_; | 123 struct cc::OutputSurface::Capabilities capabilities_; |
| 110 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; | 124 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; |
| 111 scoped_ptr<cc::SoftwareOutputDevice> software_device_; | 125 scoped_ptr<cc::SoftwareOutputDevice> software_device_; |
| 112 bool has_gl_discard_backbuffer_; | 126 bool has_gl_discard_backbuffer_; |
| 113 | 127 |
| 114 scoped_ptr<OutputSurfaceCallbacks> callbacks_; | 128 scoped_ptr<OutputSurfaceCallbacks> callbacks_; |
| 115 | 129 |
| 116 private: | 130 // The FrameRateController is deprecated. |
| 131 // Platforms should move to native BeginFrames instead. |
| 132 void OnVSyncParametersChanged(base::TimeTicks timebase, |
| 133 base::TimeDelta interval); |
| 134 virtual void FrameRateControllerTick(bool throttled) OVERRIDE; |
| 135 scoped_ptr<FrameRateController> frame_rate_controller_; |
| 136 int max_frames_pending_; |
| 137 int pending_swap_buffers_; |
| 138 bool begin_frame_pending_; |
| 139 |
| 140 // Forwarded to OutputSurfaceClient but threaded through OutputSurface |
| 141 // first so OutputSurface has a chance to update the FrameRateController |
| 142 bool hasClient() { return !!client_; } |
| 143 void SetNeedsRedrawRect(gfx::Rect damage_rect); |
| 144 void BeginFrame(base::TimeTicks frame_time); |
| 145 void OnSendFrameToParentCompositorAck(const CompositorFrameAck&); |
| 146 void DidSwapBuffers(); |
| 147 void OnSwapBuffersComplete(); |
| 148 void DidLoseOutputSurface(); |
| 149 |
| 117 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 150 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
| 118 }; | 151 }; |
| 119 | 152 |
| 120 } // namespace cc | 153 } // namespace cc |
| 121 | 154 |
| 122 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 155 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
| OLD | NEW |