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
3 // found in the LICENSE file.
5 #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_
6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_
13 #include "base/basictypes.h"
14 #include "base/containers/hash_tables.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/time/time.h"
17 #include "cc/animation/animation_events.h"
18 #include "cc/animation/animation_registrar.h"
19 #include "cc/animation/scrollbar_animation_controller.h"
20 #include "cc/base/cc_export.h"
21 #include "cc/debug/micro_benchmark_controller_impl.h"
22 #include "cc/input/input_handler.h"
23 #include "cc/input/layer_scroll_offset_delegate.h"
24 #include "cc/input/top_controls_manager_client.h"
25 #include "cc/layers/layer_lists.h"
26 #include "cc/layers/render_pass_sink.h"
27 #include "cc/output/begin_frame_args.h"
28 #include "cc/output/managed_memory_policy.h"
29 #include "cc/output/output_surface_client.h"
30 #include "cc/output/renderer.h"
31 #include "cc/quads/render_pass.h"
32 #include "cc/resources/resource_provider.h"
33 #include "cc/resources/tile_manager.h"
34 #include "cc/scheduler/draw_swap_readback_result.h"
35 #include "skia/ext/refptr.h"
36 #include "third_party/skia/include/core/SkColor.h"
37 #include "ui/gfx/rect.h"
41 class CompletionEvent;
42 class CompositorFrameMetadata;
43 class DebugRectHistory;
44 class FrameRateCounter;
46 class LayerTreeHostImplTimeSourceAdapter;
49 class PageScaleAnimation;
50 class PaintTimeCounter;
51 class RasterWorkerPool;
52 class RenderPassDrawQuad;
53 class RenderingStatsInstrumentation;
55 class ScrollbarLayerImplBase;
56 class TextureMailboxDeleter;
57 class TopControlsManager;
58 class UIResourceBitmap;
59 class UIResourceRequest;
60 struct RendererCapabilitiesImpl;
62 // LayerTreeHost->Proxy callback interface.
63 class LayerTreeHostImplClient {
65 virtual void UpdateRendererCapabilitiesOnImplThread() = 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;
70 virtual void SetMaxSwapsPendingOnImplThread(int max) = 0;
71 virtual void DidSwapBuffersOnImplThread() = 0;
72 virtual void DidSwapBuffersCompleteOnImplThread() = 0;
73 virtual void BeginFrame(const BeginFrameArgs& args) = 0;
74 virtual void OnCanDrawStateChanged(bool can_draw) = 0;
75 virtual void NotifyReadyToActivate() = 0;
76 // Please call these 3 functions through
77 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and
79 virtual void SetNeedsRedrawOnImplThread() = 0;
80 virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0;
81 virtual void SetNeedsAnimateOnImplThread() = 0;
82 virtual void DidInitializeVisibleTileOnImplThread() = 0;
83 virtual void SetNeedsCommitOnImplThread() = 0;
84 virtual void SetNeedsManageTilesOnImplThread() = 0;
85 virtual void PostAnimationEventsToMainThreadOnImplThread(
86 scoped_ptr<AnimationEventsVector> events) = 0;
87 // Returns true if resources were deleted by this call.
88 virtual bool ReduceContentsTextureMemoryOnImplThread(
90 int priority_cutoff) = 0;
91 virtual void SendManagedMemoryStats() = 0;
92 virtual bool IsInsideDraw() = 0;
93 virtual void RenewTreePriority() = 0;
94 virtual void PostDelayedScrollbarFadeOnImplThread(
95 const base::Closure& start_fade,
96 base::TimeDelta delay) = 0;
97 virtual void DidActivatePendingTree() = 0;
98 virtual void DidManageTiles() = 0;
101 virtual ~LayerTreeHostImplClient() {}
104 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
106 class CC_EXPORT LayerTreeHostImpl
107 : public InputHandler,
108 public RendererClient,
109 public TileManagerClient,
110 public OutputSurfaceClient,
111 public TopControlsManagerClient,
112 public ScrollbarAnimationControllerClient,
113 public base::SupportsWeakPtr<LayerTreeHostImpl> {
115 static scoped_ptr<LayerTreeHostImpl> Create(
116 const LayerTreeSettings& settings,
117 LayerTreeHostImplClient* client,
119 RenderingStatsInstrumentation* rendering_stats_instrumentation,
120 SharedBitmapManager* manager,
122 virtual ~LayerTreeHostImpl();
124 // InputHandler implementation
125 virtual void BindToClient(InputHandlerClient* client) OVERRIDE;
126 virtual InputHandler::ScrollStatus ScrollBegin(
127 const gfx::Point& viewport_point,
128 InputHandler::ScrollInputType type) OVERRIDE;
129 virtual bool ScrollBy(const gfx::Point& viewport_point,
130 const gfx::Vector2dF& scroll_delta) OVERRIDE;
131 virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point,
132 ScrollDirection direction) OVERRIDE;
133 virtual void SetRootLayerScrollOffsetDelegate(
134 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) OVERRIDE;
135 virtual void OnRootLayerDelegatedScrollOffsetChanged() OVERRIDE;
136 virtual void ScrollEnd() OVERRIDE;
137 virtual InputHandler::ScrollStatus FlingScrollBegin() OVERRIDE;
138 virtual void MouseMoveAt(const gfx::Point& viewport_point) OVERRIDE;
139 virtual void PinchGestureBegin() OVERRIDE;
140 virtual void PinchGestureUpdate(float magnify_delta,
141 const gfx::Point& anchor) OVERRIDE;
142 virtual void PinchGestureEnd() OVERRIDE;
143 virtual void StartPageScaleAnimation(const gfx::Vector2d& target_offset,
146 base::TimeDelta duration) OVERRIDE;
147 virtual void SetNeedsAnimate() OVERRIDE;
148 virtual bool IsCurrentlyScrollingLayerAt(
149 const gfx::Point& viewport_point,
150 InputHandler::ScrollInputType type) OVERRIDE;
151 virtual bool HaveTouchEventHandlersAt(
152 const gfx::Point& viewport_port) OVERRIDE;
153 virtual scoped_ptr<SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor(
154 ui::LatencyInfo* latency) OVERRIDE;
156 // TopControlsManagerClient implementation.
157 virtual void DidChangeTopControlsPosition() OVERRIDE;
158 virtual bool HaveRootScrollLayer() const OVERRIDE;
160 struct CC_EXPORT FrameData : public RenderPassSink {
162 virtual ~FrameData();
163 scoped_ptr<base::Value> AsValue() const;
165 std::vector<gfx::Rect> occluding_screen_space_rects;
166 std::vector<gfx::Rect> non_occluding_screen_space_rects;
167 RenderPassList render_passes;
168 RenderPassIdHashMap render_passes_by_id;
169 const LayerImplList* render_surface_layer_list;
170 LayerImplList will_draw_layers;
171 bool contains_incomplete_tile;
174 // RenderPassSink implementation.
175 virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE;
178 virtual void BeginMainFrameAborted(bool did_handle);
179 virtual void BeginCommit();
180 virtual void CommitComplete();
181 virtual void Animate(base::TimeTicks monotonic_time);
182 virtual void UpdateAnimationState(bool start_ready_animations);
183 void ActivateAnimations();
184 void MainThreadHasStoppedFlinging();
185 void UpdateBackgroundAnimateTicking(bool should_background_tick);
186 void DidAnimateScrollOffset();
187 void SetViewportDamage(const gfx::Rect& damage_rect);
189 virtual void ManageTiles();
191 // Returns false if problems occured preparing the frame, and we should try
192 // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers
193 // must also be called, regardless of whether DrawLayers is called between the
195 virtual DrawSwapReadbackResult::DrawResult PrepareToDraw(
197 const gfx::Rect& damage_rect);
198 virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time);
199 // Must be called if and only if PrepareToDraw was called.
200 void DidDrawAllLayers(const FrameData& frame);
202 const LayerTreeSettings& settings() const { return settings_; }
204 // Evict all textures by enforcing a memory policy with an allocation of 0.
205 void EvictTexturesForTesting();
207 // When blocking, this prevents client_->NotifyReadyToActivate() from being
208 // called. When disabled, it calls client_->NotifyReadyToActivate()
209 // immediately if any notifications had been blocked while blocking.
210 virtual void BlockNotifyReadyToActivateForTesting(bool block);
212 // This allows us to inject DidInitializeVisibleTile events for testing.
213 void DidInitializeVisibleTileForTesting();
215 bool device_viewport_valid_for_tile_management() const {
216 return device_viewport_valid_for_tile_management_;
219 // Viewport size in draw space: this size is in physical pixels and is used
220 // for draw properties, tilings, quads and render passes.
221 gfx::Size DrawViewportSize() const;
223 // Viewport size for scrolling and fixed-position compensation. This value
224 // excludes the URL bar and non-overlay scrollbars and is in DIP (and
225 // invariant relative to page scale).
226 gfx::SizeF UnscaledScrollableViewportSize() const;
227 float VerticalAdjust() const;
229 // RendererClient implementation.
230 virtual void SetFullRootLayerDamage() OVERRIDE;
232 // TileManagerClient implementation.
233 virtual void NotifyReadyToActivate() OVERRIDE;
234 virtual void NotifyTileInitialized(const Tile* tile) OVERRIDE;
236 // ScrollbarAnimationControllerClient implementation.
237 virtual void PostDelayedScrollbarFade(const base::Closure& start_fade,
238 base::TimeDelta delay) OVERRIDE;
239 virtual void SetNeedsScrollbarAnimationFrame() OVERRIDE;
241 // OutputSurfaceClient implementation.
242 virtual void DeferredInitialize() OVERRIDE;
243 virtual void ReleaseGL() OVERRIDE;
244 virtual void CommitVSyncParameters(base::TimeTicks timebase,
245 base::TimeDelta interval) OVERRIDE;
246 virtual void SetNeedsRedrawRect(const gfx::Rect& rect) OVERRIDE;
247 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE;
248 virtual void SetExternalDrawConstraints(
249 const gfx::Transform& transform,
250 const gfx::Rect& viewport,
251 const gfx::Rect& clip,
252 bool valid_for_tile_management) OVERRIDE;
253 virtual void DidLoseOutputSurface() OVERRIDE;
254 virtual void DidSwapBuffers() OVERRIDE;
255 virtual void DidSwapBuffersComplete() OVERRIDE;
256 virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE;
257 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE;
258 virtual void SetTreeActivationCallback(const base::Closure& callback)
261 // Called from LayerTreeImpl.
262 void OnCanDrawStateChangedForTree();
265 bool CanDraw() const;
266 OutputSurface* output_surface() const { return output_surface_.get(); }
268 std::string LayerTreeAsJson() const;
270 void FinishAllRendering();
271 int SourceAnimationFrameNumber() const;
273 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface);
274 bool IsContextLost();
275 TileManager* tile_manager() { return tile_manager_.get(); }
276 ResourcePool* resource_pool() { return resource_pool_.get(); }
277 Renderer* renderer() { return renderer_.get(); }
278 const RendererCapabilitiesImpl& GetRendererCapabilities() const;
280 virtual bool SwapBuffers(const FrameData& frame);
281 void SetNeedsBeginFrame(bool enable);
282 virtual void WillBeginImplFrame(const BeginFrameArgs& args);
283 void DidModifyTilePriorities();
285 void Readback(void* pixels, const gfx::Rect& rect_in_device_viewport);
287 LayerTreeImpl* active_tree() { return active_tree_.get(); }
288 const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
289 LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
290 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
291 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
292 virtual void CreatePendingTree();
293 virtual void UpdateVisibleTiles();
294 virtual void ActivatePendingTree();
296 // Shortcuts to layers on the active tree.
297 LayerImpl* RootLayer() const;
298 LayerImpl* InnerViewportScrollLayer() const;
299 LayerImpl* OuterViewportScrollLayer() const;
300 LayerImpl* CurrentlyScrollingLayer() const;
302 int scroll_layer_id_when_mouse_over_scrollbar() const {
303 return scroll_layer_id_when_mouse_over_scrollbar_;
305 bool scroll_affects_scroll_handler() const {
306 return scroll_affects_scroll_handler_;
309 bool IsCurrentlyScrolling() const;
311 virtual void SetVisible(bool visible);
312 bool visible() const { return visible_; }
314 void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); }
315 void SetNeedsRedraw();
317 ManagedMemoryPolicy ActualManagedMemoryPolicy() const;
319 size_t memory_allocation_limit_bytes() const;
320 int memory_allocation_priority_cutoff() const;
322 void SetViewportSize(const gfx::Size& device_viewport_size);
323 gfx::Size device_viewport_size() const { return device_viewport_size_; }
325 void SetOverdrawBottomHeight(float overdraw_bottom_height);
326 float overdraw_bottom_height() const { return overdraw_bottom_height_; }
328 void SetOverhangUIResource(UIResourceId overhang_ui_resource_id,
329 const gfx::Size& overhang_ui_resource_size);
331 void SetDeviceScaleFactor(float device_scale_factor);
332 float device_scale_factor() const { return device_scale_factor_; }
334 const gfx::Transform& DrawTransform() const;
336 scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
338 bool needs_animate_layers() const {
339 return !animation_registrar_->active_animation_controllers().empty();
342 void SendManagedMemoryStats(
343 size_t memory_visible_bytes,
344 size_t memory_visible_and_nearby_bytes,
345 size_t memory_use_bytes);
347 void set_max_memory_needed_bytes(size_t bytes) {
348 max_memory_needed_bytes_ = bytes;
351 FrameRateCounter* fps_counter() {
352 return fps_counter_.get();
354 PaintTimeCounter* paint_time_counter() {
355 return paint_time_counter_.get();
357 MemoryHistory* memory_history() {
358 return memory_history_.get();
360 DebugRectHistory* debug_rect_history() {
361 return debug_rect_history_.get();
363 ResourceProvider* resource_provider() {
364 return resource_provider_.get();
366 TopControlsManager* top_controls_manager() {
367 return top_controls_manager_.get();
369 const GlobalStateThatImpactsTilePriority& global_tile_state() {
370 return global_tile_state_;
373 Proxy* proxy() const { return proxy_; }
375 AnimationRegistrar* animation_registrar() const {
376 return animation_registrar_.get();
379 void SetDebugState(const LayerTreeDebugState& new_debug_state);
380 const LayerTreeDebugState& debug_state() const { return debug_state_; }
382 class CC_EXPORT CullRenderPassesWithNoQuads {
384 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
385 const FrameData& frame) const;
387 // Iterates in draw order, so that when a surface is removed, and its
388 // target becomes empty, then its target can be removed also.
389 size_t RenderPassListBegin(const RenderPassList& list) const { return 0; }
390 size_t RenderPassListEnd(const RenderPassList& list) const {
393 size_t RenderPassListNext(size_t it) const { return it + 1; }
396 template <typename RenderPassCuller>
397 static void RemoveRenderPasses(RenderPassCuller culler, FrameData* frame);
399 gfx::Vector2dF accumulated_root_overscroll() const {
400 return accumulated_root_overscroll_;
403 bool pinch_gesture_active() const { return pinch_gesture_active_; }
405 void SetTreePriority(TreePriority priority);
407 void UpdateCurrentFrameTime();
408 void ResetCurrentFrameTimeForNextFrame();
409 virtual base::TimeTicks CurrentFrameTimeTicks();
411 // Expected time between two begin impl frame calls.
412 base::TimeDelta begin_impl_frame_interval() const {
413 return begin_impl_frame_interval_;
416 scoped_ptr<base::Value> AsValue() const { return AsValueWithFrame(NULL); }
417 scoped_ptr<base::Value> AsValueWithFrame(FrameData* frame) const;
418 scoped_ptr<base::Value> ActivationStateAsValue() const;
420 bool page_scale_animation_active() const { return !!page_scale_animation_; }
422 virtual void CreateUIResource(UIResourceId uid,
423 const UIResourceBitmap& bitmap);
424 // Deletes a UI resource. May safely be called more than once.
425 virtual void DeleteUIResource(UIResourceId uid);
426 void EvictAllUIResources();
427 bool EvictedUIResourcesExist() const;
429 virtual ResourceProvider::ResourceId ResourceIdForUIResource(
430 UIResourceId uid) const;
432 virtual bool IsUIResourceOpaque(UIResourceId uid) const;
434 struct UIResourceData {
435 ResourceProvider::ResourceId resource_id;
440 void ScheduleMicroBenchmark(scoped_ptr<MicroBenchmarkImpl> benchmark);
442 CompositorFrameMetadata MakeCompositorFrameMetadata() const;
443 // Viewport rectangle and clip in nonflipped window space. These rects
444 // should only be used by Renderer subclasses to populate glViewport/glClip
445 // and their software-mode equivalents.
446 gfx::Rect DeviceViewport() const;
447 gfx::Rect DeviceClip() const;
449 // When a SwapPromiseMonitor is created on the impl thread, it calls
450 // InsertSwapPromiseMonitor() to register itself with LayerTreeHostImpl.
451 // When the monitor is destroyed, it calls RemoveSwapPromiseMonitor()
452 // to unregister itself.
453 void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor);
454 void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor);
458 const LayerTreeSettings& settings,
459 LayerTreeHostImplClient* client,
461 RenderingStatsInstrumentation* rendering_stats_instrumentation,
462 SharedBitmapManager* manager,
465 gfx::SizeF ComputeInnerViewportContainerSize() const;
466 void UpdateInnerViewportContainerSize();
468 // Virtual for testing.
469 virtual void AnimateLayers(base::TimeTicks monotonic_time);
471 // Virtual for testing.
472 virtual base::TimeDelta LowFrequencyAnimationInterval() const;
474 const AnimationRegistrar::AnimationControllerMap&
475 active_animation_controllers() const {
476 return animation_registrar_->active_animation_controllers();
479 bool manage_tiles_needed() const { return tile_priorities_dirty_; }
481 LayerTreeHostImplClient* client_;
485 void CreateAndSetRenderer(
486 OutputSurface* output_surface,
487 ResourceProvider* resource_provider,
488 bool skip_gl_renderer);
489 void CreateAndSetTileManager(ResourceProvider* resource_provider,
490 ContextProvider* context_provider,
493 bool allow_rasterize_on_demand);
494 void ReleaseTreeResources();
495 void EnforceZeroBudget(bool zero_budget);
497 void ScrollViewportBy(gfx::Vector2dF scroll_delta);
498 void AnimatePageScale(base::TimeTicks monotonic_time);
499 void AnimateScrollbars(base::TimeTicks monotonic_time);
500 void AnimateTopControls(base::TimeTicks monotonic_time);
502 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
503 LayerImpl* layer_impl,
504 float scale_from_viewport_to_screen_space,
505 const gfx::PointF& viewport_point,
506 const gfx::Vector2dF& viewport_delta);
508 void TrackDamageForAllSurfaces(
509 LayerImpl* root_draw_layer,
510 const LayerImplList& render_surface_layer_list);
512 void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy);
514 // This function should only be called from PrepareToDraw, as DidDrawAllLayers
515 // must be called if this helper function is called. Returns DRAW_SUCCESS if
516 // the frame should be drawn.
517 DrawSwapReadbackResult::DrawResult CalculateRenderPasses(FrameData* frame);
519 bool EnsureRenderSurfaceLayerList();
520 void ClearCurrentlyScrollingLayer();
522 bool HandleMouseOverScrollbar(LayerImpl* layer_impl,
523 const gfx::PointF& device_viewport_point);
525 void AnimateScrollbarsRecursive(LayerImpl* layer,
526 base::TimeTicks time);
528 LayerImpl* FindScrollLayerForDeviceViewportPoint(
529 const gfx::PointF& device_viewport_point,
530 InputHandler::ScrollInputType type,
531 LayerImpl* layer_hit_by_point,
532 bool* scroll_on_main_thread,
533 bool* optional_has_ancestor_scroll_handler) const;
534 float DeviceSpaceDistanceToLayer(const gfx::PointF& device_viewport_point,
535 LayerImpl* layer_impl);
536 void StartScrollbarFadeRecursive(LayerImpl* layer);
537 void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy,
539 void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy);
541 void DidInitializeVisibleTile();
543 void MarkUIResourceNotEvicted(UIResourceId uid);
545 void NotifySwapPromiseMonitorsOfSetNeedsRedraw();
547 typedef base::hash_map<UIResourceId, UIResourceData>
549 UIResourceMap ui_resource_map_;
551 // Resources that were evicted by EvictAllUIResources. Resources are removed
552 // from this when they are touched by a create or destroy from the UI resource
554 std::set<UIResourceId> evicted_ui_resources_;
556 scoped_ptr<OutputSurface> output_surface_;
557 scoped_refptr<ContextProvider> offscreen_context_provider_;
559 // |resource_provider_| and |tile_manager_| can be NULL, e.g. when using tile-
560 // free rendering - see OutputSurface::ForcedDrawToSoftwareDevice().
561 scoped_ptr<ResourceProvider> resource_provider_;
562 scoped_ptr<TileManager> tile_manager_;
563 scoped_ptr<RasterWorkerPool> raster_worker_pool_;
564 scoped_ptr<RasterWorkerPool> direct_raster_worker_pool_;
565 scoped_ptr<ResourcePool> resource_pool_;
566 scoped_ptr<ResourcePool> staging_resource_pool_;
567 scoped_ptr<Renderer> renderer_;
569 GlobalStateThatImpactsTilePriority global_tile_state_;
571 // Tree currently being drawn.
572 scoped_ptr<LayerTreeImpl> active_tree_;
574 // In impl-side painting mode, tree with possibly incomplete rasterized
575 // content. May be promoted to active by ActivatePendingTree().
576 scoped_ptr<LayerTreeImpl> pending_tree_;
578 // In impl-side painting mode, inert tree with layers that can be recycled
579 // by the next sync from the main thread.
580 scoped_ptr<LayerTreeImpl> recycle_tree_;
582 InputHandlerClient* input_handler_client_;
583 bool did_lock_scrolling_layer_;
584 bool should_bubble_scrolls_;
585 bool wheel_scrolling_;
586 bool scroll_affects_scroll_handler_;
587 int scroll_layer_id_when_mouse_over_scrollbar_;
589 bool tile_priorities_dirty_;
591 // The optional delegate for the root layer scroll offset.
592 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_;
593 LayerTreeSettings settings_;
594 LayerTreeDebugState debug_state_;
596 ManagedMemoryPolicy cached_managed_memory_policy_;
598 gfx::Vector2dF accumulated_root_overscroll_;
600 bool pinch_gesture_active_;
601 bool pinch_gesture_end_should_clear_scrolling_layer_;
602 gfx::Point previous_pinch_anchor_;
604 scoped_ptr<TopControlsManager> top_controls_manager_;
606 scoped_ptr<PageScaleAnimation> page_scale_animation_;
608 // This is used for ticking animations slowly when hidden.
609 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_;
611 scoped_ptr<FrameRateCounter> fps_counter_;
612 scoped_ptr<PaintTimeCounter> paint_time_counter_;
613 scoped_ptr<MemoryHistory> memory_history_;
614 scoped_ptr<DebugRectHistory> debug_rect_history_;
616 scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_;
618 // The maximum memory that would be used by the prioritized resource
619 // manager, if there were no limit on memory usage.
620 size_t max_memory_needed_bytes_;
622 size_t last_sent_memory_visible_bytes_;
623 size_t last_sent_memory_visible_and_nearby_bytes_;
624 size_t last_sent_memory_use_bytes_;
627 // Viewport size passed in from the main thread, in physical pixels. This
628 // value is the default size for all concepts of physical viewport (draw
629 // viewport, scrolling viewport and device viewport), but it can be
631 gfx::Size device_viewport_size_;
633 // Conversion factor from CSS pixels to physical pixels when
634 // pageScaleFactor=1.
635 float device_scale_factor_;
637 // UI resource to use for drawing overhang gutters.
638 UIResourceId overhang_ui_resource_id_;
639 gfx::Size overhang_ui_resource_size_;
641 // Vertical amount of the viewport size that's known to covered by a
642 // browser-side UI element, such as an on-screen-keyboard. This affects
643 // scrollable size since we want to still be able to scroll to the bottom of
644 // the page when the keyboard is up.
645 float overdraw_bottom_height_;
647 // Optional top-level constraints that can be set by the OutputSurface.
648 // - external_transform_ applies a transform above the root layer
649 // - external_viewport_ is used DrawProperties, tile management and
650 // glViewport/window projection matrix.
651 // - external_clip_ specifies a top-level clip rect
652 gfx::Transform external_transform_;
653 gfx::Rect external_viewport_;
654 gfx::Rect external_clip_;
655 bool device_viewport_valid_for_tile_management_;
657 gfx::Rect viewport_damage_rect_;
659 base::TimeTicks current_frame_timeticks_;
661 // Expected time between two begin impl frame calls.
662 base::TimeDelta begin_impl_frame_interval_;
664 scoped_ptr<AnimationRegistrar> animation_registrar_;
666 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
667 MicroBenchmarkControllerImpl micro_benchmark_controller_;
669 bool need_to_update_visible_tiles_before_draw_;
671 bool did_lose_called_;
674 // Optional callback to notify of new tree activations.
675 base::Closure tree_activation_callback_;
677 SharedBitmapManager* shared_bitmap_manager_;
680 std::set<SwapPromiseMonitor*> swap_promise_monitor_;
682 size_t transfer_buffer_memory_limit_;
684 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
689 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_