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/surfaces/surface_sequence.h" | 16 #include "cc/surfaces/surface_sequence.h" |
17 #include "cc/trees/layer_tree_host_client.h" | 17 #include "cc/trees/layer_tree_host_client.h" |
18 #include "cc/trees/layer_tree_host_single_thread_client.h" | 18 #include "cc/trees/layer_tree_host_single_thread_client.h" |
19 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
20 #include "ui/compositor/compositor_animation_observer.h" | 20 #include "ui/compositor/compositor_animation_observer.h" |
21 #include "ui/compositor/compositor_export.h" | 21 #include "ui/compositor/compositor_export.h" |
22 #include "ui/compositor/compositor_observer.h" | 22 #include "ui/compositor/compositor_observer.h" |
23 #include "ui/compositor/layer_animator_collection.h" | 23 #include "ui/compositor/layer_animator_collection.h" |
24 #include "ui/gfx/native_widget_types.h" | 24 #include "ui/gfx/native_widget_types.h" |
25 #include "ui/gfx/size.h" | 25 #include "ui/gfx/size.h" |
26 #include "ui/gfx/vector2d.h" | 26 #include "ui/gfx/vector2d.h" |
27 | 27 |
28 class SkBitmap; | |
29 | |
30 namespace base { | 28 namespace base { |
31 class MessageLoopProxy; | 29 class MessageLoopProxy; |
32 class RunLoop; | 30 class RunLoop; |
33 } | 31 } |
34 | 32 |
35 namespace cc { | 33 namespace cc { |
36 class ContextProvider; | 34 class ContextProvider; |
37 class GpuMemoryBufferManager; | 35 class GpuMemoryBufferManager; |
38 class Layer; | 36 class Layer; |
39 class LayerTreeDebugState; | 37 class LayerTreeDebugState; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 159 |
162 // Called when we need the compositor to preserve the alpha channel in the | 160 // Called when we need the compositor to preserve the alpha channel in the |
163 // output for situations when we want to render transparently atop something | 161 // output for situations when we want to render transparently atop something |
164 // else, e.g. Aero glass. | 162 // else, e.g. Aero glass. |
165 void SetHostHasTransparentBackground(bool host_has_transparent_background); | 163 void SetHostHasTransparentBackground(bool host_has_transparent_background); |
166 | 164 |
167 // The scale factor of the device that this compositor is | 165 // The scale factor of the device that this compositor is |
168 // compositing layers on. | 166 // compositing layers on. |
169 float device_scale_factor() const { return device_scale_factor_; } | 167 float device_scale_factor() const { return device_scale_factor_; } |
170 | 168 |
171 // Draws the scene created by the layer tree and any visual effects. | |
172 void Draw(); | |
173 | |
174 // Where possible, draws are scissored to a damage region calculated from | 169 // Where possible, draws are scissored to a damage region calculated from |
175 // changes to layer properties. This bypasses that and indicates that | 170 // changes to layer properties. This bypasses that and indicates that |
176 // the whole frame needs to be drawn. | 171 // the whole frame needs to be drawn. |
177 void ScheduleFullRedraw(); | 172 void ScheduleFullRedraw(); |
178 | 173 |
179 // Schedule redraw and append damage_rect to the damage region calculated | 174 // Schedule redraw and append damage_rect to the damage region calculated |
180 // from changes to layer properties. | 175 // from changes to layer properties. |
181 void ScheduleRedrawRect(const gfx::Rect& damage_rect); | 176 void ScheduleRedrawRect(const gfx::Rect& damage_rect); |
182 | 177 |
183 // Finishes all outstanding rendering on the GPU. | 178 // Finishes all outstanding rendering on the GPU. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 float page_scale, | 246 float page_scale, |
252 float top_controls_delta) override {} | 247 float top_controls_delta) override {} |
253 virtual void RequestNewOutputSurface(bool fallback) override; | 248 virtual void RequestNewOutputSurface(bool fallback) override; |
254 virtual void DidInitializeOutputSurface() override {} | 249 virtual void DidInitializeOutputSurface() override {} |
255 virtual void WillCommit() override {} | 250 virtual void WillCommit() override {} |
256 virtual void DidCommit() override; | 251 virtual void DidCommit() override; |
257 virtual void DidCommitAndDrawFrame() override; | 252 virtual void DidCommitAndDrawFrame() override; |
258 virtual void DidCompleteSwapBuffers() override; | 253 virtual void DidCompleteSwapBuffers() override; |
259 | 254 |
260 // cc::LayerTreeHostSingleThreadClient implementation. | 255 // cc::LayerTreeHostSingleThreadClient implementation. |
261 virtual void ScheduleComposite() override; | |
262 virtual void ScheduleAnimation() override; | |
263 virtual void DidPostSwapBuffers() override; | 256 virtual void DidPostSwapBuffers() override; |
264 virtual void DidAbortSwapBuffers() override; | 257 virtual void DidAbortSwapBuffers() override; |
265 | 258 |
266 int last_started_frame() { return last_started_frame_; } | |
267 int last_ended_frame() { return last_ended_frame_; } | |
268 | |
269 bool IsLocked() { return compositor_lock_ != NULL; } | 259 bool IsLocked() { return compositor_lock_ != NULL; } |
270 | 260 |
271 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 261 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
272 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 262 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
273 | 263 |
274 LayerAnimatorCollection* layer_animator_collection() { | 264 LayerAnimatorCollection* layer_animator_collection() { |
275 return &layer_animator_collection_; | 265 return &layer_animator_collection_; |
276 } | 266 } |
277 | 267 |
278 // Inserts a SurfaceSequence that will be satisfied on the next frame this | 268 // Inserts a SurfaceSequence that will be satisfied on the next frame this |
279 // compositor commits and swaps. | 269 // compositor commits and swaps. |
280 cc::SurfaceSequence InsertSurfaceSequenceForNextFrame(); | 270 cc::SurfaceSequence InsertSurfaceSequenceForNextFrame(); |
281 | 271 |
282 cc::SurfaceIdAllocator* surface_id_allocator() { | 272 cc::SurfaceIdAllocator* surface_id_allocator() { |
283 return surface_id_allocator_.get(); | 273 return surface_id_allocator_.get(); |
284 } | 274 } |
285 | 275 |
286 private: | 276 private: |
287 friend class base::RefCounted<Compositor>; | 277 friend class base::RefCounted<Compositor>; |
288 friend class CompositorLock; | 278 friend class CompositorLock; |
289 | 279 |
290 // Called by CompositorLock. | 280 // Called by CompositorLock. |
291 void UnlockCompositor(); | 281 void UnlockCompositor(); |
292 | 282 |
293 // Called to release any pending CompositorLock | 283 // Called to release any pending CompositorLock |
294 void CancelCompositorLock(); | 284 void CancelCompositorLock(); |
295 | 285 |
296 // Notifies the compositor that compositing is complete. | |
297 void NotifyEnd(); | |
298 | |
299 gfx::Size size_; | 286 gfx::Size size_; |
300 | 287 |
301 ui::ContextFactory* context_factory_; | 288 ui::ContextFactory* context_factory_; |
302 | 289 |
303 // The root of the Layer tree drawn by this compositor. | 290 // The root of the Layer tree drawn by this compositor. |
304 Layer* root_layer_; | 291 Layer* root_layer_; |
305 | 292 |
306 ObserverList<CompositorObserver> observer_list_; | 293 ObserverList<CompositorObserver> observer_list_; |
307 ObserverList<CompositorAnimationObserver> animation_observer_list_; | 294 ObserverList<CompositorAnimationObserver> animation_observer_list_; |
308 | 295 |
(...skipping 12 matching lines...) Expand all Loading... |
321 // layers on. | 308 // layers on. |
322 float device_scale_factor_; | 309 float device_scale_factor_; |
323 | 310 |
324 int last_started_frame_; | 311 int last_started_frame_; |
325 int last_ended_frame_; | 312 int last_ended_frame_; |
326 | 313 |
327 bool disable_schedule_composite_; | 314 bool disable_schedule_composite_; |
328 | 315 |
329 CompositorLock* compositor_lock_; | 316 CompositorLock* compositor_lock_; |
330 | 317 |
331 // Prevent more than one draw from being scheduled. | |
332 bool defer_draw_scheduling_; | |
333 | |
334 // Used to prevent Draw()s while a composite is in progress. | |
335 bool waiting_on_compositing_end_; | |
336 bool draw_on_compositing_end_; | |
337 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; | |
338 SwapState swap_state_; | |
339 | |
340 LayerAnimatorCollection layer_animator_collection_; | 318 LayerAnimatorCollection layer_animator_collection_; |
341 | 319 |
342 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | |
343 | |
344 DISALLOW_COPY_AND_ASSIGN(Compositor); | 320 DISALLOW_COPY_AND_ASSIGN(Compositor); |
345 }; | 321 }; |
346 | 322 |
347 } // namespace ui | 323 } // namespace ui |
348 | 324 |
349 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 325 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |