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/begin_frame_source.h"
35 #include "cc/scheduler/draw_result.h"
36 #include "skia/ext/refptr.h"
37 #include "third_party/skia/include/core/SkColor.h"
38 #include "ui/gfx/geometry/rect.h"
42 class CompletionEvent
;
43 class CompositorFrameMetadata
;
44 class DebugRectHistory
;
45 class EvictionTilePriorityQueue
;
46 class FrameRateCounter
;
48 class LayerTreeHostImplTimeSourceAdapter
;
51 class PageScaleAnimation
;
52 class PaintTimeCounter
;
53 class PictureLayerImpl
;
54 class RasterTilePriorityQueue
;
55 class RasterWorkerPool
;
56 class RenderPassDrawQuad
;
57 class RenderingStatsInstrumentation
;
59 class ScrollbarLayerImplBase
;
60 class TextureMailboxDeleter
;
61 class TopControlsManager
;
62 class UIResourceBitmap
;
63 class UIResourceRequest
;
64 struct RendererCapabilitiesImpl
;
66 // LayerTreeHost->Proxy callback interface.
67 class LayerTreeHostImplClient
{
69 virtual void UpdateRendererCapabilitiesOnImplThread() = 0;
70 virtual void DidLoseOutputSurfaceOnImplThread() = 0;
71 virtual void CommitVSyncParameters(base::TimeTicks timebase
,
72 base::TimeDelta interval
) = 0;
73 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time
) = 0;
74 virtual void SetMaxSwapsPendingOnImplThread(int max
) = 0;
75 virtual void DidSwapBuffersOnImplThread() = 0;
76 virtual void DidSwapBuffersCompleteOnImplThread() = 0;
77 virtual void OnCanDrawStateChanged(bool can_draw
) = 0;
78 virtual void NotifyReadyToActivate() = 0;
79 // Please call these 3 functions through
80 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and
82 virtual void SetNeedsRedrawOnImplThread() = 0;
83 virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect
& damage_rect
) = 0;
84 virtual void SetNeedsAnimateOnImplThread() = 0;
85 virtual void DidInitializeVisibleTileOnImplThread() = 0;
86 virtual void SetNeedsCommitOnImplThread() = 0;
87 virtual void SetNeedsManageTilesOnImplThread() = 0;
88 virtual void PostAnimationEventsToMainThreadOnImplThread(
89 scoped_ptr
<AnimationEventsVector
> events
) = 0;
90 // Returns true if resources were deleted by this call.
91 virtual bool ReduceContentsTextureMemoryOnImplThread(
93 int priority_cutoff
) = 0;
94 virtual bool IsInsideDraw() = 0;
95 virtual void RenewTreePriority() = 0;
96 virtual void PostDelayedScrollbarFadeOnImplThread(
97 const base::Closure
& start_fade
,
98 base::TimeDelta delay
) = 0;
99 virtual void DidActivateSyncTree() = 0;
100 virtual void DidManageTiles() = 0;
103 virtual ~LayerTreeHostImplClient() {}
106 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
108 class CC_EXPORT LayerTreeHostImpl
109 : public InputHandler
,
110 public RendererClient
,
111 public TileManagerClient
,
112 public OutputSurfaceClient
,
113 public TopControlsManagerClient
,
114 public ScrollbarAnimationControllerClient
,
115 public BeginFrameSourceMixIn
,
116 public base::SupportsWeakPtr
<LayerTreeHostImpl
> {
118 static scoped_ptr
<LayerTreeHostImpl
> Create(
119 const LayerTreeSettings
& settings
,
120 LayerTreeHostImplClient
* client
,
122 RenderingStatsInstrumentation
* rendering_stats_instrumentation
,
123 SharedBitmapManager
* shared_bitmap_manager
,
124 gpu::GpuMemoryBufferManager
* gpu_memory_buffer_manager
,
126 ~LayerTreeHostImpl() override
;
128 // BeginFrameSourceMixIn implementation
129 void OnNeedsBeginFramesChange(bool needs_begin_frames
) override
;
131 // InputHandler implementation
132 void BindToClient(InputHandlerClient
* client
) override
;
133 InputHandler::ScrollStatus
ScrollBegin(
134 const gfx::Point
& viewport_point
,
135 InputHandler::ScrollInputType type
) override
;
136 InputHandler::ScrollStatus
ScrollAnimated(
137 const gfx::Point
& viewport_point
,
138 const gfx::Vector2dF
& scroll_delta
) override
;
139 bool ScrollBy(const gfx::Point
& viewport_point
,
140 const gfx::Vector2dF
& scroll_delta
) override
;
141 bool ScrollVerticallyByPage(const gfx::Point
& viewport_point
,
142 ScrollDirection direction
) override
;
143 void SetRootLayerScrollOffsetDelegate(
144 LayerScrollOffsetDelegate
* root_layer_scroll_offset_delegate
) override
;
145 void OnRootLayerDelegatedScrollOffsetChanged() override
;
146 void ScrollEnd() override
;
147 InputHandler::ScrollStatus
FlingScrollBegin() override
;
148 void MouseMoveAt(const gfx::Point
& viewport_point
) override
;
149 void PinchGestureBegin() override
;
150 void PinchGestureUpdate(float magnify_delta
,
151 const gfx::Point
& anchor
) override
;
152 void PinchGestureEnd() override
;
153 void SetNeedsAnimate() override
;
154 bool IsCurrentlyScrollingLayerAt(const gfx::Point
& viewport_point
,
155 InputHandler::ScrollInputType type
) override
;
156 bool HaveTouchEventHandlersAt(const gfx::Point
& viewport_port
) override
;
157 scoped_ptr
<SwapPromiseMonitor
> CreateLatencyInfoSwapPromiseMonitor(
158 ui::LatencyInfo
* latency
) override
;
160 // TopControlsManagerClient implementation.
161 void SetControlsTopOffset(float offset
) override
;
162 float ControlsTopOffset() const override
;
163 void DidChangeTopControlsPosition() override
;
164 bool HaveRootScrollLayer() const override
;
166 struct CC_EXPORT FrameData
: public RenderPassSink
{
168 ~FrameData() override
;
169 void AsValueInto(base::debug::TracedValue
* value
) const;
171 std::vector
<gfx::Rect
> occluding_screen_space_rects
;
172 std::vector
<gfx::Rect
> non_occluding_screen_space_rects
;
173 RenderPassList render_passes
;
174 RenderPassIdHashMap render_passes_by_id
;
175 const LayerImplList
* render_surface_layer_list
;
176 LayerImplList will_draw_layers
;
177 bool contains_incomplete_tile
;
180 // RenderPassSink implementation.
181 void AppendRenderPass(scoped_ptr
<RenderPass
> render_pass
) override
;
184 virtual void BeginMainFrameAborted(bool did_handle
);
185 virtual void BeginCommit();
186 virtual void CommitComplete();
187 virtual void Animate(base::TimeTicks monotonic_time
);
188 virtual void UpdateAnimationState(bool start_ready_animations
);
189 void ActivateAnimations();
190 void MainThreadHasStoppedFlinging();
191 void UpdateBackgroundAnimateTicking(bool should_background_tick
);
192 void DidAnimateScrollOffset();
193 void SetViewportDamage(const gfx::Rect
& damage_rect
);
195 virtual void ManageTiles();
197 // Returns DRAW_SUCCESS unless problems occured preparing the frame, and we
198 // should try to avoid displaying the frame. If PrepareToDraw is called,
199 // DidDrawAllLayers must also be called, regardless of whether DrawLayers is
200 // called between the two.
201 virtual DrawResult
PrepareToDraw(FrameData
* frame
);
202 virtual void DrawLayers(FrameData
* frame
, base::TimeTicks frame_begin_time
);
203 // Must be called if and only if PrepareToDraw was called.
204 void DidDrawAllLayers(const FrameData
& frame
);
206 const LayerTreeSettings
& settings() const { return settings_
; }
208 // Evict all textures by enforcing a memory policy with an allocation of 0.
209 void EvictTexturesForTesting();
211 // When blocking, this prevents client_->NotifyReadyToActivate() from being
212 // called. When disabled, it calls client_->NotifyReadyToActivate()
213 // immediately if any notifications had been blocked while blocking.
214 virtual void BlockNotifyReadyToActivateForTesting(bool block
);
216 // This allows us to inject DidInitializeVisibleTile events for testing.
217 void DidInitializeVisibleTileForTesting();
219 // Resets all of the trees to an empty state.
220 void ResetTreesForTesting();
222 DrawMode
GetDrawMode() const;
224 // Viewport size in draw space: this size is in physical pixels and is used
225 // for draw properties, tilings, quads and render passes.
226 gfx::Size
DrawViewportSize() const;
228 // Viewport rect in view space used for tiling prioritization.
229 const gfx::Rect
ViewportRectForTilePriority() const;
231 // RendererClient implementation.
232 void SetFullRootLayerDamage() override
;
234 // TileManagerClient implementation.
235 const std::vector
<PictureLayerImpl
*>& GetPictureLayers() const override
;
236 void NotifyReadyToActivate() override
;
237 void NotifyTileStateChanged(const Tile
* tile
) override
;
238 void BuildRasterQueue(RasterTilePriorityQueue
* queue
,
239 TreePriority tree_priority
) override
;
240 void BuildEvictionQueue(EvictionTilePriorityQueue
* queue
,
241 TreePriority tree_priority
) override
;
243 // ScrollbarAnimationControllerClient implementation.
244 void PostDelayedScrollbarFade(const base::Closure
& start_fade
,
245 base::TimeDelta delay
) override
;
246 void SetNeedsScrollbarAnimationFrame() override
;
248 // OutputSurfaceClient implementation.
249 void DeferredInitialize() override
;
250 void ReleaseGL() override
;
251 void CommitVSyncParameters(base::TimeTicks timebase
,
252 base::TimeDelta interval
) override
;
253 void SetNeedsRedrawRect(const gfx::Rect
& rect
) override
;
254 void BeginFrame(const BeginFrameArgs
& args
) override
;
256 void SetExternalDrawConstraints(
257 const gfx::Transform
& transform
,
258 const gfx::Rect
& viewport
,
259 const gfx::Rect
& clip
,
260 const gfx::Rect
& viewport_rect_for_tile_priority
,
261 const gfx::Transform
& transform_for_tile_priority
,
262 bool resourceless_software_draw
) override
;
263 void DidLoseOutputSurface() override
;
264 void DidSwapBuffers() override
;
265 void DidSwapBuffersComplete() override
;
266 void ReclaimResources(const CompositorFrameAck
* ack
) override
;
267 void SetMemoryPolicy(const ManagedMemoryPolicy
& policy
) override
;
268 void SetTreeActivationCallback(const base::Closure
& callback
) override
;
270 // Called from LayerTreeImpl.
271 void OnCanDrawStateChangedForTree();
274 int id() const { return id_
; }
275 bool CanDraw() const;
276 OutputSurface
* output_surface() const { return output_surface_
.get(); }
278 std::string
LayerTreeAsJson() const;
280 void FinishAllRendering();
281 int SourceAnimationFrameNumber() const;
283 virtual bool InitializeRenderer(scoped_ptr
<OutputSurface
> output_surface
);
284 TileManager
* tile_manager() { return tile_manager_
.get(); }
285 void SetUseGpuRasterization(bool use_gpu
);
286 bool use_gpu_rasterization() const { return use_gpu_rasterization_
; }
287 bool create_low_res_tiling() const {
288 return settings_
.create_low_res_tiling
&& !use_gpu_rasterization_
;
290 ResourcePool
* resource_pool() { return resource_pool_
.get(); }
291 Renderer
* renderer() { return renderer_
.get(); }
292 const RendererCapabilitiesImpl
& GetRendererCapabilities() const;
294 virtual bool SwapBuffers(const FrameData
& frame
);
295 virtual void WillBeginImplFrame(const BeginFrameArgs
& args
);
296 void DidModifyTilePriorities();
298 LayerTreeImpl
* active_tree() { return active_tree_
.get(); }
299 const LayerTreeImpl
* active_tree() const { return active_tree_
.get(); }
300 LayerTreeImpl
* pending_tree() { return pending_tree_
.get(); }
301 const LayerTreeImpl
* pending_tree() const { return pending_tree_
.get(); }
302 LayerTreeImpl
* recycle_tree() { return recycle_tree_
.get(); }
303 const LayerTreeImpl
* recycle_tree() const { return recycle_tree_
.get(); }
304 // Returns the tree LTH synchronizes with.
305 LayerTreeImpl
* sync_tree() {
306 return pending_tree_
? pending_tree_
.get() : active_tree_
.get();
308 virtual void CreatePendingTree();
309 virtual void UpdateVisibleTiles();
310 virtual void ActivateSyncTree();
312 // Shortcuts to layers on the active tree.
313 LayerImpl
* RootLayer() const;
314 LayerImpl
* InnerViewportScrollLayer() const;
315 LayerImpl
* OuterViewportScrollLayer() const;
316 LayerImpl
* CurrentlyScrollingLayer() const;
318 int scroll_layer_id_when_mouse_over_scrollbar() const {
319 return scroll_layer_id_when_mouse_over_scrollbar_
;
321 bool scroll_affects_scroll_handler() const {
322 return scroll_affects_scroll_handler_
;
324 void QueueSwapPromiseForMainThreadScrollUpdate(
325 scoped_ptr
<SwapPromise
> swap_promise
);
327 bool IsActivelyScrolling() const;
329 virtual void SetVisible(bool visible
);
330 bool visible() const { return visible_
; }
332 void SetNeedsCommit() { client_
->SetNeedsCommitOnImplThread(); }
333 void SetNeedsRedraw();
335 ManagedMemoryPolicy
ActualManagedMemoryPolicy() const;
337 size_t memory_allocation_limit_bytes() const;
338 int memory_allocation_priority_cutoff() const;
340 void SetViewportSize(const gfx::Size
& device_viewport_size
);
341 gfx::Size
device_viewport_size() const { return device_viewport_size_
; }
343 void SetOverhangUIResource(UIResourceId overhang_ui_resource_id
,
344 const gfx::Size
& overhang_ui_resource_size
);
346 void SetDeviceScaleFactor(float device_scale_factor
);
347 float device_scale_factor() const { return device_scale_factor_
; }
349 const gfx::Transform
& DrawTransform() const;
351 scoped_ptr
<ScrollAndScaleSet
> ProcessScrollDeltas();
353 bool needs_animate_layers() const {
354 return !animation_registrar_
->active_animation_controllers().empty();
357 void set_max_memory_needed_bytes(size_t bytes
) {
358 max_memory_needed_bytes_
= bytes
;
361 FrameRateCounter
* fps_counter() {
362 return fps_counter_
.get();
364 PaintTimeCounter
* paint_time_counter() {
365 return paint_time_counter_
.get();
367 MemoryHistory
* memory_history() {
368 return memory_history_
.get();
370 DebugRectHistory
* debug_rect_history() {
371 return debug_rect_history_
.get();
373 ResourceProvider
* resource_provider() {
374 return resource_provider_
.get();
376 TopControlsManager
* top_controls_manager() {
377 return top_controls_manager_
.get();
379 const GlobalStateThatImpactsTilePriority
& global_tile_state() {
380 return global_tile_state_
;
383 Proxy
* proxy() const { return proxy_
; }
385 AnimationRegistrar
* animation_registrar() const {
386 return animation_registrar_
.get();
389 void SetDebugState(const LayerTreeDebugState
& new_debug_state
);
390 const LayerTreeDebugState
& debug_state() const { return debug_state_
; }
392 class CC_EXPORT CullRenderPassesWithNoQuads
{
394 bool ShouldRemoveRenderPass(const RenderPassDrawQuad
& quad
,
395 const FrameData
& frame
) const;
397 // Iterates in draw order, so that when a surface is removed, and its
398 // target becomes empty, then its target can be removed also.
399 size_t RenderPassListBegin(const RenderPassList
& list
) const { return 0; }
400 size_t RenderPassListEnd(const RenderPassList
& list
) const {
403 size_t RenderPassListNext(size_t it
) const { return it
+ 1; }
406 template <typename RenderPassCuller
>
407 static void RemoveRenderPasses(RenderPassCuller culler
, FrameData
* frame
);
409 gfx::Vector2dF
accumulated_root_overscroll() const {
410 return accumulated_root_overscroll_
;
413 bool pinch_gesture_active() const { return pinch_gesture_active_
; }
415 void SetTreePriority(TreePriority priority
);
416 TreePriority
GetTreePriority() const;
418 void UpdateCurrentBeginFrameArgs(const BeginFrameArgs
& args
);
419 void ResetCurrentBeginFrameArgsForNextFrame();
420 virtual BeginFrameArgs
CurrentBeginFrameArgs() const;
422 // Expected time between two begin impl frame calls.
423 base::TimeDelta
begin_impl_frame_interval() const {
424 return begin_impl_frame_interval_
;
427 void AsValueInto(base::debug::TracedValue
* value
) const override
;
428 void AsValueWithFrameInto(FrameData
* frame
,
429 base::debug::TracedValue
* value
) const;
430 scoped_refptr
<base::debug::ConvertableToTraceFormat
> AsValue() const;
431 scoped_refptr
<base::debug::ConvertableToTraceFormat
> AsValueWithFrame(
432 FrameData
* frame
) const;
433 scoped_refptr
<base::debug::ConvertableToTraceFormat
> ActivationStateAsValue()
435 void ActivationStateAsValueInto(base::debug::TracedValue
* value
) const;
437 bool page_scale_animation_active() const { return !!page_scale_animation_
; }
439 virtual void CreateUIResource(UIResourceId uid
,
440 const UIResourceBitmap
& bitmap
);
441 // Deletes a UI resource. May safely be called more than once.
442 virtual void DeleteUIResource(UIResourceId uid
);
443 void EvictAllUIResources();
444 bool EvictedUIResourcesExist() const;
446 virtual ResourceProvider::ResourceId
ResourceIdForUIResource(
447 UIResourceId uid
) const;
449 virtual bool IsUIResourceOpaque(UIResourceId uid
) const;
451 struct UIResourceData
{
452 ResourceProvider::ResourceId resource_id
;
457 void ScheduleMicroBenchmark(scoped_ptr
<MicroBenchmarkImpl
> benchmark
);
459 CompositorFrameMetadata
MakeCompositorFrameMetadata() const;
460 // Viewport rectangle and clip in nonflipped window space. These rects
461 // should only be used by Renderer subclasses to populate glViewport/glClip
462 // and their software-mode equivalents.
463 gfx::Rect
DeviceViewport() const;
464 gfx::Rect
DeviceClip() const;
466 // When a SwapPromiseMonitor is created on the impl thread, it calls
467 // InsertSwapPromiseMonitor() to register itself with LayerTreeHostImpl.
468 // When the monitor is destroyed, it calls RemoveSwapPromiseMonitor()
469 // to unregister itself.
470 void InsertSwapPromiseMonitor(SwapPromiseMonitor
* monitor
);
471 void RemoveSwapPromiseMonitor(SwapPromiseMonitor
* monitor
);
473 void RegisterPictureLayerImpl(PictureLayerImpl
* layer
);
474 void UnregisterPictureLayerImpl(PictureLayerImpl
* layer
);
476 void GetPictureLayerImplPairs(
477 std::vector
<PictureLayerImpl::Pair
>* layers
) const;
479 void SetTopControlsLayoutHeight(float height
);
481 void SetRequiresHighResToDraw() { requires_high_res_to_draw_
= true; }
482 void ResetRequiresHighResToDraw() { requires_high_res_to_draw_
= false; }
483 bool RequiresHighResToDraw() const { return requires_high_res_to_draw_
; }
485 // Only valid for synchronous (non-scheduled) single-threaded case.
486 void SynchronouslyInitializeAllTiles();
488 bool CanUseZeroCopyRasterizer() const;
489 bool CanUseOneCopyRasterizer() const;
490 virtual void CreateResourceAndRasterWorkerPool(
491 scoped_ptr
<RasterWorkerPool
>* raster_worker_pool
,
492 scoped_ptr
<ResourcePool
>* resource_pool
,
493 scoped_ptr
<ResourcePool
>* staging_resource_pool
);
497 const LayerTreeSettings
& settings
,
498 LayerTreeHostImplClient
* client
,
500 RenderingStatsInstrumentation
* rendering_stats_instrumentation
,
501 SharedBitmapManager
* shared_bitmap_manager
,
502 gpu::GpuMemoryBufferManager
* gpu_memory_buffer_manager
,
505 void UpdateViewportContainerSizes();
507 // Virtual for testing.
508 virtual void AnimateLayers(base::TimeTicks monotonic_time
);
509 virtual base::TimeDelta
LowFrequencyAnimationInterval() const;
511 const AnimationRegistrar::AnimationControllerMap
&
512 active_animation_controllers() const {
513 return animation_registrar_
->active_animation_controllers();
516 bool manage_tiles_needed() const { return tile_priorities_dirty_
; }
518 LayerTreeHostImplClient
* client_
;
522 void CreateAndSetRenderer();
523 void CreateAndSetTileManager();
524 void DestroyTileManager();
525 void ReleaseTreeResources();
526 void EnforceZeroBudget(bool zero_budget
);
528 bool UsePendingTreeForSync() const;
529 bool IsSynchronousSingleThreaded() const;
531 // Scroll by preferring to move the outer viewport first, only moving the
532 // inner if the outer is at its scroll extents.
533 void ScrollViewportBy(gfx::Vector2dF scroll_delta
);
534 // Scroll by preferring to move the inner viewport first, only moving the
535 // outer if the inner is at its scroll extents.
536 void ScrollViewportInnerFirst(gfx::Vector2dF scroll_delta
);
537 void AnimatePageScale(base::TimeTicks monotonic_time
);
538 void AnimateScrollbars(base::TimeTicks monotonic_time
);
539 void AnimateTopControls(base::TimeTicks monotonic_time
);
541 bool ShouldTopControlsConsumeScroll(const gfx::Vector2dF
& scroll_delta
) const;
543 gfx::Vector2dF
ScrollLayerWithViewportSpaceDelta(
544 LayerImpl
* layer_impl
,
545 float scale_from_viewport_to_screen_space
,
546 const gfx::PointF
& viewport_point
,
547 const gfx::Vector2dF
& viewport_delta
);
549 void TrackDamageForAllSurfaces(
550 LayerImpl
* root_draw_layer
,
551 const LayerImplList
& render_surface_layer_list
);
553 void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy
& policy
);
555 // This function should only be called from PrepareToDraw, as DidDrawAllLayers
556 // must be called if this helper function is called. Returns DRAW_SUCCESS if
557 // the frame should be drawn.
558 DrawResult
CalculateRenderPasses(FrameData
* frame
);
560 void ClearCurrentlyScrollingLayer();
562 bool HandleMouseOverScrollbar(LayerImpl
* layer_impl
,
563 const gfx::PointF
& device_viewport_point
);
565 void AnimateScrollbarsRecursive(LayerImpl
* layer
,
566 base::TimeTicks time
);
568 LayerImpl
* FindScrollLayerForDeviceViewportPoint(
569 const gfx::PointF
& device_viewport_point
,
570 InputHandler::ScrollInputType type
,
571 LayerImpl
* layer_hit_by_point
,
572 bool* scroll_on_main_thread
,
573 bool* optional_has_ancestor_scroll_handler
) const;
574 float DeviceSpaceDistanceToLayer(const gfx::PointF
& device_viewport_point
,
575 LayerImpl
* layer_impl
);
576 void StartScrollbarFadeRecursive(LayerImpl
* layer
);
577 void SetManagedMemoryPolicy(const ManagedMemoryPolicy
& policy
,
579 void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy
& policy
);
581 void DidInitializeVisibleTile();
583 void MarkUIResourceNotEvicted(UIResourceId uid
);
585 void NotifySwapPromiseMonitorsOfSetNeedsRedraw();
586 void NotifySwapPromiseMonitorsOfForwardingToMainThread();
588 typedef base::hash_map
<UIResourceId
, UIResourceData
>
590 UIResourceMap ui_resource_map_
;
592 // Resources that were evicted by EvictAllUIResources. Resources are removed
593 // from this when they are touched by a create or destroy from the UI resource
595 std::set
<UIResourceId
> evicted_ui_resources_
;
597 scoped_ptr
<OutputSurface
> output_surface_
;
599 // |resource_provider_| and |tile_manager_| can be NULL, e.g. when using tile-
600 // free rendering - see OutputSurface::ForcedDrawToSoftwareDevice().
601 scoped_ptr
<ResourceProvider
> resource_provider_
;
602 scoped_ptr
<TileManager
> tile_manager_
;
603 bool use_gpu_rasterization_
;
604 scoped_ptr
<RasterWorkerPool
> raster_worker_pool_
;
605 scoped_ptr
<ResourcePool
> resource_pool_
;
606 scoped_ptr
<ResourcePool
> staging_resource_pool_
;
607 scoped_ptr
<Renderer
> renderer_
;
609 GlobalStateThatImpactsTilePriority global_tile_state_
;
611 // Tree currently being drawn.
612 scoped_ptr
<LayerTreeImpl
> active_tree_
;
614 // In impl-side painting mode, tree with possibly incomplete rasterized
615 // content. May be promoted to active by ActivatePendingTree().
616 scoped_ptr
<LayerTreeImpl
> pending_tree_
;
618 // In impl-side painting mode, inert tree with layers that can be recycled
619 // by the next sync from the main thread.
620 scoped_ptr
<LayerTreeImpl
> recycle_tree_
;
622 InputHandlerClient
* input_handler_client_
;
623 bool did_lock_scrolling_layer_
;
624 bool should_bubble_scrolls_
;
625 bool wheel_scrolling_
;
626 bool scroll_affects_scroll_handler_
;
627 int scroll_layer_id_when_mouse_over_scrollbar_
;
628 ScopedPtrVector
<SwapPromise
> swap_promises_for_main_thread_scroll_update_
;
630 bool tile_priorities_dirty_
;
632 // The optional delegate for the root layer scroll offset.
633 LayerScrollOffsetDelegate
* root_layer_scroll_offset_delegate_
;
634 LayerTreeSettings settings_
;
635 LayerTreeDebugState debug_state_
;
637 ManagedMemoryPolicy cached_managed_memory_policy_
;
639 gfx::Vector2dF accumulated_root_overscroll_
;
641 bool pinch_gesture_active_
;
642 bool pinch_gesture_end_should_clear_scrolling_layer_
;
643 gfx::Point previous_pinch_anchor_
;
645 scoped_ptr
<TopControlsManager
> top_controls_manager_
;
647 scoped_ptr
<PageScaleAnimation
> page_scale_animation_
;
649 // This is used for ticking animations slowly when hidden.
650 scoped_ptr
<LayerTreeHostImplTimeSourceAdapter
> time_source_client_adapter_
;
652 scoped_ptr
<FrameRateCounter
> fps_counter_
;
653 scoped_ptr
<PaintTimeCounter
> paint_time_counter_
;
654 scoped_ptr
<MemoryHistory
> memory_history_
;
655 scoped_ptr
<DebugRectHistory
> debug_rect_history_
;
657 scoped_ptr
<TextureMailboxDeleter
> texture_mailbox_deleter_
;
659 // The maximum memory that would be used by the prioritized resource
660 // manager, if there were no limit on memory usage.
661 size_t max_memory_needed_bytes_
;
665 // Viewport size passed in from the main thread, in physical pixels. This
666 // value is the default size for all concepts of physical viewport (draw
667 // viewport, scrolling viewport and device viewport), but it can be
669 gfx::Size device_viewport_size_
;
671 // Conversion factor from CSS pixels to physical pixels when
672 // pageScaleFactor=1.
673 float device_scale_factor_
;
675 // UI resource to use for drawing overhang gutters.
676 UIResourceId overhang_ui_resource_id_
;
677 gfx::Size overhang_ui_resource_size_
;
679 // Optional top-level constraints that can be set by the OutputSurface.
680 // - external_transform_ applies a transform above the root layer
681 // - external_viewport_ is used DrawProperties, tile management and
682 // glViewport/window projection matrix.
683 // - external_clip_ specifies a top-level clip rect
684 // - viewport_rect_for_tile_priority_ is the rect in view space used for
686 gfx::Transform external_transform_
;
687 gfx::Rect external_viewport_
;
688 gfx::Rect external_clip_
;
689 gfx::Rect viewport_rect_for_tile_priority_
;
690 bool resourceless_software_draw_
;
692 gfx::Rect viewport_damage_rect_
;
694 BeginFrameArgs current_begin_frame_args_
;
696 // Expected time between two begin impl frame calls.
697 base::TimeDelta begin_impl_frame_interval_
;
699 scoped_ptr
<AnimationRegistrar
> animation_registrar_
;
701 RenderingStatsInstrumentation
* rendering_stats_instrumentation_
;
702 MicroBenchmarkControllerImpl micro_benchmark_controller_
;
703 scoped_ptr
<TaskGraphRunner
> single_thread_synchronous_task_graph_runner_
;
705 bool need_to_update_visible_tiles_before_draw_
;
707 // Optional callback to notify of new tree activations.
708 base::Closure tree_activation_callback_
;
710 SharedBitmapManager
* shared_bitmap_manager_
;
711 gpu::GpuMemoryBufferManager
* gpu_memory_buffer_manager_
;
714 std::set
<SwapPromiseMonitor
*> swap_promise_monitor_
;
716 std::vector
<PictureLayerImpl
*> picture_layers_
;
717 std::vector
<PictureLayerImpl::Pair
> picture_layer_pairs_
;
719 bool requires_high_res_to_draw_
;
721 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl
);
726 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_