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

Side by Side Diff: cc/layer_tree_host_impl.h

Issue 12648005: cc: Chromify the LayerTreeHostImpl class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compl Created 7 years, 9 months 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
« no previous file with comments | « cc/layer_tree_host_common_unittest.cc ('k') | cc/layer_tree_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 25 matching lines...) Expand all
36 class PaintTimeCounter; 36 class PaintTimeCounter;
37 class MemoryHistory; 37 class MemoryHistory;
38 class RenderPassDrawQuad; 38 class RenderPassDrawQuad;
39 class ResourceProvider; 39 class ResourceProvider;
40 class TopControlsManager; 40 class TopControlsManager;
41 struct RendererCapabilities; 41 struct RendererCapabilities;
42 struct RenderingStats; 42 struct RenderingStats;
43 43
44 // LayerTreeHost->Proxy callback interface. 44 // LayerTreeHost->Proxy callback interface.
45 class LayerTreeHostImplClient { 45 class LayerTreeHostImplClient {
46 public: 46 public:
47 virtual void didLoseOutputSurfaceOnImplThread() = 0; 47 virtual void DidLoseOutputSurfaceOnImplThread() = 0;
48 virtual void onSwapBuffersCompleteOnImplThread() = 0; 48 virtual void OnSwapBuffersCompleteOnImplThread() = 0;
49 virtual void onVSyncParametersChanged(base::TimeTicks timebase, base::TimeDe lta interval) = 0; 49 virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
50 virtual void onCanDrawStateChanged(bool canDraw) = 0; 50 base::TimeDelta interval) = 0;
51 virtual void onHasPendingTreeStateChanged(bool hasPendingTree) = 0; 51 virtual void OnCanDrawStateChanged(bool can_draw) = 0;
52 virtual void setNeedsRedrawOnImplThread() = 0; 52 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) = 0;
53 virtual void didUploadVisibleHighResolutionTileOnImplThread() = 0; 53 virtual void SetNeedsRedrawOnImplThread() = 0;
54 virtual void setNeedsCommitOnImplThread() = 0; 54 virtual void DidUploadVisibleHighResolutionTileOnImplThread() = 0;
55 virtual void setNeedsManageTilesOnImplThread() = 0; 55 virtual void SetNeedsCommitOnImplThread() = 0;
56 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio nEventsVector>, base::Time wallClockTime) = 0; 56 virtual void SetNeedsManageTilesOnImplThread() = 0;
57 // Returns true if resources were deleted by this call. 57 virtual void PostAnimationEventsToMainThreadOnImplThread(
58 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) = 0; 58 scoped_ptr<AnimationEventsVector> events,
59 virtual void reduceWastedContentsTextureMemoryOnImplThread() = 0; 59 base::Time wall_clock_time) = 0;
60 virtual void sendManagedMemoryStats() = 0; 60 // Returns true if resources were deleted by this call.
61 virtual bool isInsideDraw() = 0; 61 virtual bool ReduceContentsTextureMemoryOnImplThread(
62 virtual void renewTreePriority() = 0; 62 size_t limit_bytes,
63 int priority_cutoff) = 0;
64 virtual void ReduceWastedContentsTextureMemoryOnImplThread() = 0;
65 virtual void SendManagedMemoryStats() = 0;
66 virtual bool IsInsideDraw() = 0;
67 virtual void RenewTreePriority() = 0;
63 }; 68 };
64 69
65 // LayerTreeHostImpl owns the LayerImpl tree as well as associated rendering sta te 70 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
71 // state.
66 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient, 72 class CC_EXPORT LayerTreeHostImpl : public InputHandlerClient,
67 public RendererClient, 73 public RendererClient,
68 public TileManagerClient, 74 public TileManagerClient,
69 public OutputSurfaceClient, 75 public OutputSurfaceClient,
70 public TopControlsManagerClient { 76 public TopControlsManagerClient {
71 typedef std::vector<LayerImpl*> LayerList; 77 typedef std::vector<LayerImpl*> LayerList;
72 78
73 public: 79 public:
74 static scoped_ptr<LayerTreeHostImpl> create(const LayerTreeSettings&, LayerT reeHostImplClient*, Proxy*); 80 static scoped_ptr<LayerTreeHostImpl> Create(
75 virtual ~LayerTreeHostImpl(); 81 const LayerTreeSettings& settings,
76 82 LayerTreeHostImplClient* client,
77 // InputHandlerClient implementation 83 Proxy* proxy);
78 virtual InputHandlerClient::ScrollStatus scrollBegin(gfx::Point, InputHandle rClient::ScrollInputType) OVERRIDE; 84 virtual ~LayerTreeHostImpl();
79 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2dF&) OVERRIDE; 85
80 virtual void scrollEnd() OVERRIDE; 86 // InputHandlerClient implementation
81 virtual void pinchGestureBegin() OVERRIDE; 87 virtual InputHandlerClient::ScrollStatus ScrollBegin(
82 virtual void pinchGestureUpdate(float, gfx::Point) OVERRIDE; 88 gfx::Point viewport_point,
83 virtual void pinchGestureEnd() OVERRIDE; 89 InputHandlerClient::ScrollInputType type) OVERRIDE;
84 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchor Point, float pageScale, base::TimeTicks startTime, base::TimeDelta duration) OVE RRIDE; 90 virtual bool ScrollBy(gfx::Point viewport_point,
85 virtual void scheduleAnimation() OVERRIDE; 91 gfx::Vector2dF scroll_delta) OVERRIDE;
86 virtual bool haveTouchEventHandlersAt(const gfx::Point&) OVERRIDE; 92 virtual void ScrollEnd() OVERRIDE;
87 93 virtual void PinchGestureBegin() OVERRIDE;
88 // TopControlsManagerClient implementation. 94 virtual void PinchGestureUpdate(float magnify_delta,
89 virtual void setActiveTreeNeedsUpdateDrawProperties() OVERRIDE; 95 gfx::Point anchor) OVERRIDE;
90 virtual void setNeedsRedraw() OVERRIDE; 96 virtual void PinchGestureEnd() OVERRIDE;
91 virtual bool haveRootScrollLayer() const OVERRIDE; 97 virtual void StartPageScaleAnimation(gfx::Vector2d target_offset,
92 virtual float rootScrollLayerTotalScrollY() const OVERRIDE; 98 bool anchor_point,
93 99 float page_scale,
94 struct CC_EXPORT FrameData : public RenderPassSink { 100 base::TimeTicks start_time,
95 FrameData(); 101 base::TimeDelta duration) OVERRIDE;
96 ~FrameData(); 102 virtual void ScheduleAnimation() OVERRIDE;
97 103 virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_port) OVERRIDE;
98 std::vector<gfx::Rect> occludingScreenSpaceRects; 104
99 std::vector<gfx::Rect> nonOccludingScreenSpaceRects; 105 // TopControlsManagerClient implementation.
100 RenderPassList renderPasses; 106 virtual void setActiveTreeNeedsUpdateDrawProperties() OVERRIDE;
101 RenderPassIdHashMap renderPassesById; 107 virtual void setNeedsRedraw() OVERRIDE;
102 const LayerList* renderSurfaceLayerList; 108 virtual bool haveRootScrollLayer() const OVERRIDE;
103 LayerList willDrawLayers; 109 virtual float rootScrollLayerTotalScrollY() const OVERRIDE;
104 bool containsIncompleteTile; 110
105 111 struct CC_EXPORT FrameData : public RenderPassSink {
106 // RenderPassSink implementation. 112 FrameData();
107 virtual void appendRenderPass(scoped_ptr<RenderPass>) OVERRIDE; 113 ~FrameData();
108 }; 114
109 115 std::vector<gfx::Rect> occluding_screen_space_rects;
110 // Virtual for testing. 116 std::vector<gfx::Rect> non_occluding_screen_space_rects;
111 virtual void beginCommit(); 117 RenderPassList render_passes;
112 virtual void commitComplete(); 118 RenderPassIdHashMap render_passes_by_id;
113 virtual void animate(base::TimeTicks monotonicTime, base::Time wallClockTime ); 119 const LayerList* render_surface_layer_list;
114 virtual void setVisible(bool); 120 LayerList will_draw_layers;
115 121 bool contains_incomplete_tile;
116 void manageTiles(); 122
117 123 // RenderPassSink implementation.
118 // Returns false if problems occured preparing the frame, and we should try 124 virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE;
119 // to avoid displaying the frame. If prepareToDraw is called, 125 };
120 // didDrawAllLayers must also be called, regardless of whether drawLayers is 126
121 // called between the two. 127 virtual void BeginCommit();
122 virtual bool prepareToDraw(FrameData&); 128 virtual void CommitComplete();
123 virtual void drawLayers(FrameData&); 129 virtual void Animate(base::TimeTicks monotonic_time,
124 // Must be called if and only if prepareToDraw was called. 130 base::Time wall_clock_time);
125 void didDrawAllLayers(const FrameData&); 131
126 132 void ManageTiles();
127 // RendererClient implementation 133
128 virtual gfx::Size DeviceViewportSize() const OVERRIDE; 134 // Returns false if problems occured preparing the frame, and we should try
129 virtual const LayerTreeSettings& Settings() const OVERRIDE; 135 // to avoid displaying the frame. If prepareToDraw is called, DidDrawAllLayers
130 virtual void DidLoseOutputSurface() OVERRIDE; 136 // must also be called, regardless of whether DrawLayers is called between the
131 virtual void OnSwapBuffersComplete() OVERRIDE; 137 // two.
132 virtual void SetFullRootLayerDamage() OVERRIDE; 138 virtual bool PrepareToDraw(FrameData* frame);
133 virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR IDE; 139 virtual void DrawLayers(FrameData* frame);
134 virtual void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O VERRIDE; 140 // Must be called if and only if PrepareToDraw was called.
135 virtual bool HasImplThread() const OVERRIDE; 141 void DidDrawAllLayers(const FrameData& frame);
136 virtual bool ShouldClearRootRenderPass() const OVERRIDE; 142
137 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE ; 143 const LayerTreeSettings& settings() const { return settings_; }
138 144
139 // TileManagerClient implementation. 145 // RendererClient implementation
140 virtual void ScheduleManageTiles() OVERRIDE; 146 private:
141 virtual void DidUploadVisibleHighResolutionTile() OVERRIDE; 147 virtual gfx::Size DeviceViewportSize() const OVERRIDE;
142 148 virtual const LayerTreeSettings& Settings() const OVERRIDE;
143 // OutputSurfaceClient implementation. 149 public:
144 virtual void OnVSyncParametersChanged(base::TimeTicks timebase, base::TimeDe lta interval) OVERRIDE; 150 virtual void DidLoseOutputSurface() OVERRIDE;
145 virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck&) OVE RRIDE; 151 virtual void OnSwapBuffersComplete() OVERRIDE;
146 152 virtual void SetFullRootLayerDamage() OVERRIDE;
147 // Called from LayerTreeImpl. 153 virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
148 void OnCanDrawStateChangedForTree(LayerTreeImpl*); 154 OVERRIDE;
149 155 virtual void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
150 // Implementation 156 OVERRIDE;
151 bool canDraw(); 157 virtual bool HasImplThread() const OVERRIDE;
152 OutputSurface* outputSurface() const; 158 virtual bool ShouldClearRootRenderPass() const OVERRIDE;
153 159 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const OVERRIDE;
154 std::string layerTreeAsText() const; 160
155 std::string layerTreeAsJson() const; 161 // TileManagerClient implementation.
156 162 virtual void ScheduleManageTiles() OVERRIDE;
157 void finishAllRendering(); 163 virtual void DidUploadVisibleHighResolutionTile() OVERRIDE;
158 int sourceAnimationFrameNumber() const; 164
159 165 // OutputSurfaceClient implementation.
160 virtual bool initializeRenderer(scoped_ptr<OutputSurface>); 166 virtual void OnVSyncParametersChanged(base::TimeTicks timebase,
161 bool isContextLost(); 167 base::TimeDelta interval) OVERRIDE;
162 TileManager* tileManager() { return m_tileManager.get(); } 168 virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck& ack)
163 Renderer* renderer() { return m_renderer.get(); } 169 OVERRIDE;
164 const RendererCapabilities& rendererCapabilities() const; 170
165 171 // Called from LayerTreeImpl.
166 bool swapBuffers(); 172 void OnCanDrawStateChangedForTree();
167 173
168 void readback(void* pixels, gfx::Rect rect_in_device_viewport); 174 // Implementation
169 175 bool CanDraw();
170 LayerTreeImpl* activeTree() { return m_activeTree.get(); } 176 OutputSurface* output_surface() const { return output_surface_.get(); }
171 const LayerTreeImpl* activeTree() const { return m_activeTree.get(); } 177
172 LayerTreeImpl* pendingTree() { return m_pendingTree.get(); } 178 std::string LayerTreeAsText() const;
173 const LayerTreeImpl* pendingTree() const { return m_pendingTree.get(); } 179 std::string LayerTreeAsJson() const;
174 const LayerTreeImpl* recycleTree() const { return m_recycleTree.get(); } 180
175 void createPendingTree(); 181 void FinishAllRendering();
176 void checkForCompletedTileUploads(); 182 int SourceAnimationFrameNumber() const;
177 virtual bool activatePendingTreeIfNeeded(); 183
178 184 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface);
179 // Shortcuts to layers on the active tree. 185 bool IsContextLost();
180 LayerImpl* rootLayer() const; 186 TileManager* tile_manager() { return tile_manager_.get(); }
181 LayerImpl* rootScrollLayer() const; 187 Renderer* renderer() { return renderer_.get(); }
182 LayerImpl* currentlyScrollingLayer() const; 188 const RendererCapabilities& GetRendererCapabilities() const;
183 189
184 bool visible() const { return m_visible; } 190 bool SwapBuffers();
185 191
186 size_t memoryAllocationLimitBytes() const { return m_managedMemoryPolicy.byt esLimitWhenVisible; } 192 void Readback(void* pixels, gfx::Rect rect_in_device_viewport);
187 193
188 void setViewportSize(const gfx::Size& layoutViewportSize, const gfx::Size& d eviceViewportSize); 194 LayerTreeImpl* active_tree() { return active_tree_.get(); }
189 const gfx::Size& layoutViewportSize() const { return m_layoutViewportSize; } 195 const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
190 196 LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
191 float deviceScaleFactor() const { return m_deviceScaleFactor; } 197 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
192 void setDeviceScaleFactor(float); 198 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
193 199 void CreatePendingTree();
194 scoped_ptr<ScrollAndScaleSet> processScrollDeltas(); 200 void CheckForCompletedTileUploads();
195 201 virtual bool ActivatePendingTreeIfNeeded();
196 void startPageScaleAnimation(gfx::Vector2d targetOffset, bool useAnchor, flo at scale, base::TimeDelta duration); 202
197 203 // Shortcuts to layers on the active tree.
198 bool needsAnimateLayers() const { return !m_animationRegistrar->active_anima tion_controllers().empty(); } 204 LayerImpl* RootLayer() const;
199 205 LayerImpl* RootScrollLayer() const;
200 void renderingStats(RenderingStats*) const; 206 LayerImpl* CurrentlyScrollingLayer() const;
201 207
202 void sendManagedMemoryStats( 208 virtual void SetVisible(bool visible);
203 size_t memoryVisibleBytes, 209 bool visible() const { return visible_; }
204 size_t memoryVisibleAndNearbyBytes, 210
205 size_t memoryUseBytes); 211 size_t memory_allocation_limit_bytes() const {
206 212 return managed_memory_policy_.bytesLimitWhenVisible;
207 FrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } 213 }
208 PaintTimeCounter* paintTimeCounter() const { return m_paintTimeCounter.get() ; } 214
209 MemoryHistory* memoryHistory() const { return m_memoryHistory.get(); } 215 void SetViewportSize(gfx::Size layout_viewport_size,
210 DebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get() ; } 216 gfx::Size device_viewport_size);
211 ResourceProvider* resourceProvider() const { return m_resourceProvider.get() ; } 217 gfx::Size layout_viewport_size() const { return layout_viewport_size_; }
212 TopControlsManager* topControlsManager() const { return m_topControlsManager .get(); } 218 gfx::Size device_viewport_size() const { return device_viewport_size_; }
213 219
214 Proxy* proxy() const { return m_proxy; } 220 void SetDeviceScaleFactor(float device_scale_factor);
215 221 float device_scale_factor() const { return device_scale_factor_; }
216 AnimationRegistrar* animationRegistrar() const { return m_animationRegistrar .get(); } 222
217 223 scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
218 void setDebugState(const LayerTreeDebugState& debugState); 224
219 const LayerTreeDebugState& debugState() const { return m_debugState; } 225 void StartPageScaleAnimation(gfx::Vector2d target_offset,
220 226 bool use_anchor,
221 void savePaintTime(const base::TimeDelta& totalPaintTime, int commitNumber); 227 float scale,
222 228 base::TimeDelta duration);
223 class CC_EXPORT CullRenderPassesWithCachedTextures { 229
224 public: 230 bool needs_animate_layers() const {
225 bool shouldRemoveRenderPass(const RenderPassDrawQuad&, const FrameData&) const; 231 return !animation_registrar_->active_animation_controllers().empty();
226 232 }
227 // Iterates from the root first, in order to remove the surfaces closest 233
228 // to the root with cached textures, and all surfaces that draw into 234 void CollectRenderingStats(RenderingStats* stats) const;
229 // them. 235
230 size_t renderPassListBegin(const RenderPassList& list) const { return li st.size() - 1; } 236 void SendManagedMemoryStats(
231 size_t renderPassListEnd(const RenderPassList&) const { return 0 - 1; } 237 size_t memory_visible_bytes,
232 size_t renderPassListNext(size_t it) const { return it - 1; } 238 size_t memory_visible_and_nearby_bytes,
233 239 size_t memoryUseBytes);
234 CullRenderPassesWithCachedTextures(Renderer& renderer) : m_renderer(rend erer) { } 240
235 private: 241 FrameRateCounter* fps_counter() {
236 Renderer& m_renderer; 242 return fps_counter_.get();
237 }; 243 }
238 244 PaintTimeCounter* paint_time_counter() {
239 class CC_EXPORT CullRenderPassesWithNoQuads { 245 return paint_time_counter_.get();
240 public: 246 }
241 bool shouldRemoveRenderPass(const RenderPassDrawQuad&, const FrameData&) const; 247 MemoryHistory* memory_history() {
242 248 return memory_history_.get();
243 // Iterates in draw order, so that when a surface is removed, and its 249 }
244 // target becomes empty, then its target can be removed also. 250 DebugRectHistory* debug_rect_history() {
245 size_t renderPassListBegin(const RenderPassList&) const { return 0; } 251 return debug_rect_history_.get();
246 size_t renderPassListEnd(const RenderPassList& list) const { return list .size(); } 252 }
247 size_t renderPassListNext(size_t it) const { return it + 1; } 253 ResourceProvider* resource_provider() {
248 }; 254 return resource_provider_.get();
249 255 }
250 template<typename RenderPassCuller> 256 TopControlsManager* top_controls_manager() {
251 static void removeRenderPasses(RenderPassCuller, FrameData&); 257 return top_controls_manager_.get();
252 258 }
253 skia::RefPtr<SkPicture> capturePicture(); 259
254 260 Proxy* proxy() const { return proxy_; }
255 bool pinchGestureActive() const { return m_pinchGestureActive; } 261
256 262 AnimationRegistrar* animation_registrar() const {
257 void setTreePriority(TreePriority priority); 263 return animation_registrar_.get();
258 264 }
259 void beginNextFrame(); 265
260 base::TimeTicks currentFrameTime(); 266 void SetDebugState(const LayerTreeDebugState& debug_state);
261 267 const LayerTreeDebugState& debug_state() const { return debug_state_; }
262 scoped_ptr<base::Value> asValue() const; 268
263 scoped_ptr<base::Value> activationStateAsValue() const; 269 void SavePaintTime(const base::TimeDelta& total_paint_time,
264 scoped_ptr<base::Value> frameStateAsValue() const; 270 int commit_number);
265 271
266 bool pageScaleAnimationActive() const { return !!m_pageScaleAnimation; } 272 class CC_EXPORT CullRenderPassesWithCachedTextures {
267 273 public:
268 protected: 274 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
269 LayerTreeHostImpl(const LayerTreeSettings&, LayerTreeHostImplClient*, Proxy* ); 275 const FrameData& frame) const;
270 void activatePendingTree(); 276
271 277 // Iterates from the root first, in order to remove the surfaces closest
272 // Virtual for testing. 278 // to the root with cached textures, and all surfaces that draw into
273 virtual void animateLayers(base::TimeTicks monotonicTime, base::Time wallClo ckTime); 279 // them.
274 virtual void updateAnimationState(); 280 size_t RenderPassListBegin(const RenderPassList& list) const {
275 281 return list.size() - 1;
276 // Virtual for testing. 282 }
277 virtual base::TimeDelta lowFrequencyAnimationInterval() const; 283 size_t RenderPassListEnd(const RenderPassList& list) const { return 0 - 1; }
278 284 size_t RenderPassListNext(size_t it) const { return it - 1; }
279 const AnimationRegistrar::AnimationControllerMap& activeAnimationControllers () const { return m_animationRegistrar->active_animation_controllers(); } 285
280 286 CullRenderPassesWithCachedTextures(Renderer& renderer)
281 LayerTreeHostImplClient* m_client; 287 : renderer_(renderer) {}
282 Proxy* m_proxy; 288 private:
283 289 Renderer& renderer_;
284 private: 290 };
285 void animatePageScale(base::TimeTicks monotonicTime); 291
286 void animateScrollbars(base::TimeTicks monotonicTime); 292 class CC_EXPORT CullRenderPassesWithNoQuads {
287 293 public:
288 void setPageScaleDelta(float); 294 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
289 gfx::Vector2dF scrollLayerWithViewportSpaceDelta(LayerImpl* layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx::Vector2dF viewp ortDelta); 295 const FrameData& frame) const;
290 296
291 void updateMaxScrollOffset(); 297 // Iterates in draw order, so that when a surface is removed, and its
292 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re nderSurfaceLayerList); 298 // target becomes empty, then its target can be removed also.
293 299 size_t RenderPassListBegin(const RenderPassList& list) const { return 0; }
294 // Returns false if the frame should not be displayed. This function should 300 size_t RenderPassListEnd(const RenderPassList& list) const {
295 // only be called from prepareToDraw, as didDrawAllLayers must be called 301 return list.size();
296 // if this helper function is called. 302 }
297 bool calculateRenderPasses(FrameData&); 303 size_t RenderPassListNext(size_t it) const { return it + 1; }
298 void animateLayersRecursive(LayerImpl*, base::TimeTicks monotonicTime, base: :Time wallClockTime, AnimationEventsVector*, bool& didAnimate, bool& needsAnimat eLayers); 304 };
299 void setBackgroundTickingEnabled(bool); 305
300 306 template <typename RenderPassCuller>
301 void sendDidLoseOutputSurfaceRecursive(LayerImpl*); 307 static void RemoveRenderPasses(RenderPassCuller culler, FrameData* frame);
302 void clearRenderSurfaces(); 308
303 bool ensureRenderSurfaceLayerList(); 309 skia::RefPtr<SkPicture> CapturePicture();
304 void clearCurrentlyScrollingLayer(); 310
305 311 bool pinch_gesture_active() const { return pinch_gesture_active_; }
306 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); 312
307 313 void SetTreePriority(TreePriority priority);
308 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; 314
309 315 void BeginNextFrame();
310 static LayerImpl* getNonCompositedContentLayerRecursive(LayerImpl* layer); 316 base::TimeTicks CurrentFrameTime();
311 317
312 scoped_ptr<OutputSurface> m_outputSurface; 318 scoped_ptr<base::Value> AsValue() const;
313 scoped_ptr<ResourceProvider> m_resourceProvider; 319 scoped_ptr<base::Value> ActivationStateAsValue() const;
314 scoped_ptr<Renderer> m_renderer; 320 scoped_ptr<base::Value> FrameStateAsValue() const;
315 scoped_ptr<TileManager> m_tileManager; 321
316 322 bool page_scale_animation_active() const { return !!page_scale_animation_; }
317 // Tree currently being drawn. 323
318 scoped_ptr<LayerTreeImpl> m_activeTree; 324 protected:
319 325 LayerTreeHostImpl(const LayerTreeSettings& settings,
320 // In impl-side painting mode, tree with possibly incomplete rasterized 326 LayerTreeHostImplClient* client,
321 // content. May be promoted to active by activatePendingTreeIfNeeded(). 327 Proxy* proxy);
322 scoped_ptr<LayerTreeImpl> m_pendingTree; 328 void ActivatePendingTree();
323 329
324 // In impl-side painting mode, inert tree with layers that can be recycled 330 // Virtual for testing.
325 // by the next sync from the main thread. 331 virtual void AnimateLayers(base::TimeTicks monotonic_time,
326 scoped_ptr<LayerTreeImpl> m_recycleTree; 332 base::Time wall_clock_time);
327 333 virtual void UpdateAnimationState();
328 bool m_didLockScrollingLayer; 334
329 bool m_shouldBubbleScrolls; 335 // Virtual for testing.
330 bool m_wheelScrolling; 336 virtual base::TimeDelta LowFrequencyAnimationInterval() const;
331 LayerTreeSettings m_settings; 337
332 LayerTreeDebugState m_debugState; 338 const AnimationRegistrar::AnimationControllerMap&
333 gfx::Size m_layoutViewportSize; 339 active_animation_controllers() const {
334 gfx::Size m_deviceViewportSize; 340 return animation_registrar_->active_animation_controllers();
335 float m_deviceScaleFactor; 341 }
336 bool m_visible; 342
337 ManagedMemoryPolicy m_managedMemoryPolicy; 343 LayerTreeHostImplClient* client_;
338 344 Proxy* proxy_;
339 bool m_pinchGestureActive; 345
340 gfx::Point m_previousPinchAnchor; 346 private:
341 347 void AnimatePageScale(base::TimeTicks monotonic_time);
342 // This is set by animateLayers() and used by updateAnimationState() 348 void AnimateScrollbars(base::TimeTicks monotonic_time);
343 // when sending animation events to the main thread. 349
344 base::Time m_lastAnimationTime; 350 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
345 351 LayerImpl* layerImpl,
346 scoped_ptr<TopControlsManager> m_topControlsManager; 352 float scaleFromViewportToScreenSpace,
347 353 gfx::PointF viewportPoint,
348 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; 354 gfx::Vector2dF viewportDelta);
349 355
350 // This is used for ticking animations slowly when hidden. 356 void UpdateMaxScrollOffset();
351 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; 357 void TrackDamageForAllSurfaces(LayerImpl* root_draw_layer,
352 358 const LayerList& render_surface_layer_list);
353 scoped_ptr<FrameRateCounter> m_fpsCounter; 359
354 scoped_ptr<PaintTimeCounter> m_paintTimeCounter; 360 // Returns false if the frame should not be displayed. This function should
355 scoped_ptr<MemoryHistory> m_memoryHistory; 361 // only be called from prepareToDraw, as didDrawAllLayers must be called
356 scoped_ptr<DebugRectHistory> m_debugRectHistory; 362 // if this helper function is called.
357 363 bool CalculateRenderPasses(FrameData* frame);
358 int64 m_numImplThreadScrolls; 364 void SetBackgroundTickingEnabled(bool enabled);
359 int64 m_numMainThreadScrolls; 365
360 366 void SendDidLoseOutputSurfaceRecursive(LayerImpl* current);
361 int64 m_cumulativeNumLayersDrawn; 367 void ClearRenderSurfaces();
362 368 bool EnsureRenderSurfaceLayerList();
363 int64 m_cumulativeNumMissingTiles; 369 void ClearCurrentlyScrollingLayer();
364 370
365 size_t m_lastSentMemoryVisibleBytes; 371 void AnimateScrollbarsRecursive(LayerImpl* layer,
366 size_t m_lastSentMemoryVisibleAndNearbyBytes; 372 base::TimeTicks time);
367 size_t m_lastSentMemoryUseBytes; 373
368 374 void DumpRenderSurfaces(std::string* str,
369 base::TimeTicks m_currentFrameTime; 375 int indent,
370 376 const LayerImpl* layer) const;
371 scoped_ptr<AnimationRegistrar> m_animationRegistrar; 377
372 378 static LayerImpl* GetNonCompositedContentLayerRecursive(LayerImpl* layer);
373 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); 379
380 scoped_ptr<OutputSurface> output_surface_;
381 scoped_ptr<ResourceProvider> resource_provider_;
382 scoped_ptr<Renderer> renderer_;
383 scoped_ptr<TileManager> tile_manager_;
384
385 // Tree currently being drawn.
386 scoped_ptr<LayerTreeImpl> active_tree_;
387
388 // In impl-side painting mode, tree with possibly incomplete rasterized
389 // content. May be promoted to active by ActivatePendingTreeIfNeeded().
390 scoped_ptr<LayerTreeImpl> pending_tree_;
391
392 // In impl-side painting mode, inert tree with layers that can be recycled
393 // by the next sync from the main thread.
394 scoped_ptr<LayerTreeImpl> recycle_tree_;
395
396 bool did_lock_scrolling_layer_;
397 bool should_bubble_scrolls_;
398 bool wheel_scrolling_;
399 LayerTreeSettings settings_;
400 LayerTreeDebugState debug_state_;
401 gfx::Size layout_viewport_size_;
402 gfx::Size device_viewport_size_;
403 float device_scale_factor_;
404 bool visible_;
405 ManagedMemoryPolicy managed_memory_policy_;
406
407 bool pinch_gesture_active_;
408 gfx::Point previous_pinch_anchor_;
409
410 // This is set by AnimateLayers() and used by UpdateAnimationState()
411 // when sending animation events to the main thread.
412 base::Time last_animation_time_;
413
414 scoped_ptr<TopControlsManager> top_controls_manager_;
415
416 scoped_ptr<PageScaleAnimation> page_scale_animation_;
417
418 // This is used for ticking animations slowly when hidden.
419 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_;
420
421 scoped_ptr<FrameRateCounter> fps_counter_;
422 scoped_ptr<PaintTimeCounter> paint_time_counter_;
423 scoped_ptr<MemoryHistory> memory_history_;
424 scoped_ptr<DebugRectHistory> debug_rect_history_;
425
426 int64 num_impl_thread_scrolls_;
427 int64 num_main_thread_scrolls_;
428
429 int64 cumulative_num_layers_drawn_;
430
431 int64 cumulative_num_missing_tiles_;
432
433 size_t last_sent_memory_visible_bytes_;
434 size_t last_sent_memory_visible_and_nearby_bytes_;
435 size_t last_sent_memory_use_bytes_;
436
437 base::TimeTicks current_frame_time_;
438
439 scoped_ptr<AnimationRegistrar> animation_registrar_;
440
441 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
374 }; 442 };
375 443
376 } // namespace cc 444 } // namespace cc
377 445
378 #endif // CC_LAYER_TREE_HOST_IMPL_H_ 446 #endif // CC_LAYER_TREE_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « cc/layer_tree_host_common_unittest.cc ('k') | cc/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698