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/base/cc_export.h"
20 #include "cc/debug/micro_benchmark_controller_impl.h"
21 #include "cc/input/input_handler.h"
22 #include "cc/input/layer_scroll_offset_delegate.h"
23 #include "cc/input/top_controls_manager_client.h"
24 #include "cc/layers/layer_lists.h"
25 #include "cc/layers/render_pass_sink.h"
26 #include "cc/output/begin_frame_args.h"
27 #include "cc/output/managed_memory_policy.h"
28 #include "cc/output/output_surface_client.h"
29 #include "cc/output/renderer.h"
30 #include "cc/quads/render_pass.h"
31 #include "cc/resources/resource_provider.h"
32 #include "cc/resources/tile_manager.h"
33 #include "cc/scheduler/draw_swap_readback_result.h"
34 #include "skia/ext/refptr.h"
35 #include "third_party/skia/include/core/SkColor.h"
36 #include "ui/gfx/rect.h"
40 class CompletionEvent;
41 class CompositorFrameMetadata;
42 class DebugRectHistory;
43 class FrameRateCounter;
45 class LayerTreeHostImplTimeSourceAdapter;
47 class PageScaleAnimation;
48 class PaintTimeCounter;
50 class RenderingStatsInstrumentation;
51 class RenderPassDrawQuad;
52 class ScrollbarLayerImplBase;
53 class TextureMailboxDeleter;
54 class TopControlsManager;
55 class UIResourceBitmap;
56 class UIResourceRequest;
57 struct RendererCapabilitiesImpl;
59 // LayerTreeHost->Proxy callback interface.
60 class LayerTreeHostImplClient {
62 virtual void UpdateRendererCapabilitiesOnImplThread() = 0;
63 virtual void DidLoseOutputSurfaceOnImplThread() = 0;
64 virtual void DidSwapBuffersOnImplThread() = 0;
65 virtual void OnSwapBuffersCompleteOnImplThread() = 0;
66 virtual void BeginImplFrame(const BeginFrameArgs& args) = 0;
67 virtual void OnCanDrawStateChanged(bool can_draw) = 0;
68 virtual void NotifyReadyToActivate() = 0;
69 // Please call these 2 functions through
70 // LayerTreeHostImpl's SetNeedsRedraw() and SetNeedsRedrawRect().
71 virtual void SetNeedsRedrawOnImplThread() = 0;
72 virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0;
73 virtual void DidInitializeVisibleTileOnImplThread() = 0;
74 virtual void SetNeedsCommitOnImplThread() = 0;
75 virtual void SetNeedsManageTilesOnImplThread() = 0;
76 virtual void PostAnimationEventsToMainThreadOnImplThread(
77 scoped_ptr<AnimationEventsVector> events) = 0;
78 // Returns true if resources were deleted by this call.
79 virtual bool ReduceContentsTextureMemoryOnImplThread(
81 int priority_cutoff) = 0;
82 virtual void SendManagedMemoryStats() = 0;
83 virtual bool IsInsideDraw() = 0;
84 virtual void RenewTreePriority() = 0;
85 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) = 0;
86 virtual void DidActivatePendingTree() = 0;
87 virtual void DidManageTiles() = 0;
90 virtual ~LayerTreeHostImplClient() {}
93 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
95 class CC_EXPORT LayerTreeHostImpl
96 : public InputHandler,
97 public RendererClient,
98 public TileManagerClient,
99 public OutputSurfaceClient,
100 public TopControlsManagerClient,
101 public base::SupportsWeakPtr<LayerTreeHostImpl> {
103 static scoped_ptr<LayerTreeHostImpl> Create(
104 const LayerTreeSettings& settings,
105 LayerTreeHostImplClient* client,
107 RenderingStatsInstrumentation* rendering_stats_instrumentation,
108 SharedBitmapManager* manager,
110 virtual ~LayerTreeHostImpl();
112 // InputHandler implementation
113 virtual void BindToClient(InputHandlerClient* client) OVERRIDE;
114 virtual InputHandler::ScrollStatus ScrollBegin(
115 const gfx::Point& viewport_point,
116 InputHandler::ScrollInputType type) OVERRIDE;
117 virtual bool ScrollBy(const gfx::Point& viewport_point,
118 const gfx::Vector2dF& scroll_delta) OVERRIDE;
119 virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point,
120 ScrollDirection direction) OVERRIDE;
121 virtual void SetRootLayerScrollOffsetDelegate(
122 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) OVERRIDE;
123 virtual void OnRootLayerDelegatedScrollOffsetChanged() OVERRIDE;
124 virtual void ScrollEnd() OVERRIDE;
125 virtual InputHandler::ScrollStatus FlingScrollBegin() OVERRIDE;
126 virtual void NotifyCurrentFlingVelocity(
127 const gfx::Vector2dF& velocity) OVERRIDE;
128 virtual void MouseMoveAt(const gfx::Point& viewport_point) OVERRIDE;
129 virtual void PinchGestureBegin() OVERRIDE;
130 virtual void PinchGestureUpdate(float magnify_delta,
131 const gfx::Point& anchor) OVERRIDE;
132 virtual void PinchGestureEnd() OVERRIDE;
133 virtual void StartPageScaleAnimation(const gfx::Vector2d& target_offset,
136 base::TimeDelta duration) OVERRIDE;
137 virtual void ScheduleAnimation() OVERRIDE;
138 virtual bool HaveTouchEventHandlersAt(const gfx::Point& viewport_port)
140 virtual scoped_ptr<SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor(
141 ui::LatencyInfo* latency) OVERRIDE;
143 // TopControlsManagerClient implementation.
144 virtual void DidChangeTopControlsPosition() OVERRIDE;
145 virtual bool HaveRootScrollLayer() const OVERRIDE;
147 void StartScrollbarAnimation();
149 struct CC_EXPORT FrameData : public RenderPassSink {
151 virtual ~FrameData();
152 scoped_ptr<base::Value> AsValue() const;
154 std::vector<gfx::Rect> occluding_screen_space_rects;
155 std::vector<gfx::Rect> non_occluding_screen_space_rects;
156 RenderPassList render_passes;
157 RenderPassIdHashMap render_passes_by_id;
158 const LayerImplList* render_surface_layer_list;
159 LayerImplList will_draw_layers;
160 bool contains_incomplete_tile;
163 // RenderPassSink implementation.
164 virtual void AppendRenderPass(scoped_ptr<RenderPass> render_pass) OVERRIDE;
167 virtual void BeginMainFrameAborted(bool did_handle);
168 virtual void BeginCommit();
169 virtual void CommitComplete();
170 virtual void Animate(base::TimeTicks monotonic_time);
171 virtual void UpdateAnimationState(bool start_ready_animations);
172 void MainThreadHasStoppedFlinging();
173 void UpdateBackgroundAnimateTicking(bool should_background_tick);
174 void DidAnimateScrollOffset();
175 void SetViewportDamage(const gfx::Rect& damage_rect);
177 virtual void ManageTiles();
179 // Returns false if problems occured preparing the frame, and we should try
180 // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers
181 // must also be called, regardless of whether DrawLayers is called between the
183 virtual DrawSwapReadbackResult::DrawResult PrepareToDraw(
185 const gfx::Rect& damage_rect);
186 virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time);
187 // Must be called if and only if PrepareToDraw was called.
188 void DidDrawAllLayers(const FrameData& frame);
190 const LayerTreeSettings& settings() const { return settings_; }
192 // Evict all textures by enforcing a memory policy with an allocation of 0.
193 void EvictTexturesForTesting();
195 // When blocking, this prevents client_->NotifyReadyToActivate() from being
196 // called. When disabled, it calls client_->NotifyReadyToActivate()
197 // immediately if any notifications had been blocked while blocking.
198 virtual void BlockNotifyReadyToActivateForTesting(bool block);
200 // This allows us to inject DidInitializeVisibleTile events for testing.
201 void DidInitializeVisibleTileForTesting();
203 bool device_viewport_valid_for_tile_management() const {
204 return device_viewport_valid_for_tile_management_;
207 // Viewport size in draw space: this size is in physical pixels and is used
208 // for draw properties, tilings, quads and render passes.
209 gfx::Size DrawViewportSize() const;
211 // Viewport size for scrolling and fixed-position compensation. This value
212 // excludes the URL bar and non-overlay scrollbars and is in DIP (and
213 // invariant relative to page scale).
214 gfx::SizeF UnscaledScrollableViewportSize() const;
215 float VerticalAdjust() const;
217 // RendererClient implementation.
218 virtual void SetFullRootLayerDamage() OVERRIDE;
220 // TileManagerClient implementation.
221 virtual void NotifyReadyToActivate() OVERRIDE;
223 // OutputSurfaceClient implementation.
224 virtual bool DeferredInitialize(
225 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE;
226 virtual void ReleaseGL() OVERRIDE;
227 virtual void SetNeedsRedrawRect(const gfx::Rect& rect) OVERRIDE;
228 virtual void BeginImplFrame(const BeginFrameArgs& args) OVERRIDE;
229 virtual void SetExternalDrawConstraints(
230 const gfx::Transform& transform,
231 const gfx::Rect& viewport,
232 const gfx::Rect& clip,
233 bool valid_for_tile_management) OVERRIDE;
234 virtual void DidLoseOutputSurface() OVERRIDE;
235 virtual void DidSwapBuffers() OVERRIDE;
236 virtual void OnSwapBuffersComplete() OVERRIDE;
237 virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE;
238 virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE;
239 virtual void SetTreeActivationCallback(const base::Closure& callback)
242 // Called from LayerTreeImpl.
243 void OnCanDrawStateChangedForTree();
246 bool CanDraw() const;
247 OutputSurface* output_surface() const { return output_surface_.get(); }
249 void SetOffscreenContextProvider(
250 const scoped_refptr<ContextProvider>& offscreen_context_provider);
251 ContextProvider* offscreen_context_provider() const {
252 return offscreen_context_provider_.get();
255 std::string LayerTreeAsJson() const;
257 void FinishAllRendering();
258 int SourceAnimationFrameNumber() const;
260 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface);
261 bool IsContextLost();
262 TileManager* tile_manager() { return tile_manager_.get(); }
263 Renderer* renderer() { return renderer_.get(); }
264 const RendererCapabilitiesImpl& GetRendererCapabilities() const;
266 virtual bool SwapBuffers(const FrameData& frame);
267 void SetNeedsBeginImplFrame(bool enable);
268 void DidModifyTilePriorities();
270 void Readback(void* pixels, const gfx::Rect& rect_in_device_viewport);
272 LayerTreeImpl* active_tree() { return active_tree_.get(); }
273 const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
274 LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
275 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
276 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
277 virtual void CreatePendingTree();
278 virtual void UpdateVisibleTiles();
279 virtual void ActivatePendingTree();
281 // Shortcuts to layers on the active tree.
282 LayerImpl* RootLayer() const;
283 LayerImpl* InnerViewportScrollLayer() const;
284 LayerImpl* OuterViewportScrollLayer() const;
285 LayerImpl* CurrentlyScrollingLayer() const;
287 int scroll_layer_id_when_mouse_over_scrollbar() {
288 return scroll_layer_id_when_mouse_over_scrollbar_;
291 bool IsCurrentlyScrolling() const;
293 virtual void SetVisible(bool visible);
294 bool visible() const { return visible_; }
296 void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); }
297 void SetNeedsRedraw();
299 ManagedMemoryPolicy ActualManagedMemoryPolicy() const;
301 size_t memory_allocation_limit_bytes() const;
302 int memory_allocation_priority_cutoff() const;
304 void SetViewportSize(const gfx::Size& device_viewport_size);
306 void SetOverdrawBottomHeight(float overdraw_bottom_height);
307 float overdraw_bottom_height() const { return overdraw_bottom_height_; }
309 void SetOverhangUIResource(UIResourceId overhang_ui_resource_id,
310 const gfx::Size& overhang_ui_resource_size);
312 void SetDeviceScaleFactor(float device_scale_factor);
313 float device_scale_factor() const { return device_scale_factor_; }
315 const gfx::Transform& DrawTransform() const;
317 scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
319 bool needs_animate_layers() const {
320 return !animation_registrar_->active_animation_controllers().empty();
323 void SendManagedMemoryStats(
324 size_t memory_visible_bytes,
325 size_t memory_visible_and_nearby_bytes,
326 size_t memory_use_bytes);
328 void set_max_memory_needed_bytes(size_t bytes) {
329 max_memory_needed_bytes_ = bytes;
332 FrameRateCounter* fps_counter() {
333 return fps_counter_.get();
335 PaintTimeCounter* paint_time_counter() {
336 return paint_time_counter_.get();
338 MemoryHistory* memory_history() {
339 return memory_history_.get();
341 DebugRectHistory* debug_rect_history() {
342 return debug_rect_history_.get();
344 ResourceProvider* resource_provider() {
345 return resource_provider_.get();
347 TopControlsManager* top_controls_manager() {
348 return top_controls_manager_.get();
350 const GlobalStateThatImpactsTilePriority& global_tile_state() {
351 return global_tile_state_;
354 Proxy* proxy() const { return proxy_; }
356 AnimationRegistrar* animation_registrar() const {
357 return animation_registrar_.get();
360 void SetDebugState(const LayerTreeDebugState& new_debug_state);
361 const LayerTreeDebugState& debug_state() const { return debug_state_; }
363 class CC_EXPORT CullRenderPassesWithNoQuads {
365 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
366 const FrameData& frame) const;
368 // Iterates in draw order, so that when a surface is removed, and its
369 // target becomes empty, then its target can be removed also.
370 size_t RenderPassListBegin(const RenderPassList& list) const { return 0; }
371 size_t RenderPassListEnd(const RenderPassList& list) const {
374 size_t RenderPassListNext(size_t it) const { return it + 1; }
377 template <typename RenderPassCuller>
378 static void RemoveRenderPasses(RenderPassCuller culler, FrameData* frame);
380 gfx::Vector2dF accumulated_root_overscroll() const {
381 return accumulated_root_overscroll_;
383 gfx::Vector2dF current_fling_velocity() const {
384 return current_fling_velocity_;
387 bool pinch_gesture_active() const { return pinch_gesture_active_; }
389 void SetTreePriority(TreePriority priority);
391 void UpdateCurrentFrameTime();
392 void ResetCurrentFrameTimeForNextFrame();
393 virtual base::TimeTicks CurrentFrameTimeTicks();
395 scoped_ptr<base::Value> AsValue() const { return AsValueWithFrame(NULL); }
396 scoped_ptr<base::Value> AsValueWithFrame(FrameData* frame) const;
397 scoped_ptr<base::Value> ActivationStateAsValue() const;
399 bool page_scale_animation_active() const { return !!page_scale_animation_; }
401 virtual void CreateUIResource(UIResourceId uid,
402 const UIResourceBitmap& bitmap);
403 // Deletes a UI resource. May safely be called more than once.
404 virtual void DeleteUIResource(UIResourceId uid);
405 void EvictAllUIResources();
406 bool EvictedUIResourcesExist() const;
408 virtual ResourceProvider::ResourceId ResourceIdForUIResource(
409 UIResourceId uid) const;
411 virtual bool IsUIResourceOpaque(UIResourceId uid) const;
413 struct UIResourceData {
414 ResourceProvider::ResourceId resource_id;
419 void ScheduleMicroBenchmark(scoped_ptr<MicroBenchmarkImpl> benchmark);
421 CompositorFrameMetadata MakeCompositorFrameMetadata() const;
422 // Viewport rectangle and clip in nonflipped window space. These rects
423 // should only be used by Renderer subclasses to populate glViewport/glClip
424 // and their software-mode equivalents.
425 gfx::Rect DeviceViewport() const;
426 gfx::Rect DeviceClip() const;
428 // When a SwapPromiseMonitor is created on the impl thread, it calls
429 // InsertSwapPromiseMonitor() to register itself with LayerTreeHostImpl.
430 // When the monitor is destroyed, it calls RemoveSwapPromiseMonitor()
431 // to unregister itself.
432 void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor);
433 void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor);
437 const LayerTreeSettings& settings,
438 LayerTreeHostImplClient* client,
440 RenderingStatsInstrumentation* rendering_stats_instrumentation,
441 SharedBitmapManager* manager,
444 gfx::SizeF ComputeInnerViewportContainerSize() const;
445 void UpdateInnerViewportContainerSize();
447 // Virtual for testing.
448 virtual void AnimateLayers(base::TimeTicks monotonic_time);
450 // Virtual for testing.
451 virtual base::TimeDelta LowFrequencyAnimationInterval() const;
453 const AnimationRegistrar::AnimationControllerMap&
454 active_animation_controllers() const {
455 return animation_registrar_->active_animation_controllers();
458 bool manage_tiles_needed() const { return tile_priorities_dirty_; }
460 LayerTreeHostImplClient* client_;
464 void CreateAndSetRenderer(
465 OutputSurface* output_surface,
466 ResourceProvider* resource_provider,
467 bool skip_gl_renderer);
468 void CreateAndSetTileManager(ResourceProvider* resource_provider,
469 ContextProvider* context_provider,
470 bool using_map_image,
471 bool allow_rasterize_on_demand);
472 void ReleaseTreeResources();
473 void EnforceZeroBudget(bool zero_budget);
475 void ScrollViewportBy(gfx::Vector2dF scroll_delta);
476 void AnimatePageScale(base::TimeTicks monotonic_time);
477 void AnimateScrollbars(base::TimeTicks monotonic_time);
478 void AnimateTopControls(base::TimeTicks monotonic_time);
480 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
481 LayerImpl* layer_impl,
482 float scale_from_viewport_to_screen_space,
483 const gfx::PointF& viewport_point,
484 const gfx::Vector2dF& viewport_delta);
486 void TrackDamageForAllSurfaces(
487 LayerImpl* root_draw_layer,
488 const LayerImplList& render_surface_layer_list);
490 void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy);
492 // This function should only be called from PrepareToDraw, as DidDrawAllLayers
493 // must be called if this helper function is called. Returns DRAW_SUCCESS if
494 // the frame should be drawn.
495 DrawSwapReadbackResult::DrawResult CalculateRenderPasses(FrameData* frame);
497 void SendReleaseResourcesRecursive(LayerImpl* current);
498 bool EnsureRenderSurfaceLayerList();
499 void ClearCurrentlyScrollingLayer();
501 bool HandleMouseOverScrollbar(LayerImpl* layer_impl,
502 const gfx::PointF& device_viewport_point);
504 void AnimateScrollbarsRecursive(LayerImpl* layer,
505 base::TimeTicks time);
507 LayerImpl* FindScrollLayerForDeviceViewportPoint(
508 const gfx::PointF& device_viewport_point,
509 InputHandler::ScrollInputType type,
510 LayerImpl* layer_hit_by_point,
511 bool* scroll_on_main_thread) const;
512 float DeviceSpaceDistanceToLayer(const gfx::PointF& device_viewport_point,
513 LayerImpl* layer_impl);
514 void StartScrollbarAnimationRecursive(LayerImpl* layer, base::TimeTicks time);
515 void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy,
517 void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy);
519 void DidInitializeVisibleTile();
521 void MarkUIResourceNotEvicted(UIResourceId uid);
523 void NotifySwapPromiseMonitorsOfSetNeedsRedraw();
525 typedef base::hash_map<UIResourceId, UIResourceData>
527 UIResourceMap ui_resource_map_;
529 // Resources that were evicted by EvictAllUIResources. Resources are removed
530 // from this when they are touched by a create or destroy from the UI resource
532 std::set<UIResourceId> evicted_ui_resources_;
534 scoped_ptr<OutputSurface> output_surface_;
535 scoped_refptr<ContextProvider> offscreen_context_provider_;
537 // |resource_provider_| and |tile_manager_| can be NULL, e.g. when using tile-
538 // free rendering - see OutputSurface::ForcedDrawToSoftwareDevice().
539 scoped_ptr<ResourceProvider> resource_provider_;
540 scoped_ptr<TileManager> tile_manager_;
541 scoped_ptr<Renderer> renderer_;
543 GlobalStateThatImpactsTilePriority global_tile_state_;
545 // Tree currently being drawn.
546 scoped_ptr<LayerTreeImpl> active_tree_;
548 // In impl-side painting mode, tree with possibly incomplete rasterized
549 // content. May be promoted to active by ActivatePendingTree().
550 scoped_ptr<LayerTreeImpl> pending_tree_;
552 // In impl-side painting mode, inert tree with layers that can be recycled
553 // by the next sync from the main thread.
554 scoped_ptr<LayerTreeImpl> recycle_tree_;
556 InputHandlerClient* input_handler_client_;
557 bool did_lock_scrolling_layer_;
558 bool should_bubble_scrolls_;
559 bool wheel_scrolling_;
560 int scroll_layer_id_when_mouse_over_scrollbar_;
562 bool tile_priorities_dirty_;
564 // The optional delegate for the root layer scroll offset.
565 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_;
566 LayerTreeSettings settings_;
567 LayerTreeDebugState debug_state_;
569 ManagedMemoryPolicy cached_managed_memory_policy_;
571 gfx::Vector2dF accumulated_root_overscroll_;
572 gfx::Vector2dF current_fling_velocity_;
574 bool pinch_gesture_active_;
575 bool pinch_gesture_end_should_clear_scrolling_layer_;
576 gfx::Point previous_pinch_anchor_;
578 scoped_ptr<TopControlsManager> top_controls_manager_;
580 scoped_ptr<PageScaleAnimation> page_scale_animation_;
582 // This is used for ticking animations slowly when hidden.
583 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_;
585 scoped_ptr<FrameRateCounter> fps_counter_;
586 scoped_ptr<PaintTimeCounter> paint_time_counter_;
587 scoped_ptr<MemoryHistory> memory_history_;
588 scoped_ptr<DebugRectHistory> debug_rect_history_;
590 scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_;
592 // The maximum memory that would be used by the prioritized resource
593 // manager, if there were no limit on memory usage.
594 size_t max_memory_needed_bytes_;
596 size_t last_sent_memory_visible_bytes_;
597 size_t last_sent_memory_visible_and_nearby_bytes_;
598 size_t last_sent_memory_use_bytes_;
601 // Viewport size passed in from the main thread, in physical pixels. This
602 // value is the default size for all concepts of physical viewport (draw
603 // viewport, scrolling viewport and device viewport), but it can be
605 gfx::Size device_viewport_size_;
607 // Conversion factor from CSS pixels to physical pixels when
608 // pageScaleFactor=1.
609 float device_scale_factor_;
611 // UI resource to use for drawing overhang gutters.
612 UIResourceId overhang_ui_resource_id_;
613 gfx::Size overhang_ui_resource_size_;
615 // Vertical amount of the viewport size that's known to covered by a
616 // browser-side UI element, such as an on-screen-keyboard. This affects
617 // scrollable size since we want to still be able to scroll to the bottom of
618 // the page when the keyboard is up.
619 float overdraw_bottom_height_;
621 // Optional top-level constraints that can be set by the OutputSurface.
622 // - external_transform_ applies a transform above the root layer
623 // - external_viewport_ is used DrawProperties, tile management and
624 // glViewport/window projection matrix.
625 // - external_clip_ specifies a top-level clip rect
626 // - external_stencil_test_enabled_ tells CC to respect existing stencil bits
627 // (When these are specified, device_viewport_size_ remains used only for
629 gfx::Transform external_transform_;
630 gfx::Rect external_viewport_;
631 gfx::Rect external_clip_;
632 bool device_viewport_valid_for_tile_management_;
633 bool external_stencil_test_enabled_;
635 gfx::Rect viewport_damage_rect_;
637 base::TimeTicks current_frame_timeticks_;
639 scoped_ptr<AnimationRegistrar> animation_registrar_;
641 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
642 MicroBenchmarkControllerImpl micro_benchmark_controller_;
644 bool need_to_update_visible_tiles_before_draw_;
646 bool did_lose_called_;
649 // Optional callback to notify of new tree activations.
650 base::Closure tree_activation_callback_;
652 SharedBitmapManager* shared_bitmap_manager_;
655 std::set<SwapPromiseMonitor*> swap_promise_monitor_;
657 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
662 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_