Chromium Code Reviews| 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/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 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 bool usingPartialSwap; | 115 bool usingPartialSwap; |
| 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 int maxTextureSize; | 122 int maxTextureSize; |
| 113 }; | 123 }; |
| 114 | 124 |
| 115 class CC_EXPORT LayerTreeHost : public RateLimiterClient { | 125 class CC_EXPORT LayerTreeHost : public RateLimiterClient, |
| 126 public AnimationRegistrar { | |
| 116 public: | 127 public: |
| 117 static scoped_ptr<LayerTreeHost> create(LayerTreeHostClient*, const LayerTre eSettings&, scoped_ptr<Thread> implThread); | 128 static scoped_ptr<LayerTreeHost> create(LayerTreeHostClient*, const LayerTre eSettings&, scoped_ptr<Thread> implThread); |
| 118 virtual ~LayerTreeHost(); | 129 virtual ~LayerTreeHost(); |
| 119 | 130 |
| 120 void setSurfaceReady(); | 131 void setSurfaceReady(); |
| 121 | 132 |
| 122 // Returns true if any LayerTreeHost is alive. | 133 // Returns true if any LayerTreeHost is alive. |
| 123 static bool anyLayerTreeHostInstanceExists(); | 134 static bool anyLayerTreeHostInstanceExists(); |
| 124 | 135 |
| 125 static bool needsFilterContext() { return s_needsFilterContext; } | 136 static bool needsFilterContext() { return s_needsFilterContext; } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 void loseContext(int numTimes); | 193 void loseContext(int numTimes); |
| 183 | 194 |
| 184 void setNeedsAnimate(); | 195 void setNeedsAnimate(); |
| 185 // virtual for testing | 196 // virtual for testing |
| 186 virtual void setNeedsCommit(); | 197 virtual void setNeedsCommit(); |
| 187 virtual void setNeedsFullTreeSync(); | 198 virtual void setNeedsFullTreeSync(); |
| 188 void setNeedsRedraw(); | 199 void setNeedsRedraw(); |
| 189 bool commitRequested() const; | 200 bool commitRequested() const; |
| 190 | 201 |
| 191 void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallCl ockTime); | 202 void setAnimationEvents(scoped_ptr<AnimationEventsVector>, base::Time wallCl ockTime); |
| 192 virtual void didAddAnimation(); | |
| 193 | 203 |
| 194 Layer* rootLayer() { return m_rootLayer.get(); } | 204 Layer* rootLayer() { return m_rootLayer.get(); } |
| 195 const Layer* rootLayer() const { return m_rootLayer.get(); } | 205 const Layer* rootLayer() const { return m_rootLayer.get(); } |
| 196 void setRootLayer(scoped_refptr<Layer>); | 206 void setRootLayer(scoped_refptr<Layer>); |
| 197 | 207 |
| 198 const LayerTreeSettings& settings() const { return m_settings; } | 208 const LayerTreeSettings& settings() const { return m_settings; } |
| 199 | 209 |
| 200 void setDebugState(const LayerTreeDebugState& debugState); | 210 void setDebugState(const LayerTreeDebugState& debugState); |
| 201 const LayerTreeDebugState& debugState() const { return m_debugState; } | 211 const LayerTreeDebugState& debugState() const { return m_debugState; } |
| 202 | 212 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 float deviceScaleFactor() const { return m_deviceScaleFactor; } | 249 float deviceScaleFactor() const { return m_deviceScaleFactor; } |
| 240 | 250 |
| 241 HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); } | 251 HeadsUpDisplayLayer* hudLayer() const { return m_hudLayer.get(); } |
| 242 | 252 |
| 243 Proxy* proxy() const { return m_proxy.get(); } | 253 Proxy* proxy() const { return m_proxy.get(); } |
| 244 | 254 |
| 245 protected: | 255 protected: |
| 246 LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&); | 256 LayerTreeHost(LayerTreeHostClient*, const LayerTreeSettings&); |
| 247 bool initialize(scoped_ptr<Thread> implThread); | 257 bool initialize(scoped_ptr<Thread> implThread); |
| 248 | 258 |
| 259 // AnimationRegistar implementation. | |
| 260 virtual void ActivateAnimationController(LayerAnimationController*) OVERRIDE ; | |
| 261 virtual void DeactivateAnimationController(LayerAnimationController*) OVERRI DE; | |
|
nduca
2012/12/05 20:15:56
DidActivate, DidDeactivate. Written as Activate, i
| |
| 262 virtual void RegisterAnimationController(LayerAnimationController*) OVERRIDE ; | |
| 263 virtual void UnregisterAnimationController(LayerAnimationController*) OVERRI DE; | |
| 264 | |
| 249 private: | 265 private: |
| 250 typedef std::vector<scoped_refptr<Layer> > LayerList; | 266 typedef std::vector<scoped_refptr<Layer> > LayerList; |
| 267 typedef base::hash_set<LayerAnimationController*> AnimationControllerSet; | |
| 251 | 268 |
| 252 void initializeRenderer(); | 269 void initializeRenderer(); |
| 253 | 270 |
| 254 void update(Layer*, ResourceUpdateQueue&, const OcclusionTracker*); | 271 void update(Layer*, ResourceUpdateQueue&, const OcclusionTracker*); |
| 255 bool paintLayerContents(const LayerList&, ResourceUpdateQueue&); | 272 bool paintLayerContents(const LayerList&, ResourceUpdateQueue&); |
| 256 bool paintMasksForRenderSurface(Layer*, ResourceUpdateQueue&); | 273 bool paintMasksForRenderSurface(Layer*, ResourceUpdateQueue&); |
| 257 | 274 |
| 258 void updateLayers(Layer*, ResourceUpdateQueue&); | 275 void updateLayers(Layer*, ResourceUpdateQueue&); |
| 259 void triggerPrepaint(); | 276 void triggerPrepaint(); |
| 260 | 277 |
| 261 void prioritizeTextures(const LayerList&, OverdrawMetrics&); | 278 void prioritizeTextures(const LayerList&, OverdrawMetrics&); |
| 262 void setPrioritiesForSurfaces(size_t surfaceMemoryBytes); | 279 void setPrioritiesForSurfaces(size_t surfaceMemoryBytes); |
| 263 void setPrioritiesForLayers(const LayerList&); | 280 void setPrioritiesForLayers(const LayerList&); |
| 264 size_t calculateMemoryForRenderSurfaces(const LayerList& updateList); | 281 size_t calculateMemoryForRenderSurfaces(const LayerList& updateList); |
| 265 | 282 |
| 266 void animateLayers(base::TimeTicks monotonicTime); | 283 void animateLayers(base::TimeTicks monotonicTime); |
| 267 bool animateLayersRecursive(Layer* current, base::TimeTicks time); | 284 bool animateLayersRecursive(Layer* current, base::TimeTicks time); |
| 268 void setAnimationEventsRecursive(const AnimationEventsVector&, Layer*, base: :Time wallClockTime); | 285 void setAnimationEventsRecursive(const AnimationEventsVector&, Layer*, base: :Time wallClockTime); |
| 269 | 286 |
| 270 bool m_animating; | 287 bool m_animating; |
| 271 bool m_needsAnimateLayers; | |
| 272 bool m_needsFullTreeSync; | 288 bool m_needsFullTreeSync; |
| 273 | 289 |
| 274 base::CancelableClosure m_prepaintCallback; | 290 base::CancelableClosure m_prepaintCallback; |
| 275 | 291 |
| 276 LayerTreeHostClient* m_client; | 292 LayerTreeHostClient* m_client; |
| 277 scoped_ptr<Proxy> m_proxy; | 293 scoped_ptr<Proxy> m_proxy; |
| 278 | 294 |
| 279 int m_commitNumber; | 295 int m_commitNumber; |
| 280 RenderingStats m_renderingStats; | 296 RenderingStats m_renderingStats; |
| 281 | 297 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 308 bool m_triggerIdleUpdates; | 324 bool m_triggerIdleUpdates; |
| 309 | 325 |
| 310 SkColor m_backgroundColor; | 326 SkColor m_backgroundColor; |
| 311 bool m_hasTransparentBackground; | 327 bool m_hasTransparentBackground; |
| 312 | 328 |
| 313 typedef ScopedPtrVector<PrioritizedResource> TextureList; | 329 typedef ScopedPtrVector<PrioritizedResource> TextureList; |
| 314 size_t m_partialTextureUpdateRequests; | 330 size_t m_partialTextureUpdateRequests; |
| 315 | 331 |
| 316 static bool s_needsFilterContext; | 332 static bool s_needsFilterContext; |
| 317 | 333 |
| 334 AnimationControllerSet m_activeAnimationControllers; | |
| 335 | |
| 336 #if !defined(NDEBUG) | |
| 337 AnimationControllerSet m_allAnimationControllers; | |
| 338 #endif | |
| 339 | |
| 318 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 340 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
| 319 }; | 341 }; |
| 320 | 342 |
| 321 } // namespace cc | 343 } // namespace cc |
| 322 | 344 |
| 323 #endif // CC_LAYER_TREE_HOST_H_ | 345 #endif // CC_LAYER_TREE_HOST_H_ |
| OLD | NEW |