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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 324 |
324 void sendDidLoseContextRecursive(LayerImpl*); | 325 void sendDidLoseContextRecursive(LayerImpl*); |
325 void clearRenderSurfaces(); | 326 void clearRenderSurfaces(); |
326 bool ensureRenderSurfaceLayerList(); | 327 bool ensureRenderSurfaceLayerList(); |
327 void clearCurrentlyScrollingLayer(); | 328 void clearCurrentlyScrollingLayer(); |
328 | 329 |
329 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); | 330 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); |
330 | 331 |
331 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; | 332 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; |
332 | 333 |
| 334 // AnimationRegistar implementation. |
| 335 virtual void Register(LayerAnimationController*) OVERRIDE; |
| 336 virtual void Unregister(LayerAnimationController*) OVERRIDE; |
| 337 |
333 scoped_ptr<GraphicsContext> m_context; | 338 scoped_ptr<GraphicsContext> m_context; |
334 scoped_ptr<ResourceProvider> m_resourceProvider; | 339 scoped_ptr<ResourceProvider> m_resourceProvider; |
335 scoped_ptr<Renderer> m_renderer; | 340 scoped_ptr<Renderer> m_renderer; |
336 scoped_ptr<TileManager> m_tileManager; | 341 scoped_ptr<TileManager> m_tileManager; |
337 scoped_ptr<LayerImpl> m_rootLayerImpl; | 342 scoped_ptr<LayerImpl> m_rootLayerImpl; |
338 LayerImpl* m_rootScrollLayerImpl; | 343 LayerImpl* m_rootScrollLayerImpl; |
339 LayerImpl* m_currentlyScrollingLayerImpl; | 344 LayerImpl* m_currentlyScrollingLayerImpl; |
340 HeadsUpDisplayLayerImpl* m_hudLayerImpl; | 345 HeadsUpDisplayLayerImpl* m_hudLayerImpl; |
341 int m_scrollingLayerIdFromPreviousTree; | 346 int m_scrollingLayerIdFromPreviousTree; |
342 bool m_scrollDeltaIsInViewportSpace; | 347 bool m_scrollDeltaIsInViewportSpace; |
343 LayerTreeSettings m_settings; | 348 LayerTreeSettings m_settings; |
344 gfx::Size m_layoutViewportSize; | 349 gfx::Size m_layoutViewportSize; |
345 gfx::Size m_deviceViewportSize; | 350 gfx::Size m_deviceViewportSize; |
346 float m_deviceScaleFactor; | 351 float m_deviceScaleFactor; |
347 bool m_visible; | 352 bool m_visible; |
348 bool m_contentsTexturesPurged; | 353 bool m_contentsTexturesPurged; |
349 ManagedMemoryPolicy m_managedMemoryPolicy; | 354 ManagedMemoryPolicy m_managedMemoryPolicy; |
350 | 355 |
351 SkColor m_backgroundColor; | 356 SkColor m_backgroundColor; |
352 bool m_hasTransparentBackground; | 357 bool m_hasTransparentBackground; |
353 | 358 |
354 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. | 359 // If this is true, it is necessary to traverse the layer tree ticking the a
nimators. |
355 bool m_needsAnimateLayers; | |
356 bool m_pinchGestureActive; | 360 bool m_pinchGestureActive; |
357 gfx::Point m_previousPinchAnchor; | 361 gfx::Point m_previousPinchAnchor; |
358 | 362 |
359 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; | 363 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; |
360 | 364 |
361 // This is used for ticking animations slowly when hidden. | 365 // This is used for ticking animations slowly when hidden. |
362 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; | 366 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; |
363 | 367 |
364 LayerSorter m_layerSorter; | 368 LayerSorter m_layerSorter; |
365 | 369 |
366 // List of visible layers for the most recently prepared frame. Used for | 370 // List of visible layers for the most recently prepared frame. Used for |
367 // rendering and input event hit testing. | 371 // rendering and input event hit testing. |
368 LayerList m_renderSurfaceLayerList; | 372 LayerList m_renderSurfaceLayerList; |
369 | 373 |
370 PinchZoomViewport m_pinchZoomViewport; | 374 PinchZoomViewport m_pinchZoomViewport; |
371 | 375 |
372 scoped_ptr<FrameRateCounter> m_fpsCounter; | 376 scoped_ptr<FrameRateCounter> m_fpsCounter; |
373 scoped_ptr<DebugRectHistory> m_debugRectHistory; | 377 scoped_ptr<DebugRectHistory> m_debugRectHistory; |
374 | 378 |
375 size_t m_numImplThreadScrolls; | 379 size_t m_numImplThreadScrolls; |
376 size_t m_numMainThreadScrolls; | 380 size_t m_numMainThreadScrolls; |
377 | 381 |
378 size_t m_cumulativeNumLayersInLayerTree; | 382 size_t m_cumulativeNumLayersInLayerTree; |
379 | 383 |
| 384 AnimationControllerSet m_activeAnimationControllers; |
| 385 |
380 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 386 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
381 }; | 387 }; |
382 | 388 |
383 } // namespace cc | 389 } // namespace cc |
384 | 390 |
385 #endif // CC_LAYER_TREE_HOST_IMPL_H_ | 391 #endif // CC_LAYER_TREE_HOST_IMPL_H_ |
OLD | NEW |