| 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_IMPL_H_ | 5 #ifndef CC_LAYER_TREE_HOST_IMPL_H_ |
| 6 #define CC_LAYER_TREE_HOST_IMPL_H_ | 6 #define CC_LAYER_TREE_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "cc/animation_events.h" | 11 #include "cc/animation_events.h" |
| 12 #include "cc/animation_registrar.h" | 12 #include "cc/animation_registrar.h" |
| 13 #include "cc/cc_export.h" | 13 #include "cc/cc_export.h" |
| 14 #include "cc/input_handler.h" | 14 #include "cc/input_handler.h" |
| 15 #include "cc/output_surface_client.h" | 15 #include "cc/output_surface_client.h" |
| 16 #include "cc/pinch_zoom_viewport.h" | 16 #include "cc/pinch_zoom_viewport.h" |
| 17 #include "cc/render_pass.h" | 17 #include "cc/render_pass.h" |
| 18 #include "cc/render_pass_sink.h" | 18 #include "cc/render_pass_sink.h" |
| 19 #include "cc/renderer.h" | 19 #include "cc/renderer.h" |
| 20 #include "cc/tile_manager.h" | 20 #include "cc/tile_manager.h" |
| 21 #include "cc/top_controls_manager_client.h" |
| 21 #include "skia/ext/refptr.h" | 22 #include "skia/ext/refptr.h" |
| 22 #include "third_party/skia/include/core/SkColor.h" | 23 #include "third_party/skia/include/core/SkColor.h" |
| 23 #include "third_party/skia/include/core/SkPicture.h" | 24 #include "third_party/skia/include/core/SkPicture.h" |
| 24 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
| 25 | 26 |
| 26 namespace cc { | 27 namespace cc { |
| 27 | 28 |
| 28 class CompletionEvent; | 29 class CompletionEvent; |
| 29 class CompositorFrameMetadata; | 30 class CompositorFrameMetadata; |
| 30 class DebugRectHistory; | 31 class DebugRectHistory; |
| 31 class FrameRateCounter; | 32 class FrameRateCounter; |
| 32 class LayerImpl; | 33 class LayerImpl; |
| 33 class LayerTreeHostImplTimeSourceAdapter; | 34 class LayerTreeHostImplTimeSourceAdapter; |
| 34 class LayerTreeImpl; | 35 class LayerTreeImpl; |
| 35 class PageScaleAnimation; | 36 class PageScaleAnimation; |
| 36 class RenderPassDrawQuad; | 37 class RenderPassDrawQuad; |
| 37 class ResourceProvider; | 38 class ResourceProvider; |
| 39 class TopControlsManager; |
| 38 struct RendererCapabilities; | 40 struct RendererCapabilities; |
| 39 struct RenderingStats; | 41 struct RenderingStats; |
| 40 | 42 |
| 41 // LayerTreeHost->Proxy callback interface. | 43 // LayerTreeHost->Proxy callback interface. |
| 42 class LayerTreeHostImplClient { | 44 class LayerTreeHostImplClient { |
| 43 public: | 45 public: |
| 44 virtual void didLoseOutputSurfaceOnImplThread() = 0; | 46 virtual void didLoseOutputSurfaceOnImplThread() = 0; |
| 45 virtual void onSwapBuffersCompleteOnImplThread() = 0; | 47 virtual void onSwapBuffersCompleteOnImplThread() = 0; |
| 46 virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDe
lta interval) = 0; | 48 virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDe
lta interval) = 0; |
| 47 virtual void onCanDrawStateChanged(bool canDraw) = 0; | 49 virtual void onCanDrawStateChanged(bool canDraw) = 0; |
| 48 virtual void onHasPendingTreeStateChanged(bool hasPendingTree) = 0; | 50 virtual void onHasPendingTreeStateChanged(bool hasPendingTree) = 0; |
| 49 virtual void setNeedsRedrawOnImplThread() = 0; | 51 virtual void setNeedsRedrawOnImplThread() = 0; |
| 50 virtual void setNeedsCommitOnImplThread() = 0; | 52 virtual void setNeedsCommitOnImplThread() = 0; |
| 51 virtual void setNeedsManageTilesOnImplThread() = 0; | 53 virtual void setNeedsManageTilesOnImplThread() = 0; |
| 52 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) = 0; | 54 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) = 0; |
| 53 // Returns true if resources were deleted by this call. | 55 // Returns true if resources were deleted by this call. |
| 54 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) = 0; | 56 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) = 0; |
| 55 virtual void sendManagedMemoryStats() = 0; | 57 virtual void sendManagedMemoryStats() = 0; |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te | 60 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te |
| 59 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, | 61 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, |
| 60 public RendererClient, | 62 public RendererClient, |
| 61 public TileManagerClient, | 63 public TileManagerClient, |
| 62 public OutputSurfaceClient { | 64 public OutputSurfaceClient, |
| 65 public TopControlsManagerClient { |
| 63 typedef std::vector<LayerImpl*> LayerList; | 66 typedef std::vector<LayerImpl*> LayerList; |
| 64 | 67 |
| 65 public: | 68 public: |
| 66 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*, Proxy*); | 69 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*, Proxy*); |
| 67 virtual ~LayerTreeHostImpl(); | 70 virtual ~LayerTreeHostImpl(); |
| 68 | 71 |
| 69 // InputHandlerClient implementation | 72 // InputHandlerClient implementation |
| 70 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle
rClient::ScrollInputType) OVERRIDE; | 73 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle
rClient::ScrollInputType) OVERRIDE; |
| 71 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; | 74 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; |
| 72 virtual void scrollEnd() OVERRIDE; | 75 virtual void scrollEnd() OVERRIDE; |
| 73 virtual void pinchGestureBegin() OVERRIDE; | 76 virtual void pinchGestureBegin() OVERRIDE; |
| 74 virtual void pinchGestureUpdate(float, gfx::Point) OVERRIDE; | 77 virtual void pinchGestureUpdate(float, gfx::Point) OVERRIDE; |
| 75 virtual void pinchGestureEnd() OVERRIDE; | 78 virtual void pinchGestureEnd() OVERRIDE; |
| 76 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchor
Point, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) OVE
RRIDE; | 79 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchor
Point, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) OVE
RRIDE; |
| 77 virtual void scheduleAnimation() OVERRIDE; | 80 virtual void scheduleAnimation() OVERRIDE; |
| 78 virtual bool haveTouchEventHandlersAt(const gfx::Point&) OVERRIDE; | 81 virtual bool haveTouchEventHandlersAt(const gfx::Point&) OVERRIDE; |
| 79 | 82 |
| 83 // TopControlsManagerClient implementation. |
| 84 virtual LayerTreeImpl* activeTree() OVERRIDE; |
| 85 virtual void setNeedsUpdateDrawProperties() OVERRIDE; |
| 86 virtual void setNeedsRedraw() OVERRIDE; |
| 87 |
| 80 struct CC_EXPORT FrameData : public RenderPassSink { | 88 struct CC_EXPORT FrameData : public RenderPassSink { |
| 81 FrameData(); | 89 FrameData(); |
| 82 ~FrameData(); | 90 ~FrameData(); |
| 83 | 91 |
| 84 std::vector<gfx::Rect> occludingScreenSpaceRects; | 92 std::vector<gfx::Rect> occludingScreenSpaceRects; |
| 85 std::vector<gfx::Rect> nonOccludingScreenSpaceRects; | 93 std::vector<gfx::Rect> nonOccludingScreenSpaceRects; |
| 86 RenderPassList renderPasses; | 94 RenderPassList renderPasses; |
| 87 RenderPassIdHashMap renderPassesById; | 95 RenderPassIdHashMap renderPassesById; |
| 88 const LayerList* renderSurfaceLayerList; | 96 const LayerList* renderSurfaceLayerList; |
| 89 LayerList willDrawLayers; | 97 LayerList willDrawLayers; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 bool initializeRenderer(scoped_ptr<OutputSurface>); | 151 bool initializeRenderer(scoped_ptr<OutputSurface>); |
| 144 bool isContextLost(); | 152 bool isContextLost(); |
| 145 TileManager* tileManager() { return m_tileManager.get(); } | 153 TileManager* tileManager() { return m_tileManager.get(); } |
| 146 Renderer* renderer() { return m_renderer.get(); } | 154 Renderer* renderer() { return m_renderer.get(); } |
| 147 const RendererCapabilities& rendererCapabilities() const; | 155 const RendererCapabilities& rendererCapabilities() const; |
| 148 | 156 |
| 149 bool swapBuffers(); | 157 bool swapBuffers(); |
| 150 | 158 |
| 151 void readback(void* pixels, const gfx::Rect&); | 159 void readback(void* pixels, const gfx::Rect&); |
| 152 | 160 |
| 153 LayerTreeImpl* activeTree() { return m_activeTree.get(); } | |
| 154 const LayerTreeImpl* activeTree() const { return m_activeTree.get(); } | 161 const LayerTreeImpl* activeTree() const { return m_activeTree.get(); } |
| 155 LayerTreeImpl* pendingTree() { return m_pendingTree.get(); } | 162 LayerTreeImpl* pendingTree() { return m_pendingTree.get(); } |
| 156 const LayerTreeImpl* pendingTree() const { return m_pendingTree.get(); } | 163 const LayerTreeImpl* pendingTree() const { return m_pendingTree.get(); } |
| 157 void createPendingTree(); | 164 void createPendingTree(); |
| 158 void checkForCompletedSetPixels(); | 165 void checkForCompletedSetPixels(); |
| 159 virtual void activatePendingTreeIfNeeded(); | 166 virtual void activatePendingTreeIfNeeded(); |
| 160 | 167 |
| 161 // Shortcuts to layers on the active tree. | 168 // Shortcuts to layers on the active tree. |
| 162 LayerImpl* rootLayer() const; | 169 LayerImpl* rootLayer() const; |
| 163 LayerImpl* rootScrollLayer() const; | 170 LayerImpl* rootScrollLayer() const; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 181 void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFa
ctor, float maxPageScaleFactor); | 188 void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFa
ctor, float maxPageScaleFactor); |
| 182 | 189 |
| 183 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); | 190 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); |
| 184 gfx::Transform implTransform() const; | 191 gfx::Transform implTransform() const; |
| 185 | 192 |
| 186 void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, flo
at scale, base::TimeDelta duration); | 193 void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, flo
at scale, base::TimeDelta duration); |
| 187 | 194 |
| 188 bool needsAnimateLayers() const { return !m_animationRegistrar->active_anima
tion_controllers().empty(); } | 195 bool needsAnimateLayers() const { return !m_animationRegistrar->active_anima
tion_controllers().empty(); } |
| 189 | 196 |
| 190 bool needsUpdateDrawProperties() const { return m_needsUpdateDrawProperties;
} | 197 bool needsUpdateDrawProperties() const { return m_needsUpdateDrawProperties;
} |
| 191 void setNeedsUpdateDrawProperties() { m_needsUpdateDrawProperties = true; } | |
| 192 | |
| 193 void setNeedsRedraw(); | |
| 194 | 198 |
| 195 void renderingStats(RenderingStats*) const; | 199 void renderingStats(RenderingStats*) const; |
| 196 | 200 |
| 197 void sendManagedMemoryStats( | 201 void sendManagedMemoryStats( |
| 198 size_t memoryVisibleBytes, | 202 size_t memoryVisibleBytes, |
| 199 size_t memoryVisibleAndNearbyBytes, | 203 size_t memoryVisibleAndNearbyBytes, |
| 200 size_t memoryUseBytes); | 204 size_t memoryUseBytes); |
| 201 | 205 |
| 202 FrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } | 206 FrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } |
| 203 DebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get()
; } | 207 DebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get()
; } |
| 204 ResourceProvider* resourceProvider() const { return m_resourceProvider.get()
; } | 208 ResourceProvider* resourceProvider() const { return m_resourceProvider.get()
; } |
| 209 TopControlsManager* topControlsManager() const { return m_topControlsManager
.get(); } |
| 205 | 210 |
| 206 Proxy* proxy() const { return m_proxy; } | 211 Proxy* proxy() const { return m_proxy; } |
| 207 | 212 |
| 208 AnimationRegistrar* animationRegistrar() const { return m_animationRegistrar
.get(); } | 213 AnimationRegistrar* animationRegistrar() const { return m_animationRegistrar
.get(); } |
| 209 | 214 |
| 210 void setDebugState(const LayerTreeDebugState& debugState) { m_debugState = d
ebugState; } | 215 void setDebugState(const LayerTreeDebugState& debugState) { m_debugState = d
ebugState; } |
| 211 const LayerTreeDebugState& debugState() const { return m_debugState; } | 216 const LayerTreeDebugState& debugState() const { return m_debugState; } |
| 212 | 217 |
| 213 class CC_EXPORT CullRenderPassesWithCachedTextures { | 218 class CC_EXPORT CullRenderPassesWithCachedTextures { |
| 214 public: | 219 public: |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 gfx::Size m_deviceViewportSize; | 316 gfx::Size m_deviceViewportSize; |
| 312 float m_deviceScaleFactor; | 317 float m_deviceScaleFactor; |
| 313 bool m_visible; | 318 bool m_visible; |
| 314 bool m_contentsTexturesPurged; | 319 bool m_contentsTexturesPurged; |
| 315 ManagedMemoryPolicy m_managedMemoryPolicy; | 320 ManagedMemoryPolicy m_managedMemoryPolicy; |
| 316 | 321 |
| 317 bool m_needsUpdateDrawProperties; | 322 bool m_needsUpdateDrawProperties; |
| 318 bool m_pinchGestureActive; | 323 bool m_pinchGestureActive; |
| 319 gfx::Point m_previousPinchAnchor; | 324 gfx::Point m_previousPinchAnchor; |
| 320 | 325 |
| 326 scoped_ptr<TopControlsManager> m_topControlsManager; |
| 327 |
| 321 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; | 328 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; |
| 322 | 329 |
| 323 // This is used for ticking animations slowly when hidden. | 330 // This is used for ticking animations slowly when hidden. |
| 324 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; | 331 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; |
| 325 | 332 |
| 326 PinchZoomViewport m_pinchZoomViewport; | 333 PinchZoomViewport m_pinchZoomViewport; |
| 327 | 334 |
| 328 scoped_ptr<FrameRateCounter> m_fpsCounter; | 335 scoped_ptr<FrameRateCounter> m_fpsCounter; |
| 329 scoped_ptr<DebugRectHistory> m_debugRectHistory; | 336 scoped_ptr<DebugRectHistory> m_debugRectHistory; |
| 330 | 337 |
| 331 int64 m_numImplThreadScrolls; | 338 int64 m_numImplThreadScrolls; |
| 332 int64 m_numMainThreadScrolls; | 339 int64 m_numMainThreadScrolls; |
| 333 | 340 |
| 334 int64 m_cumulativeNumLayersDrawn; | 341 int64 m_cumulativeNumLayersDrawn; |
| 335 | 342 |
| 336 int64 m_cumulativeNumMissingTiles; | 343 int64 m_cumulativeNumMissingTiles; |
| 337 | 344 |
| 338 size_t m_lastSentMemoryVisibleBytes; | 345 size_t m_lastSentMemoryVisibleBytes; |
| 339 size_t m_lastSentMemoryVisibleAndNearbyBytes; | 346 size_t m_lastSentMemoryVisibleAndNearbyBytes; |
| 340 size_t m_lastSentMemoryUseBytes; | 347 size_t m_lastSentMemoryUseBytes; |
| 341 | 348 |
| 342 scoped_ptr<AnimationRegistrar> m_animationRegistrar; | 349 scoped_ptr<AnimationRegistrar> m_animationRegistrar; |
| 343 | 350 |
| 344 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 351 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
| 345 }; | 352 }; |
| 346 | 353 |
| 347 } // namespace cc | 354 } // namespace cc |
| 348 | 355 |
| 349 #endif // CC_LAYER_TREE_HOST_IMPL_H_ | 356 #endif // CC_LAYER_TREE_HOST_IMPL_H_ |
| OLD | NEW |