| 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_TREES_LAYER_TREE_HOST_IMPL_H_ | 5 #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| 6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "cc/layers/layer_lists.h" | 25 #include "cc/layers/layer_lists.h" |
| 26 #include "cc/layers/render_pass_sink.h" | 26 #include "cc/layers/render_pass_sink.h" |
| 27 #include "cc/output/begin_frame_args.h" | 27 #include "cc/output/begin_frame_args.h" |
| 28 #include "cc/output/managed_memory_policy.h" | 28 #include "cc/output/managed_memory_policy.h" |
| 29 #include "cc/output/output_surface_client.h" | 29 #include "cc/output/output_surface_client.h" |
| 30 #include "cc/output/renderer.h" | 30 #include "cc/output/renderer.h" |
| 31 #include "cc/quads/render_pass.h" | 31 #include "cc/quads/render_pass.h" |
| 32 #include "cc/resources/resource_provider.h" | 32 #include "cc/resources/resource_provider.h" |
| 33 #include "cc/resources/tile_manager.h" | 33 #include "cc/resources/tile_manager.h" |
| 34 #include "cc/scheduler/draw_swap_readback_result.h" | 34 #include "cc/scheduler/draw_swap_readback_result.h" |
| 35 #include "cc/scheduler/frame_source.h" |
| 35 #include "skia/ext/refptr.h" | 36 #include "skia/ext/refptr.h" |
| 36 #include "third_party/skia/include/core/SkColor.h" | 37 #include "third_party/skia/include/core/SkColor.h" |
| 37 #include "ui/gfx/rect.h" | 38 #include "ui/gfx/rect.h" |
| 38 | 39 |
| 39 namespace cc { | 40 namespace cc { |
| 40 | 41 |
| 41 class CompletionEvent; | 42 class CompletionEvent; |
| 42 class CompositorFrameMetadata; | 43 class CompositorFrameMetadata; |
| 43 class DebugRectHistory; | 44 class DebugRectHistory; |
| 44 class FrameRateCounter; | 45 class FrameRateCounter; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 57 class TopControlsManager; | 58 class TopControlsManager; |
| 58 class UIResourceBitmap; | 59 class UIResourceBitmap; |
| 59 class UIResourceRequest; | 60 class UIResourceRequest; |
| 60 struct RendererCapabilitiesImpl; | 61 struct RendererCapabilitiesImpl; |
| 61 | 62 |
| 62 // LayerTreeHost->Proxy callback interface. | 63 // LayerTreeHost->Proxy callback interface. |
| 63 class LayerTreeHostImplClient { | 64 class LayerTreeHostImplClient { |
| 64 public: | 65 public: |
| 65 virtual void UpdateRendererCapabilitiesOnImplThread() = 0; | 66 virtual void UpdateRendererCapabilitiesOnImplThread() = 0; |
| 66 virtual void DidLoseOutputSurfaceOnImplThread() = 0; | 67 virtual void DidLoseOutputSurfaceOnImplThread() = 0; |
| 67 virtual void CommitVSyncParameters(base::TimeTicks timebase, | |
| 68 base::TimeDelta interval) = 0; | |
| 69 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) = 0; | 68 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) = 0; |
| 70 virtual void SetMaxSwapsPendingOnImplThread(int max) = 0; | 69 virtual void SetMaxSwapsPendingOnImplThread(int max) = 0; |
| 71 virtual void DidSwapBuffersOnImplThread() = 0; | 70 virtual void DidSwapBuffersOnImplThread() = 0; |
| 72 virtual void DidSwapBuffersCompleteOnImplThread() = 0; | 71 virtual void DidSwapBuffersCompleteOnImplThread() = 0; |
| 73 virtual void BeginFrame(const BeginFrameArgs& args) = 0; | |
| 74 virtual void OnCanDrawStateChanged(bool can_draw) = 0; | 72 virtual void OnCanDrawStateChanged(bool can_draw) = 0; |
| 75 virtual void NotifyReadyToActivate() = 0; | 73 virtual void NotifyReadyToActivate() = 0; |
| 76 // Please call these 3 functions through | 74 // Please call these 3 functions through |
| 77 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and | 75 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and |
| 78 // SetNeedsAnimate(). | 76 // SetNeedsAnimate(). |
| 79 virtual void SetNeedsRedrawOnImplThread() = 0; | 77 virtual void SetNeedsRedrawOnImplThread() = 0; |
| 80 virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0; | 78 virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0; |
| 81 virtual void SetNeedsAnimateOnImplThread() = 0; | 79 virtual void SetNeedsAnimateOnImplThread() = 0; |
| 82 virtual void DidInitializeVisibleTileOnImplThread() = 0; | 80 virtual void DidInitializeVisibleTileOnImplThread() = 0; |
| 83 virtual void SetNeedsCommitOnImplThread() = 0; | 81 virtual void SetNeedsCommitOnImplThread() = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 103 | 101 |
| 104 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering | 102 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering |
| 105 // state. | 103 // state. |
| 106 class CC_EXPORT LayerTreeHostImpl | 104 class CC_EXPORT LayerTreeHostImpl |
| 107 : public InputHandler, | 105 : public InputHandler, |
| 108 public RendererClient, | 106 public RendererClient, |
| 109 public TileManagerClient, | 107 public TileManagerClient, |
| 110 public OutputSurfaceClient, | 108 public OutputSurfaceClient, |
| 111 public TopControlsManagerClient, | 109 public TopControlsManagerClient, |
| 112 public ScrollbarAnimationControllerClient, | 110 public ScrollbarAnimationControllerClient, |
| 111 public BaseFrameSource, |
| 113 public base::SupportsWeakPtr<LayerTreeHostImpl> { | 112 public base::SupportsWeakPtr<LayerTreeHostImpl> { |
| 114 public: | 113 public: |
| 115 static scoped_ptr<LayerTreeHostImpl> Create( | 114 static scoped_ptr<LayerTreeHostImpl> Create( |
| 116 const LayerTreeSettings& settings, | 115 const LayerTreeSettings& settings, |
| 117 LayerTreeHostImplClient* client, | 116 LayerTreeHostImplClient* client, |
| 118 Proxy* proxy, | 117 Proxy* proxy, |
| 119 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 118 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 120 SharedBitmapManager* manager, | 119 SharedBitmapManager* manager, |
| 121 int id); | 120 int id); |
| 122 virtual ~LayerTreeHostImpl(); | 121 virtual ~LayerTreeHostImpl(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE; | 174 virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE; |
| 176 }; | 175 }; |
| 177 | 176 |
| 178 virtual void BeginMainFrameAborted(bool did_handle); | 177 virtual void BeginMainFrameAborted(bool did_handle); |
| 179 virtual void BeginCommit(); | 178 virtual void BeginCommit(); |
| 180 virtual void CommitComplete(); | 179 virtual void CommitComplete(); |
| 181 virtual void Animate(base::TimeTicks monotonic_time); | 180 virtual void Animate(base::TimeTicks monotonic_time); |
| 182 virtual void UpdateAnimationState(bool start_ready_animations); | 181 virtual void UpdateAnimationState(bool start_ready_animations); |
| 183 void ActivateAnimations(); | 182 void ActivateAnimations(); |
| 184 void MainThreadHasStoppedFlinging(); | 183 void MainThreadHasStoppedFlinging(); |
| 185 void UpdateBackgroundAnimateTicking(bool should_background_tick); | |
| 186 void DidAnimateScrollOffset(); | 184 void DidAnimateScrollOffset(); |
| 187 void SetViewportDamage(const gfx::Rect& damage_rect); | 185 void SetViewportDamage(const gfx::Rect& damage_rect); |
| 188 | 186 |
| 189 virtual void ManageTiles(); | 187 virtual void ManageTiles(); |
| 190 | 188 |
| 191 // Returns false if problems occured preparing the frame, and we should try | 189 // Returns false if problems occured preparing the frame, and we should try |
| 192 // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers | 190 // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers |
| 193 // must also be called, regardless of whether DrawLayers is called between the | 191 // must also be called, regardless of whether DrawLayers is called between the |
| 194 // two. | 192 // two. |
| 195 virtual DrawSwapReadbackResult::DrawResult PrepareToDraw( | 193 virtual DrawSwapReadbackResult::DrawResult PrepareToDraw( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 const gfx::Rect& clip, | 249 const gfx::Rect& clip, |
| 252 bool valid_for_tile_management) OVERRIDE; | 250 bool valid_for_tile_management) OVERRIDE; |
| 253 virtual void DidLoseOutputSurface() OVERRIDE; | 251 virtual void DidLoseOutputSurface() OVERRIDE; |
| 254 virtual void DidSwapBuffers() OVERRIDE; | 252 virtual void DidSwapBuffers() OVERRIDE; |
| 255 virtual void DidSwapBuffersComplete() OVERRIDE; | 253 virtual void DidSwapBuffersComplete() OVERRIDE; |
| 256 virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE; | 254 virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE; |
| 257 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; | 255 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; |
| 258 virtual void SetTreeActivationCallback(const base::Closure& callback) | 256 virtual void SetTreeActivationCallback(const base::Closure& callback) |
| 259 OVERRIDE; | 257 OVERRIDE; |
| 260 | 258 |
| 259 // FrameSource implementation. |
| 260 virtual void SetNeedsBeginFrame(bool needs_begin_frame) OVERRIDE; |
| 261 virtual void SetSink(FrameSink* sink) OVERRIDE; |
| 262 virtual void SetTimeBaseAndInterval(base::TimeTicks timebase, |
| 263 base::TimeDelta interval) OVERRIDE; |
| 264 virtual scoped_ptr<base::Value> FrameSourceAsValue() const OVERRIDE; |
| 265 virtual std::string FrameSourceType() const OVERRIDE; |
| 266 |
| 261 // Called from LayerTreeImpl. | 267 // Called from LayerTreeImpl. |
| 262 void OnCanDrawStateChangedForTree(); | 268 void OnCanDrawStateChangedForTree(); |
| 263 | 269 |
| 264 // Implementation. | 270 // Implementation. |
| 265 bool CanDraw() const; | 271 bool CanDraw() const; |
| 266 OutputSurface* output_surface() const { return output_surface_.get(); } | 272 OutputSurface* output_surface() const { return output_surface_.get(); } |
| 267 | 273 |
| 268 std::string LayerTreeAsJson() const; | 274 std::string LayerTreeAsJson() const; |
| 269 | 275 |
| 270 void FinishAllRendering(); | 276 void FinishAllRendering(); |
| 271 int SourceAnimationFrameNumber() const; | 277 int SourceAnimationFrameNumber() const; |
| 272 | 278 |
| 273 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface); | 279 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface); |
| 274 bool IsContextLost(); | 280 bool IsContextLost(); |
| 275 TileManager* tile_manager() { return tile_manager_.get(); } | 281 TileManager* tile_manager() { return tile_manager_.get(); } |
| 276 ResourcePool* resource_pool() { return resource_pool_.get(); } | 282 ResourcePool* resource_pool() { return resource_pool_.get(); } |
| 277 Renderer* renderer() { return renderer_.get(); } | 283 Renderer* renderer() { return renderer_.get(); } |
| 278 const RendererCapabilitiesImpl& GetRendererCapabilities() const; | 284 const RendererCapabilitiesImpl& GetRendererCapabilities() const; |
| 279 | 285 |
| 280 virtual bool SwapBuffers(const FrameData& frame); | 286 virtual bool SwapBuffers(const FrameData& frame); |
| 281 void SetNeedsBeginFrame(bool enable); | |
| 282 virtual void WillBeginImplFrame(const BeginFrameArgs& args); | 287 virtual void WillBeginImplFrame(const BeginFrameArgs& args); |
| 283 void DidModifyTilePriorities(); | 288 void DidModifyTilePriorities(); |
| 284 | 289 |
| 285 void Readback(void* pixels, const gfx::Rect& rect_in_device_viewport); | 290 void Readback(void* pixels, const gfx::Rect& rect_in_device_viewport); |
| 286 | 291 |
| 287 LayerTreeImpl* active_tree() { return active_tree_.get(); } | 292 LayerTreeImpl* active_tree() { return active_tree_.get(); } |
| 288 const LayerTreeImpl* active_tree() const { return active_tree_.get(); } | 293 const LayerTreeImpl* active_tree() const { return active_tree_.get(); } |
| 289 LayerTreeImpl* pending_tree() { return pending_tree_.get(); } | 294 LayerTreeImpl* pending_tree() { return pending_tree_.get(); } |
| 290 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); } | 295 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); } |
| 291 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); } | 296 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); } |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 gfx::Vector2dF accumulated_root_overscroll_; | 599 gfx::Vector2dF accumulated_root_overscroll_; |
| 595 | 600 |
| 596 bool pinch_gesture_active_; | 601 bool pinch_gesture_active_; |
| 597 bool pinch_gesture_end_should_clear_scrolling_layer_; | 602 bool pinch_gesture_end_should_clear_scrolling_layer_; |
| 598 gfx::Point previous_pinch_anchor_; | 603 gfx::Point previous_pinch_anchor_; |
| 599 | 604 |
| 600 scoped_ptr<TopControlsManager> top_controls_manager_; | 605 scoped_ptr<TopControlsManager> top_controls_manager_; |
| 601 | 606 |
| 602 scoped_ptr<PageScaleAnimation> page_scale_animation_; | 607 scoped_ptr<PageScaleAnimation> page_scale_animation_; |
| 603 | 608 |
| 604 // This is used for ticking animations slowly when hidden. | |
| 605 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_; | |
| 606 | |
| 607 scoped_ptr<FrameRateCounter> fps_counter_; | 609 scoped_ptr<FrameRateCounter> fps_counter_; |
| 608 scoped_ptr<PaintTimeCounter> paint_time_counter_; | 610 scoped_ptr<PaintTimeCounter> paint_time_counter_; |
| 609 scoped_ptr<MemoryHistory> memory_history_; | 611 scoped_ptr<MemoryHistory> memory_history_; |
| 610 scoped_ptr<DebugRectHistory> debug_rect_history_; | 612 scoped_ptr<DebugRectHistory> debug_rect_history_; |
| 611 | 613 |
| 612 scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_; | 614 scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_; |
| 613 | 615 |
| 614 // The maximum memory that would be used by the prioritized resource | 616 // The maximum memory that would be used by the prioritized resource |
| 615 // manager, if there were no limit on memory usage. | 617 // manager, if there were no limit on memory usage. |
| 616 size_t max_memory_needed_bytes_; | 618 size_t max_memory_needed_bytes_; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 std::set<SwapPromiseMonitor*> swap_promise_monitor_; | 675 std::set<SwapPromiseMonitor*> swap_promise_monitor_; |
| 674 | 676 |
| 675 size_t transfer_buffer_memory_limit_; | 677 size_t transfer_buffer_memory_limit_; |
| 676 | 678 |
| 677 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 679 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
| 678 }; | 680 }; |
| 679 | 681 |
| 680 } // namespace cc | 682 } // namespace cc |
| 681 | 683 |
| 682 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 684 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| OLD | NEW |