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

Side by Side Diff: cc/layer_tree_host.h

Issue 11348256: Use an auxiliary list of 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
« no previous file with comments | « cc/layer_impl.cc ('k') | cc/layer_tree_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_H_ 5 #ifndef CC_LAYER_TREE_HOST_H_
6 #define CC_LAYER_TREE_HOST_H_ 6 #define CC_LAYER_TREE_HOST_H_
7 7
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/cancelable_callback.h" 11 #include "base/cancelable_callback.h"
12 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "cc/animation_events.h" 16 #include "cc/animation_events.h"
17 #include "cc/animation_registrar.h"
17 #include "cc/cc_export.h" 18 #include "cc/cc_export.h"
18 #include "cc/layer_tree_host_client.h" 19 #include "cc/layer_tree_host_client.h"
19 #include "cc/layer_tree_host_common.h" 20 #include "cc/layer_tree_host_common.h"
20 #include "cc/occlusion_tracker.h" 21 #include "cc/occlusion_tracker.h"
21 #include "cc/output_surface.h" 22 #include "cc/output_surface.h"
22 #include "cc/prioritized_resource_manager.h" 23 #include "cc/prioritized_resource_manager.h"
23 #include "cc/proxy.h" 24 #include "cc/proxy.h"
24 #include "cc/rate_limiter.h" 25 #include "cc/rate_limiter.h"
25 #include "cc/rendering_stats.h" 26 #include "cc/rendering_stats.h"
26 #include "cc/scoped_ptr_vector.h" 27 #include "cc/scoped_ptr_vector.h"
27 #include "third_party/skia/include/core/SkColor.h" 28 #include "third_party/skia/include/core/SkColor.h"
28 #include "ui/gfx/rect.h" 29 #include "ui/gfx/rect.h"
29 30
30 #if defined(COMPILER_GCC) 31 #if defined(COMPILER_GCC)
31 namespace BASE_HASH_NAMESPACE { 32 namespace BASE_HASH_NAMESPACE {
32 template<> 33 template<>
33 struct hash<WebKit::WebGraphicsContext3D*> { 34 struct hash<WebKit::WebGraphicsContext3D*> {
34 size_t operator()(WebKit::WebGraphicsContext3D* ptr) const { 35 size_t operator()(WebKit::WebGraphicsContext3D* ptr) const {
35 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); 36 return hash<size_t>()(reinterpret_cast<size_t>(ptr));
36 } 37 }
37 }; 38 };
38 } // namespace BASE_HASH_NAMESPACE 39 } // namespace BASE_HASH_NAMESPACE
40
41 namespace BASE_HASH_NAMESPACE {
42 template<>
43 struct hash<cc::LayerAnimationController*> {
44 size_t operator()(cc::LayerAnimationController* ptr) const {
45 return hash<size_t>()(reinterpret_cast<size_t>(ptr));
46 }
47 };
48 } // namespace BASE_HASH_NAMESPACE
39 #endif // COMPILER 49 #endif // COMPILER
40 50
41 namespace cc { 51 namespace cc {
42 52
43 class Layer; 53 class Layer;
44 class LayerTreeHostImpl; 54 class LayerTreeHostImpl;
45 class LayerTreeHostImplClient; 55 class LayerTreeHostImplClient;
46 class PrioritizedResourceManager; 56 class PrioritizedResourceManager;
47 class ResourceUpdateQueue; 57 class ResourceUpdateQueue;
48 class HeadsUpDisplayLayer; 58 class HeadsUpDisplayLayer;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 bool usingAcceleratedPainting; 116 bool usingAcceleratedPainting;
107 bool usingSetVisibility; 117 bool usingSetVisibility;
108 bool usingSwapCompleteCallback; 118 bool usingSwapCompleteCallback;
109 bool usingGpuMemoryManager; 119 bool usingGpuMemoryManager;
110 bool usingDiscardFramebuffer; 120 bool usingDiscardFramebuffer;
111 bool usingEglImage; 121 bool usingEglImage;
112 bool allowPartialTextureUpdates; 122 bool allowPartialTextureUpdates;
113 int maxTextureSize; 123 int maxTextureSize;
114 }; 124 };
115 125
116 class CC_EXPORT LayerTreeHost : public RateLimiterClient { 126 class CC_EXPORT LayerTreeHost : public RateLimiterClient,
127 public AnimationRegistrar {
117 public: 128 public:
118 static scoped_ptr<LayerTreeHost> create(LayerTreeHostClient*, const LayerTre eSettings&, scoped_ptr<Thread> implThread); 129 static scoped_ptr<LayerTreeHost> create(LayerTreeHostClient*, const LayerTre eSettings&, scoped_ptr<Thread> implThread);
119 virtual ~LayerTreeHost(); 130 virtual ~LayerTreeHost();
120 131
121 void setSurfaceReady(); 132 void setSurfaceReady();
122 133
123 // Returns true if any LayerTreeHost is alive. 134 // Returns true if any LayerTreeHost is alive.
124 static bool anyLayerTreeHostInstanceExists(); 135 static bool anyLayerTreeHostInstanceExists();
125 136
126 static bool needsFilterContext() { return s_needsFilterContext; } 137 static bool needsFilterContext() { return s_needsFilterContext; }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void loseOutputSurface(int numTimes); 194 void loseOutputSurface(int numTimes);
184 195
185 void setNeedsAnimate(); 196 void setNeedsAnimate();
186 // virtual for testing 197 // virtual for testing
187 virtual void setNeedsCommit(); 198 virtual void setNeedsCommit();
188 virtual void setNeedsFullTreeSync(); 199 virtual void setNeedsFullTreeSync();
189 void setNeedsRedraw(); 200 void setNeedsRedraw();
190 bool commitRequested() const; 201 bool commitRequested() const;
191 202
192 void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallCl ockTime); 203 void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallCl ockTime);
193 virtual void didAddAnimation();
194 204
195 Layer* rootLayer() { return m_rootLayer.get(); } 205 Layer* rootLayer() { return m_rootLayer.get(); }
196 const Layer* rootLayer() const { return m_rootLayer.get(); } 206 const Layer* rootLayer() const { return m_rootLayer.get(); }
197 void setRootLayer(scoped_refptr<Layer>); 207 void setRootLayer(scoped_refptr<Layer>);
198 208
199 const LayerTreeSettings& settings() const { return m_settings; } 209 const LayerTreeSettings& settings() const { return m_settings; }
200 210
201 void setDebugState(const LayerTreeDebugState& debugState); 211 void setDebugState(const LayerTreeDebugState& debugState);
202 const LayerTreeDebugState& debugState() const { return m_debugState; } 212 const LayerTreeDebugState& debugState() const { return m_debugState; }
203 213
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 251
242 HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); } 252 HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); }
243 253
244 Proxy* proxy() const { return m_proxy.get(); } 254 Proxy* proxy() const { return m_proxy.get(); }
245 255
246 protected: 256 protected:
247 LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&); 257 LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&);
248 bool initialize(scoped_ptr<Thread> implThread); 258 bool initialize(scoped_ptr<Thread> implThread);
249 bool initializeForTesting(scoped_ptr<Proxy> proxyForTesting); 259 bool initializeForTesting(scoped_ptr<Proxy> proxyForTesting);
250 260
261 // AnimationRegistar implementation.
262 virtual void DidActivateAnimationController(LayerAnimationController*) OVERR IDE;
263 virtual void DidDeactivateAnimationController(LayerAnimationController*) OVE RRIDE;
264 virtual void RegisterAnimationController(LayerAnimationController*) OVERRIDE ;
265 virtual void UnregisterAnimationController(LayerAnimationController*) OVERRI DE;
266
251 private: 267 private:
252 typedef std::vector<scoped_refptr<Layer> > LayerList; 268 typedef std::vector<scoped_refptr<Layer> > LayerList;
269 typedef base::hash_set<LayerAnimationController*> AnimationControllerSet;
253 270
254 bool initializeProxy(scoped_ptr<Proxy> proxy); 271 bool initializeProxy(scoped_ptr<Proxy> proxy);
255 void initializeRenderer(); 272 void initializeRenderer();
256 273
257 void update(Layer*, ResourceUpdateQueue&, const OcclusionTracker*); 274 void update(Layer*, ResourceUpdateQueue&, const OcclusionTracker*);
258 bool paintLayerContents(const LayerList&, ResourceUpdateQueue&); 275 bool paintLayerContents(const LayerList&, ResourceUpdateQueue&);
259 bool paintMasksForRenderSurface(Layer*, ResourceUpdateQueue&); 276 bool paintMasksForRenderSurface(Layer*, ResourceUpdateQueue&);
260 277
261 void updateLayers(Layer*, ResourceUpdateQueue&); 278 void updateLayers(Layer*, ResourceUpdateQueue&);
262 void triggerPrepaint(); 279 void triggerPrepaint();
263 280
264 void prioritizeTextures(const LayerList&, OverdrawMetrics&); 281 void prioritizeTextures(const LayerList&, OverdrawMetrics&);
265 void setPrioritiesForSurfaces(size_t surfaceMemoryBytes); 282 void setPrioritiesForSurfaces(size_t surfaceMemoryBytes);
266 void setPrioritiesForLayers(const LayerList&); 283 void setPrioritiesForLayers(const LayerList&);
267 size_t calculateMemoryForRenderSurfaces(const LayerList& updateList); 284 size_t calculateMemoryForRenderSurfaces(const LayerList& updateList);
268 285
269 void animateLayers(base::TimeTicks monotonicTime); 286 void animateLayers(base::TimeTicks monotonicTime);
270 bool animateLayersRecursive(Layer* current, base::TimeTicks time); 287 bool animateLayersRecursive(Layer* current, base::TimeTicks time);
271 void setAnimationEventsRecursive(const AnimationEventsVector&, Layer*, base: :Time wallClockTime); 288 void setAnimationEventsRecursive(const AnimationEventsVector&, Layer*, base: :Time wallClockTime);
272 289
273 bool m_animating; 290 bool m_animating;
274 bool m_needsAnimateLayers;
275 bool m_needsFullTreeSync; 291 bool m_needsFullTreeSync;
276 292
277 base::CancelableClosure m_prepaintCallback; 293 base::CancelableClosure m_prepaintCallback;
278 294
279 LayerTreeHostClient* m_client; 295 LayerTreeHostClient* m_client;
280 scoped_ptr<Proxy> m_proxy; 296 scoped_ptr<Proxy> m_proxy;
281 297
282 int m_commitNumber; 298 int m_commitNumber;
283 RenderingStats m_renderingStats; 299 RenderingStats m_renderingStats;
284 300
(...skipping 26 matching lines...) Expand all
311 bool m_triggerIdleUpdates; 327 bool m_triggerIdleUpdates;
312 328
313 SkColor m_backgroundColor; 329 SkColor m_backgroundColor;
314 bool m_hasTransparentBackground; 330 bool m_hasTransparentBackground;
315 331
316 typedef ScopedPtrVector<PrioritizedResource> TextureList; 332 typedef ScopedPtrVector<PrioritizedResource> TextureList;
317 size_t m_partialTextureUpdateRequests; 333 size_t m_partialTextureUpdateRequests;
318 334
319 static bool s_needsFilterContext; 335 static bool s_needsFilterContext;
320 336
337 AnimationControllerSet m_activeAnimationControllers;
338
339 #if !defined(NDEBUG)
340 AnimationControllerSet m_allAnimationControllers;
341 #endif
342
321 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); 343 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost);
322 }; 344 };
323 345
324 } // namespace cc 346 } // namespace cc
325 347
326 #endif // CC_LAYER_TREE_HOST_H_ 348 #endif // CC_LAYER_TREE_HOST_H_
OLDNEW
« no previous file with comments | « cc/layer_impl.cc ('k') | cc/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698