Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / cc / trees / layer_tree_host_impl.h
blob8cb7c5764fe57bd413996fd4976b969097577219
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 <set>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/containers/hash_tables.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/time/time.h"
16 #include "cc/animation/animation_events.h"
17 #include "cc/animation/animation_registrar.h"
18 #include "cc/animation/scrollbar_animation_controller.h"
19 #include "cc/base/cc_export.h"
20 #include "cc/base/synced_property.h"
21 #include "cc/debug/frame_timing_tracker.h"
22 #include "cc/debug/micro_benchmark_controller_impl.h"
23 #include "cc/input/input_handler.h"
24 #include "cc/input/layer_scroll_offset_delegate.h"
25 #include "cc/input/top_controls_manager_client.h"
26 #include "cc/layers/layer_lists.h"
27 #include "cc/layers/render_pass_sink.h"
28 #include "cc/output/begin_frame_args.h"
29 #include "cc/output/managed_memory_policy.h"
30 #include "cc/output/output_surface_client.h"
31 #include "cc/output/renderer.h"
32 #include "cc/quads/render_pass.h"
33 #include "cc/resources/resource_provider.h"
34 #include "cc/resources/ui_resource_client.h"
35 #include "cc/scheduler/begin_frame_tracker.h"
36 #include "cc/scheduler/commit_earlyout_reason.h"
37 #include "cc/scheduler/draw_result.h"
38 #include "cc/scheduler/video_frame_controller.h"
39 #include "cc/tiles/tile_manager.h"
40 #include "cc/trees/layer_tree_settings.h"
41 #include "cc/trees/proxy.h"
42 #include "skia/ext/refptr.h"
43 #include "third_party/skia/include/core/SkColor.h"
44 #include "ui/gfx/geometry/rect.h"
46 namespace gfx {
47 class ScrollOffset;
50 namespace cc {
52 class CompletionEvent;
53 class CompositorFrameMetadata;
54 class DebugRectHistory;
55 class EvictionTilePriorityQueue;
56 class FrameRateCounter;
57 class LayerImpl;
58 class LayerTreeImpl;
59 class MemoryHistory;
60 class PageScaleAnimation;
61 class PaintTimeCounter;
62 class PictureLayerImpl;
63 class RasterTilePriorityQueue;
64 class TileTaskWorkerPool;
65 class RenderPassDrawQuad;
66 class RenderingStatsInstrumentation;
67 class ResourcePool;
68 class ScrollElasticityHelper;
69 class ScrollbarLayerImplBase;
70 class SwapPromise;
71 class SwapPromiseMonitor;
72 class TextureMailboxDeleter;
73 class TopControlsManager;
74 class UIResourceBitmap;
75 class UIResourceRequest;
76 struct ScrollAndScaleSet;
77 class Viewport;
79 enum class GpuRasterizationStatus {
80 ON,
81 ON_FORCED,
82 OFF_DEVICE,
83 OFF_VIEWPORT,
84 MSAA_CONTENT,
85 OFF_CONTENT
88 // LayerTreeHost->Proxy callback interface.
89 class LayerTreeHostImplClient {
90 public:
91 virtual void UpdateRendererCapabilitiesOnImplThread() = 0;
92 virtual void DidLoseOutputSurfaceOnImplThread() = 0;
93 virtual void CommitVSyncParameters(base::TimeTicks timebase,
94 base::TimeDelta interval) = 0;
95 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) = 0;
96 virtual void SetMaxSwapsPendingOnImplThread(int max) = 0;
97 virtual void DidSwapBuffersOnImplThread() = 0;
98 virtual void DidSwapBuffersCompleteOnImplThread() = 0;
99 virtual void OnCanDrawStateChanged(bool can_draw) = 0;
100 virtual void NotifyReadyToActivate() = 0;
101 virtual void NotifyReadyToDraw() = 0;
102 // Please call these 3 functions through
103 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and
104 // SetNeedsAnimate().
105 virtual void SetNeedsRedrawOnImplThread() = 0;
106 virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0;
107 virtual void SetNeedsAnimateOnImplThread() = 0;
108 virtual void SetNeedsCommitOnImplThread() = 0;
109 virtual void SetNeedsPrepareTilesOnImplThread() = 0;
110 virtual void SetVideoNeedsBeginFrames(bool needs_begin_frames) = 0;
111 virtual void PostAnimationEventsToMainThreadOnImplThread(
112 scoped_ptr<AnimationEventsVector> events) = 0;
113 // Returns true if resources were deleted by this call.
114 virtual bool ReduceContentsTextureMemoryOnImplThread(
115 size_t limit_bytes,
116 int priority_cutoff) = 0;
117 virtual bool IsInsideDraw() = 0;
118 virtual void RenewTreePriority() = 0;
119 virtual void PostDelayedAnimationTaskOnImplThread(const base::Closure& task,
120 base::TimeDelta delay) = 0;
121 virtual void DidActivateSyncTree() = 0;
122 virtual void DidPrepareTiles() = 0;
124 // Called when page scale animation has completed on the impl thread.
125 virtual void DidCompletePageScaleAnimationOnImplThread() = 0;
127 // Called when output surface asks for a draw.
128 virtual void OnDrawForOutputSurface() = 0;
130 protected:
131 virtual ~LayerTreeHostImplClient() {}
134 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
135 // state.
136 class CC_EXPORT LayerTreeHostImpl
137 : public InputHandler,
138 public RendererClient,
139 public TileManagerClient,
140 public OutputSurfaceClient,
141 public TopControlsManagerClient,
142 public ScrollbarAnimationControllerClient,
143 public VideoFrameControllerClient,
144 public base::SupportsWeakPtr<LayerTreeHostImpl> {
145 public:
146 static scoped_ptr<LayerTreeHostImpl> Create(
147 const LayerTreeSettings& settings,
148 LayerTreeHostImplClient* client,
149 Proxy* proxy,
150 RenderingStatsInstrumentation* rendering_stats_instrumentation,
151 SharedBitmapManager* shared_bitmap_manager,
152 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
153 TaskGraphRunner* task_graph_runner,
154 int id);
155 ~LayerTreeHostImpl() override;
157 // InputHandler implementation
158 void BindToClient(InputHandlerClient* client) override;
159 InputHandler::ScrollStatus ScrollBegin(
160 const gfx::Point& viewport_point,
161 InputHandler::ScrollInputType type) override;
162 InputHandler::ScrollStatus ScrollAnimated(
163 const gfx::Point& viewport_point,
164 const gfx::Vector2dF& scroll_delta) override;
165 InputHandlerScrollResult ScrollBy(
166 const gfx::Point& viewport_point,
167 const gfx::Vector2dF& scroll_delta) override;
168 bool ScrollVerticallyByPage(const gfx::Point& viewport_point,
169 ScrollDirection direction) override;
170 void SetRootLayerScrollOffsetDelegate(
171 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) override;
172 void OnRootLayerDelegatedScrollOffsetChanged() override;
173 void ScrollEnd() override;
174 InputHandler::ScrollStatus FlingScrollBegin() override;
175 void MouseMoveAt(const gfx::Point& viewport_point) override;
176 void PinchGestureBegin() override;
177 void PinchGestureUpdate(float magnify_delta,
178 const gfx::Point& anchor) override;
179 void PinchGestureEnd() override;
180 void StartPageScaleAnimation(const gfx::Vector2d& target_offset,
181 bool anchor_point,
182 float page_scale,
183 base::TimeDelta duration);
184 void SetNeedsAnimate() override;
185 bool IsCurrentlyScrollingLayerAt(const gfx::Point& viewport_point,
186 InputHandler::ScrollInputType type) override;
187 bool HaveWheelEventHandlersAt(const gfx::Point& viewport_point) override;
188 bool DoTouchEventsBlockScrollAt(const gfx::Point& viewport_port) override;
189 scoped_ptr<SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor(
190 ui::LatencyInfo* latency) override;
191 ScrollElasticityHelper* CreateScrollElasticityHelper() override;
193 // TopControlsManagerClient implementation.
194 float TopControlsHeight() const override;
195 void SetCurrentTopControlsShownRatio(float offset) override;
196 float CurrentTopControlsShownRatio() const override;
197 void DidChangeTopControlsPosition() override;
198 bool HaveRootScrollLayer() const override;
200 void UpdateViewportContainerSizes();
202 struct CC_EXPORT FrameData : public RenderPassSink {
203 FrameData();
204 ~FrameData() override;
205 void AsValueInto(base::trace_event::TracedValue* value) const;
207 std::vector<gfx::Rect> occluding_screen_space_rects;
208 std::vector<gfx::Rect> non_occluding_screen_space_rects;
209 std::vector<FrameTimingTracker::FrameAndRectIds> composite_events;
210 RenderPassList render_passes;
211 RenderPassIdHashMap render_passes_by_id;
212 const LayerImplList* render_surface_layer_list;
213 LayerImplList will_draw_layers;
214 bool has_no_damage;
216 // RenderPassSink implementation.
217 void AppendRenderPass(scoped_ptr<RenderPass> render_pass) override;
220 virtual void BeginMainFrameAborted(CommitEarlyOutReason reason);
221 virtual void BeginCommit();
222 virtual void CommitComplete();
223 virtual void Animate(base::TimeTicks monotonic_time);
224 virtual void UpdateAnimationState(bool start_ready_animations);
225 void ActivateAnimations();
226 void MainThreadHasStoppedFlinging();
227 void DidAnimateScrollOffset();
228 void SetViewportDamage(const gfx::Rect& damage_rect);
230 virtual void PrepareTiles();
232 // Returns DRAW_SUCCESS unless problems occured preparing the frame, and we
233 // should try to avoid displaying the frame. If PrepareToDraw is called,
234 // DidDrawAllLayers must also be called, regardless of whether DrawLayers is
235 // called between the two.
236 virtual DrawResult PrepareToDraw(FrameData* frame);
237 virtual void DrawLayers(FrameData* frame);
238 // Must be called if and only if PrepareToDraw was called.
239 void DidDrawAllLayers(const FrameData& frame);
241 const LayerTreeSettings& settings() const { return settings_; }
243 // Evict all textures by enforcing a memory policy with an allocation of 0.
244 void EvictTexturesForTesting();
246 // When blocking, this prevents client_->NotifyReadyToActivate() from being
247 // called. When disabled, it calls client_->NotifyReadyToActivate()
248 // immediately if any notifications had been blocked while blocking.
249 virtual void BlockNotifyReadyToActivateForTesting(bool block);
251 // Resets all of the trees to an empty state.
252 void ResetTreesForTesting();
254 DrawMode GetDrawMode() const;
256 // Viewport size in draw space: this size is in physical pixels and is used
257 // for draw properties, tilings, quads and render passes.
258 gfx::Size DrawViewportSize() const;
260 // Viewport rect in view space used for tiling prioritization.
261 const gfx::Rect ViewportRectForTilePriority() const;
263 // RendererClient implementation.
264 void SetFullRootLayerDamage() override;
266 // TileManagerClient implementation.
267 void NotifyReadyToActivate() override;
268 void NotifyReadyToDraw() override;
269 void NotifyTileStateChanged(const Tile* tile) override;
270 scoped_ptr<RasterTilePriorityQueue> BuildRasterQueue(
271 TreePriority tree_priority,
272 RasterTilePriorityQueue::Type type) override;
273 scoped_ptr<EvictionTilePriorityQueue> BuildEvictionQueue(
274 TreePriority tree_priority) override;
275 void SetIsLikelyToRequireADraw(bool is_likely_to_require_a_draw) override;
277 // ScrollbarAnimationControllerClient implementation.
278 void StartAnimatingScrollbarAnimationController(
279 ScrollbarAnimationController* controller) override;
280 void StopAnimatingScrollbarAnimationController(
281 ScrollbarAnimationController* controller) override;
282 void PostDelayedScrollbarAnimationTask(const base::Closure& task,
283 base::TimeDelta delay) override;
284 void SetNeedsRedrawForScrollbarAnimation() override;
286 // VideoBeginFrameSource implementation.
287 void AddVideoFrameController(VideoFrameController* controller) override;
288 void RemoveVideoFrameController(VideoFrameController* controller) override;
290 // OutputSurfaceClient implementation.
291 void CommitVSyncParameters(base::TimeTicks timebase,
292 base::TimeDelta interval) override;
293 void SetNeedsRedrawRect(const gfx::Rect& rect) override;
294 void SetExternalDrawConstraints(
295 const gfx::Transform& transform,
296 const gfx::Rect& viewport,
297 const gfx::Rect& clip,
298 const gfx::Rect& viewport_rect_for_tile_priority,
299 const gfx::Transform& transform_for_tile_priority,
300 bool resourceless_software_draw) override;
301 void DidLoseOutputSurface() override;
302 void DidSwapBuffers() override;
303 void DidSwapBuffersComplete() override;
304 void ReclaimResources(const CompositorFrameAck* ack) override;
305 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override;
306 void SetTreeActivationCallback(const base::Closure& callback) override;
307 void OnDraw() override;
309 // Called from LayerTreeImpl.
310 void OnCanDrawStateChangedForTree();
312 // Implementation.
313 int id() const { return id_; }
314 bool CanDraw() const;
315 OutputSurface* output_surface() const { return output_surface_.get(); }
317 std::string LayerTreeAsJson() const;
319 void FinishAllRendering();
320 int SourceAnimationFrameNumber() const;
322 virtual bool InitializeRenderer(scoped_ptr<OutputSurface> output_surface);
323 TileManager* tile_manager() { return tile_manager_.get(); }
325 void SetHasGpuRasterizationTrigger(bool flag) {
326 has_gpu_rasterization_trigger_ = flag;
327 UpdateGpuRasterizationStatus();
329 void SetContentIsSuitableForGpuRasterization(bool flag) {
330 content_is_suitable_for_gpu_rasterization_ = flag;
331 UpdateGpuRasterizationStatus();
333 bool CanUseGpuRasterization();
334 void UpdateTreeResourcesForGpuRasterizationIfNeeded();
335 bool use_gpu_rasterization() const { return use_gpu_rasterization_; }
336 bool use_msaa() const { return use_msaa_; }
338 GpuRasterizationStatus gpu_rasterization_status() const {
339 return gpu_rasterization_status_;
342 bool create_low_res_tiling() const {
343 return settings_.create_low_res_tiling && !use_gpu_rasterization_;
345 ResourcePool* resource_pool() { return resource_pool_.get(); }
346 Renderer* renderer() { return renderer_.get(); }
347 const RendererCapabilitiesImpl& GetRendererCapabilities() const;
349 virtual bool SwapBuffers(const FrameData& frame);
350 virtual void WillBeginImplFrame(const BeginFrameArgs& args);
351 virtual void DidFinishImplFrame();
352 void DidModifyTilePriorities();
354 LayerTreeImpl* active_tree() { return active_tree_.get(); }
355 const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
356 LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
357 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
358 LayerTreeImpl* recycle_tree() { return recycle_tree_.get(); }
359 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
360 // Returns the tree LTH synchronizes with.
361 LayerTreeImpl* sync_tree() {
362 // TODO(enne): This is bogus. It should return based on the value of
363 // Proxy::CommitToActiveTree and not whether the pending tree exists.
364 return pending_tree_ ? pending_tree_.get() : active_tree_.get();
366 virtual void CreatePendingTree();
367 virtual void ActivateSyncTree();
369 // Shortcuts to layers on the active tree.
370 LayerImpl* RootLayer() const;
371 LayerImpl* InnerViewportScrollLayer() const;
372 LayerImpl* OuterViewportScrollLayer() const;
373 LayerImpl* CurrentlyScrollingLayer() const;
375 int scroll_layer_id_when_mouse_over_scrollbar() const {
376 return scroll_layer_id_when_mouse_over_scrollbar_;
378 bool scroll_affects_scroll_handler() const {
379 return scroll_affects_scroll_handler_;
381 void QueueSwapPromiseForMainThreadScrollUpdate(
382 scoped_ptr<SwapPromise> swap_promise);
384 bool IsActivelyScrolling() const;
386 virtual void SetVisible(bool visible);
387 bool visible() const { return visible_; }
389 bool AnimationsAreVisible() { return visible() && CanDraw(); }
391 void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); }
392 void SetNeedsRedraw();
394 ManagedMemoryPolicy ActualManagedMemoryPolicy() const;
396 size_t memory_allocation_limit_bytes() const;
397 int memory_allocation_priority_cutoff() const;
399 void SetViewportSize(const gfx::Size& device_viewport_size);
400 gfx::Size device_viewport_size() const { return device_viewport_size_; }
402 void SetDeviceScaleFactor(float device_scale_factor);
403 float device_scale_factor() const { return device_scale_factor_; }
405 void SetPageScaleOnActiveTree(float page_scale_factor);
407 const gfx::Transform& DrawTransform() const;
409 scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
411 void set_max_memory_needed_bytes(size_t bytes) {
412 max_memory_needed_bytes_ = bytes;
415 FrameRateCounter* fps_counter() {
416 return fps_counter_.get();
418 PaintTimeCounter* paint_time_counter() {
419 return paint_time_counter_.get();
421 MemoryHistory* memory_history() {
422 return memory_history_.get();
424 DebugRectHistory* debug_rect_history() {
425 return debug_rect_history_.get();
427 ResourceProvider* resource_provider() {
428 return resource_provider_.get();
430 TopControlsManager* top_controls_manager() {
431 return top_controls_manager_.get();
433 const GlobalStateThatImpactsTilePriority& global_tile_state() {
434 return global_tile_state_;
437 Proxy* proxy() const { return proxy_; }
439 AnimationRegistrar* animation_registrar() const {
440 return animation_registrar_.get();
443 void SetDebugState(const LayerTreeDebugState& new_debug_state);
444 const LayerTreeDebugState& debug_state() const { return debug_state_; }
446 gfx::Vector2dF accumulated_root_overscroll() const {
447 return accumulated_root_overscroll_;
450 bool pinch_gesture_active() const { return pinch_gesture_active_; }
452 void SetTreePriority(TreePriority priority);
453 TreePriority GetTreePriority() const;
455 // TODO(mithro): Remove this methods which exposes the internal
456 // BeginFrameArgs to external callers.
457 virtual BeginFrameArgs CurrentBeginFrameArgs() const;
459 // Expected time between two begin impl frame calls.
460 base::TimeDelta CurrentBeginFrameInterval() const;
462 void AsValueWithFrameInto(FrameData* frame,
463 base::trace_event::TracedValue* value) const;
464 scoped_refptr<base::trace_event::ConvertableToTraceFormat> AsValueWithFrame(
465 FrameData* frame) const;
466 void ActivationStateAsValueInto(base::trace_event::TracedValue* value) const;
468 bool page_scale_animation_active() const { return !!page_scale_animation_; }
470 virtual void CreateUIResource(UIResourceId uid,
471 const UIResourceBitmap& bitmap);
472 // Deletes a UI resource. May safely be called more than once.
473 virtual void DeleteUIResource(UIResourceId uid);
474 void EvictAllUIResources();
475 bool EvictedUIResourcesExist() const;
477 virtual ResourceId ResourceIdForUIResource(UIResourceId uid) const;
479 virtual bool IsUIResourceOpaque(UIResourceId uid) const;
481 struct UIResourceData {
482 ResourceId resource_id;
483 gfx::Size size;
484 bool opaque;
487 void ScheduleMicroBenchmark(scoped_ptr<MicroBenchmarkImpl> benchmark);
489 CompositorFrameMetadata MakeCompositorFrameMetadata() const;
490 // Viewport rectangle and clip in nonflipped window space. These rects
491 // should only be used by Renderer subclasses to populate glViewport/glClip
492 // and their software-mode equivalents.
493 gfx::Rect DeviceViewport() const;
494 gfx::Rect DeviceClip() const;
496 // When a SwapPromiseMonitor is created on the impl thread, it calls
497 // InsertSwapPromiseMonitor() to register itself with LayerTreeHostImpl.
498 // When the monitor is destroyed, it calls RemoveSwapPromiseMonitor()
499 // to unregister itself.
500 void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor);
501 void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor);
503 // TODO(weiliangc): Replace RequiresHighResToDraw with scheduler waits for
504 // ReadyToDraw. crbug.com/469175
505 void SetRequiresHighResToDraw() { requires_high_res_to_draw_ = true; }
506 void ResetRequiresHighResToDraw() { requires_high_res_to_draw_ = false; }
507 bool RequiresHighResToDraw() const { return requires_high_res_to_draw_; }
509 // Only valid for synchronous (non-scheduled) single-threaded case.
510 void SynchronouslyInitializeAllTiles();
512 virtual void CreateResourceAndTileTaskWorkerPool(
513 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool,
514 scoped_ptr<ResourcePool>* resource_pool,
515 scoped_ptr<ResourcePool>* staging_resource_pool);
517 bool prepare_tiles_needed() const { return tile_priorities_dirty_; }
519 FrameTimingTracker* frame_timing_tracker() {
520 return frame_timing_tracker_.get();
523 gfx::Vector2dF ScrollLayer(LayerImpl* layer_impl,
524 const gfx::Vector2dF& delta,
525 const gfx::Point& viewport_point,
526 bool is_wheel_scroll);
528 // Record main frame timing information.
529 // |start_of_main_frame_args| is the BeginFrameArgs of the beginning of the
530 // main frame (ie the frame that kicked off the main frame).
531 // |expected_next_main_frame_args| is the BeginFrameArgs of the frame that
532 // follows the completion of the main frame (whether it is activation or some
533 // other completion, such as early out). Note that if there is a main frame
534 // scheduled in that frame, then this BeginFrameArgs will become the main
535 // frame args. However, if no such frame is scheduled, then this _would_ be
536 // the main frame args if it was scheduled.
537 void RecordMainFrameTiming(
538 const BeginFrameArgs& start_of_main_frame_args,
539 const BeginFrameArgs& expected_next_main_frame_args);
541 protected:
542 LayerTreeHostImpl(
543 const LayerTreeSettings& settings,
544 LayerTreeHostImplClient* client,
545 Proxy* proxy,
546 RenderingStatsInstrumentation* rendering_stats_instrumentation,
547 SharedBitmapManager* shared_bitmap_manager,
548 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
549 TaskGraphRunner* task_graph_runner,
550 int id);
552 // Virtual for testing.
553 virtual void AnimateLayers(base::TimeTicks monotonic_time);
555 bool is_likely_to_require_a_draw() const {
556 return is_likely_to_require_a_draw_;
559 // Removes empty or orphan RenderPasses from the frame.
560 static void RemoveRenderPasses(FrameData* frame);
562 LayerTreeHostImplClient* client_;
563 Proxy* proxy_;
565 BeginFrameTracker current_begin_frame_tracker_;
567 private:
568 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta(
569 LayerImpl* layer_impl,
570 const gfx::PointF& viewport_point,
571 const gfx::Vector2dF& viewport_delta);
573 void CreateAndSetRenderer();
574 void CreateAndSetTileManager();
575 void DestroyTileManager();
576 void ReleaseTreeResources();
577 void RecreateTreeResources();
579 void UpdateGpuRasterizationStatus();
581 bool IsSynchronousSingleThreaded() const;
583 Viewport* viewport() { return viewport_.get(); }
585 // Scroll by preferring to move the outer viewport first, only moving the
586 // inner if the outer is at its scroll extents.
587 void ScrollViewportBy(gfx::Vector2dF scroll_delta);
588 // Scroll by preferring to move the inner viewport first, only moving the
589 // outer if the inner is at its scroll extents.
590 void ScrollViewportInnerFirst(gfx::Vector2dF scroll_delta);
592 void AnimatePageScale(base::TimeTicks monotonic_time);
593 void AnimateScrollbars(base::TimeTicks monotonic_time);
594 void AnimateTopControls(base::TimeTicks monotonic_time);
596 void TrackDamageForAllSurfaces(
597 LayerImpl* root_draw_layer,
598 const LayerImplList& render_surface_layer_list);
600 void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy);
602 // This function should only be called from PrepareToDraw, as DidDrawAllLayers
603 // must be called if this helper function is called. Returns DRAW_SUCCESS if
604 // the frame should be drawn.
605 DrawResult CalculateRenderPasses(FrameData* frame);
607 void ClearCurrentlyScrollingLayer();
609 bool HandleMouseOverScrollbar(LayerImpl* layer_impl,
610 const gfx::PointF& device_viewport_point);
612 LayerImpl* FindScrollLayerForDeviceViewportPoint(
613 const gfx::PointF& device_viewport_point,
614 InputHandler::ScrollInputType type,
615 LayerImpl* layer_hit_by_point,
616 bool* scroll_on_main_thread,
617 bool* optional_has_ancestor_scroll_handler) const;
618 float DeviceSpaceDistanceToLayer(const gfx::PointF& device_viewport_point,
619 LayerImpl* layer_impl);
620 void StartScrollbarFadeRecursive(LayerImpl* layer);
621 void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy);
622 void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy);
624 void MarkUIResourceNotEvicted(UIResourceId uid);
626 void NotifySwapPromiseMonitorsOfSetNeedsRedraw();
627 void NotifySwapPromiseMonitorsOfForwardingToMainThread();
629 void ScrollAnimationCreate(LayerImpl* layer_impl,
630 const gfx::ScrollOffset& target_offset,
631 const gfx::ScrollOffset& current_offset);
632 bool ScrollAnimationUpdateTarget(LayerImpl* layer_impl,
633 const gfx::Vector2dF& scroll_delta);
635 typedef base::hash_map<UIResourceId, UIResourceData>
636 UIResourceMap;
637 UIResourceMap ui_resource_map_;
639 // Resources that were evicted by EvictAllUIResources. Resources are removed
640 // from this when they are touched by a create or destroy from the UI resource
641 // request queue.
642 std::set<UIResourceId> evicted_ui_resources_;
644 scoped_ptr<OutputSurface> output_surface_;
646 // |resource_provider_| and |tile_manager_| can be NULL, e.g. when using tile-
647 // free rendering - see OutputSurface::ForcedDrawToSoftwareDevice().
648 // |tile_manager_| can also be NULL when raster_enabled is false.
649 scoped_ptr<ResourceProvider> resource_provider_;
650 scoped_ptr<TileManager> tile_manager_;
651 bool content_is_suitable_for_gpu_rasterization_;
652 bool has_gpu_rasterization_trigger_;
653 bool use_gpu_rasterization_;
654 bool use_msaa_;
655 GpuRasterizationStatus gpu_rasterization_status_;
656 bool tree_resources_for_gpu_rasterization_dirty_;
657 scoped_ptr<TileTaskWorkerPool> tile_task_worker_pool_;
658 scoped_ptr<ResourcePool> resource_pool_;
659 scoped_ptr<ResourcePool> staging_resource_pool_;
660 scoped_ptr<Renderer> renderer_;
662 GlobalStateThatImpactsTilePriority global_tile_state_;
664 // Tree currently being drawn.
665 scoped_ptr<LayerTreeImpl> active_tree_;
667 // In impl-side painting mode, tree with possibly incomplete rasterized
668 // content. May be promoted to active by ActivatePendingTree().
669 scoped_ptr<LayerTreeImpl> pending_tree_;
671 // In impl-side painting mode, inert tree with layers that can be recycled
672 // by the next sync from the main thread.
673 scoped_ptr<LayerTreeImpl> recycle_tree_;
675 InputHandlerClient* input_handler_client_;
676 bool did_lock_scrolling_layer_;
677 bool should_bubble_scrolls_;
678 bool wheel_scrolling_;
679 bool scroll_affects_scroll_handler_;
680 int scroll_layer_id_when_mouse_over_scrollbar_;
681 ScopedPtrVector<SwapPromise> swap_promises_for_main_thread_scroll_update_;
683 // An object to implement the ScrollElasticityHelper interface and
684 // hold all state related to elasticity. May be NULL if never requested.
685 scoped_ptr<ScrollElasticityHelper> scroll_elasticity_helper_;
687 bool tile_priorities_dirty_;
689 // The optional delegate for the root layer scroll offset.
690 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_;
691 const LayerTreeSettings settings_;
692 LayerTreeDebugState debug_state_;
693 bool visible_;
694 ManagedMemoryPolicy cached_managed_memory_policy_;
696 gfx::Vector2dF accumulated_root_overscroll_;
698 bool pinch_gesture_active_;
699 bool pinch_gesture_end_should_clear_scrolling_layer_;
700 gfx::Point previous_pinch_anchor_;
702 scoped_ptr<TopControlsManager> top_controls_manager_;
704 scoped_ptr<PageScaleAnimation> page_scale_animation_;
706 scoped_ptr<FrameRateCounter> fps_counter_;
707 scoped_ptr<PaintTimeCounter> paint_time_counter_;
708 scoped_ptr<MemoryHistory> memory_history_;
709 scoped_ptr<DebugRectHistory> debug_rect_history_;
711 scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_;
713 // The maximum memory that would be used by the prioritized resource
714 // manager, if there were no limit on memory usage.
715 size_t max_memory_needed_bytes_;
717 // Viewport size passed in from the main thread, in physical pixels. This
718 // value is the default size for all concepts of physical viewport (draw
719 // viewport, scrolling viewport and device viewport), but it can be
720 // overridden.
721 gfx::Size device_viewport_size_;
723 // Conversion factor from CSS pixels to physical pixels when
724 // pageScaleFactor=1.
725 float device_scale_factor_;
727 // Optional top-level constraints that can be set by the OutputSurface.
728 // - external_transform_ applies a transform above the root layer
729 // - external_viewport_ is used DrawProperties, tile management and
730 // glViewport/window projection matrix.
731 // - external_clip_ specifies a top-level clip rect
732 // - viewport_rect_for_tile_priority_ is the rect in view space used for
733 // tiling priority.
734 gfx::Transform external_transform_;
735 gfx::Rect external_viewport_;
736 gfx::Rect external_clip_;
737 gfx::Rect viewport_rect_for_tile_priority_;
738 bool resourceless_software_draw_;
740 gfx::Rect viewport_damage_rect_;
742 scoped_ptr<AnimationRegistrar> animation_registrar_;
743 std::set<ScrollbarAnimationController*> scrollbar_animation_controllers_;
744 std::set<VideoFrameController*> video_frame_controllers_;
746 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
747 MicroBenchmarkControllerImpl micro_benchmark_controller_;
748 scoped_ptr<TaskGraphRunner> single_thread_synchronous_task_graph_runner_;
750 // Optional callback to notify of new tree activations.
751 base::Closure tree_activation_callback_;
753 SharedBitmapManager* shared_bitmap_manager_;
754 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
755 TaskGraphRunner* task_graph_runner_;
756 int id_;
758 std::set<SwapPromiseMonitor*> swap_promise_monitor_;
760 bool requires_high_res_to_draw_;
761 bool is_likely_to_require_a_draw_;
763 scoped_ptr<FrameTimingTracker> frame_timing_tracker_;
765 scoped_ptr<Viewport> viewport_;
767 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
770 } // namespace cc
772 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_