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