Chromium Code Reviews| 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" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 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 MemoryAllocationLimitBytes() const { return managed_memory_policy_.byte sLimitWhenVisible; } |
|
enne (OOO)
2013/03/13 05:22:05
80 col.
danakj
2013/03/13 15:49:11
Done.
| |
| 206 | 212 |
| 207 FrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } | 213 void SetViewportSize(gfx::Size layout_viewport_size, gfx::Size device_viewport _size); |
|
enne (OOO)
2013/03/13 05:22:05
80 col.
danakj
2013/03/13 15:49:11
Done.
| |
| 208 PaintTimeCounter* paintTimeCounter() const { return m_paintTimeCounter.get() ; } | 214 gfx::Size layout_viewport_size() const { return layout_viewport_size_; } |
| 209 MemoryHistory* memoryHistory() const { return m_memoryHistory.get(); } | 215 gfx::Size device_viewport_size() const { return device_viewport_size_; } |
| 210 DebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get() ; } | 216 |
| 211 ResourceProvider* resourceProvider() const { return m_resourceProvider.get() ; } | 217 void SetDeviceScaleFactor(float device_scale_factor); |
| 212 TopControlsManager* topControlsManager() const { return m_topControlsManager .get(); } | 218 float device_scale_factor() const { return device_scale_factor_; } |
| 213 | 219 |
| 214 Proxy* proxy() const { return m_proxy; } | 220 scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas(); |
| 215 | 221 |
| 216 AnimationRegistrar* animationRegistrar() const { return m_animationRegistrar .get(); } | 222 void StartPageScaleAnimation(gfx::Vector2d target_offset, |
| 217 | 223 bool use_anchor, |
| 218 void setDebugState(const LayerTreeDebugState& debugState); | 224 float scale, |
| 219 const LayerTreeDebugState& debugState() const { return m_debugState; } | 225 base::TimeDelta duration); |
| 220 | 226 |
| 221 void savePaintTime(const base::TimeDelta& totalPaintTime, int commitNumber); | 227 bool needs_animate_layers() const { return !animation_registrar_->active_anima tion_controllers().empty(); } |
|
enne (OOO)
2013/03/13 05:22:05
80 col.
danakj
2013/03/13 15:49:11
Done.
| |
| 222 | 228 |
| 223 class CC_EXPORT CullRenderPassesWithCachedTextures { | 229 void CollectRenderingStats(RenderingStats* stats) const; |
| 224 public: | 230 |
| 225 bool shouldRemoveRenderPass(const RenderPassDrawQuad&, const FrameData&) const; | 231 void SendManagedMemoryStats( |
| 226 | 232 size_t memory_visible_bytes, |
| 227 // Iterates from the root first, in order to remove the surfaces closest | 233 size_t memory_visible_and_nearby_bytes, |
| 228 // to the root with cached textures, and all surfaces that draw into | 234 size_t memoryUseBytes); |
| 229 // them. | 235 |
| 230 size_t renderPassListBegin(const RenderPassList& list) const { return li st.size() - 1; } | 236 FrameRateCounter* fps_counter() { |
| 231 size_t renderPassListEnd(const RenderPassList&) const { return 0 - 1; } | 237 return fps_counter_.get(); |
| 232 size_t renderPassListNext(size_t it) const { return it - 1; } | 238 } |
| 233 | 239 PaintTimeCounter* paint_time_counter() { |
| 234 CullRenderPassesWithCachedTextures(Renderer& renderer) : m_renderer(rend erer) { } | 240 return paint_time_counter_.get(); |
| 235 private: | 241 } |
| 236 Renderer& m_renderer; | 242 MemoryHistory* memory_history() { |
| 237 }; | 243 return memory_history_.get(); |
| 238 | 244 } |
| 239 class CC_EXPORT CullRenderPassesWithNoQuads { | 245 DebugRectHistory* debug_rect_history() { |
| 240 public: | 246 return debug_rect_history_.get(); |
| 241 bool shouldRemoveRenderPass(const RenderPassDrawQuad&, const FrameData&) const; | 247 } |
| 242 | 248 ResourceProvider* resource_provider() { |
| 243 // Iterates in draw order, so that when a surface is removed, and its | 249 return resource_provider_.get(); |
| 244 // target becomes empty, then its target can be removed also. | 250 } |
| 245 size_t renderPassListBegin(const RenderPassList&) const { return 0; } | 251 TopControlsManager* top_controls_manager() { |
| 246 size_t renderPassListEnd(const RenderPassList& list) const { return list .size(); } | 252 return top_controls_manager_.get(); |
| 247 size_t renderPassListNext(size_t it) const { return it + 1; } | 253 } |
| 248 }; | 254 |
| 249 | 255 Proxy* proxy() const { return proxy_; } |
| 250 template<typename RenderPassCuller> | 256 |
| 251 static void removeRenderPasses(RenderPassCuller, FrameData&); | 257 AnimationRegistrar* animation_registrar() const { |
| 252 | 258 return animation_registrar_.get(); |
| 253 skia::RefPtr<SkPicture> capturePicture(); | 259 } |
| 254 | 260 |
| 255 bool pinchGestureActive() const { return m_pinchGestureActive; } | 261 void SetDebugState(const LayerTreeDebugState& debug_state); |
| 256 | 262 const LayerTreeDebugState& debug_state() const { return debug_state_; } |
| 257 void setTreePriority(TreePriority priority); | 263 |
| 258 | 264 void SavePaintTime(const base::TimeDelta& total_paint_time, |
| 259 void beginNextFrame(); | 265 int commit_number); |
| 260 base::TimeTicks currentFrameTime(); | 266 |
| 261 | 267 class CC_EXPORT CullRenderPassesWithCachedTextures { |
| 262 scoped_ptr<base::Value> asValue() const; | 268 public: |
| 263 scoped_ptr<base::Value> activationStateAsValue() const; | 269 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad, |
| 264 scoped_ptr<base::Value> frameStateAsValue() const; | 270 const FrameData& frame) const; |
| 265 | 271 |
| 266 bool pageScaleAnimationActive() const { return !!m_pageScaleAnimation; } | 272 // Iterates from the root first, in order to remove the surfaces closest |
| 267 | 273 // to the root with cached textures, and all surfaces that draw into |
| 268 protected: | 274 // them. |
| 269 LayerTreeHostImpl(const LayerTreeSettings&, LayerTreeHostImplClient*, Proxy* ); | 275 size_t RenderPassListBegin(const RenderPassList& list) const { |
| 270 void activatePendingTree(); | 276 return list.size() - 1; |
| 271 | 277 } |
| 272 // Virtual for testing. | 278 size_t RenderPassListEnd(const RenderPassList& list) const { return 0 - 1; } |
| 273 virtual void animateLayers(base::TimeTicks monotonicTime, base::Time wallClo ckTime); | 279 size_t RenderPassListNext(size_t it) const { return it - 1; } |
| 274 virtual void updateAnimationState(); | 280 |
| 275 | 281 CullRenderPassesWithCachedTextures(Renderer& renderer) |
| 276 // Virtual for testing. | 282 : renderer_(renderer) {} |
| 277 virtual base::TimeDelta lowFrequencyAnimationInterval() const; | 283 private: |
| 278 | 284 Renderer& renderer_; |
| 279 const AnimationRegistrar::AnimationControllerMap& activeAnimationControllers () const { return m_animationRegistrar->active_animation_controllers(); } | 285 }; |
| 280 | 286 |
| 281 LayerTreeHostImplClient* m_client; | 287 class CC_EXPORT CullRenderPassesWithNoQuads { |
| 282 Proxy* m_proxy; | 288 public: |
| 283 | 289 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad, |
| 284 private: | 290 const FrameData& frame) const; |
| 285 void animatePageScale(base::TimeTicks monotonicTime); | 291 |
| 286 void animateScrollbars(base::TimeTicks monotonicTime); | 292 // Iterates in draw order, so that when a surface is removed, and its |
| 287 | 293 // target becomes empty, then its target can be removed also. |
| 288 void setPageScaleDelta(float); | 294 size_t RenderPassListBegin(const RenderPassList& list) const { return 0; } |
| 289 gfx::Vector2dF scrollLayerWithViewportSpaceDelta(LayerImpl* layerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx::Vector2dF viewp ortDelta); | 295 size_t RenderPassListEnd(const RenderPassList& list) const { |
| 290 | 296 return list.size(); |
| 291 void updateMaxScrollOffset(); | 297 } |
| 292 void trackDamageForAllSurfaces(LayerImpl* rootDrawLayer, const LayerList& re nderSurfaceLayerList); | 298 size_t RenderPassListNext(size_t it) const { return it + 1; } |
| 293 | 299 }; |
| 294 // Returns false if the frame should not be displayed. This function should | 300 |
| 295 // only be called from prepareToDraw, as didDrawAllLayers must be called | 301 template <typename RenderPassCuller> |
| 296 // if this helper function is called. | 302 static void RemoveRenderPasses(RenderPassCuller culler, FrameData* frame); |
| 297 bool calculateRenderPasses(FrameData&); | 303 |
| 298 void animateLayersRecursive(LayerImpl*, base::TimeTicks monotonicTime, base: :Time wallClockTime, AnimationEventsVector*, bool& didAnimate, bool& needsAnimat eLayers); | 304 skia::RefPtr<SkPicture> CapturePicture(); |
| 299 void setBackgroundTickingEnabled(bool); | 305 |
| 300 | 306 bool pinch_gesture_active() const { return pinch_gesture_active_; } |
| 301 void sendDidLoseOutputSurfaceRecursive(LayerImpl*); | 307 |
| 302 void clearRenderSurfaces(); | 308 void SetTreePriority(TreePriority priority); |
| 303 bool ensureRenderSurfaceLayerList(); | 309 |
| 304 void clearCurrentlyScrollingLayer(); | 310 void BeginNextFrame(); |
| 305 | 311 base::TimeTicks CurrentFrameTime(); |
| 306 void animateScrollbarsRecursive(LayerImpl*, base::TimeTicks monotonicTime); | 312 |
| 307 | 313 scoped_ptr<base::Value> AsValue() const; |
| 308 void dumpRenderSurfaces(std::string*, int indent, const LayerImpl*) const; | 314 scoped_ptr<base::Value> ActivationStateAsValue() const; |
| 309 | 315 scoped_ptr<base::Value> FrameStateAsValue() const; |
| 310 static LayerImpl* getNonCompositedContentLayerRecursive(LayerImpl* layer); | 316 |
| 311 | 317 bool page_scale_animation_active() const { return !!page_scale_animation_; } |
| 312 scoped_ptr<OutputSurface> m_outputSurface; | 318 |
| 313 scoped_ptr<ResourceProvider> m_resourceProvider; | 319 protected: |
| 314 scoped_ptr<Renderer> m_renderer; | 320 LayerTreeHostImpl(const LayerTreeSettings& settings, |
| 315 scoped_ptr<TileManager> m_tileManager; | 321 LayerTreeHostImplClient* client, |
| 316 | 322 Proxy* proxy); |
| 317 // Tree currently being drawn. | 323 void ActivatePendingTree(); |
| 318 scoped_ptr<LayerTreeImpl> m_activeTree; | 324 |
| 319 | 325 // Virtual for testing. |
| 320 // In impl-side painting mode, tree with possibly incomplete rasterized | 326 virtual void AnimateLayers(base::TimeTicks monotonic_time, |
| 321 // content. May be promoted to active by activatePendingTreeIfNeeded(). | 327 base::Time wall_clock_time); |
| 322 scoped_ptr<LayerTreeImpl> m_pendingTree; | 328 virtual void UpdateAnimationState(); |
| 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 base::TimeDelta LowFrequencyAnimationInterval() const; |
| 326 scoped_ptr<LayerTreeImpl> m_recycleTree; | 332 |
| 327 | 333 const AnimationRegistrar::AnimationControllerMap& |
| 328 bool m_didLockScrollingLayer; | 334 active_animation_controllers() const { |
| 329 bool m_shouldBubbleScrolls; | 335 return animation_registrar_->active_animation_controllers(); |
| 330 bool m_wheelScrolling; | 336 } |
| 331 LayerTreeSettings m_settings; | 337 |
| 332 LayerTreeDebugState m_debugState; | 338 LayerTreeHostImplClient* client_; |
| 333 gfx::Size m_layoutViewportSize; | 339 Proxy* proxy_; |
| 334 gfx::Size m_deviceViewportSize; | 340 |
| 335 float m_deviceScaleFactor; | 341 private: |
| 336 bool m_visible; | 342 void AnimatePageScale(base::TimeTicks monotonic_time); |
| 337 ManagedMemoryPolicy m_managedMemoryPolicy; | 343 void AnimateScrollbars(base::TimeTicks monotonic_time); |
| 338 | 344 |
| 339 bool m_pinchGestureActive; | 345 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta( |
| 340 gfx::Point m_previousPinchAnchor; | 346 LayerImpl* layerImpl, |
| 341 | 347 float scaleFromViewportToScreenSpace, |
| 342 // This is set by animateLayers() and used by updateAnimationState() | 348 gfx::PointF viewportPoint, |
| 343 // when sending animation events to the main thread. | 349 gfx::Vector2dF viewportDelta); |
| 344 base::Time m_lastAnimationTime; | 350 |
| 345 | 351 void UpdateMaxScrollOffset(); |
| 346 scoped_ptr<TopControlsManager> m_topControlsManager; | 352 void TrackDamageForAllSurfaces(LayerImpl* root_draw_layer, |
| 347 | 353 const LayerList& render_surface_layer_list); |
| 348 scoped_ptr<PageScaleAnimation> m_pageScaleAnimation; | 354 |
| 349 | 355 // Returns false if the frame should not be displayed. This function should |
| 350 // This is used for ticking animations slowly when hidden. | 356 // only be called from prepareToDraw, as didDrawAllLayers must be called |
| 351 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> m_timeSourceClientAdapter; | 357 // if this helper function is called. |
| 352 | 358 bool CalculateRenderPasses(FrameData* frame); |
| 353 scoped_ptr<FrameRateCounter> m_fpsCounter; | 359 void SetBackgroundTickingEnabled(bool enabled); |
| 354 scoped_ptr<PaintTimeCounter> m_paintTimeCounter; | 360 |
| 355 scoped_ptr<MemoryHistory> m_memoryHistory; | 361 void SendDidLoseOutputSurfaceRecursive(LayerImpl* current); |
| 356 scoped_ptr<DebugRectHistory> m_debugRectHistory; | 362 void ClearRenderSurfaces(); |
| 357 | 363 bool EnsureRenderSurfaceLayerList(); |
| 358 int64 m_numImplThreadScrolls; | 364 void ClearCurrentlyScrollingLayer(); |
| 359 int64 m_numMainThreadScrolls; | 365 |
| 360 | 366 void AnimateScrollbarsRecursive(LayerImpl* layer, |
| 361 int64 m_cumulativeNumLayersDrawn; | 367 base::TimeTicks time); |
| 362 | 368 |
| 363 int64 m_cumulativeNumMissingTiles; | 369 void DumpRenderSurfaces(std::string* str, |
| 364 | 370 int indent, |
| 365 size_t m_lastSentMemoryVisibleBytes; | 371 const LayerImpl* layer) const; |
| 366 size_t m_lastSentMemoryVisibleAndNearbyBytes; | 372 |
| 367 size_t m_lastSentMemoryUseBytes; | 373 static LayerImpl* GetNonCompositedContentLayerRecursive(LayerImpl* layer); |
| 368 | 374 |
| 369 base::TimeTicks m_currentFrameTime; | 375 scoped_ptr<OutputSurface> output_surface_; |
| 370 | 376 scoped_ptr<ResourceProvider> resource_provider_; |
| 371 scoped_ptr<AnimationRegistrar> m_animationRegistrar; | 377 scoped_ptr<Renderer> renderer_; |
| 372 | 378 scoped_ptr<TileManager> tile_manager_; |
| 373 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 379 |
| 380 // Tree currently being drawn. | |
| 381 scoped_ptr<LayerTreeImpl> active_tree_; | |
| 382 | |
| 383 // In impl-side painting mode, tree with possibly incomplete rasterized | |
| 384 // content. May be promoted to active by ActivatePendingTreeIfNeeded(). | |
| 385 scoped_ptr<LayerTreeImpl> pending_tree_; | |
| 386 | |
| 387 // In impl-side painting mode, inert tree with layers that can be recycled | |
| 388 // by the next sync from the main thread. | |
| 389 scoped_ptr<LayerTreeImpl> recycle_tree_; | |
| 390 | |
| 391 bool did_lock_scrolling_layer_; | |
| 392 bool should_bubble_scrolls_; | |
| 393 bool wheel_scrolling_; | |
| 394 LayerTreeSettings settings_; | |
| 395 LayerTreeDebugState debug_state_; | |
| 396 gfx::Size layout_viewport_size_; | |
| 397 gfx::Size device_viewport_size_; | |
| 398 float device_scale_factor_; | |
| 399 bool visible_; | |
| 400 ManagedMemoryPolicy managed_memory_policy_; | |
| 401 | |
| 402 bool pinch_gesture_active_; | |
| 403 gfx::Point previous_pinch_anchor_; | |
| 404 | |
| 405 // This is set by AnimateLayers() and used by UpdateAnimationState() | |
| 406 // when sending animation events to the main thread. | |
| 407 base::Time last_animation_time_; | |
| 408 | |
| 409 scoped_ptr<TopControlsManager> top_controls_manager_; | |
| 410 | |
| 411 scoped_ptr<PageScaleAnimation> page_scale_animation_; | |
| 412 | |
| 413 // This is used for ticking animations slowly when hidden. | |
| 414 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_; | |
| 415 | |
| 416 scoped_ptr<FrameRateCounter> fps_counter_; | |
| 417 scoped_ptr<PaintTimeCounter> paint_time_counter_; | |
| 418 scoped_ptr<MemoryHistory> memory_history_; | |
| 419 scoped_ptr<DebugRectHistory> debug_rect_history_; | |
| 420 | |
| 421 int64 num_impl_thread_scrolls_; | |
| 422 int64 num_main_thread_scrolls_; | |
| 423 | |
| 424 int64 cumulative_num_layers_drawn_; | |
| 425 | |
| 426 int64 cumulative_num_missing_tiles_; | |
| 427 | |
| 428 size_t last_sent_memory_visible_bytes_; | |
| 429 size_t last_sent_memory_visible_and_nearby_bytes_; | |
| 430 size_t last_sent_memory_use_bytes_; | |
| 431 | |
| 432 base::TimeTicks current_frame_time_; | |
| 433 | |
| 434 scoped_ptr<AnimationRegistrar> animation_registrar_; | |
| 435 | |
| 436 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | |
| 374 }; | 437 }; |
| 375 | 438 |
| 376 } // namespace cc | 439 } // namespace cc |
| 377 | 440 |
| 378 #endif // CC_LAYER_TREE_HOST_IMPL_H_ | 441 #endif // CC_LAYER_TREE_HOST_IMPL_H_ |
| OLD | NEW |