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/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 // Represents the output surface for a compositor. The compositor owns | 34 // Represents the output surface for a compositor. The compositor owns |
35 // and manages its destruction. Its lifetime is: | 35 // and manages its destruction. Its lifetime is: |
36 // 1. Created on the main thread by the LayerTreeHost through its client. | 36 // 1. Created on the main thread by the LayerTreeHost through its client. |
37 // 2. Passed to the compositor thread and bound to a client via BindToClient. | 37 // 2. Passed to the compositor thread and bound to a client via BindToClient. |
38 // From here on, it will only be used on the compositor thread. | 38 // From here on, it will only be used on the compositor thread. |
39 // 3. If the 3D context is lost, then the compositor will delete the output | 39 // 3. If the 3D context is lost, then the compositor will delete the output |
40 // surface (on the compositor thread) and go back to step 1. | 40 // surface (on the compositor thread) and go back to step 1. |
41 class CC_EXPORT OutputSurface : public FrameRateControllerClient { | 41 class CC_EXPORT OutputSurface : public FrameRateControllerClient { |
42 public: | 42 public: |
| 43 enum { |
| 44 DEFAULT_MAX_FRAMES_PENDING = 2 |
| 45 }; |
| 46 |
43 explicit OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); | 47 explicit OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); |
44 | 48 |
45 explicit OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); | 49 explicit OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); |
46 | 50 |
47 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, | 51 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, |
48 scoped_ptr<cc::SoftwareOutputDevice> software_device); | 52 scoped_ptr<cc::SoftwareOutputDevice> software_device); |
49 | 53 |
50 virtual ~OutputSurface(); | 54 virtual ~OutputSurface(); |
51 | 55 |
52 struct Capabilities { | 56 struct Capabilities { |
53 Capabilities() | 57 Capabilities() |
54 : delegated_rendering(false), | 58 : delegated_rendering(false), |
55 max_frames_pending(0), | 59 max_frames_pending(0), |
56 deferred_gl_initialization(false) {} | 60 deferred_gl_initialization(false), |
| 61 has_parent_compositor(true) {} |
57 | 62 |
58 bool delegated_rendering; | 63 bool delegated_rendering; |
59 int max_frames_pending; | 64 int max_frames_pending; |
60 bool deferred_gl_initialization; | 65 bool deferred_gl_initialization; |
| 66 bool has_parent_compositor; |
61 }; | 67 }; |
62 | 68 |
63 const Capabilities& capabilities() const { | 69 const Capabilities& capabilities() const { |
64 return capabilities_; | 70 return capabilities_; |
65 } | 71 } |
66 | 72 |
67 // Obtain the 3d context or the software device associated with this output | 73 // Obtain the 3d context or the software device associated with this output |
68 // surface. Either of these may return a null pointer, but not both. | 74 // surface. Either of these may return a null pointer, but not both. |
69 // In the event of a lost context, the entire output surface should be | 75 // In the event of a lost context, the entire output surface should be |
70 // recreated. | 76 // recreated. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 bool has_gl_discard_backbuffer_; | 140 bool has_gl_discard_backbuffer_; |
135 bool has_swap_buffers_complete_callback_; | 141 bool has_swap_buffers_complete_callback_; |
136 gfx::Size surface_size_; | 142 gfx::Size surface_size_; |
137 float device_scale_factor_; | 143 float device_scale_factor_; |
138 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; | 144 base::WeakPtrFactory<OutputSurface> weak_ptr_factory_; |
139 | 145 |
140 // The FrameRateController is deprecated. | 146 // The FrameRateController is deprecated. |
141 // Platforms should move to native BeginFrames instead. | 147 // Platforms should move to native BeginFrames instead. |
142 void OnVSyncParametersChanged(base::TimeTicks timebase, | 148 void OnVSyncParametersChanged(base::TimeTicks timebase, |
143 base::TimeDelta interval); | 149 base::TimeDelta interval); |
144 virtual void FrameRateControllerTick(bool throttled) OVERRIDE; | 150 virtual void FrameRateControllerTick(bool throttled, BeginFrameArgs args) |
| 151 OVERRIDE; |
145 scoped_ptr<FrameRateController> frame_rate_controller_; | 152 scoped_ptr<FrameRateController> frame_rate_controller_; |
146 int max_frames_pending_; | 153 int max_frames_pending_; |
147 int pending_swap_buffers_; | 154 int pending_swap_buffers_; |
148 bool begin_frame_pending_; | 155 bool begin_frame_pending_; |
149 | 156 |
150 // Forwarded to OutputSurfaceClient but threaded through OutputSurface | 157 // Forwarded to OutputSurfaceClient but threaded through OutputSurface |
151 // first so OutputSurface has a chance to update the FrameRateController | 158 // first so OutputSurface has a chance to update the FrameRateController |
152 bool HasClient() { return !!client_; } | 159 bool HasClient() { return !!client_; } |
153 void SetNeedsRedrawRect(gfx::Rect damage_rect); | 160 void SetNeedsRedrawRect(gfx::Rect damage_rect); |
154 void BeginFrame(base::TimeTicks frame_time); | 161 void BeginFrame(BeginFrameArgs args); |
155 void DidSwapBuffers(); | 162 void DidSwapBuffers(); |
156 void OnSwapBuffersComplete(const CompositorFrameAck* ack); | 163 void OnSwapBuffersComplete(const CompositorFrameAck* ack); |
157 void DidLoseOutputSurface(); | 164 void DidLoseOutputSurface(); |
158 void SetExternalDrawConstraints(const gfx::Transform& transform, | 165 void SetExternalDrawConstraints(const gfx::Transform& transform, |
159 gfx::Rect viewport); | 166 gfx::Rect viewport); |
160 | 167 |
161 private: | 168 private: |
162 OutputSurfaceClient* client_; | 169 OutputSurfaceClient* client_; |
163 friend class OutputSurfaceCallbacks; | 170 friend class OutputSurfaceCallbacks; |
164 | 171 |
165 void SetContext3D(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); | 172 void SetContext3D(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); |
166 | 173 |
167 DISALLOW_COPY_AND_ASSIGN(OutputSurface); | 174 DISALLOW_COPY_AND_ASSIGN(OutputSurface); |
168 }; | 175 }; |
169 | 176 |
170 } // namespace cc | 177 } // namespace cc |
171 | 178 |
172 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ | 179 #endif // CC_OUTPUT_OUTPUT_SURFACE_H_ |
OLD | NEW |