Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: cc/layer_tree_host_impl.h

Issue 11450015: [cc] Move root layer pointer to LayerTreeImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 GraphicsContext* context() const; 188 GraphicsContext* context() 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<GraphicsContext>); 195 bool initializeRenderer(scoped_ptr<GraphicsContext>);
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( ); }
212 216
213 bool visible() const { return m_visible; } 217 bool visible() const { return m_visible; }
214 void setVisible(bool); 218 void setVisible(bool);
215 219
216 int sourceFrameNumber() const { return m_sourceFrameNumber; }
217 void setSourceFrameNumber(int frameNumber) { m_sourceFrameNumber = frameNumb er; }
218
219 bool contentsTexturesPurged() const { return m_contentsTexturesPurged; } 220 bool contentsTexturesPurged() const { return m_contentsTexturesPurged; }
220 void setContentsTexturesPurged(); 221 void setContentsTexturesPurged();
221 void resetContentsTexturesPurged(); 222 void resetContentsTexturesPurged();
222 size_t memoryAllocationLimitBytes() const { return m_managedMemoryPolicy.byt esLimitWhenVisible; } 223 size_t memoryAllocationLimitBytes() const { return m_managedMemoryPolicy.byt esLimitWhenVisible; }
223 224
224 void setViewportSize(const gfx::Size& layoutViewportSize, const gfx::Size& d eviceViewportSize); 225 void setViewportSize(const gfx::Size& layoutViewportSize, const gfx::Size& d eviceViewportSize);
225 const gfx::Size& layoutViewportSize() const { return m_layoutViewportSize; } 226 const gfx::Size& layoutViewportSize() const { return m_layoutViewportSize; }
226 227
227 float deviceScaleFactor() const { return m_deviceScaleFactor; } 228 float deviceScaleFactor() const { return m_deviceScaleFactor; }
228 void setDeviceScaleFactor(float); 229 void setDeviceScaleFactor(float);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void calculateRenderSurfaceLayerList(LayerList&); 299 void calculateRenderSurfaceLayerList(LayerList&);
299 300
300 // Virtual for testing. 301 // Virtual for testing.
301 virtual void animateLayers(base::TimeTicks monotonicTime, base::Time wallClo ckTime); 302 virtual void animateLayers(base::TimeTicks monotonicTime, base::Time wallClo ckTime);
302 303
303 // Virtual for testing. 304 // Virtual for testing.
304 virtual base::TimeDelta lowFrequencyAnimationInterval() const; 305 virtual base::TimeDelta lowFrequencyAnimationInterval() const;
305 306
306 LayerTreeHostImplClient* m_client; 307 LayerTreeHostImplClient* m_client;
307 Proxy* m_proxy; 308 Proxy* m_proxy;
308 int m_sourceFrameNumber;
309 309
310 private: 310 private:
311 void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo); 311 void computeDoubleTapZoomDeltas(ScrollAndScaleSet* scrollInfo);
312 void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo); 312 void computePinchZoomDeltas(ScrollAndScaleSet* scrollInfo);
313 void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scro llOffset, float pageScale); 313 void makeScrollAndScaleSet(ScrollAndScaleSet* scrollInfo, gfx::Vector2d scro llOffset, float pageScale);
314 314
315 void setPageScaleDelta(float); 315 void setPageScaleDelta(float);
316 void updateMaxScrollOffset(); 316 void updateMaxScrollOffset();
317 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re nderSurfaceLayerList); 317 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re nderSurfaceLayerList);
318 318
(...skipping 11 matching lines...) Expand all
330 void clearCurrentlyScrollingLayer(); 330 void clearCurrentlyScrollingLayer();
331 331
332 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); 332 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime);
333 333
334 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; 334 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const;
335 335
336 scoped_ptr<GraphicsContext> m_context; 336 scoped_ptr<GraphicsContext> m_context;
337 scoped_ptr<ResourceProvider> m_resourceProvider; 337 scoped_ptr<ResourceProvider> m_resourceProvider;
338 scoped_ptr<Renderer> m_renderer; 338 scoped_ptr<Renderer> m_renderer;
339 scoped_ptr<TileManager> m_tileManager; 339 scoped_ptr<TileManager> m_tileManager;
340 scoped_ptr<LayerImpl> m_rootLayerImpl; 340
341 LayerImpl* m_rootScrollLayerImpl; 341 scoped_ptr<LayerTreeImpl> m_activeTree;
342 LayerImpl* m_currentlyScrollingLayerImpl; 342
343 HeadsUpDisplayLayerImpl* m_hudLayerImpl;
344 int m_scrollingLayerIdFromPreviousTree;
345 bool m_scrollDeltaIsInViewportSpace; 343 bool m_scrollDeltaIsInViewportSpace;
346 LayerTreeSettings m_settings; 344 LayerTreeSettings m_settings;
347 LayerTreeDebugState m_debugState; 345 LayerTreeDebugState m_debugState;
348 gfx::Size m_layoutViewportSize; 346 gfx::Size m_layoutViewportSize;
349 gfx::Size m_deviceViewportSize; 347 gfx::Size m_deviceViewportSize;
350 float m_deviceScaleFactor; 348 float m_deviceScaleFactor;
351 bool m_visible; 349 bool m_visible;
352 bool m_contentsTexturesPurged; 350 bool m_contentsTexturesPurged;
353 ManagedMemoryPolicy m_managedMemoryPolicy; 351 ManagedMemoryPolicy m_managedMemoryPolicy;
354 352
(...skipping 25 matching lines...) Expand all
380 size_t m_numMainThreadScrolls; 378 size_t m_numMainThreadScrolls;
381 379
382 size_t m_cumulativeNumLayersDrawn; 380 size_t m_cumulativeNumLayersDrawn;
383 381
384 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); 382 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
385 }; 383 };
386 384
387 } // namespace cc 385 } // namespace cc
388 386
389 #endif // CC_LAYER_TREE_HOST_IMPL_H_ 387 #endif // CC_LAYER_TREE_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698