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 UI_COMPOSITOR_COMPOSITOR_H_ | 5 #ifndef UI_COMPOSITOR_COMPOSITOR_H_ |
6 #define UI_COMPOSITOR_COMPOSITOR_H_ | 6 #define UI_COMPOSITOR_COMPOSITOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.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/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "cc/trees/layer_tree_host_client.h" | 16 #include "cc/trees/layer_tree_host_client.h" |
17 #include "cc/trees/layer_tree_host_single_thread_client.h" | 17 #include "cc/trees/layer_tree_host_single_thread_client.h" |
18 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
19 #include "ui/compositor/compositor_animation_observer.h" | 19 #include "ui/compositor/compositor_animation_observer.h" |
20 #include "ui/compositor/compositor_export.h" | 20 #include "ui/compositor/compositor_export.h" |
21 #include "ui/compositor/compositor_observer.h" | 21 #include "ui/compositor/compositor_observer.h" |
22 #include "ui/compositor/layer_animator_collection.h" | 22 #include "ui/compositor/layer_animator_collection.h" |
23 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
24 #include "ui/gfx/size.h" | 24 #include "ui/gfx/size.h" |
25 #include "ui/gfx/vector2d.h" | 25 #include "ui/gfx/vector2d.h" |
26 | 26 |
27 class SkBitmap; | |
28 | |
29 namespace base { | 27 namespace base { |
30 class MessageLoopProxy; | 28 class MessageLoopProxy; |
31 class RunLoop; | 29 class RunLoop; |
32 } | 30 } |
33 | 31 |
34 namespace cc { | 32 namespace cc { |
35 class ContextProvider; | 33 class ContextProvider; |
36 class Layer; | 34 class Layer; |
37 class LayerTreeDebugState; | 35 class LayerTreeDebugState; |
38 class LayerTreeHost; | 36 class LayerTreeHost; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 150 |
153 // Called when we need the compositor to preserve the alpha channel in the | 151 // Called when we need the compositor to preserve the alpha channel in the |
154 // output for situations when we want to render transparently atop something | 152 // output for situations when we want to render transparently atop something |
155 // else, e.g. Aero glass. | 153 // else, e.g. Aero glass. |
156 void SetHostHasTransparentBackground(bool host_has_transparent_background); | 154 void SetHostHasTransparentBackground(bool host_has_transparent_background); |
157 | 155 |
158 // The scale factor of the device that this compositor is | 156 // The scale factor of the device that this compositor is |
159 // compositing layers on. | 157 // compositing layers on. |
160 float device_scale_factor() const { return device_scale_factor_; } | 158 float device_scale_factor() const { return device_scale_factor_; } |
161 | 159 |
162 // Draws the scene created by the layer tree and any visual effects. | |
163 void Draw(); | |
164 | |
165 // Where possible, draws are scissored to a damage region calculated from | 160 // Where possible, draws are scissored to a damage region calculated from |
166 // changes to layer properties. This bypasses that and indicates that | 161 // changes to layer properties. This bypasses that and indicates that |
167 // the whole frame needs to be drawn. | 162 // the whole frame needs to be drawn. |
168 void ScheduleFullRedraw(); | 163 void ScheduleFullRedraw(); |
169 | 164 |
170 // Schedule redraw and append damage_rect to the damage region calculated | 165 // Schedule redraw and append damage_rect to the damage region calculated |
171 // from changes to layer properties. | 166 // from changes to layer properties. |
172 void ScheduleRedrawRect(const gfx::Rect& damage_rect); | 167 void ScheduleRedrawRect(const gfx::Rect& damage_rect); |
173 | 168 |
174 // Finishes all outstanding rendering on the GPU. | 169 // Finishes all outstanding rendering on the GPU. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 float page_scale) OVERRIDE {} | 222 float page_scale) OVERRIDE {} |
228 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) | 223 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) |
229 OVERRIDE; | 224 OVERRIDE; |
230 virtual void DidInitializeOutputSurface() OVERRIDE {} | 225 virtual void DidInitializeOutputSurface() OVERRIDE {} |
231 virtual void WillCommit() OVERRIDE {} | 226 virtual void WillCommit() OVERRIDE {} |
232 virtual void DidCommit() OVERRIDE; | 227 virtual void DidCommit() OVERRIDE; |
233 virtual void DidCommitAndDrawFrame() OVERRIDE; | 228 virtual void DidCommitAndDrawFrame() OVERRIDE; |
234 virtual void DidCompleteSwapBuffers() OVERRIDE; | 229 virtual void DidCompleteSwapBuffers() OVERRIDE; |
235 | 230 |
236 // cc::LayerTreeHostSingleThreadClient implementation. | 231 // cc::LayerTreeHostSingleThreadClient implementation. |
237 virtual void ScheduleComposite() OVERRIDE; | |
238 virtual void ScheduleAnimation() OVERRIDE; | |
239 virtual void DidPostSwapBuffers() OVERRIDE; | 232 virtual void DidPostSwapBuffers() OVERRIDE; |
240 virtual void DidAbortSwapBuffers() OVERRIDE; | 233 virtual void DidAbortSwapBuffers() OVERRIDE; |
241 | 234 |
242 int last_started_frame() { return last_started_frame_; } | |
243 int last_ended_frame() { return last_ended_frame_; } | |
244 | |
245 bool IsLocked() { return compositor_lock_ != NULL; } | 235 bool IsLocked() { return compositor_lock_ != NULL; } |
246 | 236 |
247 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 237 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
248 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 238 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
249 | 239 |
250 LayerAnimatorCollection* layer_animator_collection() { | 240 LayerAnimatorCollection* layer_animator_collection() { |
251 return &layer_animator_collection_; | 241 return &layer_animator_collection_; |
252 } | 242 } |
253 | 243 |
254 private: | 244 private: |
255 friend class base::RefCounted<Compositor>; | 245 friend class base::RefCounted<Compositor>; |
256 friend class CompositorLock; | 246 friend class CompositorLock; |
257 | 247 |
258 // Called by CompositorLock. | 248 // Called by CompositorLock. |
259 void UnlockCompositor(); | 249 void UnlockCompositor(); |
260 | 250 |
261 // Called to release any pending CompositorLock | 251 // Called to release any pending CompositorLock |
262 void CancelCompositorLock(); | 252 void CancelCompositorLock(); |
263 | 253 |
264 // Notifies the compositor that compositing is complete. | |
265 void NotifyEnd(); | |
266 | |
267 gfx::Size size_; | 254 gfx::Size size_; |
268 | 255 |
269 ui::ContextFactory* context_factory_; | 256 ui::ContextFactory* context_factory_; |
270 | 257 |
271 // The root of the Layer tree drawn by this compositor. | 258 // The root of the Layer tree drawn by this compositor. |
272 Layer* root_layer_; | 259 Layer* root_layer_; |
273 | 260 |
274 ObserverList<CompositorObserver> observer_list_; | 261 ObserverList<CompositorObserver> observer_list_; |
275 ObserverList<CompositorAnimationObserver> animation_observer_list_; | 262 ObserverList<CompositorAnimationObserver> animation_observer_list_; |
276 | 263 |
(...skipping 10 matching lines...) Expand all Loading... |
287 // layers on. | 274 // layers on. |
288 float device_scale_factor_; | 275 float device_scale_factor_; |
289 | 276 |
290 int last_started_frame_; | 277 int last_started_frame_; |
291 int last_ended_frame_; | 278 int last_ended_frame_; |
292 | 279 |
293 bool disable_schedule_composite_; | 280 bool disable_schedule_composite_; |
294 | 281 |
295 CompositorLock* compositor_lock_; | 282 CompositorLock* compositor_lock_; |
296 | 283 |
297 // Prevent more than one draw from being scheduled. | |
298 bool defer_draw_scheduling_; | |
299 | |
300 // Used to prevent Draw()s while a composite is in progress. | |
301 bool waiting_on_compositing_end_; | |
302 bool draw_on_compositing_end_; | |
303 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; | |
304 SwapState swap_state_; | |
305 | |
306 LayerAnimatorCollection layer_animator_collection_; | 284 LayerAnimatorCollection layer_animator_collection_; |
307 | 285 |
308 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | |
309 | |
310 DISALLOW_COPY_AND_ASSIGN(Compositor); | 286 DISALLOW_COPY_AND_ASSIGN(Compositor); |
311 }; | 287 }; |
312 | 288 |
313 } // namespace ui | 289 } // namespace ui |
314 | 290 |
315 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 291 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |