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

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: Unit tests pass! 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_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/graphics_context.h" 19 #include "cc/graphics_context.h"
19 #include "cc/layer_tree_host_client.h" 20 #include "cc/layer_tree_host_client.h"
20 #include "cc/layer_tree_host_common.h" 21 #include "cc/layer_tree_host_common.h"
21 #include "cc/occlusion_tracker.h" 22 #include "cc/occlusion_tracker.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 FontAtlas; 53 class FontAtlas;
44 class Layer; 54 class Layer;
45 class LayerTreeHostImpl; 55 class LayerTreeHostImpl;
46 class LayerTreeHostImplClient; 56 class LayerTreeHostImplClient;
47 class PrioritizedResourceManager; 57 class PrioritizedResourceManager;
48 class ResourceUpdateQueue; 58 class ResourceUpdateQueue;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 bool usingPartialSwap; 102 bool usingPartialSwap;
93 bool usingAcceleratedPainting; 103 bool usingAcceleratedPainting;
94 bool usingSetVisibility; 104 bool usingSetVisibility;
95 bool usingSwapCompleteCallback; 105 bool usingSwapCompleteCallback;
96 bool usingGpuMemoryManager; 106 bool usingGpuMemoryManager;
97 bool usingDiscardFramebuffer; 107 bool usingDiscardFramebuffer;
98 bool usingEglImage; 108 bool usingEglImage;
99 int maxTextureSize; 109 int maxTextureSize;
100 }; 110 };
101 111
102 class CC_EXPORT LayerTreeHost : public RateLimiterClient { 112 class CC_EXPORT LayerTreeHost : public RateLimiterClient,
113 public AnimationRegistrar {
103 public: 114 public:
104 static scoped_ptr<LayerTreeHost> create(LayerTreeHostClient*, const LayerTre eSettings&, scoped_ptr<Thread> implThread); 115 static scoped_ptr<LayerTreeHost> create(LayerTreeHostClient*, const LayerTre eSettings&, scoped_ptr<Thread> implThread);
105 virtual ~LayerTreeHost(); 116 virtual ~LayerTreeHost();
106 117
107 void setSurfaceReady(); 118 void setSurfaceReady();
108 119
109 // Returns true if any LayerTreeHost is alive. 120 // Returns true if any LayerTreeHost is alive.
110 static bool anyLayerTreeHostInstanceExists(); 121 static bool anyLayerTreeHostInstanceExists();
111 122
112 static bool needsFilterContext() { return s_needsFilterContext; } 123 static bool needsFilterContext() { return s_needsFilterContext; }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // Test only hook 179 // Test only hook
169 void loseContext(int numTimes); 180 void loseContext(int numTimes);
170 181
171 void setNeedsAnimate(); 182 void setNeedsAnimate();
172 // virtual for testing 183 // virtual for testing
173 virtual void setNeedsCommit(); 184 virtual void setNeedsCommit();
174 void setNeedsRedraw(); 185 void setNeedsRedraw();
175 bool commitRequested() const; 186 bool commitRequested() const;
176 187
177 void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallCl ockTime); 188 void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallCl ockTime);
178 virtual void didAddAnimation();
179 189
180 Layer* rootLayer() { return m_rootLayer.get(); } 190 Layer* rootLayer() { return m_rootLayer.get(); }
181 const Layer* rootLayer() const { return m_rootLayer.get(); } 191 const Layer* rootLayer() const { return m_rootLayer.get(); }
182 void setRootLayer(scoped_refptr<Layer>); 192 void setRootLayer(scoped_refptr<Layer>);
183 193
184 const LayerTreeSettings& settings() const { return m_settings; } 194 const LayerTreeSettings& settings() const { return m_settings; }
185 195
186 void setViewportSize(const gfx::Size& layoutViewportSize, const gfx::Size& d eviceViewportSize); 196 void setViewportSize(const gfx::Size& layoutViewportSize, const gfx::Size& d eviceViewportSize);
187 197
188 const gfx::Size& layoutViewportSize() const { return m_layoutViewportSize; } 198 const gfx::Size& layoutViewportSize() const { return m_layoutViewportSize; }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 void setFontAtlas(scoped_ptr<FontAtlas>); 235 void setFontAtlas(scoped_ptr<FontAtlas>);
226 236
227 HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); } 237 HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); }
228 238
229 Proxy* proxy() const { return m_proxy.get(); } 239 Proxy* proxy() const { return m_proxy.get(); }
230 240
231 protected: 241 protected:
232 LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&); 242 LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&);
233 bool initialize(scoped_ptr<Thread> implThread); 243 bool initialize(scoped_ptr<Thread> implThread);
234 244
245 // AnimationRegistar implementation.
nduca 2012/12/04 05:40:26 so, walk me through the benefit of this being LTH
246 virtual void Register(LayerAnimationController*) OVERRIDE;
247 virtual void Unregister(LayerAnimationController*) OVERRIDE;
248
235 private: 249 private:
236 typedef std::vector<scoped_refptr<Layer> > LayerList; 250 typedef std::vector<scoped_refptr<Layer> > LayerList;
251 typedef base::hash_set<LayerAnimationController*> AnimationControllerSet;
237 252
238 void initializeRenderer(); 253 void initializeRenderer();
239 254
240 void update(Layer*, ResourceUpdateQueue&, const OcclusionTracker*); 255 void update(Layer*, ResourceUpdateQueue&, const OcclusionTracker*);
241 bool paintLayerContents(const LayerList&, ResourceUpdateQueue&); 256 bool paintLayerContents(const LayerList&, ResourceUpdateQueue&);
242 bool paintMasksForRenderSurface(Layer*, ResourceUpdateQueue&); 257 bool paintMasksForRenderSurface(Layer*, ResourceUpdateQueue&);
243 258
244 void updateLayers(Layer*, ResourceUpdateQueue&); 259 void updateLayers(Layer*, ResourceUpdateQueue&);
245 void triggerPrepaint(); 260 void triggerPrepaint();
246 261
247 void prioritizeTextures(const LayerList&, OverdrawMetrics&); 262 void prioritizeTextures(const LayerList&, OverdrawMetrics&);
248 void setPrioritiesForSurfaces(size_t surfaceMemoryBytes); 263 void setPrioritiesForSurfaces(size_t surfaceMemoryBytes);
249 void setPrioritiesForLayers(const LayerList&); 264 void setPrioritiesForLayers(const LayerList&);
250 size_t calculateMemoryForRenderSurfaces(const LayerList& updateList); 265 size_t calculateMemoryForRenderSurfaces(const LayerList& updateList);
251 266
252 void animateLayers(base::TimeTicks monotonicTime); 267 void animateLayers(base::TimeTicks monotonicTime);
253 bool animateLayersRecursive(Layer* current, base::TimeTicks time); 268 bool animateLayersRecursive(Layer* current, base::TimeTicks time);
254 void setAnimationEventsRecursive(const AnimationEventsVector&, Layer*, base: :Time wallClockTime); 269 void setAnimationEventsRecursive(const AnimationEventsVector&, Layer*, base: :Time wallClockTime);
255 270
256 void createHUDLayerIfNeeded(); 271 void createHUDLayerIfNeeded();
257 272
258 bool m_animating; 273 bool m_animating;
259 bool m_needsAnimateLayers;
260 274
261 base::CancelableClosure m_prepaintCallback; 275 base::CancelableClosure m_prepaintCallback;
262 276
263 LayerTreeHostClient* m_client; 277 LayerTreeHostClient* m_client;
264 scoped_ptr<Proxy> m_proxy; 278 scoped_ptr<Proxy> m_proxy;
265 279
266 int m_commitNumber; 280 int m_commitNumber;
267 RenderingStats m_renderingStats; 281 RenderingStats m_renderingStats;
268 282
269 bool m_rendererInitialized; 283 bool m_rendererInitialized;
(...skipping 24 matching lines...) Expand all
294 bool m_triggerIdleUpdates; 308 bool m_triggerIdleUpdates;
295 309
296 SkColor m_backgroundColor; 310 SkColor m_backgroundColor;
297 bool m_hasTransparentBackground; 311 bool m_hasTransparentBackground;
298 312
299 typedef ScopedPtrVector<PrioritizedResource> TextureList; 313 typedef ScopedPtrVector<PrioritizedResource> TextureList;
300 size_t m_partialTextureUpdateRequests; 314 size_t m_partialTextureUpdateRequests;
301 315
302 static bool s_needsFilterContext; 316 static bool s_needsFilterContext;
303 317
318 AnimationControllerSet m_activeAnimationControllers;
319
304 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); 320 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost);
305 }; 321 };
306 322
307 } // namespace cc 323 } // namespace cc
308 324
309 #endif // CC_LAYER_TREE_HOST_H_ 325 #endif // CC_LAYER_TREE_HOST_H_
OLDNEW
« cc/layer_animation_controller.cc ('K') | « 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