Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Side by Side Diff: cc/layer_tree_host_impl.h

Issue 11598005: Ref count layer animation controllers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/output_surface_client.h" 15 #include "cc/output_surface_client.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 22
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 float m_deviceScaleFactor; 106 float m_deviceScaleFactor;
106 107
107 gfx::Vector2dF m_zoomedViewportOffset; 108 gfx::Vector2dF m_zoomedViewportOffset;
108 gfx::SizeF m_layoutViewportSize; 109 gfx::SizeF m_layoutViewportSize;
109 }; 110 };
110 111
111 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta te 112 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta te
112 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, 113 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient,
113 public RendererClient, 114 public RendererClient,
114 public TileManagerClient, 115 public TileManagerClient,
116 public AnimationRegistrar,
115 public OutputSurfaceClient { 117 public OutputSurfaceClient {
116 typedef std::vector<LayerImpl*> LayerList; 118 typedef std::vector<LayerImpl*> LayerList;
117 119
118 public: 120 public:
119 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT reeHostImplClient*, Proxy*); 121 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT reeHostImplClient*, Proxy*);
120 virtual ~LayerTreeHostImpl(); 122 virtual ~LayerTreeHostImpl();
121 123
122 // InputHandlerClient implementation 124 // InputHandlerClient implementation
123 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle rClient::ScrollInputType) OVERRIDE; 125 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle rClient::ScrollInputType) OVERRIDE;
124 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; 126 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); 241 scoped_ptr<ScrollAndScaleSet> processScrollDeltas();
240 gfx::Transform implTransform() const; 242 gfx::Transform implTransform() const;
241 243
242 void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, flo at scale, base::TimeDelta duration); 244 void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, flo at scale, base::TimeDelta duration);
243 245
244 SkColor backgroundColor() const { return m_backgroundColor; } 246 SkColor backgroundColor() const { return m_backgroundColor; }
245 void setBackgroundColor(SkColor color) { m_backgroundColor = color; } 247 void setBackgroundColor(SkColor color) { m_backgroundColor = color; }
246 248
247 bool hasTransparentBackground() const { return m_hasTransparentBackground; } 249 bool hasTransparentBackground() const { return m_hasTransparentBackground; }
248 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro und = transparent; } 250 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro und = transparent; }
249 251 bool needsAnimateLayers() const { return !m_activeAnimationControllers.empty (); }
250 bool needsAnimateLayers() const { return m_needsAnimateLayers; }
251 void setNeedsAnimateLayers() { m_needsAnimateLayers = true; }
252 252
253 bool needsUpdateDrawProperties() const { return m_needsUpdateDrawProperties; } 253 bool needsUpdateDrawProperties() const { return m_needsUpdateDrawProperties; }
254 void setNeedsUpdateDrawProperties() { m_needsUpdateDrawProperties = true; } 254 void setNeedsUpdateDrawProperties() { m_needsUpdateDrawProperties = true; }
255 255
256 void setNeedsRedraw(); 256 void setNeedsRedraw();
257 257
258 void renderingStats(RenderingStats*) const; 258 void renderingStats(RenderingStats*) const;
259 259
260 void updateRootScrollLayerImplTransform(); 260 void updateRootScrollLayerImplTransform();
261 261
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // target becomes empty, then its target can be removed also. 297 // target becomes empty, then its target can be removed also.
298 size_t renderPassListBegin(const RenderPassList&) const { return 0; } 298 size_t renderPassListBegin(const RenderPassList&) const { return 0; }
299 size_t renderPassListEnd(const RenderPassList& list) const { return list .size(); } 299 size_t renderPassListEnd(const RenderPassList& list) const { return list .size(); }
300 size_t renderPassListNext(size_t it) const { return it + 1; } 300 size_t renderPassListNext(size_t it) const { return it + 1; }
301 }; 301 };
302 302
303 template<typename RenderPassCuller> 303 template<typename RenderPassCuller>
304 static void removeRenderPasses(RenderPassCuller, FrameData&); 304 static void removeRenderPasses(RenderPassCuller, FrameData&);
305 305
306 protected: 306 protected:
307 typedef base::hash_map<int, LayerAnimationController*> AnimationControllerMa p;
308
307 LayerTreeHostImpl(const LayerTreeSettings&, LayerTreeHostImplClient*, Proxy* ); 309 LayerTreeHostImpl(const LayerTreeSettings&, LayerTreeHostImplClient*, Proxy* );
308 310
309 void animatePageScale(base::TimeTicks monotonicTime); 311 void animatePageScale(base::TimeTicks monotonicTime);
310 void animateScrollbars(base::TimeTicks monotonicTime); 312 void animateScrollbars(base::TimeTicks monotonicTime);
311 313
312 void updateDrawProperties(); 314 void updateDrawProperties();
313 315
314 // Exposed for testing. 316 // Exposed for testing.
315 void calculateRenderSurfaceLayerList(LayerList&); 317 void calculateRenderSurfaceLayerList(LayerList&);
316 void resetNeedsUpdateDrawPropertiesForTesting() { m_needsUpdateDrawPropertie s = false; } 318 void resetNeedsUpdateDrawPropertiesForTesting() { m_needsUpdateDrawPropertie s = false; }
317 319
318 // Virtual for testing. 320 // Virtual for testing.
319 virtual void animateLayers(base::TimeTicks monotonicTime, base::Time wallClo ckTime); 321 virtual void animateLayers(base::TimeTicks monotonicTime, base::Time wallClo ckTime);
320 322
321 // Virtual for testing. 323 // Virtual for testing.
322 virtual base::TimeDelta lowFrequencyAnimationInterval() const; 324 virtual base::TimeDelta lowFrequencyAnimationInterval() const;
323 325
326 const AnimationControllerMap& activeAnimationControllers() const { return m_ activeAnimationControllers; }
327
324 LayerTreeHostImplClient* m_client; 328 LayerTreeHostImplClient* m_client;
325 Proxy* m_proxy; 329 Proxy* m_proxy;
326 330
327 private: 331 private:
328 void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo); 332 void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo);
329 void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo); 333 void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo);
330 void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scro llOffset, float pageScale); 334 void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scro llOffset, float pageScale);
331 335
332 void setPageScaleDelta(float); 336 void setPageScaleDelta(float);
333 void updateMaxScrollOffset(); 337 void updateMaxScrollOffset();
334 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re nderSurfaceLayerList); 338 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re nderSurfaceLayerList);
335 339
336 // Returns false if the frame should not be displayed. This function should 340 // Returns false if the frame should not be displayed. This function should
337 // only be called from prepareToDraw, as didDrawAllLayers must be called 341 // only be called from prepareToDraw, as didDrawAllLayers must be called
338 // if this helper function is called. 342 // if this helper function is called.
339 bool calculateRenderPasses(FrameData&); 343 bool calculateRenderPasses(FrameData&);
340 void animateLayersRecursive(LayerImpl*, base::TimeTicks monotonicTime, base: :Time wallClockTime, AnimationEventsVector*, bool& didAnimate, bool& needsAnimat eLayers); 344 void animateLayersRecursive(LayerImpl*, base::TimeTicks monotonicTime, base: :Time wallClockTime, AnimationEventsVector*, bool& didAnimate, bool& needsAnimat eLayers);
341 void setBackgroundTickingEnabled(bool); 345 void setBackgroundTickingEnabled(bool);
342 gfx::Size contentSize() const; 346 gfx::Size contentSize() const;
343 347
344 void sendDidLoseOutputSurfaceRecursive(LayerImpl*); 348 void sendDidLoseOutputSurfaceRecursive(LayerImpl*);
345 void clearRenderSurfaces(); 349 void clearRenderSurfaces();
346 bool ensureRenderSurfaceLayerList(); 350 bool ensureRenderSurfaceLayerList();
347 void clearCurrentlyScrollingLayer(); 351 void clearCurrentlyScrollingLayer();
348 352
349 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); 353 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime);
350 354
351 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; 355 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const;
352 356
357 // AnimationRegistar implementation.
358 virtual scoped_refptr<LayerAnimationController> GetAnimationControllerForId( int id) OVERRIDE;
359 virtual void DidActivateAnimationController(LayerAnimationController*) OVERR IDE;
360 virtual void DidDeactivateAnimationController(LayerAnimationController*) OVE RRIDE;
361 virtual void RegisterAnimationController(LayerAnimationController*) OVERRIDE ;
362 virtual void UnregisterAnimationController(LayerAnimationController*) OVERRI DE;
363
353 scoped_ptr<OutputSurface> m_outputSurface; 364 scoped_ptr<OutputSurface> m_outputSurface;
354 scoped_ptr<ResourceProvider> m_resourceProvider; 365 scoped_ptr<ResourceProvider> m_resourceProvider;
355 scoped_ptr<Renderer> m_renderer; 366 scoped_ptr<Renderer> m_renderer;
356 scoped_ptr<TileManager> m_tileManager; 367 scoped_ptr<TileManager> m_tileManager;
357 368
358 scoped_ptr<LayerTreeImpl> m_pendingTree; 369 scoped_ptr<LayerTreeImpl> m_pendingTree;
359 scoped_ptr<LayerTreeImpl> m_activeTree; 370 scoped_ptr<LayerTreeImpl> m_activeTree;
360 371
361 bool m_scrollDeltaIsInViewportSpace; 372 bool m_scrollDeltaIsInViewportSpace;
362 LayerTreeSettings m_settings; 373 LayerTreeSettings m_settings;
363 LayerTreeDebugState m_debugState; 374 LayerTreeDebugState m_debugState;
364 gfx::Size m_layoutViewportSize; 375 gfx::Size m_layoutViewportSize;
365 gfx::Size m_deviceViewportSize; 376 gfx::Size m_deviceViewportSize;
366 float m_deviceScaleFactor; 377 float m_deviceScaleFactor;
367 bool m_visible; 378 bool m_visible;
368 bool m_contentsTexturesPurged; 379 bool m_contentsTexturesPurged;
369 ManagedMemoryPolicy m_managedMemoryPolicy; 380 ManagedMemoryPolicy m_managedMemoryPolicy;
370 381
371 SkColor m_backgroundColor; 382 SkColor m_backgroundColor;
372 bool m_hasTransparentBackground; 383 bool m_hasTransparentBackground;
373 384
374 // If this is true, it is necessary to traverse the layer tree ticking the a nimators.
375 bool m_needsAnimateLayers;
376 bool m_needsUpdateDrawProperties; 385 bool m_needsUpdateDrawProperties;
377 bool m_pinchGestureActive; 386 bool m_pinchGestureActive;
378 gfx::Point m_previousPinchAnchor; 387 gfx::Point m_previousPinchAnchor;
379 388
380 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; 389 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation;
381 390
382 // This is used for ticking animations slowly when hidden. 391 // This is used for ticking animations slowly when hidden.
383 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; 392 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter;
384 393
385 // List of visible layers for the most recently prepared frame. Used for 394 // List of visible layers for the most recently prepared frame. Used for
386 // rendering and input event hit testing. 395 // rendering and input event hit testing.
387 LayerList m_renderSurfaceLayerList; 396 LayerList m_renderSurfaceLayerList;
388 397
389 PinchZoomViewport m_pinchZoomViewport; 398 PinchZoomViewport m_pinchZoomViewport;
390 399
391 scoped_ptr<FrameRateCounter> m_fpsCounter; 400 scoped_ptr<FrameRateCounter> m_fpsCounter;
392 scoped_ptr<DebugRectHistory> m_debugRectHistory; 401 scoped_ptr<DebugRectHistory> m_debugRectHistory;
393 402
394 int64 m_numImplThreadScrolls; 403 int64 m_numImplThreadScrolls;
395 int64 m_numMainThreadScrolls; 404 int64 m_numMainThreadScrolls;
396 405
397 int64 m_cumulativeNumLayersDrawn; 406 int64 m_cumulativeNumLayersDrawn;
398 407
399 int64 m_cumulativeNumMissingTiles; 408 int64 m_cumulativeNumMissingTiles;
400 409
401 size_t m_lastSentMemoryVisibleBytes; 410 size_t m_lastSentMemoryVisibleBytes;
402 size_t m_lastSentMemoryVisibleAndNearbyBytes; 411 size_t m_lastSentMemoryVisibleAndNearbyBytes;
403 size_t m_lastSentMemoryUseBytes; 412 size_t m_lastSentMemoryUseBytes;
404 413
414 AnimationControllerMap m_activeAnimationControllers;
415 AnimationControllerMap m_allAnimationControllers;
416
405 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); 417 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
406 }; 418 };
407 419
408 } // namespace cc 420 } // namespace cc
409 421
410 #endif // CC_LAYER_TREE_HOST_IMPL_H_ 422 #endif // CC_LAYER_TREE_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698