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/cc_export.h" | 12 #include "cc/cc_export.h" |
13 #include "cc/input_handler.h" | 13 #include "cc/input_handler.h" |
14 #include "cc/layer_sorter.h" | 14 #include "cc/layer_sorter.h" |
| 15 #include "cc/layer_tree_impl.h" |
15 #include "cc/render_pass.h" | 16 #include "cc/render_pass.h" |
16 #include "cc/render_pass_sink.h" | 17 #include "cc/render_pass_sink.h" |
17 #include "cc/renderer.h" | 18 #include "cc/renderer.h" |
18 #include "cc/tile_manager.h" | 19 #include "cc/tile_manager.h" |
19 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
20 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
21 #include <public/WebCompositorOutputSurfaceClient.h> | 22 #include <public/WebCompositorOutputSurfaceClient.h> |
22 | 23 |
23 namespace cc { | 24 namespace cc { |
24 | 25 |
25 class CompletionEvent; | 26 class CompletionEvent; |
26 class DebugRectHistory; | 27 class DebugRectHistory; |
27 class FrameRateCounter; | 28 class FrameRateCounter; |
28 class HeadsUpDisplayLayerImpl; | |
29 class LayerImpl; | 29 class LayerImpl; |
30 class LayerTreeHostImplTimeSourceAdapter; | 30 class LayerTreeHostImplTimeSourceAdapter; |
31 class PageScaleAnimation; | 31 class PageScaleAnimation; |
32 class RenderPassDrawQuad; | 32 class RenderPassDrawQuad; |
33 class ResourceProvider; | 33 class ResourceProvider; |
34 struct RendererCapabilities; | 34 struct RendererCapabilities; |
35 struct RenderingStats; | 35 struct RenderingStats; |
36 | 36 |
37 // LayerTreeHost->Proxy callback interface. | 37 // LayerTreeHost->Proxy callback interface. |
38 class LayerTreeHostImplClient { | 38 class LayerTreeHostImplClient { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 float m_deviceScaleFactor; | 106 float m_deviceScaleFactor; |
107 | 107 |
108 gfx::Vector2dF m_zoomedViewportOffset; | 108 gfx::Vector2dF m_zoomedViewportOffset; |
109 gfx::SizeF m_layoutViewportSize; | 109 gfx::SizeF m_layoutViewportSize; |
110 }; | 110 }; |
111 | 111 |
112 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te | 112 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te |
113 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, | 113 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, |
114 public RendererClient, | 114 public RendererClient, |
115 public TileManagerClient, | 115 public TileManagerClient, |
| 116 public LayerTreeImplClient, |
116 public NON_EXPORTED_BASE(WebKit::WebComposit
orOutputSurfaceClient) { | 117 public NON_EXPORTED_BASE(WebKit::WebComposit
orOutputSurfaceClient) { |
117 typedef std::vector<LayerImpl*> LayerList; | 118 typedef std::vector<LayerImpl*> LayerList; |
118 | 119 |
119 public: | 120 public: |
120 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*, Proxy*); | 121 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*, Proxy*); |
121 virtual ~LayerTreeHostImpl(); | 122 virtual ~LayerTreeHostImpl(); |
122 | 123 |
123 // InputHandlerClient implementation | 124 // InputHandlerClient implementation |
124 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle
rClient::ScrollInputType) OVERRIDE; | 125 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle
rClient::ScrollInputType) OVERRIDE; |
125 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; | 126 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE; | 173 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE; |
173 virtual bool hasImplThread() const OVERRIDE; | 174 virtual bool hasImplThread() const OVERRIDE; |
174 | 175 |
175 // TileManagerClient implementation. | 176 // TileManagerClient implementation. |
176 virtual void ScheduleManageTiles() OVERRIDE; | 177 virtual void ScheduleManageTiles() OVERRIDE; |
177 virtual void ScheduleRedraw() OVERRIDE; | 178 virtual void ScheduleRedraw() OVERRIDE; |
178 | 179 |
179 // WebCompositorOutputSurfaceClient implementation. | 180 // WebCompositorOutputSurfaceClient implementation. |
180 virtual void onVSyncParametersChanged(double monotonicTimebase, double inter
valInSeconds) OVERRIDE; | 181 virtual void onVSyncParametersChanged(double monotonicTimebase, double inter
valInSeconds) OVERRIDE; |
181 | 182 |
| 183 // LayerTreeImplClient implementation. |
| 184 virtual void OnCanDrawStateChangedForTree(LayerTreeImpl*) OVERRIDE; |
| 185 |
182 // Implementation | 186 // Implementation |
183 bool canDraw(); | 187 bool canDraw(); |
184 OutputSurface* outputSurface() const; | 188 OutputSurface* outputSurface() const; |
185 | 189 |
186 std::string layerTreeAsText() const; | 190 std::string layerTreeAsText() const; |
187 | 191 |
188 void finishAllRendering(); | 192 void finishAllRendering(); |
189 int sourceAnimationFrameNumber() const; | 193 int sourceAnimationFrameNumber() const; |
190 | 194 |
191 bool initializeRenderer(scoped_ptr<OutputSurface>); | 195 bool initializeRenderer(scoped_ptr<OutputSurface>); |
192 bool isContextLost(); | 196 bool isContextLost(); |
193 TileManager* tileManager() { return m_tileManager.get(); } | 197 TileManager* tileManager() { return m_tileManager.get(); } |
194 Renderer* renderer() { return m_renderer.get(); } | 198 Renderer* renderer() { return m_renderer.get(); } |
195 const RendererCapabilities& rendererCapabilities() const; | 199 const RendererCapabilities& rendererCapabilities() const; |
196 | 200 |
197 bool swapBuffers(); | 201 bool swapBuffers(); |
198 | 202 |
199 void readback(void* pixels, const gfx::Rect&); | 203 void readback(void* pixels, const gfx::Rect&); |
200 | 204 |
| 205 LayerTreeImpl* activeTree() { return m_activeTree.get(); } |
| 206 |
| 207 // TODO(nduca): Remove these in favor of LayerTreeImpl. |
201 void setRootLayer(scoped_ptr<LayerImpl>); | 208 void setRootLayer(scoped_ptr<LayerImpl>); |
202 LayerImpl* rootLayer() { return m_rootLayerImpl.get(); } | 209 LayerImpl* rootLayer() const { return m_activeTree->RootLayer(); } |
203 | |
204 void setHudLayer(HeadsUpDisplayLayerImpl* layerImpl) { m_hudLayerImpl = laye
rImpl; } | |
205 HeadsUpDisplayLayerImpl* hudLayer() { return m_hudLayerImpl; } | |
206 | 210 |
207 // Release ownership of the current layer tree and replace it with an empty | 211 // Release ownership of the current layer tree and replace it with an empty |
208 // tree. Returns the root layer of the detached tree. | 212 // tree. Returns the root layer of the detached tree. |
209 scoped_ptr<LayerImpl> detachLayerTree(); | 213 scoped_ptr<LayerImpl> detachLayerTree(); |
210 | 214 |
211 LayerImpl* rootScrollLayer() const { return m_rootScrollLayerImpl; } | 215 LayerImpl* rootScrollLayer() const { return m_activeTree->root_scroll_layer(
); } |
| 216 |
| 217 // TOOD(nduca): This goes away when scrolling moves to LayerTreeImpl. |
| 218 LayerImpl* currentlyScrollingLayer() const { return m_activeTree->currently_
scrolling_layer(); } |
212 | 219 |
213 bool visible() const { return m_visible; } | 220 bool visible() const { return m_visible; } |
214 void setVisible(bool); | 221 void setVisible(bool); |
215 | 222 |
216 int sourceFrameNumber() const { return m_sourceFrameNumber; } | |
217 void setSourceFrameNumber(int frameNumber) { m_sourceFrameNumber = frameNumb
er; } | |
218 | |
219 bool contentsTexturesPurged() const { return m_contentsTexturesPurged; } | 223 bool contentsTexturesPurged() const { return m_contentsTexturesPurged; } |
220 void setContentsTexturesPurged(); | 224 void setContentsTexturesPurged(); |
221 void resetContentsTexturesPurged(); | 225 void resetContentsTexturesPurged(); |
222 size_t memoryAllocationLimitBytes() const { return m_managedMemoryPolicy.byt
esLimitWhenVisible; } | 226 size_t memoryAllocationLimitBytes() const { return m_managedMemoryPolicy.byt
esLimitWhenVisible; } |
223 | 227 |
224 void setViewportSize(const gfx::Size& layoutViewportSize, const gfx::Size& d
eviceViewportSize); | 228 void setViewportSize(const gfx::Size& layoutViewportSize, const gfx::Size& d
eviceViewportSize); |
225 const gfx::Size& layoutViewportSize() const { return m_layoutViewportSize; } | 229 const gfx::Size& layoutViewportSize() const { return m_layoutViewportSize; } |
226 | 230 |
227 float deviceScaleFactor() const { return m_deviceScaleFactor; } | 231 float deviceScaleFactor() const { return m_deviceScaleFactor; } |
228 void setDeviceScaleFactor(float); | 232 void setDeviceScaleFactor(float); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 void calculateRenderSurfaceLayerList(LayerList&); | 302 void calculateRenderSurfaceLayerList(LayerList&); |
299 | 303 |
300 // Virtual for testing. | 304 // Virtual for testing. |
301 virtual void animateLayers(base::TimeTicks monotonicTime, base::Time wallClo
ckTime); | 305 virtual void animateLayers(base::TimeTicks monotonicTime, base::Time wallClo
ckTime); |
302 | 306 |
303 // Virtual for testing. | 307 // Virtual for testing. |
304 virtual base::TimeDelta lowFrequencyAnimationInterval() const; | 308 virtual base::TimeDelta lowFrequencyAnimationInterval() const; |
305 | 309 |
306 LayerTreeHostImplClient* m_client; | 310 LayerTreeHostImplClient* m_client; |
307 Proxy* m_proxy; | 311 Proxy* m_proxy; |
308 int m_sourceFrameNumber; | |
309 | 312 |
310 private: | 313 private: |
311 void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo); | 314 void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo); |
312 void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo); | 315 void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo); |
313 void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scro
llOffset, float pageScale); | 316 void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scro
llOffset, float pageScale); |
314 | 317 |
315 void setPageScaleDelta(float); | 318 void setPageScaleDelta(float); |
316 void updateMaxScrollOffset(); | 319 void updateMaxScrollOffset(); |
317 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re
nderSurfaceLayerList); | 320 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re
nderSurfaceLayerList); |
318 | 321 |
(...skipping 11 matching lines...) Expand all Loading... |
330 void clearCurrentlyScrollingLayer(); | 333 void clearCurrentlyScrollingLayer(); |
331 | 334 |
332 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); | 335 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); |
333 | 336 |
334 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; | 337 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; |
335 | 338 |
336 scoped_ptr<OutputSurface> m_outputSurface; | 339 scoped_ptr<OutputSurface> m_outputSurface; |
337 scoped_ptr<ResourceProvider> m_resourceProvider; | 340 scoped_ptr<ResourceProvider> m_resourceProvider; |
338 scoped_ptr<Renderer> m_renderer; | 341 scoped_ptr<Renderer> m_renderer; |
339 scoped_ptr<TileManager> m_tileManager; | 342 scoped_ptr<TileManager> m_tileManager; |
340 scoped_ptr<LayerImpl> m_rootLayerImpl; | 343 |
341 LayerImpl* m_rootScrollLayerImpl; | 344 scoped_ptr<LayerTreeImpl> m_activeTree; |
342 LayerImpl* m_currentlyScrollingLayerImpl; | 345 |
343 HeadsUpDisplayLayerImpl* m_hudLayerImpl; | |
344 int m_scrollingLayerIdFromPreviousTree; | |
345 bool m_scrollDeltaIsInViewportSpace; | 346 bool m_scrollDeltaIsInViewportSpace; |
346 LayerTreeSettings m_settings; | 347 LayerTreeSettings m_settings; |
347 LayerTreeDebugState m_debugState; | 348 LayerTreeDebugState m_debugState; |
348 gfx::Size m_layoutViewportSize; | 349 gfx::Size m_layoutViewportSize; |
349 gfx::Size m_deviceViewportSize; | 350 gfx::Size m_deviceViewportSize; |
350 float m_deviceScaleFactor; | 351 float m_deviceScaleFactor; |
351 bool m_visible; | 352 bool m_visible; |
352 bool m_contentsTexturesPurged; | 353 bool m_contentsTexturesPurged; |
353 ManagedMemoryPolicy m_managedMemoryPolicy; | 354 ManagedMemoryPolicy m_managedMemoryPolicy; |
354 | 355 |
(...skipping 25 matching lines...) Expand all Loading... |
380 size_t m_numMainThreadScrolls; | 381 size_t m_numMainThreadScrolls; |
381 | 382 |
382 size_t m_cumulativeNumLayersDrawn; | 383 size_t m_cumulativeNumLayersDrawn; |
383 | 384 |
384 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 385 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
385 }; | 386 }; |
386 | 387 |
387 } // namespace cc | 388 } // namespace cc |
388 | 389 |
389 #endif // CC_LAYER_TREE_HOST_IMPL_H_ | 390 #endif // CC_LAYER_TREE_HOST_IMPL_H_ |
OLD | NEW |