[safe browsing] Push missing download BINHASH histograms.
[chromium-blink-merge.git] / cc / trees / layer_tree_host_impl.h
blob5af40ee75b8f572a712895b9877d7cfba09e8be1
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_
8 #include <list>
9 #include <set>
10 #include <string>
11 #include <vector>
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"
38 namespace cc {
40 class CompletionEvent;
41 class CompositorFrameMetadata;
42 class DebugRectHistory;
43 class FrameRateCounter;
44 class LayerImpl;
45 class LayerTreeHostImplTimeSourceAdapter;
46 class LayerTreeImpl;
47 class PageScaleAnimation;
48 class PaintTimeCounter;
49 class MemoryHistory;
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 {
61 public:
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,
78 base::Time wall_clock_time) = 0;
79 // Returns true if resources were deleted by this call.
80 virtual bool ReduceContentsTextureMemoryOnImplThread(
81 size_t limit_bytes,
82 int priority_cutoff) = 0;
83 virtual void SendManagedMemoryStats() = 0;
84 virtual bool IsInsideDraw() = 0;
85 virtual void RenewTreePriority() = 0;
86 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) = 0;
87 virtual void DidActivatePendingTree() = 0;
88 virtual void DidManageTiles() = 0;
90 protected:
91 virtual ~LayerTreeHostImplClient() {}
94 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
95 // state.
96 class CC_EXPORT LayerTreeHostImpl
97 : public InputHandler,
98 public RendererClient,
99 public TileManagerClient,
100 public OutputSurfaceClient,
101 public TopControlsManagerClient,
102 public base::SupportsWeakPtr<LayerTreeHostImpl> {
103 public:
104 static scoped_ptr<LayerTreeHostImpl> Create(
105 const LayerTreeSettings& settings,
106 LayerTreeHostImplClient* client,
107 Proxy* proxy,
108 RenderingStatsInstrumentation* rendering_stats_instrumentation,
109 SharedBitmapManager* manager,
110 int id);
111 virtual ~LayerTreeHostImpl();
113 // InputHandler implementation
114 virtual void BindToClient(InputHandlerClient* client) OVERRIDE;
115 virtual InputHandler::ScrollStatus ScrollBegin(
116 gfx::Point viewport_point,
117 InputHandler::ScrollInputType type) OVERRIDE;
118 virtual bool ScrollBy(gfx::Point viewport_point,
119 const gfx::Vector2dF& scroll_delta) OVERRIDE;
120 virtual bool ScrollVerticallyByPage(gfx::Point viewport_point,
121 ScrollDirection direction) OVERRIDE;
122 virtual void SetRootLayerScrollOffsetDelegate(
123 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) OVERRIDE;
124 virtual void OnRootLayerDelegatedScrollOffsetChanged() OVERRIDE;
125 virtual void ScrollEnd() OVERRIDE;
126 virtual InputHandler::ScrollStatus FlingScrollBegin() OVERRIDE;
127 virtual void NotifyCurrentFlingVelocity(
128 const gfx::Vector2dF& velocity) OVERRIDE;
129 virtual void MouseMoveAt(gfx::Point viewport_point) OVERRIDE;
130 virtual void PinchGestureBegin() OVERRIDE;
131 virtual void PinchGestureUpdate(float magnify_delta,
132 gfx::Point anchor) OVERRIDE;
133 virtual void PinchGestureEnd() OVERRIDE;
134 virtual void StartPageScaleAnimation(const gfx::Vector2d& target_offset,
135 bool anchor_point,
136 float page_scale,
137 base::TimeDelta duration) OVERRIDE;
138 virtual void ScheduleAnimation() OVERRIDE;
139 virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_port) OVERRIDE;
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 {
150 FrameData();
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;
161 bool has_no_damage;
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 base::Time wall_clock_time);
172 virtual void UpdateAnimationState(bool start_ready_animations);
173 void MainThreadHasStoppedFlinging();
174 void UpdateBackgroundAnimateTicking(bool should_background_tick);
175 void DidAnimateScrollOffset();
176 void SetViewportDamage(const gfx::Rect& damage_rect);
178 virtual void ManageTiles();
180 // Returns false if problems occured preparing the frame, and we should try
181 // to avoid displaying the frame. If PrepareToDraw is called, DidDrawAllLayers
182 // must also be called, regardless of whether DrawLayers is called between the
183 // two.
184 virtual DrawSwapReadbackResult::DrawResult PrepareToDraw(
185 FrameData* frame,
186 const gfx::Rect& damage_rect);
187 virtual void DrawLayers(FrameData* frame, base::TimeTicks frame_begin_time);
188 // Must be called if and only if PrepareToDraw was called.
189 void DidDrawAllLayers(const FrameData& frame);
191 const LayerTreeSettings& settings() const { return settings_; }
193 // Evict all textures by enforcing a memory policy with an allocation of 0.
194 void EvictTexturesForTesting();
196 // When blocking, this prevents client_->NotifyReadyToActivate() from being
197 // called. When disabled, it calls client_->NotifyReadyToActivate()
198 // immediately if any notifications had been blocked while blocking.
199 virtual void BlockNotifyReadyToActivateForTesting(bool block);
201 // This allows us to inject DidInitializeVisibleTile events for testing.
202 void DidInitializeVisibleTileForTesting();
204 bool device_viewport_valid_for_tile_management() const {
205 return device_viewport_valid_for_tile_management_;
208 // Viewport size in draw space: this size is in physical pixels and is used
209 // for draw properties, tilings, quads and render passes.
210 gfx::Size DrawViewportSize() const;
212 // Viewport size for scrolling and fixed-position compensation. This value
213 // excludes the URL bar and non-overlay scrollbars and is in DIP (and
214 // invariant relative to page scale).
215 gfx::SizeF UnscaledScrollableViewportSize() 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)
240 OVERRIDE;
242 // Called from LayerTreeImpl.
243 void OnCanDrawStateChangedForTree();
245 // Implementation.
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();
351 Proxy* proxy() const { return proxy_; }
353 AnimationRegistrar* animation_registrar() const {
354 return animation_registrar_.get();
357 void SetDebugState(const LayerTreeDebugState& new_debug_state);
358 const LayerTreeDebugState& debug_state() const { return debug_state_; }
360 class CC_EXPORT CullRenderPassesWithNoQuads {
361 public:
362 bool ShouldRemoveRenderPass(const RenderPassDrawQuad& quad,
363 const FrameData& frame) const;
365 // Iterates in draw order, so that when a surface is removed, and its
366 // target becomes empty, then its target can be removed also.
367 size_t RenderPassListBegin(const RenderPassList& list) const { return 0; }
368 size_t RenderPassListEnd(const RenderPassList& list) const {
369 return list.size();
371 size_t RenderPassListNext(size_t it) const { return it + 1; }
374 template <typename RenderPassCuller>
375 static void RemoveRenderPasses(RenderPassCuller culler, FrameData* frame);
377 gfx::Vector2dF accumulated_root_overscroll() const {
378 return accumulated_root_overscroll_;
380 gfx::Vector2dF current_fling_velocity() const {
381 return current_fling_velocity_;
384 bool pinch_gesture_active() const { return pinch_gesture_active_; }
386 void SetTreePriority(TreePriority priority);
388 void ResetCurrentFrameTimeForNextFrame();
389 virtual base::TimeTicks CurrentFrameTimeTicks();
390 base::Time CurrentFrameTime();
392 virtual base::TimeTicks CurrentPhysicalTimeTicks() const;
394 scoped_ptr<base::Value> AsValue() const { return AsValueWithFrame(NULL); }
395 scoped_ptr<base::Value> AsValueWithFrame(FrameData* frame) const;
396 scoped_ptr<base::Value> ActivationStateAsValue() const;
398 bool page_scale_animation_active() const { return !!page_scale_animation_; }
400 virtual void CreateUIResource(UIResourceId uid,
401 const UIResourceBitmap& bitmap);
402 // Deletes a UI resource. May safely be called more than once.
403 virtual void DeleteUIResource(UIResourceId uid);
404 void EvictAllUIResources();
405 bool EvictedUIResourcesExist() const;
407 virtual ResourceProvider::ResourceId ResourceIdForUIResource(
408 UIResourceId uid) const;
410 virtual bool IsUIResourceOpaque(UIResourceId uid) const;
412 struct UIResourceData {
413 ResourceProvider::ResourceId resource_id;
414 gfx::Size size;
415 bool opaque;
418 void ScheduleMicroBenchmark(scoped_ptr<MicroBenchmarkImpl> benchmark);
420 CompositorFrameMetadata MakeCompositorFrameMetadata() const;
421 // Viewport rectangle and clip in nonflipped window space. These rects
422 // should only be used by Renderer subclasses to populate glViewport/glClip
423 // and their software-mode equivalents.
424 gfx::Rect DeviceViewport() const;
425 gfx::Rect DeviceClip() const;
427 // When a SwapPromiseMonitor is created on the impl thread, it calls
428 // InsertSwapPromiseMonitor() to register itself with LayerTreeHostImpl.
429 // When the monitor is destroyed, it calls RemoveSwapPromiseMonitor()
430 // to unregister itself.
431 void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor);
432 void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor);
434 protected:
435 LayerTreeHostImpl(
436 const LayerTreeSettings& settings,
437 LayerTreeHostImplClient* client,
438 Proxy* proxy,
439 RenderingStatsInstrumentation* rendering_stats_instrumentation,
440 SharedBitmapManager* manager,
441 int id);
443 // Virtual for testing.
444 virtual void AnimateLayers(base::TimeTicks monotonic_time,
445 base::Time wall_clock_time);
447 // Virtual for testing.
448 virtual base::TimeDelta LowFrequencyAnimationInterval() const;
450 const AnimationRegistrar::AnimationControllerMap&
451 active_animation_controllers() const {
452 return animation_registrar_->active_animation_controllers();
455 bool manage_tiles_needed() const { return tile_priorities_dirty_; }
457 LayerTreeHostImplClient* client_;
458 Proxy* proxy_;
460 private:
461 void CreateAndSetRenderer(
462 OutputSurface* output_surface,
463 ResourceProvider* resource_provider,
464 bool skip_gl_renderer);
465 void CreateAndSetTileManager(ResourceProvider* resource_provider,
466 ContextProvider* context_provider,
467 bool using_map_image,
468 bool allow_rasterize_on_demand);
469 void ReleaseTreeResources();
470 void EnforceZeroBudget(bool zero_budget);
472 void ScrollViewportBy(gfx::Vector2dF scroll_delta);
473 void AnimatePageScale(base::TimeTicks monotonic_time);
474 void AnimateScrollbars(base::TimeTicks monotonic_time);
475 void AnimateTopControls(base::TimeTicks monotonic_time);
477 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
478 LayerImpl* layer_impl,
479 float scale_from_viewport_to_screen_space,
480 const gfx::PointF& viewport_point,
481 const gfx::Vector2dF& viewport_delta);
483 void TrackDamageForAllSurfaces(
484 LayerImpl* root_draw_layer,
485 const LayerImplList& render_surface_layer_list);
487 void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy);
489 // This function should only be called from PrepareToDraw, as DidDrawAllLayers
490 // must be called if this helper function is called. Returns DRAW_SUCCESS if
491 // the frame should be drawn.
492 DrawSwapReadbackResult::DrawResult CalculateRenderPasses(FrameData* frame);
494 void SendReleaseResourcesRecursive(LayerImpl* current);
495 bool EnsureRenderSurfaceLayerList();
496 void ClearCurrentlyScrollingLayer();
498 bool HandleMouseOverScrollbar(LayerImpl* layer_impl,
499 const gfx::PointF& device_viewport_point);
501 void AnimateScrollbarsRecursive(LayerImpl* layer,
502 base::TimeTicks time);
504 void UpdateCurrentFrameTime(base::TimeTicks* ticks, base::Time* now) const;
506 LayerImpl* FindScrollLayerForDeviceViewportPoint(
507 const gfx::PointF& device_viewport_point,
508 InputHandler::ScrollInputType type,
509 LayerImpl* layer_hit_by_point,
510 bool* scroll_on_main_thread) const;
511 float DeviceSpaceDistanceToLayer(const gfx::PointF& device_viewport_point,
512 LayerImpl* layer_impl);
513 void StartScrollbarAnimationRecursive(LayerImpl* layer, base::TimeTicks time);
514 void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy,
515 bool zero_budget);
516 void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy);
518 void DidInitializeVisibleTile();
520 void MarkUIResourceNotEvicted(UIResourceId uid);
522 void NotifySwapPromiseMonitorsOfSetNeedsRedraw();
524 typedef base::hash_map<UIResourceId, UIResourceData>
525 UIResourceMap;
526 UIResourceMap ui_resource_map_;
528 // Resources that were evicted by EvictAllUIResources. Resources are removed
529 // from this when they are touched by a create or destroy from the UI resource
530 // request queue.
531 std::set<UIResourceId> evicted_ui_resources_;
533 scoped_ptr<OutputSurface> output_surface_;
534 scoped_refptr<ContextProvider> offscreen_context_provider_;
536 // |resource_provider_| and |tile_manager_| can be NULL, e.g. when using tile-
537 // free rendering - see OutputSurface::ForcedDrawToSoftwareDevice().
538 scoped_ptr<ResourceProvider> resource_provider_;
539 scoped_ptr<TileManager> tile_manager_;
540 scoped_ptr<Renderer> renderer_;
542 GlobalStateThatImpactsTilePriority global_tile_state_;
544 // Tree currently being drawn.
545 scoped_ptr<LayerTreeImpl> active_tree_;
547 // In impl-side painting mode, tree with possibly incomplete rasterized
548 // content. May be promoted to active by ActivatePendingTree().
549 scoped_ptr<LayerTreeImpl> pending_tree_;
551 // In impl-side painting mode, inert tree with layers that can be recycled
552 // by the next sync from the main thread.
553 scoped_ptr<LayerTreeImpl> recycle_tree_;
555 InputHandlerClient* input_handler_client_;
556 bool did_lock_scrolling_layer_;
557 bool should_bubble_scrolls_;
558 bool wheel_scrolling_;
559 int scroll_layer_id_when_mouse_over_scrollbar_;
561 bool tile_priorities_dirty_;
563 // The optional delegate for the root layer scroll offset.
564 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_;
565 LayerTreeSettings settings_;
566 LayerTreeDebugState debug_state_;
567 bool visible_;
568 ManagedMemoryPolicy cached_managed_memory_policy_;
570 gfx::Vector2dF accumulated_root_overscroll_;
571 gfx::Vector2dF current_fling_velocity_;
573 bool pinch_gesture_active_;
574 bool pinch_gesture_end_should_clear_scrolling_layer_;
575 gfx::Point previous_pinch_anchor_;
577 // This is set by AnimateLayers() and used by UpdateAnimationState()
578 // when sending animation events to the main thread.
579 base::Time last_animation_time_;
581 scoped_ptr<TopControlsManager> top_controls_manager_;
583 scoped_ptr<PageScaleAnimation> page_scale_animation_;
585 // This is used for ticking animations slowly when hidden.
586 scoped_ptr<LayerTreeHostImplTimeSourceAdapter> time_source_client_adapter_;
588 scoped_ptr<FrameRateCounter> fps_counter_;
589 scoped_ptr<PaintTimeCounter> paint_time_counter_;
590 scoped_ptr<MemoryHistory> memory_history_;
591 scoped_ptr<DebugRectHistory> debug_rect_history_;
593 scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_;
595 // The maximum memory that would be used by the prioritized resource
596 // manager, if there were no limit on memory usage.
597 size_t max_memory_needed_bytes_;
599 size_t last_sent_memory_visible_bytes_;
600 size_t last_sent_memory_visible_and_nearby_bytes_;
601 size_t last_sent_memory_use_bytes_;
602 bool zero_budget_;
604 // Viewport size passed in from the main thread, in physical pixels. This
605 // value is the default size for all concepts of physical viewport (draw
606 // viewport, scrolling viewport and device viewport), but it can be
607 // overridden.
608 gfx::Size device_viewport_size_;
610 // Conversion factor from CSS pixels to physical pixels when
611 // pageScaleFactor=1.
612 float device_scale_factor_;
614 // UI resource to use for drawing overhang gutters.
615 UIResourceId overhang_ui_resource_id_;
616 gfx::Size overhang_ui_resource_size_;
618 // Vertical amount of the viewport size that's known to covered by a
619 // browser-side UI element, such as an on-screen-keyboard. This affects
620 // scrollable size since we want to still be able to scroll to the bottom of
621 // the page when the keyboard is up.
622 float overdraw_bottom_height_;
624 // Optional top-level constraints that can be set by the OutputSurface.
625 // - external_transform_ applies a transform above the root layer
626 // - external_viewport_ is used DrawProperties, tile management and
627 // glViewport/window projection matrix.
628 // - external_clip_ specifies a top-level clip rect
629 // - external_stencil_test_enabled_ tells CC to respect existing stencil bits
630 // (When these are specified, device_viewport_size_ remains used only for
631 // scrollable size.)
632 gfx::Transform external_transform_;
633 gfx::Rect external_viewport_;
634 gfx::Rect external_clip_;
635 bool device_viewport_valid_for_tile_management_;
636 bool external_stencil_test_enabled_;
638 gfx::Rect viewport_damage_rect_;
640 base::TimeTicks current_frame_timeticks_;
641 base::Time current_frame_time_;
643 scoped_ptr<AnimationRegistrar> animation_registrar_;
645 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
646 MicroBenchmarkControllerImpl micro_benchmark_controller_;
648 bool need_to_update_visible_tiles_before_draw_;
649 #ifndef NDEBUG
650 bool did_lose_called_;
651 #endif
653 // Optional callback to notify of new tree activations.
654 base::Closure tree_activation_callback_;
656 SharedBitmapManager* shared_bitmap_manager_;
657 int id_;
659 std::set<SwapPromiseMonitor*> swap_promise_monitor_;
661 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
664 } // namespace cc
666 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_