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_result.h" | 34 #include "cc/scheduler/draw_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; |
45 class LayerImpl; | 46 class LayerImpl; |
46 class LayerTreeHostImplTimeSourceAdapter; | |
47 class LayerTreeImpl; | 47 class LayerTreeImpl; |
48 class MemoryHistory; | 48 class MemoryHistory; |
49 class PageScaleAnimation; | 49 class PageScaleAnimation; |
50 class PaintTimeCounter; | 50 class PaintTimeCounter; |
51 class RasterWorkerPool; | 51 class RasterWorkerPool; |
52 class RenderPassDrawQuad; | 52 class RenderPassDrawQuad; |
53 class RenderingStatsInstrumentation; | 53 class RenderingStatsInstrumentation; |
54 class ResourcePool; | 54 class ResourcePool; |
55 class ScrollbarLayerImplBase; | 55 class ScrollbarLayerImplBase; |
56 class TextureMailboxDeleter; | 56 class TextureMailboxDeleter; |
57 class TopControlsManager; | 57 class TopControlsManager; |
58 class UIResourceBitmap; | 58 class UIResourceBitmap; |
59 class UIResourceRequest; | 59 class UIResourceRequest; |
60 struct RendererCapabilitiesImpl; | 60 struct RendererCapabilitiesImpl; |
61 | 61 |
62 // LayerTreeHost->Proxy callback interface. | 62 // LayerTreeHost->Proxy callback interface. |
63 class LayerTreeHostImplClient { | 63 class LayerTreeHostImplClient { |
64 public: | 64 public: |
65 virtual void UpdateRendererCapabilitiesOnImplThread() = 0; | 65 virtual void UpdateRendererCapabilitiesOnImplThread() = 0; |
66 virtual void DidLoseOutputSurfaceOnImplThread() = 0; | 66 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; | 67 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) = 0; |
70 virtual void SetMaxSwapsPendingOnImplThread(int max) = 0; | 68 virtual void SetMaxSwapsPendingOnImplThread(int max) = 0; |
71 virtual void DidSwapBuffersOnImplThread() = 0; | 69 virtual void DidSwapBuffersOnImplThread() = 0; |
72 virtual void DidSwapBuffersCompleteOnImplThread() = 0; | 70 virtual void DidSwapBuffersCompleteOnImplThread() = 0; |
73 virtual void BeginFrame(const BeginFrameArgs& args) = 0; | |
74 virtual void OnCanDrawStateChanged(bool can_draw) = 0; | 71 virtual void OnCanDrawStateChanged(bool can_draw) = 0; |
75 virtual void NotifyReadyToActivate() = 0; | 72 virtual void NotifyReadyToActivate() = 0; |
76 // Please call these 3 functions through | 73 // Please call these 3 functions through |
77 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and | 74 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and |
78 // SetNeedsAnimate(). | 75 // SetNeedsAnimate(). |
79 virtual void SetNeedsRedrawOnImplThread() = 0; | 76 virtual void SetNeedsRedrawOnImplThread() = 0; |
80 virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0; | 77 virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0; |
81 virtual void SetNeedsAnimateOnImplThread() = 0; | 78 virtual void SetNeedsAnimateOnImplThread() = 0; |
82 virtual void DidInitializeVisibleTileOnImplThread() = 0; | 79 virtual void DidInitializeVisibleTileOnImplThread() = 0; |
83 virtual void SetNeedsCommitOnImplThread() = 0; | 80 virtual void SetNeedsCommitOnImplThread() = 0; |
(...skipping 19 matching lines...) Expand all Loading... |
103 | 100 |
104 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering | 101 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering |
105 // state. | 102 // state. |
106 class CC_EXPORT LayerTreeHostImpl | 103 class CC_EXPORT LayerTreeHostImpl |
107 : public InputHandler, | 104 : public InputHandler, |
108 public RendererClient, | 105 public RendererClient, |
109 public TileManagerClient, | 106 public TileManagerClient, |
110 public OutputSurfaceClient, | 107 public OutputSurfaceClient, |
111 public TopControlsManagerClient, | 108 public TopControlsManagerClient, |
112 public ScrollbarAnimationControllerClient, | 109 public ScrollbarAnimationControllerClient, |
| 110 public BaseBeginFrameSource, |
113 public base::SupportsWeakPtr<LayerTreeHostImpl> { | 111 public base::SupportsWeakPtr<LayerTreeHostImpl> { |
114 public: | 112 public: |
115 static scoped_ptr<LayerTreeHostImpl> Create( | 113 static scoped_ptr<LayerTreeHostImpl> Create( |
116 const LayerTreeSettings& settings, | 114 const LayerTreeSettings& settings, |
117 LayerTreeHostImplClient* client, | 115 LayerTreeHostImplClient* client, |
118 Proxy* proxy, | 116 Proxy* proxy, |
119 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 117 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
120 SharedBitmapManager* manager, | 118 SharedBitmapManager* manager, |
121 int id); | 119 int id); |
122 virtual ~LayerTreeHostImpl(); | 120 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; | 173 virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE; |
176 }; | 174 }; |
177 | 175 |
178 virtual void BeginMainFrameAborted(bool did_handle); | 176 virtual void BeginMainFrameAborted(bool did_handle); |
179 virtual void BeginCommit(); | 177 virtual void BeginCommit(); |
180 virtual void CommitComplete(); | 178 virtual void CommitComplete(); |
181 virtual void Animate(base::TimeTicks monotonic_time); | 179 virtual void Animate(base::TimeTicks monotonic_time); |
182 virtual void UpdateAnimationState(bool start_ready_animations); | 180 virtual void UpdateAnimationState(bool start_ready_animations); |
183 void ActivateAnimations(); | 181 void ActivateAnimations(); |
184 void MainThreadHasStoppedFlinging(); | 182 void MainThreadHasStoppedFlinging(); |
185 void UpdateBackgroundAnimateTicking(bool should_background_tick); | |
186 void DidAnimateScrollOffset(); | 183 void DidAnimateScrollOffset(); |
187 void SetViewportDamage(const gfx::Rect& damage_rect); | 184 void SetViewportDamage(const gfx::Rect& damage_rect); |
188 | 185 |
189 virtual void ManageTiles(); | 186 virtual void ManageTiles(); |
190 | 187 |
191 // Returns DRAW_SUCCESS unless problems occured preparing the frame, and we | 188 // Returns DRAW_SUCCESS unless problems occured preparing the frame, and we |
192 // should try to avoid displaying the frame. If PrepareToDraw is called, | 189 // should try to avoid displaying the frame. If PrepareToDraw is called, |
193 // DidDrawAllLayers must also be called, regardless of whether DrawLayers is | 190 // DidDrawAllLayers must also be called, regardless of whether DrawLayers is |
194 // called between the two. | 191 // called between the two. |
195 virtual DrawResult PrepareToDraw(FrameData* frame); | 192 virtual DrawResult PrepareToDraw(FrameData* frame); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 const gfx::Rect& clip, | 249 const gfx::Rect& clip, |
253 bool valid_for_tile_management) OVERRIDE; | 250 bool valid_for_tile_management) OVERRIDE; |
254 virtual void DidLoseOutputSurface() OVERRIDE; | 251 virtual void DidLoseOutputSurface() OVERRIDE; |
255 virtual void DidSwapBuffers() OVERRIDE; | 252 virtual void DidSwapBuffers() OVERRIDE; |
256 virtual void DidSwapBuffersComplete() OVERRIDE; | 253 virtual void DidSwapBuffersComplete() OVERRIDE; |
257 virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE; | 254 virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE; |
258 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; | 255 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE; |
259 virtual void SetTreeActivationCallback(const base::Closure& callback) | 256 virtual void SetTreeActivationCallback(const base::Closure& callback) |
260 OVERRIDE; | 257 OVERRIDE; |
261 | 258 |
| 259 // BeginFrameSource implementation. |
| 260 virtual void OnGenerateChange(bool generate_frames) OVERRIDE; |
| 261 virtual std::string TypeString() const OVERRIDE; |
| 262 |
262 // Called from LayerTreeImpl. | 263 // Called from LayerTreeImpl. |
263 void OnCanDrawStateChangedForTree(); | 264 void OnCanDrawStateChangedForTree(); |
264 | 265 |
265 // Implementation. | 266 // Implementation. |
266 bool CanDraw() const; | 267 bool CanDraw() const; |
267 OutputSurface* output_surface() const { return output_surface_.get(); } | 268 OutputSurface* output_surface() const { return output_surface_.get(); } |
268 | 269 |
269 std::string LayerTreeAsJson() const; | 270 std::string LayerTreeAsJson() const; |
270 | 271 |
271 void FinishAllRendering(); | 272 void FinishAllRendering(); |
272 int SourceAnimationFrameNumber() const; | 273 int SourceAnimationFrameNumber() const; |
273 | 274 |
274 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface); | 275 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface); |
275 bool IsContextLost(); | 276 bool IsContextLost(); |
276 TileManager* tile_manager() { return tile_manager_.get(); } | 277 TileManager* tile_manager() { return tile_manager_.get(); } |
277 void SetUseGpuRasterization(bool use_gpu); | 278 void SetUseGpuRasterization(bool use_gpu); |
278 bool use_gpu_rasterization() const { return use_gpu_rasterization_; } | 279 bool use_gpu_rasterization() const { return use_gpu_rasterization_; } |
279 bool create_low_res_tiling() const { | 280 bool create_low_res_tiling() const { |
280 return settings_.create_low_res_tiling && !use_gpu_rasterization_; | 281 return settings_.create_low_res_tiling && !use_gpu_rasterization_; |
281 } | 282 } |
282 ResourcePool* resource_pool() { return resource_pool_.get(); } | 283 ResourcePool* resource_pool() { return resource_pool_.get(); } |
283 Renderer* renderer() { return renderer_.get(); } | 284 Renderer* renderer() { return renderer_.get(); } |
284 const RendererCapabilitiesImpl& GetRendererCapabilities() const; | 285 const RendererCapabilitiesImpl& GetRendererCapabilities() const; |
285 | 286 |
286 virtual bool SwapBuffers(const FrameData& frame); | 287 virtual bool SwapBuffers(const FrameData& frame); |
287 void SetNeedsBeginFrame(bool enable); | |
288 virtual void WillBeginImplFrame(const BeginFrameArgs& args); | 288 virtual void WillBeginImplFrame(const BeginFrameArgs& args); |
289 void DidModifyTilePriorities(); | 289 void DidModifyTilePriorities(); |
290 | 290 |
291 LayerTreeImpl* active_tree() { return active_tree_.get(); } | 291 LayerTreeImpl* active_tree() { return active_tree_.get(); } |
292 const LayerTreeImpl* active_tree() const { return active_tree_.get(); } | 292 const LayerTreeImpl* active_tree() const { return active_tree_.get(); } |
293 LayerTreeImpl* pending_tree() { return pending_tree_.get(); } | 293 LayerTreeImpl* pending_tree() { return pending_tree_.get(); } |
294 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); } | 294 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); } |
295 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); } | 295 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); } |
296 virtual void CreatePendingTree(); | 296 virtual void CreatePendingTree(); |
297 virtual void UpdateVisibleTiles(); | 297 virtual void UpdateVisibleTiles(); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 gfx::Vector2dF accumulated_root_overscroll_; | 599 gfx::Vector2dF accumulated_root_overscroll_; |
600 | 600 |
601 bool pinch_gesture_active_; | 601 bool pinch_gesture_active_; |
602 bool pinch_gesture_end_should_clear_scrolling_layer_; | 602 bool pinch_gesture_end_should_clear_scrolling_layer_; |
603 gfx::Point previous_pinch_anchor_; | 603 gfx::Point previous_pinch_anchor_; |
604 | 604 |
605 scoped_ptr<TopControlsManager> top_controls_manager_; | 605 scoped_ptr<TopControlsManager> top_controls_manager_; |
606 | 606 |
607 scoped_ptr<PageScaleAnimation> page_scale_animation_; | 607 scoped_ptr<PageScaleAnimation> page_scale_animation_; |
608 | 608 |
609 // This is used for ticking animations slowly when hidden. | |
610 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_; | |
611 | |
612 scoped_ptr<FrameRateCounter> fps_counter_; | 609 scoped_ptr<FrameRateCounter> fps_counter_; |
613 scoped_ptr<PaintTimeCounter> paint_time_counter_; | 610 scoped_ptr<PaintTimeCounter> paint_time_counter_; |
614 scoped_ptr<MemoryHistory> memory_history_; | 611 scoped_ptr<MemoryHistory> memory_history_; |
615 scoped_ptr<DebugRectHistory> debug_rect_history_; | 612 scoped_ptr<DebugRectHistory> debug_rect_history_; |
616 | 613 |
617 scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_; | 614 scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_; |
618 | 615 |
619 // The maximum memory that would be used by the prioritized resource | 616 // The maximum memory that would be used by the prioritized resource |
620 // manager, if there were no limit on memory usage. | 617 // manager, if there were no limit on memory usage. |
621 size_t max_memory_needed_bytes_; | 618 size_t max_memory_needed_bytes_; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 std::set<SwapPromiseMonitor*> swap_promise_monitor_; | 678 std::set<SwapPromiseMonitor*> swap_promise_monitor_; |
682 | 679 |
683 size_t transfer_buffer_memory_limit_; | 680 size_t transfer_buffer_memory_limit_; |
684 | 681 |
685 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 682 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
686 }; | 683 }; |
687 | 684 |
688 } // namespace cc | 685 } // namespace cc |
689 | 686 |
690 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 687 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
OLD | NEW |