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_tree_impl.h" | |
15 #include "cc/output_surface_client.h" | 14 #include "cc/output_surface_client.h" |
16 #include "cc/render_pass.h" | 15 #include "cc/render_pass.h" |
17 #include "cc/render_pass_sink.h" | 16 #include "cc/render_pass_sink.h" |
18 #include "cc/renderer.h" | 17 #include "cc/renderer.h" |
19 #include "cc/tile_manager.h" | 18 #include "cc/tile_manager.h" |
20 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
21 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
22 | 21 |
23 namespace cc { | 22 namespace cc { |
24 | 23 |
25 class CompletionEvent; | 24 class CompletionEvent; |
26 class DebugRectHistory; | 25 class DebugRectHistory; |
27 class FrameRateCounter; | 26 class FrameRateCounter; |
28 class LayerImpl; | 27 class LayerImpl; |
29 class LayerTreeHostImplTimeSourceAdapter; | 28 class LayerTreeHostImplTimeSourceAdapter; |
| 29 class LayerTreeImpl; |
30 class PageScaleAnimation; | 30 class PageScaleAnimation; |
31 class RenderPassDrawQuad; | 31 class RenderPassDrawQuad; |
32 class ResourceProvider; | 32 class ResourceProvider; |
33 struct RendererCapabilities; | 33 struct RendererCapabilities; |
34 struct RenderingStats; | 34 struct RenderingStats; |
35 | 35 |
36 // LayerTreeHost->Proxy callback interface. | 36 // LayerTreeHost->Proxy callback interface. |
37 class LayerTreeHostImplClient { | 37 class LayerTreeHostImplClient { |
38 public: | 38 public: |
39 virtual void didLoseOutputSurfaceOnImplThread() = 0; | 39 virtual void didLoseOutputSurfaceOnImplThread() = 0; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 float m_deviceScaleFactor; | 105 float m_deviceScaleFactor; |
106 | 106 |
107 gfx::Vector2dF m_zoomedViewportOffset; | 107 gfx::Vector2dF m_zoomedViewportOffset; |
108 gfx::SizeF m_layoutViewportSize; | 108 gfx::SizeF m_layoutViewportSize; |
109 }; | 109 }; |
110 | 110 |
111 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te | 111 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta
te |
112 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, | 112 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, |
113 public RendererClient, | 113 public RendererClient, |
114 public TileManagerClient, | 114 public TileManagerClient, |
115 public LayerTreeImplClient, | |
116 public OutputSurfaceClient { | 115 public OutputSurfaceClient { |
117 typedef std::vector<LayerImpl*> LayerList; | 116 typedef std::vector<LayerImpl*> LayerList; |
118 | 117 |
119 public: | 118 public: |
120 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*, Proxy*); | 119 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT
reeHostImplClient*, Proxy*); |
121 virtual ~LayerTreeHostImpl(); | 120 virtual ~LayerTreeHostImpl(); |
122 | 121 |
123 // InputHandlerClient implementation | 122 // InputHandlerClient implementation |
124 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle
rClient::ScrollInputType) OVERRIDE; | 123 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle
rClient::ScrollInputType) OVERRIDE; |
125 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; | 124 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2d&) OVERRIDE; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 virtual bool hasImplThread() const OVERRIDE; | 172 virtual bool hasImplThread() const OVERRIDE; |
174 | 173 |
175 // TileManagerClient implementation. | 174 // TileManagerClient implementation. |
176 virtual void ScheduleManageTiles() OVERRIDE; | 175 virtual void ScheduleManageTiles() OVERRIDE; |
177 virtual void ScheduleCheckForCompletedSetPixels() OVERRIDE; | 176 virtual void ScheduleCheckForCompletedSetPixels() OVERRIDE; |
178 | 177 |
179 // OutputSurfaceClient implementation. | 178 // OutputSurfaceClient implementation. |
180 virtual void OnVSyncParametersChanged(base::TimeTicks timebase, base::TimeDe
lta interval) OVERRIDE; | 179 virtual void OnVSyncParametersChanged(base::TimeTicks timebase, base::TimeDe
lta interval) OVERRIDE; |
181 virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck&) OVE
RRIDE; | 180 virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck&) OVE
RRIDE; |
182 | 181 |
183 // LayerTreeImplClient implementation. | 182 // Called from LayerTreeImpl. |
184 virtual void OnCanDrawStateChangedForTree(LayerTreeImpl*) OVERRIDE; | 183 void OnCanDrawStateChangedForTree(LayerTreeImpl*); |
185 | 184 |
186 // Implementation | 185 // Implementation |
187 bool canDraw(); | 186 bool canDraw(); |
188 OutputSurface* outputSurface() const; | 187 OutputSurface* outputSurface() const; |
189 | 188 |
190 std::string layerTreeAsText() const; | 189 std::string layerTreeAsText() const; |
191 std::string layerTreeAsJson() const; | 190 std::string layerTreeAsJson() const; |
192 | 191 |
193 void finishAllRendering(); | 192 void finishAllRendering(); |
194 int sourceAnimationFrameNumber() const; | 193 int sourceAnimationFrameNumber() const; |
195 | 194 |
196 bool initializeRenderer(scoped_ptr<OutputSurface>); | 195 bool initializeRenderer(scoped_ptr<OutputSurface>); |
197 bool isContextLost(); | 196 bool isContextLost(); |
198 TileManager* tileManager() { return m_tileManager.get(); } | 197 TileManager* tileManager() { return m_tileManager.get(); } |
199 Renderer* renderer() { return m_renderer.get(); } | 198 Renderer* renderer() { return m_renderer.get(); } |
200 const RendererCapabilities& rendererCapabilities() const; | 199 const RendererCapabilities& rendererCapabilities() const; |
201 | 200 |
202 bool swapBuffers(); | 201 bool swapBuffers(); |
203 | 202 |
204 void readback(void* pixels, const gfx::Rect&); | 203 void readback(void* pixels, const gfx::Rect&); |
205 | 204 |
206 LayerTreeImpl* activeTree() { return m_activeTree.get(); } | 205 LayerTreeImpl* activeTree() { return m_activeTree.get(); } |
207 | 206 |
208 // TODO(nduca): Remove these in favor of LayerTreeImpl. | 207 // TODO(nduca): Remove these in favor of LayerTreeImpl. |
209 void setRootLayer(scoped_ptr<LayerImpl>); | 208 void setRootLayer(scoped_ptr<LayerImpl>); |
210 LayerImpl* rootLayer() const { return m_activeTree->RootLayer(); } | 209 LayerImpl* rootLayer() const; |
211 | 210 |
212 // 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 |
213 // tree. Returns the root layer of the detached tree. | 212 // tree. Returns the root layer of the detached tree. |
214 scoped_ptr<LayerImpl> detachLayerTree(); | 213 scoped_ptr<LayerImpl> detachLayerTree(); |
215 | 214 |
216 LayerImpl* rootScrollLayer() const { return m_activeTree->root_scroll_layer(
); } | 215 LayerImpl* rootScrollLayer() const; |
217 | 216 |
218 // TOOD(nduca): This goes away when scrolling moves to LayerTreeImpl. | 217 // TOOD(nduca): This goes away when scrolling moves to LayerTreeImpl. |
219 LayerImpl* currentlyScrollingLayer() const { return m_activeTree->currently_
scrolling_layer(); } | 218 LayerImpl* currentlyScrollingLayer() const; |
220 | 219 |
221 bool visible() const { return m_visible; } | 220 bool visible() const { return m_visible; } |
222 void setVisible(bool); | 221 void setVisible(bool); |
223 | 222 |
224 bool contentsTexturesPurged() const { return m_contentsTexturesPurged; } | 223 bool contentsTexturesPurged() const { return m_contentsTexturesPurged; } |
225 void setContentsTexturesPurged(); | 224 void setContentsTexturesPurged(); |
226 void resetContentsTexturesPurged(); | 225 void resetContentsTexturesPurged(); |
227 size_t memoryAllocationLimitBytes() const { return m_managedMemoryPolicy.byt
esLimitWhenVisible; } | 226 size_t memoryAllocationLimitBytes() const { return m_managedMemoryPolicy.byt
esLimitWhenVisible; } |
228 | 227 |
229 void setViewportSize(const gfx::Size& layoutViewportSize, const gfx::Size& d
eviceViewportSize); | 228 void setViewportSize(const gfx::Size& layoutViewportSize, const gfx::Size& d
eviceViewportSize); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 size_t m_lastSentMemoryVisibleBytes; | 397 size_t m_lastSentMemoryVisibleBytes; |
399 size_t m_lastSentMemoryVisibleAndNearbyBytes; | 398 size_t m_lastSentMemoryVisibleAndNearbyBytes; |
400 size_t m_lastSentMemoryUseBytes; | 399 size_t m_lastSentMemoryUseBytes; |
401 | 400 |
402 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 401 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
403 }; | 402 }; |
404 | 403 |
405 } // namespace cc | 404 } // namespace cc |
406 | 405 |
407 #endif // CC_LAYER_TREE_HOST_IMPL_H_ | 406 #endif // CC_LAYER_TREE_HOST_IMPL_H_ |
OLD | NEW |