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" |
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/layer_tree_settings.h" | 21 #include "cc/layer_tree_settings.h" |
21 #include "cc/occlusion_tracker.h" | 22 #include "cc/occlusion_tracker.h" |
22 #include "cc/output_surface.h" | 23 #include "cc/output_surface.h" |
23 #include "cc/prioritized_resource_manager.h" | 24 #include "cc/prioritized_resource_manager.h" |
24 #include "cc/proxy.h" | 25 #include "cc/proxy.h" |
25 #include "cc/rate_limiter.h" | 26 #include "cc/rate_limiter.h" |
26 #include "cc/rendering_stats.h" | 27 #include "cc/rendering_stats.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 bool usingAcceleratedPainting; | 62 bool usingAcceleratedPainting; |
62 bool usingSetVisibility; | 63 bool usingSetVisibility; |
63 bool usingSwapCompleteCallback; | 64 bool usingSwapCompleteCallback; |
64 bool usingGpuMemoryManager; | 65 bool usingGpuMemoryManager; |
65 bool usingDiscardBackbuffer; | 66 bool usingDiscardBackbuffer; |
66 bool usingEglImage; | 67 bool usingEglImage; |
67 bool allowPartialTextureUpdates; | 68 bool allowPartialTextureUpdates; |
68 int maxTextureSize; | 69 int maxTextureSize; |
69 }; | 70 }; |
70 | 71 |
71 class CC_EXPORT LayerTreeHost : public RateLimiterClient { | 72 class CC_EXPORT LayerTreeHost : public RateLimiterClient, |
| 73 public AnimationRegistrar { |
72 public: | 74 public: |
73 static scoped_ptr<LayerTreeHost> create(LayerTreeHostClient*, const LayerTre
eSettings&, scoped_ptr<Thread> implThread); | 75 static scoped_ptr<LayerTreeHost> create(LayerTreeHostClient*, const LayerTre
eSettings&, scoped_ptr<Thread> implThread); |
74 virtual ~LayerTreeHost(); | 76 virtual ~LayerTreeHost(); |
75 | 77 |
76 void setSurfaceReady(); | 78 void setSurfaceReady(); |
77 | 79 |
78 // Returns true if any LayerTreeHost is alive. | 80 // Returns true if any LayerTreeHost is alive. |
79 static bool anyLayerTreeHostInstanceExists(); | 81 static bool anyLayerTreeHostInstanceExists(); |
80 | 82 |
81 static bool needsFilterContext() { return s_needsFilterContext; } | 83 static bool needsFilterContext() { return s_needsFilterContext; } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 void loseOutputSurface(int numTimes); | 140 void loseOutputSurface(int numTimes); |
139 | 141 |
140 void setNeedsAnimate(); | 142 void setNeedsAnimate(); |
141 // virtual for testing | 143 // virtual for testing |
142 virtual void setNeedsCommit(); | 144 virtual void setNeedsCommit(); |
143 virtual void setNeedsFullTreeSync(); | 145 virtual void setNeedsFullTreeSync(); |
144 void setNeedsRedraw(); | 146 void setNeedsRedraw(); |
145 bool commitRequested() const; | 147 bool commitRequested() const; |
146 | 148 |
147 void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallCl
ockTime); | 149 void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallCl
ockTime); |
148 virtual void didAddAnimation(); | |
149 | 150 |
150 Layer* rootLayer() { return m_rootLayer.get(); } | 151 Layer* rootLayer() { return m_rootLayer.get(); } |
151 const Layer* rootLayer() const { return m_rootLayer.get(); } | 152 const Layer* rootLayer() const { return m_rootLayer.get(); } |
152 void setRootLayer(scoped_refptr<Layer>); | 153 void setRootLayer(scoped_refptr<Layer>); |
153 | 154 |
154 const LayerTreeSettings& settings() const { return m_settings; } | 155 const LayerTreeSettings& settings() const { return m_settings; } |
155 | 156 |
156 void setDebugState(const LayerTreeDebugState& debugState); | 157 void setDebugState(const LayerTreeDebugState& debugState); |
157 const LayerTreeDebugState& debugState() const { return m_debugState; } | 158 const LayerTreeDebugState& debugState() const { return m_debugState; } |
158 | 159 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 197 |
197 HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); } | 198 HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); } |
198 | 199 |
199 Proxy* proxy() const { return m_proxy.get(); } | 200 Proxy* proxy() const { return m_proxy.get(); } |
200 | 201 |
201 protected: | 202 protected: |
202 LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&); | 203 LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&); |
203 bool initialize(scoped_ptr<Thread> implThread); | 204 bool initialize(scoped_ptr<Thread> implThread); |
204 bool initializeForTesting(scoped_ptr<Proxy> proxyForTesting); | 205 bool initializeForTesting(scoped_ptr<Proxy> proxyForTesting); |
205 | 206 |
| 207 // AnimationRegistar implementation. |
| 208 virtual scoped_refptr<LayerAnimationController> GetAnimationControllerForId(
int id) OVERRIDE; |
| 209 virtual void DidActivateAnimationController(LayerAnimationController*) OVERR
IDE; |
| 210 virtual void DidDeactivateAnimationController(LayerAnimationController*) OVE
RRIDE; |
| 211 virtual void RegisterAnimationController(LayerAnimationController*) OVERRIDE
; |
| 212 virtual void UnregisterAnimationController(LayerAnimationController*) OVERRI
DE; |
| 213 |
206 private: | 214 private: |
207 typedef std::vector<scoped_refptr<Layer> > LayerList; | 215 typedef std::vector<scoped_refptr<Layer> > LayerList; |
| 216 typedef base::hash_map<int, LayerAnimationController*> AnimationControllerMa
p; |
208 | 217 |
209 bool initializeProxy(scoped_ptr<Proxy> proxy); | 218 bool initializeProxy(scoped_ptr<Proxy> proxy); |
210 void initializeRenderer(); | 219 void initializeRenderer(); |
211 | 220 |
212 void update(Layer*, ResourceUpdateQueue&, const OcclusionTracker*); | 221 void update(Layer*, ResourceUpdateQueue&, const OcclusionTracker*); |
213 bool paintLayerContents(const LayerList&, ResourceUpdateQueue&); | 222 bool paintLayerContents(const LayerList&, ResourceUpdateQueue&); |
214 bool paintMasksForRenderSurface(Layer*, ResourceUpdateQueue&); | 223 bool paintMasksForRenderSurface(Layer*, ResourceUpdateQueue&); |
215 | 224 |
216 void updateLayers(Layer*, ResourceUpdateQueue&); | 225 void updateLayers(Layer*, ResourceUpdateQueue&); |
217 void triggerPrepaint(); | 226 void triggerPrepaint(); |
218 | 227 |
219 void prioritizeTextures(const LayerList&, OverdrawMetrics&); | 228 void prioritizeTextures(const LayerList&, OverdrawMetrics&); |
220 void setPrioritiesForSurfaces(size_t surfaceMemoryBytes); | 229 void setPrioritiesForSurfaces(size_t surfaceMemoryBytes); |
221 void setPrioritiesForLayers(const LayerList&); | 230 void setPrioritiesForLayers(const LayerList&); |
222 size_t calculateMemoryForRenderSurfaces(const LayerList& updateList); | 231 size_t calculateMemoryForRenderSurfaces(const LayerList& updateList); |
223 | 232 |
224 void animateLayers(base::TimeTicks monotonicTime); | 233 void animateLayers(base::TimeTicks monotonicTime); |
225 bool animateLayersRecursive(Layer* current, base::TimeTicks time); | 234 bool animateLayersRecursive(Layer* current, base::TimeTicks time); |
226 void setAnimationEventsRecursive(const AnimationEventsVector&, Layer*, base:
:Time wallClockTime); | 235 void setAnimationEventsRecursive(const AnimationEventsVector&, Layer*, base:
:Time wallClockTime); |
227 | 236 |
228 bool m_animating; | 237 bool m_animating; |
229 bool m_needsAnimateLayers; | |
230 bool m_needsFullTreeSync; | 238 bool m_needsFullTreeSync; |
231 | 239 |
232 base::CancelableClosure m_prepaintCallback; | 240 base::CancelableClosure m_prepaintCallback; |
233 | 241 |
234 LayerTreeHostClient* m_client; | 242 LayerTreeHostClient* m_client; |
235 scoped_ptr<Proxy> m_proxy; | 243 scoped_ptr<Proxy> m_proxy; |
236 | 244 |
237 int m_commitNumber; | 245 int m_commitNumber; |
238 RenderingStats m_renderingStats; | 246 RenderingStats m_renderingStats; |
239 | 247 |
(...skipping 26 matching lines...) Expand all Loading... |
266 bool m_triggerIdleUpdates; | 274 bool m_triggerIdleUpdates; |
267 | 275 |
268 SkColor m_backgroundColor; | 276 SkColor m_backgroundColor; |
269 bool m_hasTransparentBackground; | 277 bool m_hasTransparentBackground; |
270 | 278 |
271 typedef ScopedPtrVector<PrioritizedResource> TextureList; | 279 typedef ScopedPtrVector<PrioritizedResource> TextureList; |
272 size_t m_partialTextureUpdateRequests; | 280 size_t m_partialTextureUpdateRequests; |
273 | 281 |
274 static bool s_needsFilterContext; | 282 static bool s_needsFilterContext; |
275 | 283 |
| 284 AnimationControllerMap m_activeAnimationControllers; |
| 285 AnimationControllerMap m_allAnimationControllers; |
| 286 |
276 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 287 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
277 }; | 288 }; |
278 | 289 |
279 } // namespace cc | 290 } // namespace cc |
280 | 291 |
281 #endif // CC_LAYER_TREE_HOST_H_ | 292 #endif // CC_LAYER_TREE_HOST_H_ |
OLD | NEW |