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/layer_tree_impl.h" | 16 #include "cc/layer_tree_impl.h" |
16 #include "cc/render_pass.h" | 17 #include "cc/render_pass.h" |
17 #include "cc/render_pass_sink.h" | 18 #include "cc/render_pass_sink.h" |
18 #include "cc/renderer.h" | 19 #include "cc/renderer.h" |
19 #include "cc/tile_manager.h" | 20 #include "cc/tile_manager.h" |
20 #include "third_party/skia/include/core/SkColor.h" | 21 #include "third_party/skia/include/core/SkColor.h" |
21 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, |
116 public LayerTreeImplClient, | 117 public LayerTreeImplClient, |
| 118 public AnimationRegistrar, |
117 public NON_EXPORTED_BASE(WebKit::WebComposit
orOutputSurfaceClient) { | 119 public NON_EXPORTED_BASE(WebKit::WebComposit
orOutputSurfaceClient) { |
118 typedef std::vector<LayerImpl*> LayerList; | 120 typedef std::vector<LayerImpl*> LayerList; |
| 121 typedef base::hash_set<LayerAnimationController*> AnimationControllerSet; |
119 | 122 |
120 public: | 123 public: |
121 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*, Proxy*); | 124 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*, Proxy*); |
122 virtual ~LayerTreeHostImpl(); | 125 virtual ~LayerTreeHostImpl(); |
123 | 126 |
124 // InputHandlerClient implementation | 127 // InputHandlerClient implementation |
125 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle
rClient::ScrollInputType) OVERRIDE; | 128 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle
rClient::ScrollInputType) OVERRIDE; |
126 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; | 129 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; |
127 virtual void scrollEnd() OVERRIDE; | 130 virtual void scrollEnd() OVERRIDE; |
128 virtual void pinchGestureBegin() OVERRIDE; | 131 virtual void pinchGestureBegin() OVERRIDE; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); | 240 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); |
238 gfx::Transform implTransform() const; | 241 gfx::Transform implTransform() const; |
239 | 242 |
240 void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, flo
at scale, base::TimeDelta duration); | 243 void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, flo
at scale, base::TimeDelta duration); |
241 | 244 |
242 SkColor backgroundColor() const { return m_backgroundColor; } | 245 SkColor backgroundColor() const { return m_backgroundColor; } |
243 void setBackgroundColor(SkColor color) { m_backgroundColor = color; } | 246 void setBackgroundColor(SkColor color) { m_backgroundColor = color; } |
244 | 247 |
245 bool hasTransparentBackground() const { return m_hasTransparentBackground; } | 248 bool hasTransparentBackground() const { return m_hasTransparentBackground; } |
246 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro
und = transparent; } | 249 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro
und = transparent; } |
247 | 250 bool needsAnimateLayers() const { return !m_activeAnimationControllers.empty
(); } |
248 bool needsAnimateLayers() const { return m_needsAnimateLayers; } | |
249 void setNeedsAnimateLayers() { m_needsAnimateLayers = true; } | |
250 | 251 |
251 void setNeedsRedraw(); | 252 void setNeedsRedraw(); |
252 | 253 |
253 void renderingStats(RenderingStats*) const; | 254 void renderingStats(RenderingStats*) const; |
254 | 255 |
255 void updateRootScrollLayerImplTransform(); | 256 void updateRootScrollLayerImplTransform(); |
256 | 257 |
257 FrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } | 258 FrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } |
258 DebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get()
; } | 259 DebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get()
; } |
259 ResourceProvider* resourceProvider() const { return m_resourceProvider.get()
; } | 260 ResourceProvider* resourceProvider() const { return m_resourceProvider.get()
; } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 330 |
330 void sendDidLoseOutputSurfaceRecursive(LayerImpl*); | 331 void sendDidLoseOutputSurfaceRecursive(LayerImpl*); |
331 void clearRenderSurfaces(); | 332 void clearRenderSurfaces(); |
332 bool ensureRenderSurfaceLayerList(); | 333 bool ensureRenderSurfaceLayerList(); |
333 void clearCurrentlyScrollingLayer(); | 334 void clearCurrentlyScrollingLayer(); |
334 | 335 |
335 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); | 336 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); |
336 | 337 |
337 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; | 338 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; |
338 | 339 |
| 340 // AnimationRegistar implementation. |
| 341 virtual void DidActivateAnimationController(LayerAnimationController*) OVERR
IDE; |
| 342 virtual void DidDeactivateAnimationController(LayerAnimationController*) OVE
RRIDE; |
| 343 virtual void RegisterAnimationController(LayerAnimationController*) OVERRIDE
; |
| 344 virtual void UnregisterAnimationController(LayerAnimationController*) OVERRI
DE; |
| 345 |
339 scoped_ptr<OutputSurface> m_outputSurface; | 346 scoped_ptr<OutputSurface> m_outputSurface; |
| 347 |
340 scoped_ptr<ResourceProvider> m_resourceProvider; | 348 scoped_ptr<ResourceProvider> m_resourceProvider; |
341 scoped_ptr<Renderer> m_renderer; | 349 scoped_ptr<Renderer> m_renderer; |
342 scoped_ptr<TileManager> m_tileManager; | 350 scoped_ptr<TileManager> m_tileManager; |
343 | 351 |
344 scoped_ptr<LayerTreeImpl> m_activeTree; | 352 scoped_ptr<LayerTreeImpl> m_activeTree; |
345 | 353 |
346 bool m_scrollDeltaIsInViewportSpace; | 354 bool m_scrollDeltaIsInViewportSpace; |
347 LayerTreeSettings m_settings; | 355 LayerTreeSettings m_settings; |
348 LayerTreeDebugState m_debugState; | 356 LayerTreeDebugState m_debugState; |
349 gfx::Size m_layoutViewportSize; | 357 gfx::Size m_layoutViewportSize; |
350 gfx::Size m_deviceViewportSize; | 358 gfx::Size m_deviceViewportSize; |
351 float m_deviceScaleFactor; | 359 float m_deviceScaleFactor; |
352 bool m_visible; | 360 bool m_visible; |
353 bool m_contentsTexturesPurged; | 361 bool m_contentsTexturesPurged; |
354 ManagedMemoryPolicy m_managedMemoryPolicy; | 362 ManagedMemoryPolicy m_managedMemoryPolicy; |
355 | 363 |
356 SkColor m_backgroundColor; | 364 SkColor m_backgroundColor; |
357 bool m_hasTransparentBackground; | 365 bool m_hasTransparentBackground; |
358 | 366 |
359 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. | 367 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. |
360 bool m_needsAnimateLayers; | |
361 bool m_pinchGestureActive; | 368 bool m_pinchGestureActive; |
362 gfx::Point m_previousPinchAnchor; | 369 gfx::Point m_previousPinchAnchor; |
363 | 370 |
364 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; | 371 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; |
365 | 372 |
366 // This is used for ticking animations slowly when hidden. | 373 // This is used for ticking animations slowly when hidden. |
367 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; | 374 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; |
368 | 375 |
369 LayerSorter m_layerSorter; | 376 LayerSorter m_layerSorter; |
370 | 377 |
371 // List of visible layers for the most recently prepared frame. Used for | 378 // List of visible layers for the most recently prepared frame. Used for |
372 // rendering and input event hit testing. | 379 // rendering and input event hit testing. |
373 LayerList m_renderSurfaceLayerList; | 380 LayerList m_renderSurfaceLayerList; |
374 | 381 |
375 PinchZoomViewport m_pinchZoomViewport; | 382 PinchZoomViewport m_pinchZoomViewport; |
376 | 383 |
377 scoped_ptr<FrameRateCounter> m_fpsCounter; | 384 scoped_ptr<FrameRateCounter> m_fpsCounter; |
378 scoped_ptr<DebugRectHistory> m_debugRectHistory; | 385 scoped_ptr<DebugRectHistory> m_debugRectHistory; |
379 | 386 |
380 size_t m_numImplThreadScrolls; | 387 size_t m_numImplThreadScrolls; |
381 size_t m_numMainThreadScrolls; | 388 size_t m_numMainThreadScrolls; |
382 | 389 |
383 size_t m_cumulativeNumLayersDrawn; | 390 size_t m_cumulativeNumLayersDrawn; |
384 | 391 |
| 392 AnimationControllerSet m_activeAnimationControllers; |
| 393 |
| 394 #if !defined(NDEBUG) |
| 395 AnimationControllerSet m_allAnimationControllers; |
| 396 #endif |
| 397 |
385 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 398 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
386 }; | 399 }; |
387 | 400 |
388 } // namespace cc | 401 } // namespace cc |
389 | 402 |
390 #endif // CC_LAYER_TREE_HOST_IMPL_H_ | 403 #endif // CC_LAYER_TREE_HOST_IMPL_H_ |
OLD | NEW |