blob: ba9b674e4077d8f20e9c4efea81281da030e6dcd [file] [log] [blame]
[email protected]cd57cc5a2012-10-12 22:43:411// Copyright 2011 The Chromium Authors. All rights reserved.
[email protected]0fb25002012-10-12 07:20:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
[email protected]cd57cc5a2012-10-12 22:43:414
[email protected]556fd292013-03-18 08:03:045#ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_
6#define CC_TREES_LAYER_TREE_HOST_IMPL_H_
[email protected]cd57cc5a2012-10-12 22:43:417
avi02a4d172015-12-21 06:14:368#include <stddef.h>
9
danakj60bc3bc2016-04-09 00:24:4810#include <memory>
[email protected]127bdc1a2013-09-11 01:44:4811#include <set>
[email protected]bf691c22013-03-26 21:15:0612#include <string>
davidben5877ffe2016-01-28 00:29:5113#include <unordered_map>
[email protected]bf691c22013-03-26 21:15:0614#include <vector>
15
majidvp96452d02016-04-11 20:36:0416#include "base/callback.h"
avi02a4d172015-12-21 06:14:3617#include "base/macros.h"
[email protected]1b0df502013-06-27 23:39:5818#include "base/time/time.h"
majidvp96452d02016-04-11 20:36:0419#include "cc/animation/layer_tree_mutator.h"
[email protected]681ccff2013-03-18 06:13:5220#include "cc/base/cc_export.h"
aelias58eec0812014-12-04 01:04:4021#include "cc/base/synced_property.h"
vmpstr99aa853c2015-02-03 20:31:2222#include "cc/debug/frame_timing_tracker.h"
[email protected]5e5648a2013-11-18 00:39:3323#include "cc/debug/micro_benchmark_controller_impl.h"
[email protected]3052b10f2013-03-18 07:41:2124#include "cc/input/input_handler.h"
loyso455b4f602016-02-24 02:59:4225#include "cc/input/scrollbar_animation_controller.h"
[email protected]3052b10f2013-03-18 07:41:2126#include "cc/input/top_controls_manager_client.h"
vollick83fbfc82016-03-22 18:33:2727#include "cc/layers/layer_collections.h"
[email protected]cc3cfaa2013-03-18 09:05:5228#include "cc/layers/render_pass_sink.h"
[email protected]df3c24c92013-06-19 03:54:3529#include "cc/output/begin_frame_args.h"
[email protected]fd32d122013-06-29 13:11:0430#include "cc/output/managed_memory_policy.h"
[email protected]7f0d825f2013-03-18 07:24:3031#include "cc/output/output_surface_client.h"
32#include "cc/output/renderer.h"
[email protected]89e8267a2013-03-18 07:50:5633#include "cc/quads/render_pass.h"
[email protected]c9280762013-08-01 06:28:5734#include "cc/resources/resource_provider.h"
jamesr9b8fda32015-03-16 19:11:0535#include "cc/resources/ui_resource_client.h"
mithro0bdb49d2015-05-27 13:08:0136#include "cc/scheduler/begin_frame_tracker.h"
mithrof7a21502014-12-17 03:24:4837#include "cc/scheduler/commit_earlyout_reason.h"
[email protected]30d82142014-05-12 04:26:0238#include "cc/scheduler/draw_result.h"
sunnyps7d073dc2015-04-16 23:29:1239#include "cc/scheduler/video_frame_controller.h"
vmpstr64cdba32016-03-03 00:38:4040#include "cc/tiles/image_decode_controller.h"
danakj920156852015-05-18 20:22:2941#include "cc/tiles/tile_manager.h"
jamesr9b8fda32015-03-16 19:11:0542#include "cc/trees/layer_tree_settings.h"
loysobb93befc2015-07-03 00:19:5043#include "cc/trees/mutator_host_client.h"
khushalsagarb64b360d2015-10-21 19:25:1644#include "cc/trees/task_runner_provider.h"
[email protected]c9280762013-08-01 06:28:5745#include "skia/ext/refptr.h"
[email protected]ddf9df82012-10-16 06:52:4646#include "third_party/skia/include/core/SkColor.h"
heejin.r.chungd28506ba2014-10-23 16:36:2047#include "ui/gfx/geometry/rect.h"
[email protected]cd57cc5a2012-10-12 22:43:4148
loyso2c4002d2015-03-13 02:31:4349namespace gfx {
50class ScrollOffset;
51}
52
[email protected]cd57cc5a2012-10-12 22:43:4153namespace cc {
54
loysoe926437dd2016-01-14 22:55:3055class AnimationEvents;
loysobb93befc2015-07-03 00:19:5056class AnimationHost;
[email protected]96baf3e2012-10-22 23:09:5557class CompletionEvent;
[email protected]bf189f62012-12-18 03:42:1158class CompositorFrameMetadata;
[email protected]96baf3e2012-10-22 23:09:5559class DebugRectHistory;
[email protected]bf050582014-07-24 11:10:5860class EvictionTilePriorityQueue;
[email protected]96baf3e2012-10-22 23:09:5561class FrameRateCounter;
[email protected]96baf3e2012-10-22 23:09:5562class LayerImpl;
[email protected]8bef40572012-12-11 21:38:0863class LayerTreeImpl;
[email protected]ec7541d2014-04-09 01:23:5364class MemoryHistory;
[email protected]96baf3e2012-10-22 23:09:5565class PageScaleAnimation;
[email protected]8aa39ecb2014-06-12 14:19:1466class PictureLayerImpl;
[email protected]bf050582014-07-24 11:10:5867class RasterTilePriorityQueue;
vmiuraa30e1ea2014-12-09 19:23:5168class TileTaskWorkerPool;
[email protected]96baf3e2012-10-22 23:09:5569class RenderPassDrawQuad;
[email protected]ec7541d2014-04-09 01:23:5370class RenderingStatsInstrumentation;
[email protected]eece11e2014-04-12 03:07:1671class ResourcePool;
ccameron4163cc352014-11-13 19:06:3672class ScrollElasticityHelper;
[email protected]bf1cfd9a2013-09-26 05:43:0273class ScrollbarLayerImplBase;
jamesr9b8fda32015-03-16 19:11:0574class SwapPromise;
75class SwapPromiseMonitor;
ericrk4e3aa5a2015-12-01 03:53:5676class SynchronousTaskGraphRunner;
prashant.n49b3e64652016-04-19 07:04:4977class TaskGraphRunner;
[email protected]ea468c6c2013-09-10 08:25:1178class TextureMailboxDeleter;
[email protected]3ba4cae2013-01-16 03:58:3879class TopControlsManager;
[email protected]c9280762013-08-01 06:28:5780class UIResourceBitmap;
[email protected]741fba422013-09-20 03:34:1481class UIResourceRequest;
jamesr9b8fda32015-03-16 19:11:0582struct ScrollAndScaleSet;
bokanaa2748312015-03-26 00:10:3783class Viewport;
[email protected]cd57cc5a2012-10-12 22:43:4184
majidvp96452d02016-04-11 20:36:0485using BeginFrameCallbackList = std::vector<base::Closure>;
86
hendrikwc2bbd612014-12-03 23:49:3487enum class GpuRasterizationStatus {
88 ON,
89 ON_FORCED,
90 OFF_DEVICE,
91 OFF_VIEWPORT,
senorblancofb88a4e2015-05-08 17:28:4192 MSAA_CONTENT,
hendrikwc2bbd612014-12-03 23:49:3493 OFF_CONTENT
94};
95
[email protected]96baf3e2012-10-22 23:09:5596// LayerTreeHost->Proxy callback interface.
97class LayerTreeHostImplClient {
[email protected]c1bb5af2013-03-13 19:06:2798 public:
[email protected]fa339032014-02-18 22:11:5999 virtual void UpdateRendererCapabilitiesOnImplThread() = 0;
[email protected]c1bb5af2013-03-13 19:06:27100 virtual void DidLoseOutputSurfaceOnImplThread() = 0;
[email protected]3dc0c772014-04-26 10:06:05101 virtual void CommitVSyncParameters(base::TimeTicks timebase,
102 base::TimeDelta interval) = 0;
enne19c108582016-04-14 03:35:32103 virtual void SetBeginFrameSource(BeginFrameSource* source) = 0;
[email protected]3dc0c772014-04-26 10:06:05104 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) = 0;
[email protected]4d7e46a2013-11-08 05:33:40105 virtual void DidSwapBuffersOnImplThread() = 0;
[email protected]c14902662014-04-18 05:06:11106 virtual void DidSwapBuffersCompleteOnImplThread() = 0;
[email protected]c1bb5af2013-03-13 19:06:27107 virtual void OnCanDrawStateChanged(bool can_draw) = 0;
[email protected]4f48f6e2013-08-27 06:33:38108 virtual void NotifyReadyToActivate() = 0;
ernstmdfac03e12014-11-11 20:18:05109 virtual void NotifyReadyToDraw() = 0;
[email protected]43b8f982014-04-30 21:24:33110 // Please call these 3 functions through
111 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and
danakja18e826a2015-12-03 00:27:03112 // SetNeedsOneBeginImplFrame().
[email protected]c1bb5af2013-03-13 19:06:27113 virtual void SetNeedsRedrawOnImplThread() = 0;
[email protected]0023fc72014-01-10 20:05:06114 virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0;
danakja18e826a2015-12-03 00:27:03115 virtual void SetNeedsOneBeginImplFrameOnImplThread() = 0;
[email protected]c1bb5af2013-03-13 19:06:27116 virtual void SetNeedsCommitOnImplThread() = 0;
vmiura59ea9b4042014-12-09 20:50:39117 virtual void SetNeedsPrepareTilesOnImplThread() = 0;
sunnyps7d073dc2015-04-16 23:29:12118 virtual void SetVideoNeedsBeginFrames(bool needs_begin_frames) = 0;
[email protected]c1bb5af2013-03-13 19:06:27119 virtual void PostAnimationEventsToMainThreadOnImplThread(
danakj60bc3bc2016-04-09 00:24:48120 std::unique_ptr<AnimationEvents> events) = 0;
[email protected]c1bb5af2013-03-13 19:06:27121 virtual bool IsInsideDraw() = 0;
122 virtual void RenewTreePriority() = 0;
sunnypsae4316a2015-02-25 00:54:58123 virtual void PostDelayedAnimationTaskOnImplThread(const base::Closure& task,
124 base::TimeDelta delay) = 0;
[email protected]fc20d142014-07-01 00:49:15125 virtual void DidActivateSyncTree() = 0;
brianderson68749812015-07-07 22:39:39126 virtual void WillPrepareTiles() = 0;
vmiura59ea9b4042014-12-09 20:50:39127 virtual void DidPrepareTiles() = 0;
[email protected]bf691c22013-03-26 21:15:06128
rouslanf7ebd8832015-01-22 01:54:14129 // Called when page scale animation has completed on the impl thread.
130 virtual void DidCompletePageScaleAnimationOnImplThread() = 0;
131
sunnypseab5ac92015-04-02 20:26:13132 // Called when output surface asks for a draw.
boliu7097ee5b2015-12-17 03:16:09133 virtual void OnDrawForOutputSurface(bool resourceless_software_draw) = 0;
sunnypseab5ac92015-04-02 20:26:13134
mpbed24c2c2015-06-05 20:57:13135 virtual void PostFrameTimingEventsOnImplThread(
danakj60bc3bc2016-04-09 00:24:48136 std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
137 std::unique_ptr<FrameTimingTracker::MainFrameTimingSet>
138 main_frame_events) = 0;
mpbed24c2c2015-06-05 20:57:13139
[email protected]bf691c22013-03-26 21:15:06140 protected:
141 virtual ~LayerTreeHostImplClient() {}
[email protected]cd57cc5a2012-10-12 22:43:41142};
143
[email protected]c1bb5af2013-03-13 19:06:27144// LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering
145// state.
[email protected]200a9c062013-05-20 04:34:37146class CC_EXPORT LayerTreeHostImpl
147 : public InputHandler,
148 public RendererClient,
149 public TileManagerClient,
150 public OutputSurfaceClient,
151 public TopControlsManagerClient,
[email protected]930ff43b2014-05-02 05:24:00152 public ScrollbarAnimationControllerClient,
sunnyps7d073dc2015-04-16 23:29:12153 public VideoFrameControllerClient,
loysobb93befc2015-07-03 00:19:50154 public MutatorHostClient,
[email protected]200a9c062013-05-20 04:34:37155 public base::SupportsWeakPtr<LayerTreeHostImpl> {
[email protected]e216fef02013-03-20 22:56:10156 public:
danakj60bc3bc2016-04-09 00:24:48157 static std::unique_ptr<LayerTreeHostImpl> Create(
[email protected]c1bb5af2013-03-13 19:06:27158 const LayerTreeSettings& settings,
159 LayerTreeHostImplClient* client,
khushalsagarb64b360d2015-10-21 19:25:16160 TaskRunnerProvider* task_runner_provider,
[email protected]a7f35682013-10-22 23:05:57161 RenderingStatsInstrumentation* rendering_stats_instrumentation,
reveman22dd9292014-10-13 20:52:05162 SharedBitmapManager* shared_bitmap_manager,
revemanf9a8a2342014-10-28 17:54:52163 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
reveman34b7a1522015-03-23 20:27:47164 TaskGraphRunner* task_graph_runner,
[email protected]dbe759a2013-12-02 19:23:02165 int id);
dcheng716bedf2014-10-21 09:51:08166 ~LayerTreeHostImpl() override;
[email protected]cd57cc5a2012-10-12 22:43:41167
[email protected]5ff3c9782013-04-29 17:35:12168 // InputHandler implementation
dcheng716bedf2014-10-21 09:51:08169 void BindToClient(InputHandlerClient* client) override;
170 InputHandler::ScrollStatus ScrollBegin(
majidvp944a8cd2016-01-12 21:05:18171 ScrollState* scroll_state,
mostynbf68776d82014-10-06 18:07:37172 InputHandler::ScrollInputType type) override;
hush1c873232015-06-23 21:22:11173 InputHandler::ScrollStatus RootScrollBegin(
majidvp944a8cd2016-01-12 21:05:18174 ScrollState* scroll_state,
hush1c873232015-06-23 21:22:11175 InputHandler::ScrollInputType type) override;
dtapuska1827dd22016-03-11 15:24:59176 ScrollStatus ScrollAnimatedBegin(const gfx::Point& viewport_point) override;
dcheng716bedf2014-10-21 09:51:08177 InputHandler::ScrollStatus ScrollAnimated(
[email protected]749cbc62014-07-10 01:06:35178 const gfx::Point& viewport_point,
mostynbf68776d82014-10-06 18:07:37179 const gfx::Vector2dF& scroll_delta) override;
sunxd2668bea62016-03-17 00:49:47180 void ApplyScroll(ScrollNode* scroll_node, ScrollState* scroll_state);
majidvp944a8cd2016-01-12 21:05:18181 InputHandlerScrollResult ScrollBy(ScrollState* scroll_state) override;
dcheng716bedf2014-10-21 09:51:08182 bool ScrollVerticallyByPage(const gfx::Point& viewport_point,
183 ScrollDirection direction) override;
danakjdd74e512015-09-21 23:07:59184 void RequestUpdateForSynchronousInputHandler() override;
185 void SetSynchronousInputHandlerRootScrollOffset(
danakj0481b572015-09-10 01:18:01186 const gfx::ScrollOffset& root_offset) override;
majidvp944a8cd2016-01-12 21:05:18187 void ScrollEnd(ScrollState* scroll_state) override;
dcheng716bedf2014-10-21 09:51:08188 InputHandler::ScrollStatus FlingScrollBegin() override;
189 void MouseMoveAt(const gfx::Point& viewport_point) override;
190 void PinchGestureBegin() override;
191 void PinchGestureUpdate(float magnify_delta,
192 const gfx::Point& anchor) override;
193 void PinchGestureEnd() override;
bokanfcdbc182014-11-21 21:53:33194 void StartPageScaleAnimation(const gfx::Vector2d& target_offset,
195 bool anchor_point,
196 float page_scale,
197 base::TimeDelta duration);
hushb0ee8dc2015-06-10 00:48:57198 void SetNeedsAnimateInput() override;
skobesde5abdb82015-10-20 19:16:34199 bool IsCurrentlyScrollingInnerViewport() const override;
danakje9f830c2015-09-09 21:36:16200 bool IsCurrentlyScrollingLayerAt(
201 const gfx::Point& viewport_point,
202 InputHandler::ScrollInputType type) const override;
dtapuskaf206a40d2016-02-05 21:36:02203 EventListenerProperties GetEventListenerProperties(
204 EventListenerClass event_class) const override;
rbyers18779d822015-02-05 06:22:06205 bool DoTouchEventsBlockScrollAt(const gfx::Point& viewport_port) override;
danakj60bc3bc2016-04-09 00:24:48206 std::unique_ptr<SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor(
mostynbf68776d82014-10-06 18:07:37207 ui::LatencyInfo* latency) override;
ccameron4163cc352014-11-13 19:06:36208 ScrollElasticityHelper* CreateScrollElasticityHelper() override;
[email protected]cd57cc5a2012-10-12 22:43:41209
[email protected]c1bb5af2013-03-13 19:06:27210 // TopControlsManagerClient implementation.
aelias6004fe02015-02-07 21:43:01211 float TopControlsHeight() const override;
212 void SetCurrentTopControlsShownRatio(float offset) override;
213 float CurrentTopControlsShownRatio() const override;
dcheng716bedf2014-10-21 09:51:08214 void DidChangeTopControlsPosition() override;
215 bool HaveRootScrollLayer() const override;
[email protected]3ba4cae2013-01-16 03:58:38216
aelias6004fe02015-02-07 21:43:01217 void UpdateViewportContainerSizes();
218
[email protected]c1bb5af2013-03-13 19:06:27219 struct CC_EXPORT FrameData : public RenderPassSink {
220 FrameData();
dcheng716bedf2014-10-21 09:51:08221 ~FrameData() override;
ssid911e40e2015-02-09 17:55:20222 void AsValueInto(base::trace_event::TracedValue* value) const;
[email protected]cd57cc5a2012-10-12 22:43:41223
[email protected]c1bb5af2013-03-13 19:06:27224 std::vector<gfx::Rect> occluding_screen_space_rects;
225 std::vector<gfx::Rect> non_occluding_screen_space_rects;
vmpstr99aa853c2015-02-03 20:31:22226 std::vector<FrameTimingTracker::FrameAndRectIds> composite_events;
[email protected]c1bb5af2013-03-13 19:06:27227 RenderPassList render_passes;
[email protected]50761e92013-03-29 20:51:28228 const LayerImplList* render_surface_layer_list;
229 LayerImplList will_draw_layers;
[email protected]e0341352013-04-06 05:01:20230 bool has_no_damage;
[email protected]cd57cc5a2012-10-12 22:43:41231
[email protected]c1bb5af2013-03-13 19:06:27232 // RenderPassSink implementation.
danakj60bc3bc2016-04-09 00:24:48233 void AppendRenderPass(std::unique_ptr<RenderPass> render_pass) override;
vmpstra370ef52015-11-18 10:41:28234
235 private:
236 DISALLOW_COPY_AND_ASSIGN(FrameData);
[email protected]c1bb5af2013-03-13 19:06:27237 };
[email protected]cd57cc5a2012-10-12 22:43:41238
mithrof7a21502014-12-17 03:24:48239 virtual void BeginMainFrameAborted(CommitEarlyOutReason reason);
[email protected]c1bb5af2013-03-13 19:06:27240 virtual void BeginCommit();
241 virtual void CommitComplete();
[email protected]3d9f7432013-04-06 00:35:18242 virtual void UpdateAnimationState(bool start_ready_animations);
[email protected]b33348f2014-04-30 18:17:34243 void ActivateAnimations();
danakj4923440542015-10-29 19:34:53244 void Animate();
245 void AnimatePendingTreeAfterCommit();
[email protected]200a9c062013-05-20 04:34:37246 void MainThreadHasStoppedFlinging();
[email protected]b8384e22013-12-03 02:20:48247 void DidAnimateScrollOffset();
[email protected]0023fc72014-01-10 20:05:06248 void SetViewportDamage(const gfx::Rect& damage_rect);
[email protected]cd57cc5a2012-10-12 22:43:41249
loysobb93befc2015-07-03 00:19:50250 void SetTreeLayerFilterMutated(int layer_id,
251 LayerTreeImpl* tree,
252 const FilterOperations& filters);
253 void SetTreeLayerOpacityMutated(int layer_id,
254 LayerTreeImpl* tree,
255 float opacity);
256 void SetTreeLayerTransformMutated(int layer_id,
257 LayerTreeImpl* tree,
258 const gfx::Transform& transform);
259 void SetTreeLayerScrollOffsetMutated(int layer_id,
260 LayerTreeImpl* tree,
261 const gfx::ScrollOffset& scroll_offset);
ajumacaaa9b32015-08-04 15:55:29262 void TreeLayerTransformIsPotentiallyAnimatingChanged(int layer_id,
263 LayerTreeImpl* tree,
264 bool is_animating);
weiliangcc154ce22015-12-09 03:39:26265 bool AnimationsPreserveAxisAlignment(const LayerImpl* layer) const;
loysobb93befc2015-07-03 00:19:50266
267 // LayerTreeMutatorsClient implementation.
vollickcb3f6b12016-03-01 23:44:10268 bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override;
loysobb93befc2015-07-03 00:19:50269 void SetMutatorsNeedCommit() override;
loysod02fc472015-10-21 14:26:44270 void SetMutatorsNeedRebuildPropertyTrees() override;
loysobb93befc2015-07-03 00:19:50271 void SetLayerFilterMutated(int layer_id,
vollickcb3f6b12016-03-01 23:44:10272 LayerTreeType tree_type,
loysobb93befc2015-07-03 00:19:50273 const FilterOperations& filters) override;
274 void SetLayerOpacityMutated(int layer_id,
vollickcb3f6b12016-03-01 23:44:10275 LayerTreeType tree_type,
loysobb93befc2015-07-03 00:19:50276 float opacity) override;
277 void SetLayerTransformMutated(int layer_id,
vollickcb3f6b12016-03-01 23:44:10278 LayerTreeType tree_type,
loysobb93befc2015-07-03 00:19:50279 const gfx::Transform& transform) override;
280 void SetLayerScrollOffsetMutated(
281 int layer_id,
vollickcb3f6b12016-03-01 23:44:10282 LayerTreeType tree_type,
loysobb93befc2015-07-03 00:19:50283 const gfx::ScrollOffset& scroll_offset) override;
ajumacaaa9b32015-08-04 15:55:29284 void LayerTransformIsPotentiallyAnimatingChanged(int layer_id,
vollickcb3f6b12016-03-01 23:44:10285 LayerTreeType tree_type,
ajumacaaa9b32015-08-04 15:55:29286 bool is_animating) override;
loysoce3bb822015-07-08 02:40:47287 void ScrollOffsetAnimationFinished() override;
288 gfx::ScrollOffset GetScrollOffsetForAnimation(int layer_id) const override;
loysobb93befc2015-07-03 00:19:50289
vmpstr79191842015-07-10 20:40:33290 virtual bool PrepareTiles();
[email protected]8947cbe2012-11-28 05:27:43291
[email protected]2aae96792014-05-15 23:10:50292 // Returns DRAW_SUCCESS unless problems occured preparing the frame, and we
293 // should try to avoid displaying the frame. If PrepareToDraw is called,
294 // DidDrawAllLayers must also be called, regardless of whether DrawLayers is
295 // called between the two.
296 virtual DrawResult PrepareToDraw(FrameData* frame);
mithro248d1722015-05-05 05:23:45297 virtual void DrawLayers(FrameData* frame);
[email protected]c1bb5af2013-03-13 19:06:27298 // Must be called if and only if PrepareToDraw was called.
299 void DidDrawAllLayers(const FrameData& frame);
[email protected]cd57cc5a2012-10-12 22:43:41300
[email protected]c1bb5af2013-03-13 19:06:27301 const LayerTreeSettings& settings() const { return settings_; }
[email protected]cd57cc5a2012-10-12 22:43:41302
[email protected]0309ba5e02013-06-26 04:11:08303 // Evict all textures by enforcing a memory policy with an allocation of 0.
304 void EvictTexturesForTesting();
305
[email protected]4f48f6e2013-08-27 06:33:38306 // When blocking, this prevents client_->NotifyReadyToActivate() from being
307 // called. When disabled, it calls client_->NotifyReadyToActivate()
308 // immediately if any notifications had been blocked while blocking.
309 virtual void BlockNotifyReadyToActivateForTesting(bool block);
310
[email protected]34bff2122014-05-16 04:09:34311 // Resets all of the trees to an empty state.
312 void ResetTreesForTesting();
313
vmpstr380db092015-06-02 00:50:18314 size_t SourceAnimationFrameNumberForTesting() const;
315
aeliasa57c40d122015-10-08 00:20:09316 void RegisterScrollbarAnimationController(int scroll_layer_id);
317 void UnregisterScrollbarAnimationController(int scroll_layer_id);
318 ScrollbarAnimationController* ScrollbarAnimationControllerForId(
319 int scroll_layer_id) const;
320
[email protected]c05dfbb2014-07-10 22:49:04321 DrawMode GetDrawMode() const;
[email protected]54af03522013-09-05 00:43:28322
323 // Viewport size in draw space: this size is in physical pixels and is used
324 // for draw properties, tilings, quads and render passes.
325 gfx::Size DrawViewportSize() const;
326
[email protected]bd5324592014-07-31 09:09:33327 // Viewport rect in view space used for tiling prioritization.
328 const gfx::Rect ViewportRectForTilePriority() const;
329
[email protected]59fee302013-12-10 17:53:30330 // RendererClient implementation.
dcheng716bedf2014-10-21 09:51:08331 void SetFullRootLayerDamage() override;
[email protected]8947cbe2012-11-28 05:27:43332
[email protected]c1bb5af2013-03-13 19:06:27333 // TileManagerClient implementation.
dcheng716bedf2014-10-21 09:51:08334 void NotifyReadyToActivate() override;
ernstmdfac03e12014-11-11 20:18:05335 void NotifyReadyToDraw() override;
ericrk58049242015-06-22 20:32:15336 void NotifyAllTileTasksCompleted() override;
dcheng716bedf2014-10-21 09:51:08337 void NotifyTileStateChanged(const Tile* tile) override;
danakj60bc3bc2016-04-09 00:24:48338 std::unique_ptr<RasterTilePriorityQueue> BuildRasterQueue(
vmpstrb4040632015-01-23 17:53:41339 TreePriority tree_priority,
340 RasterTilePriorityQueue::Type type) override;
danakj60bc3bc2016-04-09 00:24:48341 std::unique_ptr<EvictionTilePriorityQueue> BuildEvictionQueue(
vmpstr997b00e2015-01-23 21:03:07342 TreePriority tree_priority) override;
vmpstr4973f5b2015-02-02 19:27:29343 void SetIsLikelyToRequireADraw(bool is_likely_to_require_a_draw) override;
[email protected]cd57cc5a2012-10-12 22:43:41344
[email protected]930ff43b2014-05-02 05:24:00345 // ScrollbarAnimationControllerClient implementation.
sunnypsae4316a2015-02-25 00:54:58346 void PostDelayedScrollbarAnimationTask(const base::Closure& task,
347 base::TimeDelta delay) override;
aeliasa57c40d122015-10-08 00:20:09348 void SetNeedsAnimateForScrollbarAnimation() override;
sunnypsae4316a2015-02-25 00:54:58349 void SetNeedsRedrawForScrollbarAnimation() override;
aeliasa57c40d122015-10-08 00:20:09350 ScrollbarSet ScrollbarsFor(int scroll_layer_id) const override;
[email protected]930ff43b2014-05-02 05:24:00351
sunnyps7d073dc2015-04-16 23:29:12352 // VideoBeginFrameSource implementation.
353 void AddVideoFrameController(VideoFrameController* controller) override;
354 void RemoveVideoFrameController(VideoFrameController* controller) override;
355
[email protected]c1bb5af2013-03-13 19:06:27356 // OutputSurfaceClient implementation.
dcheng716bedf2014-10-21 09:51:08357 void CommitVSyncParameters(base::TimeTicks timebase,
358 base::TimeDelta interval) override;
enne19c108582016-04-14 03:35:32359 void SetBeginFrameSource(BeginFrameSource* source) override;
dcheng716bedf2014-10-21 09:51:08360 void SetNeedsRedrawRect(const gfx::Rect& rect) override;
boliu7097ee5b2015-12-17 03:16:09361 void SetExternalTilePriorityConstraints(
362 const gfx::Rect& viewport_rect,
363 const gfx::Transform& transform) override;
dcheng716bedf2014-10-21 09:51:08364 void DidLoseOutputSurface() override;
365 void DidSwapBuffers() override;
366 void DidSwapBuffersComplete() override;
367 void ReclaimResources(const CompositorFrameAck* ack) override;
368 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override;
369 void SetTreeActivationCallback(const base::Closure& callback) override;
boliu7097ee5b2015-12-17 03:16:09370 void OnDraw(const gfx::Transform& transform,
371 const gfx::Rect& viewport,
372 const gfx::Rect& clip,
373 bool resourceless_software_draw) override;
[email protected]3b31c6ac2012-12-06 21:27:29374
[email protected]c1bb5af2013-03-13 19:06:27375 // Called from LayerTreeImpl.
376 void OnCanDrawStateChangedForTree();
[email protected]cd57cc5a2012-10-12 22:43:41377
[email protected]b5174d712013-08-28 08:10:43378 // Implementation.
[email protected]12a63da2014-06-13 06:06:22379 int id() const { return id_; }
[email protected]6133cc232013-07-30 18:47:07380 bool CanDraw() const;
revemand180dfc32015-09-24 00:19:43381 OutputSurface* output_surface() const { return output_surface_; }
382 void ReleaseOutputSurface();
383
[email protected]c1bb5af2013-03-13 19:06:27384 std::string LayerTreeAsJson() const;
[email protected]cd57cc5a2012-10-12 22:43:41385
[email protected]c1bb5af2013-03-13 19:06:27386 void FinishAllRendering();
senorblanco2a5b0e12015-08-14 21:55:37387 int RequestedMSAASampleCount() const;
[email protected]cd57cc5a2012-10-12 22:43:41388
revemand180dfc32015-09-24 00:19:43389 virtual bool InitializeRenderer(OutputSurface* output_surface);
[email protected]c1bb5af2013-03-13 19:06:27390 TileManager* tile_manager() { return tile_manager_.get(); }
senorblanco8d1b3ac2015-05-05 00:14:26391
senorblanco9c04acb2015-05-15 19:41:32392 void SetHasGpuRasterizationTrigger(bool flag) {
senorblanco8d1b3ac2015-05-05 00:14:26393 has_gpu_rasterization_trigger_ = flag;
senorblanco9c04acb2015-05-15 19:41:32394 UpdateGpuRasterizationStatus();
senorblanco8d1b3ac2015-05-05 00:14:26395 }
senorblanco9c04acb2015-05-15 19:41:32396 void SetContentIsSuitableForGpuRasterization(bool flag) {
senorblanco8d1b3ac2015-05-05 00:14:26397 content_is_suitable_for_gpu_rasterization_ = flag;
senorblanco9c04acb2015-05-15 19:41:32398 UpdateGpuRasterizationStatus();
senorblanco8d1b3ac2015-05-05 00:14:26399 }
vmiura4e7e199c2015-05-15 16:16:20400 bool CanUseGpuRasterization();
senorblanco9c04acb2015-05-15 19:41:32401 void UpdateTreeResourcesForGpuRasterizationIfNeeded();
[email protected]13525d62014-05-20 21:22:04402 bool use_gpu_rasterization() const { return use_gpu_rasterization_; }
senorblancofb88a4e2015-05-08 17:28:41403 bool use_msaa() const { return use_msaa_; }
hendrikwc2bbd612014-12-03 23:49:34404
405 GpuRasterizationStatus gpu_rasterization_status() const {
406 return gpu_rasterization_status_;
407 }
hendrikwc2bbd612014-12-03 23:49:34408
[email protected]473f1f22014-05-22 08:19:17409 bool create_low_res_tiling() const {
410 return settings_.create_low_res_tiling && !use_gpu_rasterization_;
411 }
[email protected]b7635e02014-04-28 07:08:43412 ResourcePool* resource_pool() { return resource_pool_.get(); }
[email protected]c1bb5af2013-03-13 19:06:27413 Renderer* renderer() { return renderer_.get(); }
vmpstr64cdba32016-03-03 00:38:40414 ImageDecodeController* image_decode_controller() {
415 return image_decode_controller_.get();
416 }
[email protected]7a8bcd262014-01-15 12:54:58417 const RendererCapabilitiesImpl& GetRendererCapabilities() const;
[email protected]cd57cc5a2012-10-12 22:43:41418
[email protected]e0341352013-04-06 05:01:20419 virtual bool SwapBuffers(const FrameData& frame);
[email protected]97e9ccd62014-04-12 01:07:15420 virtual void WillBeginImplFrame(const BeginFrameArgs& args);
mithro51693e382015-05-07 23:52:41421 virtual void DidFinishImplFrame();
[email protected]c48536a52013-09-14 00:02:08422 void DidModifyTilePriorities();
[email protected]cd57cc5a2012-10-12 22:43:41423
[email protected]c1bb5af2013-03-13 19:06:27424 LayerTreeImpl* active_tree() { return active_tree_.get(); }
425 const LayerTreeImpl* active_tree() const { return active_tree_.get(); }
426 LayerTreeImpl* pending_tree() { return pending_tree_.get(); }
427 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); }
[email protected]71618ed2014-07-24 02:23:45428 LayerTreeImpl* recycle_tree() { return recycle_tree_.get(); }
[email protected]c1bb5af2013-03-13 19:06:27429 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); }
[email protected]12a63da2014-06-13 06:06:22430 // Returns the tree LTH synchronizes with.
431 LayerTreeImpl* sync_tree() {
enneaf5bda32015-02-19 01:27:36432 // TODO(enne): This is bogus. It should return based on the value of
khushalsagarb64b360d2015-10-21 19:25:16433 // CommitToActiveTree() and not whether the pending tree exists.
[email protected]fc20d142014-07-01 00:49:15434 return pending_tree_ ? pending_tree_.get() : active_tree_.get();
[email protected]12a63da2014-06-13 06:06:22435 }
[email protected]2f0d92f2013-06-11 04:07:20436 virtual void CreatePendingTree();
[email protected]fc20d142014-07-01 00:49:15437 virtual void ActivateSyncTree();
[email protected]cd57cc5a2012-10-12 22:43:41438
[email protected]c1bb5af2013-03-13 19:06:27439 // Shortcuts to layers on the active tree.
440 LayerImpl* RootLayer() const;
[email protected]adeda572014-01-31 00:49:47441 LayerImpl* InnerViewportScrollLayer() const;
442 LayerImpl* OuterViewportScrollLayer() const;
[email protected]c1bb5af2013-03-13 19:06:27443 LayerImpl* CurrentlyScrollingLayer() const;
[email protected]cd57cc5a2012-10-12 22:43:41444
[email protected]f161ca9e2014-04-01 13:57:01445 int scroll_layer_id_when_mouse_over_scrollbar() const {
[email protected]f620b0e72013-10-01 21:38:24446 return scroll_layer_id_when_mouse_over_scrollbar_;
447 }
[email protected]f161ca9e2014-04-01 13:57:01448 bool scroll_affects_scroll_handler() const {
449 return scroll_affects_scroll_handler_;
450 }
[email protected]dab0a422014-08-13 16:09:46451 void QueueSwapPromiseForMainThreadScrollUpdate(
danakj60bc3bc2016-04-09 00:24:48452 std::unique_ptr<SwapPromise> swap_promise);
[email protected]f620b0e72013-10-01 21:38:24453
jdduke16dde6e2014-10-24 00:22:56454 bool IsActivelyScrolling() const;
[email protected]251699b2013-10-09 00:21:26455
[email protected]c1bb5af2013-03-13 19:06:27456 virtual void SetVisible(bool visible);
457 bool visible() const { return visible_; }
[email protected]cd57cc5a2012-10-12 22:43:41458
[email protected]d7eb8c72013-03-23 22:57:13459 void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); }
danakja18e826a2015-12-03 00:27:03460 void SetNeedsOneBeginImplFrame();
[email protected]6be422b2013-12-08 06:47:31461 void SetNeedsRedraw();
[email protected]d7eb8c72013-03-23 22:57:13462
[email protected]206a3922013-05-17 06:34:12463 ManagedMemoryPolicy ActualManagedMemoryPolicy() const;
464
[email protected]3f2ff112013-08-03 02:41:07465 size_t memory_allocation_limit_bytes() const;
[email protected]cd57cc5a2012-10-12 22:43:41466
[email protected]64348ea2014-01-29 22:58:26467 void SetViewportSize(const gfx::Size& device_viewport_size);
[email protected]4a6c091d2014-04-24 21:06:46468 gfx::Size device_viewport_size() const { return device_viewport_size_; }
[email protected]cd57cc5a2012-10-12 22:43:41469
[email protected]54af03522013-09-05 00:43:28470 const gfx::Transform& DrawTransform() const;
[email protected]f224cc92013-06-06 23:23:32471
majidvp96452d02016-04-11 20:36:04472 std::unique_ptr<BeginFrameCallbackList> ProcessLayerTreeMutations();
473
danakj60bc3bc2016-04-09 00:24:48474 std::unique_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
[email protected]cd57cc5a2012-10-12 22:43:41475
[email protected]d7626ffd2013-03-29 00:17:42476 void set_max_memory_needed_bytes(size_t bytes) {
477 max_memory_needed_bytes_ = bytes;
478 }
479
[email protected]c1bb5af2013-03-13 19:06:27480 FrameRateCounter* fps_counter() {
481 return fps_counter_.get();
482 }
[email protected]c1bb5af2013-03-13 19:06:27483 MemoryHistory* memory_history() {
484 return memory_history_.get();
485 }
486 DebugRectHistory* debug_rect_history() {
487 return debug_rect_history_.get();
488 }
489 ResourceProvider* resource_provider() {
490 return resource_provider_.get();
491 }
492 TopControlsManager* top_controls_manager() {
493 return top_controls_manager_.get();
494 }
[email protected]4bb0f312014-02-25 02:02:32495 const GlobalStateThatImpactsTilePriority& global_tile_state() {
496 return global_tile_state_;
497 }
[email protected]ff762fb2012-12-12 19:18:37498
khushalsagarb64b360d2015-10-21 19:25:16499 TaskRunnerProvider* task_runner_provider() const {
500 return task_runner_provider_;
501 }
[email protected]cd57cc5a2012-10-12 22:43:41502
loysobb93befc2015-07-03 00:19:50503 AnimationHost* animation_host() const { return animation_host_.get(); }
[email protected]de4afb5e2012-12-20 00:11:34504
[email protected]6e7fdeb2013-07-09 14:28:38505 void SetDebugState(const LayerTreeDebugState& new_debug_state);
[email protected]c1bb5af2013-03-13 19:06:27506 const LayerTreeDebugState& debug_state() const { return debug_state_; }
[email protected]f511afb2012-11-30 01:55:20507
[email protected]a2b5ded2013-05-20 21:32:53508 gfx::Vector2dF accumulated_root_overscroll() const {
509 return accumulated_root_overscroll_;
510 }
[email protected]a2b5ded2013-05-20 21:32:53511
[email protected]c1bb5af2013-03-13 19:06:27512 bool pinch_gesture_active() const { return pinch_gesture_active_; }
[email protected]166db5c82013-01-09 23:54:31513
[email protected]c1bb5af2013-03-13 19:06:27514 void SetTreePriority(TreePriority priority);
vmpstr56ace232014-10-09 20:16:28515 TreePriority GetTreePriority() const;
[email protected]362f1e8b2013-01-21 16:54:30516
mithro0bdb49d2015-05-27 13:08:01517 // TODO(mithro): Remove this methods which exposes the internal
518 // BeginFrameArgs to external callers.
[email protected]04c5900d2014-08-18 13:38:36519 virtual BeginFrameArgs CurrentBeginFrameArgs() const;
[email protected]829ad972013-01-28 23:36:10520
[email protected]c92195e2014-05-07 18:18:49521 // Expected time between two begin impl frame calls.
mithro0bdb49d2015-05-27 13:08:01522 base::TimeDelta CurrentBeginFrameInterval() const;
[email protected]c92195e2014-05-07 18:18:49523
[email protected]d12aa932014-08-01 13:10:38524 void AsValueWithFrameInto(FrameData* frame,
ssid911e40e2015-02-09 17:55:20525 base::trace_event::TracedValue* value) const;
danakj60bc3bc2016-04-09 00:24:48526 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValueWithFrame(
[email protected]d12aa932014-08-01 13:10:38527 FrameData* frame) const;
ssid911e40e2015-02-09 17:55:20528 void ActivationStateAsValueInto(base::trace_event::TracedValue* value) const;
[email protected]131a0c22013-02-12 18:31:08529
[email protected]c1bb5af2013-03-13 19:06:27530 bool page_scale_animation_active() const { return !!page_scale_animation_; }
[email protected]498ddd02013-02-28 23:59:25531
[email protected]741fba422013-09-20 03:34:14532 virtual void CreateUIResource(UIResourceId uid,
533 const UIResourceBitmap& bitmap);
[email protected]c9280762013-08-01 06:28:57534 // Deletes a UI resource. May safely be called more than once.
[email protected]741fba422013-09-20 03:34:14535 virtual void DeleteUIResource(UIResourceId uid);
[email protected]127bdc1a2013-09-11 01:44:48536 void EvictAllUIResources();
537 bool EvictedUIResourcesExist() const;
[email protected]c9280762013-08-01 06:28:57538
jbaumanbbd425e2015-05-19 00:33:35539 virtual ResourceId ResourceIdForUIResource(UIResourceId uid) const;
[email protected]c9280762013-08-01 06:28:57540
[email protected]709c9542013-10-26 01:43:51541 virtual bool IsUIResourceOpaque(UIResourceId uid) const;
542
[email protected]efbdb3a2013-10-04 00:35:13543 struct UIResourceData {
jbaumanbbd425e2015-05-19 00:33:35544 ResourceId resource_id;
[email protected]efbdb3a2013-10-04 00:35:13545 gfx::Size size;
[email protected]709c9542013-10-26 01:43:51546 bool opaque;
[email protected]efbdb3a2013-10-04 00:35:13547 };
548
ymalik99740e852016-04-07 04:18:13549 // Returns the amount of delta that can be applied to scroll_node, taking
550 // page scale into account.
551 gfx::Vector2dF ComputeScrollDelta(ScrollNode* scroll_node,
552 const gfx::Vector2dF& delta);
553
danakj60bc3bc2016-04-09 00:24:48554 void ScheduleMicroBenchmark(std::unique_ptr<MicroBenchmarkImpl> benchmark);
[email protected]5e5648a2013-11-18 00:39:33555
[email protected]4a28a612013-11-27 02:06:33556 CompositorFrameMetadata MakeCompositorFrameMetadata() const;
[email protected]59fee302013-12-10 17:53:30557 // Viewport rectangle and clip in nonflipped window space. These rects
558 // should only be used by Renderer subclasses to populate glViewport/glClip
559 // and their software-mode equivalents.
560 gfx::Rect DeviceViewport() const;
561 gfx::Rect DeviceClip() const;
[email protected]4a28a612013-11-27 02:06:33562
[email protected]6be422b2013-12-08 06:47:31563 // When a SwapPromiseMonitor is created on the impl thread, it calls
564 // InsertSwapPromiseMonitor() to register itself with LayerTreeHostImpl.
565 // When the monitor is destroyed, it calls RemoveSwapPromiseMonitor()
566 // to unregister itself.
567 void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor);
568 void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor);
569
weiliangc8dac5a62015-04-02 06:12:35570 // TODO(weiliangc): Replace RequiresHighResToDraw with scheduler waits for
571 // ReadyToDraw. crbug.com/469175
vmpstr61ed94a12014-10-09 04:49:30572 void SetRequiresHighResToDraw() { requires_high_res_to_draw_ = true; }
573 void ResetRequiresHighResToDraw() { requires_high_res_to_draw_ = false; }
574 bool RequiresHighResToDraw() const { return requires_high_res_to_draw_; }
575
enne69277cb2014-10-29 23:03:40576 // Only valid for synchronous (non-scheduled) single-threaded case.
577 void SynchronouslyInitializeAllTiles();
578
khushalsagarb64b360d2015-10-21 19:25:16579 bool SupportsImplScrolling() const;
580 bool CommitToActiveTree() const;
581
vmiuraa30e1ea2014-12-09 19:23:51582 virtual void CreateResourceAndTileTaskWorkerPool(
danakj60bc3bc2016-04-09 00:24:48583 std::unique_ptr<TileTaskWorkerPool>* tile_task_worker_pool,
584 std::unique_ptr<ResourcePool>* resource_pool);
enne03dbe8ae2014-10-30 01:32:55585
vmpstr5377520a2014-12-29 23:26:13586 bool prepare_tiles_needed() const { return tile_priorities_dirty_; }
587
vmpstr99aa853c2015-02-03 20:31:22588 FrameTimingTracker* frame_timing_tracker() {
589 return frame_timing_tracker_.get();
590 }
591
sunxd2668bea62016-03-17 00:49:47592 gfx::Vector2dF ScrollSingleNode(ScrollNode* scroll_node,
593 const gfx::Vector2dF& delta,
594 const gfx::Point& viewport_point,
595 bool is_direct_manipulation,
596 ScrollTree* scroll_tree);
bokanaa2748312015-03-26 00:10:37597
dcastagna1e6a2bc2016-03-22 21:30:50598 void set_output_is_secure(bool output_is_secure) {
599 output_is_secure_ = output_is_secure;
600 }
601
602 bool output_is_secure() const { return output_is_secure_; }
603
vmpstrd704c872015-04-03 20:29:51604 // Record main frame timing information.
605 // |start_of_main_frame_args| is the BeginFrameArgs of the beginning of the
606 // main frame (ie the frame that kicked off the main frame).
607 // |expected_next_main_frame_args| is the BeginFrameArgs of the frame that
608 // follows the completion of the main frame (whether it is activation or some
609 // other completion, such as early out). Note that if there is a main frame
610 // scheduled in that frame, then this BeginFrameArgs will become the main
611 // frame args. However, if no such frame is scheduled, then this _would_ be
612 // the main frame args if it was scheduled.
613 void RecordMainFrameTiming(
614 const BeginFrameArgs& start_of_main_frame_args,
615 const BeginFrameArgs& expected_next_main_frame_args);
616
mpbed24c2c2015-06-05 20:57:13617 // Post the given frame timing events to the requester.
618 void PostFrameTimingEvents(
danakj60bc3bc2016-04-09 00:24:48619 std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
620 std::unique_ptr<FrameTimingTracker::MainFrameTimingSet>
621 main_frame_events);
mpbed24c2c2015-06-05 20:57:13622
khushalsagarb64b360d2015-10-21 19:25:16623 base::SingleThreadTaskRunner* GetTaskRunner() const {
624 DCHECK(task_runner_provider_);
625 return task_runner_provider_->HasImplThread()
626 ? task_runner_provider_->ImplThreadTaskRunner()
627 : task_runner_provider_->MainThreadTaskRunner();
628 }
629
sunxdd1abacf2016-02-16 22:08:30630 InputHandler::ScrollStatus TryScroll(const gfx::PointF& screen_space_point,
631 InputHandler::ScrollInputType type,
632 const ScrollTree& scroll_tree,
633 ScrollNode* scroll_node) const;
634
ymalik99740e852016-04-07 04:18:13635 // Returns true if a scroll offset animation is created and false if we scroll
636 // by the desired amount without an animation.
637 bool ScrollAnimationCreate(ScrollNode* scroll_node,
638 const gfx::Vector2dF& scroll_amount);
639
majidvp96452d02016-04-11 20:36:04640 void SetLayerTreeMutator(LayerTreeMutator* mutator);
641 LayerTreeMutator* mutator() { return mutator_; }
642
[email protected]c1bb5af2013-03-13 19:06:27643 protected:
[email protected]372bad5f2013-03-21 16:38:43644 LayerTreeHostImpl(
645 const LayerTreeSettings& settings,
646 LayerTreeHostImplClient* client,
khushalsagarb64b360d2015-10-21 19:25:16647 TaskRunnerProvider* task_runner_provider,
[email protected]a7f35682013-10-22 23:05:57648 RenderingStatsInstrumentation* rendering_stats_instrumentation,
reveman22dd9292014-10-13 20:52:05649 SharedBitmapManager* shared_bitmap_manager,
revemanf9a8a2342014-10-28 17:54:52650 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
reveman34b7a1522015-03-23 20:27:47651 TaskGraphRunner* task_graph_runner,
[email protected]dbe759a2013-12-02 19:23:02652 int id);
[email protected]cd57cc5a2012-10-12 22:43:41653
[email protected]c1bb5af2013-03-13 19:06:27654 // Virtual for testing.
danakj4923440542015-10-29 19:34:53655 virtual bool AnimateLayers(base::TimeTicks monotonic_time);
[email protected]de4afb5e2012-12-20 00:11:34656
sunnypsc61ff5192015-03-18 01:41:25657 bool is_likely_to_require_a_draw() const {
658 return is_likely_to_require_a_draw_;
659 }
660
danakj112d3a102015-04-14 18:24:49661 // Removes empty or orphan RenderPasses from the frame.
662 static void RemoveRenderPasses(FrameData* frame);
663
[email protected]c1bb5af2013-03-13 19:06:27664 LayerTreeHostImplClient* client_;
khushalsagarb64b360d2015-10-21 19:25:16665 TaskRunnerProvider* task_runner_provider_;
[email protected]cd57cc5a2012-10-12 22:43:41666
mithro0bdb49d2015-05-27 13:08:01667 BeginFrameTracker current_begin_frame_tracker_;
668
[email protected]c1bb5af2013-03-13 19:06:27669 private:
sunxd2668bea62016-03-17 00:49:47670 gfx::Vector2dF ScrollNodeWithViewportSpaceDelta(
671 ScrollNode* scroll_node,
bokanaa2748312015-03-26 00:10:37672 const gfx::PointF& viewport_point,
sunxd2668bea62016-03-17 00:49:47673 const gfx::Vector2dF& viewport_delta,
674 ScrollTree* scroll_tree);
bokanaa2748312015-03-26 00:10:37675
[email protected]ced667b2014-05-22 21:49:53676 void CreateAndSetRenderer();
ccameronf8a370a2015-11-18 07:44:36677 void CleanUpTileManagerAndUIResources();
vmpstr79191842015-07-10 20:40:33678 void CreateTileManagerResources();
[email protected]50644642013-06-20 13:58:55679 void ReleaseTreeResources();
vmpstr9ce5c662015-02-05 23:29:26680 void RecreateTreeResources();
[email protected]2b154b22013-06-07 09:03:27681
danakj4923440542015-10-29 19:34:53682 void AnimateInternal(bool active_tree);
683
senorblanco9c04acb2015-05-15 19:41:32684 void UpdateGpuRasterizationStatus();
685
bokanaa2748312015-03-26 00:10:37686 Viewport* viewport() { return viewport_.get(); }
687
bokan59379b092014-09-29 13:47:21688 // Scroll by preferring to move the outer viewport first, only moving the
689 // inner if the outer is at its scroll extents.
[email protected]adeda572014-01-31 00:49:47690 void ScrollViewportBy(gfx::Vector2dF scroll_delta);
bokan59379b092014-09-29 13:47:21691 // Scroll by preferring to move the inner viewport first, only moving the
692 // outer if the inner is at its scroll extents.
693 void ScrollViewportInnerFirst(gfx::Vector2dF scroll_delta);
sunnyps7d073dc2015-04-16 23:29:12694
hush1c873232015-06-23 21:22:11695 InputHandler::ScrollStatus ScrollBeginImpl(
majidvp944a8cd2016-01-12 21:05:18696 ScrollState* scroll_state,
hush1c873232015-06-23 21:22:11697 LayerImpl* scrolling_layer_impl,
698 InputHandler::ScrollInputType type);
majidvp944a8cd2016-01-12 21:05:18699 void DistributeScrollDelta(ScrollState* scroll_state);
hush1c873232015-06-23 21:22:11700
danakj4923440542015-10-29 19:34:53701 bool AnimatePageScale(base::TimeTicks monotonic_time);
702 bool AnimateScrollbars(base::TimeTicks monotonic_time);
703 bool AnimateTopControls(base::TimeTicks monotonic_time);
[email protected]2d692992012-12-19 01:19:32704
[email protected]50761e92013-03-29 20:51:28705 void TrackDamageForAllSurfaces(
706 LayerImpl* root_draw_layer,
707 const LayerImplList& render_surface_layer_list);
[email protected]cd57cc5a2012-10-12 22:43:41708
[email protected]8be1a9bf2013-05-01 03:45:19709 void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy);
710
[email protected]7ddfe7e82014-01-30 07:22:11711 // This function should only be called from PrepareToDraw, as DidDrawAllLayers
712 // must be called if this helper function is called. Returns DRAW_SUCCESS if
713 // the frame should be drawn.
[email protected]30d82142014-05-12 04:26:02714 DrawResult CalculateRenderPasses(FrameData* frame);
[email protected]cd57cc5a2012-10-12 22:43:41715
[email protected]c1bb5af2013-03-13 19:06:27716 void ClearCurrentlyScrollingLayer();
[email protected]cd57cc5a2012-10-12 22:43:41717
aeliasa57c40d122015-10-08 00:20:09718 void HandleMouseOverScrollbar(LayerImpl* layer_impl);
[email protected]f620b0e72013-10-01 21:38:24719
[email protected]f620b0e72013-10-01 21:38:24720 LayerImpl* FindScrollLayerForDeviceViewportPoint(
[email protected]14bc5d682014-01-17 07:26:47721 const gfx::PointF& device_viewport_point,
[email protected]bf1cfd9a2013-09-26 05:43:02722 InputHandler::ScrollInputType type,
[email protected]f620b0e72013-10-01 21:38:24723 LayerImpl* layer_hit_by_point,
[email protected]f161ca9e2014-04-01 13:57:01724 bool* scroll_on_main_thread,
danakj35904762016-01-21 20:49:40725 uint32_t* main_thread_scrolling_reason) const;
[email protected]14bc5d682014-01-17 07:26:47726 float DeviceSpaceDistanceToLayer(const gfx::PointF& device_viewport_point,
[email protected]bf1cfd9a2013-09-26 05:43:02727 LayerImpl* layer_impl);
[email protected]930ff43b2014-05-02 05:24:00728 void StartScrollbarFadeRecursive(LayerImpl* layer);
boliu247624d2015-04-11 02:04:25729 void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy);
[email protected]0fc818e2013-03-18 06:45:20730
[email protected]127bdc1a2013-09-11 01:44:48731 void MarkUIResourceNotEvicted(UIResourceId uid);
ccameronf8a370a2015-11-18 07:44:36732 void ClearUIResources();
[email protected]127bdc1a2013-09-11 01:44:48733
[email protected]6be422b2013-12-08 06:47:31734 void NotifySwapPromiseMonitorsOfSetNeedsRedraw();
[email protected]dab0a422014-08-13 16:09:46735 void NotifySwapPromiseMonitorsOfForwardingToMainThread();
danakjdd74e512015-09-21 23:07:59736
737 void UpdateRootLayerStateForSynchronousInputHandler();
[email protected]6be422b2013-12-08 06:47:31738
ymalik0f4192062016-01-14 17:18:35739 void ScrollAnimationAbort(LayerImpl* layer_impl);
740
sunxd54e08e9d2016-02-22 23:01:28741 bool ScrollAnimationUpdateTarget(ScrollNode* scroll_node,
loyso2c4002d2015-03-13 02:31:43742 const gfx::Vector2dF& scroll_delta);
743
davidben5877ffe2016-01-28 00:29:51744 using UIResourceMap = std::unordered_map<UIResourceId, UIResourceData>;
[email protected]c9280762013-08-01 06:28:57745 UIResourceMap ui_resource_map_;
746
[email protected]127bdc1a2013-09-11 01:44:48747 // Resources that were evicted by EvictAllUIResources. Resources are removed
748 // from this when they are touched by a create or destroy from the UI resource
749 // request queue.
750 std::set<UIResourceId> evicted_ui_resources_;
751
revemand180dfc32015-09-24 00:19:43752 OutputSurface* output_surface_;
[email protected]fbe89f72013-05-21 07:24:24753
danakj60bc3bc2016-04-09 00:24:48754 std::unique_ptr<ResourceProvider> resource_provider_;
senorblanco8d1b3ac2015-05-05 00:14:26755 bool content_is_suitable_for_gpu_rasterization_;
756 bool has_gpu_rasterization_trigger_;
[email protected]13525d62014-05-20 21:22:04757 bool use_gpu_rasterization_;
senorblancofb88a4e2015-05-08 17:28:41758 bool use_msaa_;
hendrikwc2bbd612014-12-03 23:49:34759 GpuRasterizationStatus gpu_rasterization_status_;
senorblanco9c04acb2015-05-15 19:41:32760 bool tree_resources_for_gpu_rasterization_dirty_;
danakj60bc3bc2016-04-09 00:24:48761 std::unique_ptr<TileTaskWorkerPool> tile_task_worker_pool_;
762 std::unique_ptr<ResourcePool> resource_pool_;
763 std::unique_ptr<Renderer> renderer_;
764 std::unique_ptr<ImageDecodeController> image_decode_controller_;
[email protected]3b31c6ac2012-12-06 21:27:29765
[email protected]1bcced22013-09-24 13:51:19766 GlobalStateThatImpactsTilePriority global_tile_state_;
767
[email protected]c1bb5af2013-03-13 19:06:27768 // Tree currently being drawn.
danakj60bc3bc2016-04-09 00:24:48769 std::unique_ptr<LayerTreeImpl> active_tree_;
[email protected]3b31c6ac2012-12-06 21:27:29770
[email protected]c1bb5af2013-03-13 19:06:27771 // In impl-side painting mode, tree with possibly incomplete rasterized
[email protected]4f48f6e2013-08-27 06:33:38772 // content. May be promoted to active by ActivatePendingTree().
danakj60bc3bc2016-04-09 00:24:48773 std::unique_ptr<LayerTreeImpl> pending_tree_;
[email protected]48871fc2013-01-23 07:36:51774
[email protected]c1bb5af2013-03-13 19:06:27775 // In impl-side painting mode, inert tree with layers that can be recycled
776 // by the next sync from the main thread.
danakj60bc3bc2016-04-09 00:24:48777 std::unique_ptr<LayerTreeImpl> recycle_tree_;
[email protected]48871fc2013-01-23 07:36:51778
[email protected]200a9c062013-05-20 04:34:37779 InputHandlerClient* input_handler_client_;
[email protected]c1bb5af2013-03-13 19:06:27780 bool did_lock_scrolling_layer_;
[email protected]c1bb5af2013-03-13 19:06:27781 bool wheel_scrolling_;
[email protected]f161ca9e2014-04-01 13:57:01782 bool scroll_affects_scroll_handler_;
[email protected]f620b0e72013-10-01 21:38:24783 int scroll_layer_id_when_mouse_over_scrollbar_;
danakj60bc3bc2016-04-09 00:24:48784 std::vector<std::unique_ptr<SwapPromise>>
vmpstra370ef52015-11-18 10:41:28785 swap_promises_for_main_thread_scroll_update_;
[email protected]a23451e2013-06-07 20:58:26786
ccameron4163cc352014-11-13 19:06:36787 // An object to implement the ScrollElasticityHelper interface and
788 // hold all state related to elasticity. May be NULL if never requested.
danakj60bc3bc2016-04-09 00:24:48789 std::unique_ptr<ScrollElasticityHelper> scroll_elasticity_helper_;
ccameron4163cc352014-11-13 19:06:36790
[email protected]c48536a52013-09-14 00:02:08791 bool tile_priorities_dirty_;
[email protected]a23451e2013-06-07 20:58:26792
enne65dc6212015-04-29 21:44:23793 const LayerTreeSettings settings_;
[email protected]c1bb5af2013-03-13 19:06:27794 LayerTreeDebugState debug_state_;
[email protected]c1bb5af2013-03-13 19:06:27795 bool visible_;
[email protected]3f2ff112013-08-03 02:41:07796 ManagedMemoryPolicy cached_managed_memory_policy_;
[email protected]cd57cc5a2012-10-12 22:43:41797
vmpstrc57abc82015-07-14 22:16:19798 const bool is_synchronous_single_threaded_;
danakj60bc3bc2016-04-09 00:24:48799 std::unique_ptr<TileManager> tile_manager_;
vmpstr79191842015-07-10 20:40:33800
[email protected]a2b5ded2013-05-20 21:32:53801 gfx::Vector2dF accumulated_root_overscroll_;
[email protected]6e921bd2013-04-29 21:10:20802
[email protected]c1bb5af2013-03-13 19:06:27803 bool pinch_gesture_active_;
[email protected]2fa342b82013-09-24 03:19:13804 bool pinch_gesture_end_should_clear_scrolling_layer_;
[email protected]cd57cc5a2012-10-12 22:43:41805
danakj60bc3bc2016-04-09 00:24:48806 std::unique_ptr<TopControlsManager> top_controls_manager_;
[email protected]3ba4cae2013-01-16 03:58:38807
danakj60bc3bc2016-04-09 00:24:48808 std::unique_ptr<PageScaleAnimation> page_scale_animation_;
[email protected]cd57cc5a2012-10-12 22:43:41809
danakj60bc3bc2016-04-09 00:24:48810 std::unique_ptr<FrameRateCounter> fps_counter_;
811 std::unique_ptr<MemoryHistory> memory_history_;
812 std::unique_ptr<DebugRectHistory> debug_rect_history_;
[email protected]cd57cc5a2012-10-12 22:43:41813
danakj60bc3bc2016-04-09 00:24:48814 std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter_;
[email protected]ea468c6c2013-09-10 08:25:11815
[email protected]d7626ffd2013-03-29 00:17:42816 // The maximum memory that would be used by the prioritized resource
817 // manager, if there were no limit on memory usage.
818 size_t max_memory_needed_bytes_;
819
[email protected]54af03522013-09-05 00:43:28820 // Viewport size passed in from the main thread, in physical pixels. This
821 // value is the default size for all concepts of physical viewport (draw
822 // viewport, scrolling viewport and device viewport), but it can be
823 // overridden.
[email protected]f224cc92013-06-06 23:23:32824 gfx::Size device_viewport_size_;
825
[email protected]54af03522013-09-05 00:43:28826 // Optional top-level constraints that can be set by the OutputSurface.
827 // - external_transform_ applies a transform above the root layer
828 // - external_viewport_ is used DrawProperties, tile management and
829 // glViewport/window projection matrix.
830 // - external_clip_ specifies a top-level clip rect
[email protected]bd5324592014-07-31 09:09:33831 // - viewport_rect_for_tile_priority_ is the rect in view space used for
832 // tiling priority.
[email protected]f224cc92013-06-06 23:23:32833 gfx::Transform external_transform_;
834 gfx::Rect external_viewport_;
[email protected]54af03522013-09-05 00:43:28835 gfx::Rect external_clip_;
[email protected]bd5324592014-07-31 09:09:33836 gfx::Rect viewport_rect_for_tile_priority_;
[email protected]c05dfbb2014-07-10 22:49:04837 bool resourceless_software_draw_;
[email protected]f224cc92013-06-06 23:23:32838
dcastagna1e6a2bc2016-03-22 21:30:50839 bool output_is_secure_;
840
[email protected]878705be2013-04-15 22:44:02841 gfx::Rect viewport_damage_rect_;
[email protected]e0341352013-04-06 05:01:20842
danakj60bc3bc2016-04-09 00:24:48843 std::unique_ptr<AnimationHost> animation_host_;
sunnyps7d073dc2015-04-16 23:29:12844 std::set<VideoFrameController*> video_frame_controllers_;
[email protected]de4afb5e2012-12-20 00:11:34845
aeliasa57c40d122015-10-08 00:20:09846 // Map from scroll layer ID to scrollbar animation controller.
847 // There is one animation controller per pair of overlay scrollbars.
danakj60bc3bc2016-04-09 00:24:48848 std::unordered_map<int, std::unique_ptr<ScrollbarAnimationController>>
aeliasa57c40d122015-10-08 00:20:09849 scrollbar_animation_controllers_;
850
[email protected]372bad5f2013-03-21 16:38:43851 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
[email protected]5e5648a2013-11-18 00:39:33852 MicroBenchmarkControllerImpl micro_benchmark_controller_;
danakj60bc3bc2016-04-09 00:24:48853 std::unique_ptr<SynchronousTaskGraphRunner>
ericrk4e3aa5a2015-12-01 03:53:56854 single_thread_synchronous_task_graph_runner_;
[email protected]372bad5f2013-03-21 16:38:43855
[email protected]5f07afc2013-07-19 05:17:18856 // Optional callback to notify of new tree activations.
[email protected]2022c672013-07-23 19:55:26857 base::Closure tree_activation_callback_;
[email protected]5f07afc2013-07-19 05:17:18858
[email protected]a7f35682013-10-22 23:05:57859 SharedBitmapManager* shared_bitmap_manager_;
revemanf9a8a2342014-10-28 17:54:52860 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
reveman34b7a1522015-03-23 20:27:47861 TaskGraphRunner* task_graph_runner_;
[email protected]dbe759a2013-12-02 19:23:02862 int id_;
[email protected]a7f35682013-10-22 23:05:57863
[email protected]6be422b2013-12-08 06:47:31864 std::set<SwapPromiseMonitor*> swap_promise_monitor_;
[email protected]8aa39ecb2014-06-12 14:19:14865
vmpstr61ed94a12014-10-09 04:49:30866 bool requires_high_res_to_draw_;
vmpstr4973f5b2015-02-02 19:27:29867 bool is_likely_to_require_a_draw_;
vmpstr61ed94a12014-10-09 04:49:30868
danakj60bc3bc2016-04-09 00:24:48869 std::unique_ptr<FrameTimingTracker> frame_timing_tracker_;
vmpstr99aa853c2015-02-03 20:31:22870
danakj60bc3bc2016-04-09 00:24:48871 std::unique_ptr<Viewport> viewport_;
bokanaa2748312015-03-26 00:10:37872
majidvp96452d02016-04-11 20:36:04873 LayerTreeMutator* mutator_;
874
[email protected]c1bb5af2013-03-13 19:06:27875 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl);
[email protected]cd57cc5a2012-10-12 22:43:41876};
877
[email protected]0023e8b2012-10-15 12:52:45878} // namespace cc
[email protected]cd57cc5a2012-10-12 22:43:41879
[email protected]556fd292013-03-18 08:03:04880#endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_