OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_LAYER_TREE_HOST_IMPL_H_ | 5 #ifndef CC_LAYER_TREE_HOST_IMPL_H_ |
6 #define CC_LAYER_TREE_HOST_IMPL_H_ | 6 #define CC_LAYER_TREE_HOST_IMPL_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 "base/time.h" | 10 #include "base/time.h" |
11 #include "cc/animation_events.h" | 11 #include "cc/animation_events.h" |
| 12 #include "cc/animation_registrar.h" |
12 #include "cc/cc_export.h" | 13 #include "cc/cc_export.h" |
13 #include "cc/input_handler.h" | 14 #include "cc/input_handler.h" |
14 #include "cc/layer_sorter.h" | 15 #include "cc/layer_sorter.h" |
15 #include "cc/render_pass.h" | 16 #include "cc/render_pass.h" |
16 #include "cc/render_pass_sink.h" | 17 #include "cc/render_pass_sink.h" |
17 #include "cc/renderer.h" | 18 #include "cc/renderer.h" |
18 #include "cc/tile_manager.h" | 19 #include "cc/tile_manager.h" |
19 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
20 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
21 #include <public/WebCompositorOutputSurfaceClient.h> | 22 #include <public/WebCompositorOutputSurfaceClient.h> |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 float m_deviceScaleFactor; | 107 float m_deviceScaleFactor; |
107 | 108 |
108 gfx::Vector2dF m_zoomedViewportOffset; | 109 gfx::Vector2dF m_zoomedViewportOffset; |
109 gfx::SizeF m_layoutViewportSize; | 110 gfx::SizeF m_layoutViewportSize; |
110 }; | 111 }; |
111 | 112 |
112 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te | 113 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te |
113 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, | 114 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, |
114 public RendererClient, | 115 public RendererClient, |
115 public TileManagerClient, | 116 public TileManagerClient, |
| 117 public AnimationRegistrar, |
116 public NON_EXPORTED_BASE(WebKit::WebComposit
orOutputSurfaceClient) { | 118 public NON_EXPORTED_BASE(WebKit::WebComposit
orOutputSurfaceClient) { |
117 typedef std::vector<LayerImpl*> LayerList; | 119 typedef std::vector<LayerImpl*> LayerList; |
| 120 typedef base::hash_set<LayerAnimationController*> AnimationControllerSet; |
118 | 121 |
119 public: | 122 public: |
120 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*, Proxy*); | 123 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*, Proxy*); |
121 virtual ~LayerTreeHostImpl(); | 124 virtual ~LayerTreeHostImpl(); |
122 | 125 |
123 // InputHandlerClient implementation | 126 // InputHandlerClient implementation |
124 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle
rClient::ScrollInputType) OVERRIDE; | 127 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle
rClient::ScrollInputType) OVERRIDE; |
125 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; | 128 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; |
126 virtual void scrollEnd() OVERRIDE; | 129 virtual void scrollEnd() OVERRIDE; |
127 virtual void pinchGestureBegin() OVERRIDE; | 130 virtual void pinchGestureBegin() OVERRIDE; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); | 236 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); |
234 gfx::Transform implTransform() const; | 237 gfx::Transform implTransform() const; |
235 | 238 |
236 void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, flo
at scale, base::TimeDelta duration); | 239 void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, flo
at scale, base::TimeDelta duration); |
237 | 240 |
238 SkColor backgroundColor() const { return m_backgroundColor; } | 241 SkColor backgroundColor() const { return m_backgroundColor; } |
239 void setBackgroundColor(SkColor color) { m_backgroundColor = color; } | 242 void setBackgroundColor(SkColor color) { m_backgroundColor = color; } |
240 | 243 |
241 bool hasTransparentBackground() const { return m_hasTransparentBackground; } | 244 bool hasTransparentBackground() const { return m_hasTransparentBackground; } |
242 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro
und = transparent; } | 245 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro
und = transparent; } |
243 | 246 bool needsAnimateLayers() const { return !m_activeAnimationControllers.empty
(); } |
244 bool needsAnimateLayers() const { return m_needsAnimateLayers; } | |
245 void setNeedsAnimateLayers() { m_needsAnimateLayers = true; } | |
246 | 247 |
247 void setNeedsRedraw(); | 248 void setNeedsRedraw(); |
248 | 249 |
249 void renderingStats(RenderingStats*) const; | 250 void renderingStats(RenderingStats*) const; |
250 | 251 |
251 void updateRootScrollLayerImplTransform(); | 252 void updateRootScrollLayerImplTransform(); |
252 | 253 |
253 FrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } | 254 FrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } |
254 DebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get()
; } | 255 DebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get()
; } |
255 ResourceProvider* resourceProvider() const { return m_resourceProvider.get()
; } | 256 ResourceProvider* resourceProvider() const { return m_resourceProvider.get()
; } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 327 |
327 void sendDidLoseContextRecursive(LayerImpl*); | 328 void sendDidLoseContextRecursive(LayerImpl*); |
328 void clearRenderSurfaces(); | 329 void clearRenderSurfaces(); |
329 bool ensureRenderSurfaceLayerList(); | 330 bool ensureRenderSurfaceLayerList(); |
330 void clearCurrentlyScrollingLayer(); | 331 void clearCurrentlyScrollingLayer(); |
331 | 332 |
332 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); | 333 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); |
333 | 334 |
334 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; | 335 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; |
335 | 336 |
| 337 // AnimationRegistar implementation. |
| 338 virtual void ActivateAnimationController(LayerAnimationController*) OVERRIDE
; |
| 339 virtual void DeactivateAnimationController(LayerAnimationController*) OVERRI
DE; |
| 340 virtual void RegisterAnimationController(LayerAnimationController*) OVERRIDE
; |
| 341 virtual void UnregisterAnimationController(LayerAnimationController*) OVERRI
DE; |
| 342 |
336 scoped_ptr<GraphicsContext> m_context; | 343 scoped_ptr<GraphicsContext> m_context; |
337 scoped_ptr<ResourceProvider> m_resourceProvider; | 344 scoped_ptr<ResourceProvider> m_resourceProvider; |
338 scoped_ptr<Renderer> m_renderer; | 345 scoped_ptr<Renderer> m_renderer; |
339 scoped_ptr<TileManager> m_tileManager; | 346 scoped_ptr<TileManager> m_tileManager; |
340 scoped_ptr<LayerImpl> m_rootLayerImpl; | 347 scoped_ptr<LayerImpl> m_rootLayerImpl; |
341 LayerImpl* m_rootScrollLayerImpl; | 348 LayerImpl* m_rootScrollLayerImpl; |
342 LayerImpl* m_currentlyScrollingLayerImpl; | 349 LayerImpl* m_currentlyScrollingLayerImpl; |
343 HeadsUpDisplayLayerImpl* m_hudLayerImpl; | 350 HeadsUpDisplayLayerImpl* m_hudLayerImpl; |
344 int m_scrollingLayerIdFromPreviousTree; | 351 int m_scrollingLayerIdFromPreviousTree; |
345 bool m_scrollDeltaIsInViewportSpace; | 352 bool m_scrollDeltaIsInViewportSpace; |
346 LayerTreeSettings m_settings; | 353 LayerTreeSettings m_settings; |
347 LayerTreeDebugState m_debugState; | 354 LayerTreeDebugState m_debugState; |
348 gfx::Size m_layoutViewportSize; | 355 gfx::Size m_layoutViewportSize; |
349 gfx::Size m_deviceViewportSize; | 356 gfx::Size m_deviceViewportSize; |
350 float m_deviceScaleFactor; | 357 float m_deviceScaleFactor; |
351 bool m_visible; | 358 bool m_visible; |
352 bool m_contentsTexturesPurged; | 359 bool m_contentsTexturesPurged; |
353 ManagedMemoryPolicy m_managedMemoryPolicy; | 360 ManagedMemoryPolicy m_managedMemoryPolicy; |
354 | 361 |
355 SkColor m_backgroundColor; | 362 SkColor m_backgroundColor; |
356 bool m_hasTransparentBackground; | 363 bool m_hasTransparentBackground; |
357 | 364 |
358 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. | 365 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. |
359 bool m_needsAnimateLayers; | |
360 bool m_pinchGestureActive; | 366 bool m_pinchGestureActive; |
361 gfx::Point m_previousPinchAnchor; | 367 gfx::Point m_previousPinchAnchor; |
362 | 368 |
363 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; | 369 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; |
364 | 370 |
365 // This is used for ticking animations slowly when hidden. | 371 // This is used for ticking animations slowly when hidden. |
366 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; | 372 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; |
367 | 373 |
368 LayerSorter m_layerSorter; | 374 LayerSorter m_layerSorter; |
369 | 375 |
370 // List of visible layers for the most recently prepared frame. Used for | 376 // List of visible layers for the most recently prepared frame. Used for |
371 // rendering and input event hit testing. | 377 // rendering and input event hit testing. |
372 LayerList m_renderSurfaceLayerList; | 378 LayerList m_renderSurfaceLayerList; |
373 | 379 |
374 PinchZoomViewport m_pinchZoomViewport; | 380 PinchZoomViewport m_pinchZoomViewport; |
375 | 381 |
376 scoped_ptr<FrameRateCounter> m_fpsCounter; | 382 scoped_ptr<FrameRateCounter> m_fpsCounter; |
377 scoped_ptr<DebugRectHistory> m_debugRectHistory; | 383 scoped_ptr<DebugRectHistory> m_debugRectHistory; |
378 | 384 |
379 size_t m_numImplThreadScrolls; | 385 size_t m_numImplThreadScrolls; |
380 size_t m_numMainThreadScrolls; | 386 size_t m_numMainThreadScrolls; |
381 | 387 |
382 size_t m_cumulativeNumLayersDrawn; | 388 size_t m_cumulativeNumLayersDrawn; |
383 | 389 |
| 390 AnimationControllerSet m_activeAnimationControllers; |
| 391 |
| 392 #if !defined(NDEBUG) |
| 393 AnimationControllerSet m_allAnimationControllers; |
| 394 #endif |
| 395 |
384 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 396 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
385 }; | 397 }; |
386 | 398 |
387 } // namespace cc | 399 } // namespace cc |
388 | 400 |
389 #endif // CC_LAYER_TREE_HOST_IMPL_H_ | 401 #endif // CC_LAYER_TREE_HOST_IMPL_H_ |
OLD | NEW |