[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors. All rights reserved. |
[email protected] | 0fb2500 | 2012-10-12 07:20:02 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 4 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 5 | #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| 6 | #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 7 | |
avi | 02a4d17 | 2015-12-21 06:14:36 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 10 | #include <memory> |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 11 | #include <set> |
[email protected] | bf691c2 | 2013-03-26 21:15:06 | [diff] [blame] | 12 | #include <string> |
davidben | 5877ffe | 2016-01-28 00:29:51 | [diff] [blame] | 13 | #include <unordered_map> |
[email protected] | bf691c2 | 2013-03-26 21:15:06 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
majidvp | 96452d0 | 2016-04-11 20:36:04 | [diff] [blame] | 16 | #include "base/callback.h" |
avi | 02a4d17 | 2015-12-21 06:14:36 | [diff] [blame] | 17 | #include "base/macros.h" |
[email protected] | 1b0df50 | 2013-06-27 23:39:58 | [diff] [blame] | 18 | #include "base/time/time.h" |
majidvp | 96452d0 | 2016-04-11 20:36:04 | [diff] [blame] | 19 | #include "cc/animation/layer_tree_mutator.h" |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 20 | #include "cc/base/cc_export.h" |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 21 | #include "cc/base/synced_property.h" |
vmpstr | 99aa853c | 2015-02-03 20:31:22 | [diff] [blame] | 22 | #include "cc/debug/frame_timing_tracker.h" |
[email protected] | 5e5648a | 2013-11-18 00:39:33 | [diff] [blame] | 23 | #include "cc/debug/micro_benchmark_controller_impl.h" |
[email protected] | 3052b10f | 2013-03-18 07:41:21 | [diff] [blame] | 24 | #include "cc/input/input_handler.h" |
loyso | 455b4f60 | 2016-02-24 02:59:42 | [diff] [blame] | 25 | #include "cc/input/scrollbar_animation_controller.h" |
[email protected] | 3052b10f | 2013-03-18 07:41:21 | [diff] [blame] | 26 | #include "cc/input/top_controls_manager_client.h" |
vollick | 83fbfc8 | 2016-03-22 18:33:27 | [diff] [blame] | 27 | #include "cc/layers/layer_collections.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 28 | #include "cc/layers/render_pass_sink.h" |
[email protected] | df3c24c9 | 2013-06-19 03:54:35 | [diff] [blame] | 29 | #include "cc/output/begin_frame_args.h" |
[email protected] | fd32d12 | 2013-06-29 13:11:04 | [diff] [blame] | 30 | #include "cc/output/managed_memory_policy.h" |
[email protected] | 7f0d825f | 2013-03-18 07:24:30 | [diff] [blame] | 31 | #include "cc/output/output_surface_client.h" |
| 32 | #include "cc/output/renderer.h" |
[email protected] | 89e8267a | 2013-03-18 07:50:56 | [diff] [blame] | 33 | #include "cc/quads/render_pass.h" |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 34 | #include "cc/resources/resource_provider.h" |
jamesr | 9b8fda3 | 2015-03-16 19:11:05 | [diff] [blame] | 35 | #include "cc/resources/ui_resource_client.h" |
mithro | 0bdb49d | 2015-05-27 13:08:01 | [diff] [blame] | 36 | #include "cc/scheduler/begin_frame_tracker.h" |
mithro | f7a2150 | 2014-12-17 03:24:48 | [diff] [blame] | 37 | #include "cc/scheduler/commit_earlyout_reason.h" |
[email protected] | 30d8214 | 2014-05-12 04:26:02 | [diff] [blame] | 38 | #include "cc/scheduler/draw_result.h" |
sunnyps | 7d073dc | 2015-04-16 23:29:12 | [diff] [blame] | 39 | #include "cc/scheduler/video_frame_controller.h" |
vmpstr | 64cdba3 | 2016-03-03 00:38:40 | [diff] [blame] | 40 | #include "cc/tiles/image_decode_controller.h" |
danakj | 92015685 | 2015-05-18 20:22:29 | [diff] [blame] | 41 | #include "cc/tiles/tile_manager.h" |
jamesr | 9b8fda3 | 2015-03-16 19:11:05 | [diff] [blame] | 42 | #include "cc/trees/layer_tree_settings.h" |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 43 | #include "cc/trees/mutator_host_client.h" |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 44 | #include "cc/trees/task_runner_provider.h" |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 45 | #include "skia/ext/refptr.h" |
[email protected] | ddf9df8 | 2012-10-16 06:52:46 | [diff] [blame] | 46 | #include "third_party/skia/include/core/SkColor.h" |
heejin.r.chung | d28506ba | 2014-10-23 16:36:20 | [diff] [blame] | 47 | #include "ui/gfx/geometry/rect.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 48 | |
loyso | 2c4002d | 2015-03-13 02:31:43 | [diff] [blame] | 49 | namespace gfx { |
| 50 | class ScrollOffset; |
| 51 | } |
| 52 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 53 | namespace cc { |
| 54 | |
loyso | e926437dd | 2016-01-14 22:55:30 | [diff] [blame] | 55 | class AnimationEvents; |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 56 | class AnimationHost; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 57 | class CompletionEvent; |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 58 | class CompositorFrameMetadata; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 59 | class DebugRectHistory; |
[email protected] | bf05058 | 2014-07-24 11:10:58 | [diff] [blame] | 60 | class EvictionTilePriorityQueue; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 61 | class FrameRateCounter; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 62 | class LayerImpl; |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 63 | class LayerTreeImpl; |
[email protected] | ec7541d | 2014-04-09 01:23:53 | [diff] [blame] | 64 | class MemoryHistory; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 65 | class PageScaleAnimation; |
[email protected] | 8aa39ecb | 2014-06-12 14:19:14 | [diff] [blame] | 66 | class PictureLayerImpl; |
[email protected] | bf05058 | 2014-07-24 11:10:58 | [diff] [blame] | 67 | class RasterTilePriorityQueue; |
vmiura | a30e1ea | 2014-12-09 19:23:51 | [diff] [blame] | 68 | class TileTaskWorkerPool; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 69 | class RenderPassDrawQuad; |
[email protected] | ec7541d | 2014-04-09 01:23:53 | [diff] [blame] | 70 | class RenderingStatsInstrumentation; |
[email protected] | eece11e | 2014-04-12 03:07:16 | [diff] [blame] | 71 | class ResourcePool; |
ccameron | 4163cc35 | 2014-11-13 19:06:36 | [diff] [blame] | 72 | class ScrollElasticityHelper; |
[email protected] | bf1cfd9a | 2013-09-26 05:43:02 | [diff] [blame] | 73 | class ScrollbarLayerImplBase; |
jamesr | 9b8fda3 | 2015-03-16 19:11:05 | [diff] [blame] | 74 | class SwapPromise; |
| 75 | class SwapPromiseMonitor; |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 76 | class SynchronousTaskGraphRunner; |
prashant.n | 49b3e6465 | 2016-04-19 07:04:49 | [diff] [blame^] | 77 | class TaskGraphRunner; |
[email protected] | ea468c6c | 2013-09-10 08:25:11 | [diff] [blame] | 78 | class TextureMailboxDeleter; |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 79 | class TopControlsManager; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 80 | class UIResourceBitmap; |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 81 | class UIResourceRequest; |
jamesr | 9b8fda3 | 2015-03-16 19:11:05 | [diff] [blame] | 82 | struct ScrollAndScaleSet; |
bokan | aa274831 | 2015-03-26 00:10:37 | [diff] [blame] | 83 | class Viewport; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 84 | |
majidvp | 96452d0 | 2016-04-11 20:36:04 | [diff] [blame] | 85 | using BeginFrameCallbackList = std::vector<base::Closure>; |
| 86 | |
hendrikw | c2bbd61 | 2014-12-03 23:49:34 | [diff] [blame] | 87 | enum class GpuRasterizationStatus { |
| 88 | ON, |
| 89 | ON_FORCED, |
| 90 | OFF_DEVICE, |
| 91 | OFF_VIEWPORT, |
senorblanco | fb88a4e | 2015-05-08 17:28:41 | [diff] [blame] | 92 | MSAA_CONTENT, |
hendrikw | c2bbd61 | 2014-12-03 23:49:34 | [diff] [blame] | 93 | OFF_CONTENT |
| 94 | }; |
| 95 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 96 | // LayerTreeHost->Proxy callback interface. |
| 97 | class LayerTreeHostImplClient { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 98 | public: |
[email protected] | fa33903 | 2014-02-18 22:11:59 | [diff] [blame] | 99 | virtual void UpdateRendererCapabilitiesOnImplThread() = 0; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 100 | virtual void DidLoseOutputSurfaceOnImplThread() = 0; |
[email protected] | 3dc0c77 | 2014-04-26 10:06:05 | [diff] [blame] | 101 | virtual void CommitVSyncParameters(base::TimeTicks timebase, |
| 102 | base::TimeDelta interval) = 0; |
enne | 19c10858 | 2016-04-14 03:35:32 | [diff] [blame] | 103 | virtual void SetBeginFrameSource(BeginFrameSource* source) = 0; |
[email protected] | 3dc0c77 | 2014-04-26 10:06:05 | [diff] [blame] | 104 | virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) = 0; |
[email protected] | 4d7e46a | 2013-11-08 05:33:40 | [diff] [blame] | 105 | virtual void DidSwapBuffersOnImplThread() = 0; |
[email protected] | c1490266 | 2014-04-18 05:06:11 | [diff] [blame] | 106 | virtual void DidSwapBuffersCompleteOnImplThread() = 0; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 107 | virtual void OnCanDrawStateChanged(bool can_draw) = 0; |
[email protected] | 4f48f6e | 2013-08-27 06:33:38 | [diff] [blame] | 108 | virtual void NotifyReadyToActivate() = 0; |
ernstm | dfac03e1 | 2014-11-11 20:18:05 | [diff] [blame] | 109 | virtual void NotifyReadyToDraw() = 0; |
[email protected] | 43b8f98 | 2014-04-30 21:24:33 | [diff] [blame] | 110 | // Please call these 3 functions through |
| 111 | // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and |
danakj | a18e826a | 2015-12-03 00:27:03 | [diff] [blame] | 112 | // SetNeedsOneBeginImplFrame(). |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 113 | virtual void SetNeedsRedrawOnImplThread() = 0; |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 114 | virtual void SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) = 0; |
danakj | a18e826a | 2015-12-03 00:27:03 | [diff] [blame] | 115 | virtual void SetNeedsOneBeginImplFrameOnImplThread() = 0; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 116 | virtual void SetNeedsCommitOnImplThread() = 0; |
vmiura | 59ea9b404 | 2014-12-09 20:50:39 | [diff] [blame] | 117 | virtual void SetNeedsPrepareTilesOnImplThread() = 0; |
sunnyps | 7d073dc | 2015-04-16 23:29:12 | [diff] [blame] | 118 | virtual void SetVideoNeedsBeginFrames(bool needs_begin_frames) = 0; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 119 | virtual void PostAnimationEventsToMainThreadOnImplThread( |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 120 | std::unique_ptr<AnimationEvents> events) = 0; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 121 | virtual bool IsInsideDraw() = 0; |
| 122 | virtual void RenewTreePriority() = 0; |
sunnyps | ae4316a | 2015-02-25 00:54:58 | [diff] [blame] | 123 | virtual void PostDelayedAnimationTaskOnImplThread(const base::Closure& task, |
| 124 | base::TimeDelta delay) = 0; |
[email protected] | fc20d14 | 2014-07-01 00:49:15 | [diff] [blame] | 125 | virtual void DidActivateSyncTree() = 0; |
brianderson | 6874981 | 2015-07-07 22:39:39 | [diff] [blame] | 126 | virtual void WillPrepareTiles() = 0; |
vmiura | 59ea9b404 | 2014-12-09 20:50:39 | [diff] [blame] | 127 | virtual void DidPrepareTiles() = 0; |
[email protected] | bf691c2 | 2013-03-26 21:15:06 | [diff] [blame] | 128 | |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 129 | // Called when page scale animation has completed on the impl thread. |
| 130 | virtual void DidCompletePageScaleAnimationOnImplThread() = 0; |
| 131 | |
sunnyps | eab5ac9 | 2015-04-02 20:26:13 | [diff] [blame] | 132 | // Called when output surface asks for a draw. |
boliu | 7097ee5b | 2015-12-17 03:16:09 | [diff] [blame] | 133 | virtual void OnDrawForOutputSurface(bool resourceless_software_draw) = 0; |
sunnyps | eab5ac9 | 2015-04-02 20:26:13 | [diff] [blame] | 134 | |
mpb | ed24c2c | 2015-06-05 20:57:13 | [diff] [blame] | 135 | virtual void PostFrameTimingEventsOnImplThread( |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 136 | std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 137 | std::unique_ptr<FrameTimingTracker::MainFrameTimingSet> |
| 138 | main_frame_events) = 0; |
mpb | ed24c2c | 2015-06-05 20:57:13 | [diff] [blame] | 139 | |
[email protected] | bf691c2 | 2013-03-26 21:15:06 | [diff] [blame] | 140 | protected: |
| 141 | virtual ~LayerTreeHostImplClient() {} |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 142 | }; |
| 143 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 144 | // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering |
| 145 | // state. |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 146 | class CC_EXPORT LayerTreeHostImpl |
| 147 | : public InputHandler, |
| 148 | public RendererClient, |
| 149 | public TileManagerClient, |
| 150 | public OutputSurfaceClient, |
| 151 | public TopControlsManagerClient, |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 152 | public ScrollbarAnimationControllerClient, |
sunnyps | 7d073dc | 2015-04-16 23:29:12 | [diff] [blame] | 153 | public VideoFrameControllerClient, |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 154 | public MutatorHostClient, |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 155 | public base::SupportsWeakPtr<LayerTreeHostImpl> { |
[email protected] | e216fef0 | 2013-03-20 22:56:10 | [diff] [blame] | 156 | public: |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 157 | static std::unique_ptr<LayerTreeHostImpl> Create( |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 158 | const LayerTreeSettings& settings, |
| 159 | LayerTreeHostImplClient* client, |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 160 | TaskRunnerProvider* task_runner_provider, |
[email protected] | a7f3568 | 2013-10-22 23:05:57 | [diff] [blame] | 161 | RenderingStatsInstrumentation* rendering_stats_instrumentation, |
reveman | 22dd929 | 2014-10-13 20:52:05 | [diff] [blame] | 162 | SharedBitmapManager* shared_bitmap_manager, |
reveman | f9a8a234 | 2014-10-28 17:54:52 | [diff] [blame] | 163 | gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
reveman | 34b7a152 | 2015-03-23 20:27:47 | [diff] [blame] | 164 | TaskGraphRunner* task_graph_runner, |
[email protected] | dbe759a | 2013-12-02 19:23:02 | [diff] [blame] | 165 | int id); |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 166 | ~LayerTreeHostImpl() override; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 167 | |
[email protected] | 5ff3c978 | 2013-04-29 17:35:12 | [diff] [blame] | 168 | // InputHandler implementation |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 169 | void BindToClient(InputHandlerClient* client) override; |
| 170 | InputHandler::ScrollStatus ScrollBegin( |
majidvp | 944a8cd | 2016-01-12 21:05:18 | [diff] [blame] | 171 | ScrollState* scroll_state, |
mostynb | f68776d8 | 2014-10-06 18:07:37 | [diff] [blame] | 172 | InputHandler::ScrollInputType type) override; |
hush | 1c87323 | 2015-06-23 21:22:11 | [diff] [blame] | 173 | InputHandler::ScrollStatus RootScrollBegin( |
majidvp | 944a8cd | 2016-01-12 21:05:18 | [diff] [blame] | 174 | ScrollState* scroll_state, |
hush | 1c87323 | 2015-06-23 21:22:11 | [diff] [blame] | 175 | InputHandler::ScrollInputType type) override; |
dtapuska | 1827dd2 | 2016-03-11 15:24:59 | [diff] [blame] | 176 | ScrollStatus ScrollAnimatedBegin(const gfx::Point& viewport_point) override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 177 | InputHandler::ScrollStatus ScrollAnimated( |
[email protected] | 749cbc6 | 2014-07-10 01:06:35 | [diff] [blame] | 178 | const gfx::Point& viewport_point, |
mostynb | f68776d8 | 2014-10-06 18:07:37 | [diff] [blame] | 179 | const gfx::Vector2dF& scroll_delta) override; |
sunxd | 2668bea6 | 2016-03-17 00:49:47 | [diff] [blame] | 180 | void ApplyScroll(ScrollNode* scroll_node, ScrollState* scroll_state); |
majidvp | 944a8cd | 2016-01-12 21:05:18 | [diff] [blame] | 181 | InputHandlerScrollResult ScrollBy(ScrollState* scroll_state) override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 182 | bool ScrollVerticallyByPage(const gfx::Point& viewport_point, |
| 183 | ScrollDirection direction) override; |
danakj | dd74e51 | 2015-09-21 23:07:59 | [diff] [blame] | 184 | void RequestUpdateForSynchronousInputHandler() override; |
| 185 | void SetSynchronousInputHandlerRootScrollOffset( |
danakj | 0481b57 | 2015-09-10 01:18:01 | [diff] [blame] | 186 | const gfx::ScrollOffset& root_offset) override; |
majidvp | 944a8cd | 2016-01-12 21:05:18 | [diff] [blame] | 187 | void ScrollEnd(ScrollState* scroll_state) override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 188 | 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; |
bokan | fcdbc18 | 2014-11-21 21:53:33 | [diff] [blame] | 194 | void StartPageScaleAnimation(const gfx::Vector2d& target_offset, |
| 195 | bool anchor_point, |
| 196 | float page_scale, |
| 197 | base::TimeDelta duration); |
hush | b0ee8dc | 2015-06-10 00:48:57 | [diff] [blame] | 198 | void SetNeedsAnimateInput() override; |
skobes | de5abdb8 | 2015-10-20 19:16:34 | [diff] [blame] | 199 | bool IsCurrentlyScrollingInnerViewport() const override; |
danakj | e9f830c | 2015-09-09 21:36:16 | [diff] [blame] | 200 | bool IsCurrentlyScrollingLayerAt( |
| 201 | const gfx::Point& viewport_point, |
| 202 | InputHandler::ScrollInputType type) const override; |
dtapuska | f206a40d | 2016-02-05 21:36:02 | [diff] [blame] | 203 | EventListenerProperties GetEventListenerProperties( |
| 204 | EventListenerClass event_class) const override; |
rbyers | 18779d82 | 2015-02-05 06:22:06 | [diff] [blame] | 205 | bool DoTouchEventsBlockScrollAt(const gfx::Point& viewport_port) override; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 206 | std::unique_ptr<SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor( |
mostynb | f68776d8 | 2014-10-06 18:07:37 | [diff] [blame] | 207 | ui::LatencyInfo* latency) override; |
ccameron | 4163cc35 | 2014-11-13 19:06:36 | [diff] [blame] | 208 | ScrollElasticityHelper* CreateScrollElasticityHelper() override; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 209 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 210 | // TopControlsManagerClient implementation. |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 211 | float TopControlsHeight() const override; |
| 212 | void SetCurrentTopControlsShownRatio(float offset) override; |
| 213 | float CurrentTopControlsShownRatio() const override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 214 | void DidChangeTopControlsPosition() override; |
| 215 | bool HaveRootScrollLayer() const override; |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 216 | |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 217 | void UpdateViewportContainerSizes(); |
| 218 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 219 | struct CC_EXPORT FrameData : public RenderPassSink { |
| 220 | FrameData(); |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 221 | ~FrameData() override; |
ssid | 911e40e | 2015-02-09 17:55:20 | [diff] [blame] | 222 | void AsValueInto(base::trace_event::TracedValue* value) const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 223 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 224 | std::vector<gfx::Rect> occluding_screen_space_rects; |
| 225 | std::vector<gfx::Rect> non_occluding_screen_space_rects; |
vmpstr | 99aa853c | 2015-02-03 20:31:22 | [diff] [blame] | 226 | std::vector<FrameTimingTracker::FrameAndRectIds> composite_events; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 227 | RenderPassList render_passes; |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 228 | const LayerImplList* render_surface_layer_list; |
| 229 | LayerImplList will_draw_layers; |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 230 | bool has_no_damage; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 231 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 232 | // RenderPassSink implementation. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 233 | void AppendRenderPass(std::unique_ptr<RenderPass> render_pass) override; |
vmpstr | a370ef5 | 2015-11-18 10:41:28 | [diff] [blame] | 234 | |
| 235 | private: |
| 236 | DISALLOW_COPY_AND_ASSIGN(FrameData); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 237 | }; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 238 | |
mithro | f7a2150 | 2014-12-17 03:24:48 | [diff] [blame] | 239 | virtual void BeginMainFrameAborted(CommitEarlyOutReason reason); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 240 | virtual void BeginCommit(); |
| 241 | virtual void CommitComplete(); |
[email protected] | 3d9f743 | 2013-04-06 00:35:18 | [diff] [blame] | 242 | virtual void UpdateAnimationState(bool start_ready_animations); |
[email protected] | b33348f | 2014-04-30 18:17:34 | [diff] [blame] | 243 | void ActivateAnimations(); |
danakj | 492344054 | 2015-10-29 19:34:53 | [diff] [blame] | 244 | void Animate(); |
| 245 | void AnimatePendingTreeAfterCommit(); |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 246 | void MainThreadHasStoppedFlinging(); |
[email protected] | b8384e2 | 2013-12-03 02:20:48 | [diff] [blame] | 247 | void DidAnimateScrollOffset(); |
[email protected] | 0023fc7 | 2014-01-10 20:05:06 | [diff] [blame] | 248 | void SetViewportDamage(const gfx::Rect& damage_rect); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 249 | |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 250 | 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); |
ajuma | caaa9b3 | 2015-08-04 15:55:29 | [diff] [blame] | 262 | void TreeLayerTransformIsPotentiallyAnimatingChanged(int layer_id, |
| 263 | LayerTreeImpl* tree, |
| 264 | bool is_animating); |
weiliangc | c154ce2 | 2015-12-09 03:39:26 | [diff] [blame] | 265 | bool AnimationsPreserveAxisAlignment(const LayerImpl* layer) const; |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 266 | |
| 267 | // LayerTreeMutatorsClient implementation. |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 268 | bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override; |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 269 | void SetMutatorsNeedCommit() override; |
loyso | d02fc47 | 2015-10-21 14:26:44 | [diff] [blame] | 270 | void SetMutatorsNeedRebuildPropertyTrees() override; |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 271 | void SetLayerFilterMutated(int layer_id, |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 272 | LayerTreeType tree_type, |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 273 | const FilterOperations& filters) override; |
| 274 | void SetLayerOpacityMutated(int layer_id, |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 275 | LayerTreeType tree_type, |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 276 | float opacity) override; |
| 277 | void SetLayerTransformMutated(int layer_id, |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 278 | LayerTreeType tree_type, |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 279 | const gfx::Transform& transform) override; |
| 280 | void SetLayerScrollOffsetMutated( |
| 281 | int layer_id, |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 282 | LayerTreeType tree_type, |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 283 | const gfx::ScrollOffset& scroll_offset) override; |
ajuma | caaa9b3 | 2015-08-04 15:55:29 | [diff] [blame] | 284 | void LayerTransformIsPotentiallyAnimatingChanged(int layer_id, |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 285 | LayerTreeType tree_type, |
ajuma | caaa9b3 | 2015-08-04 15:55:29 | [diff] [blame] | 286 | bool is_animating) override; |
loyso | ce3bb82 | 2015-07-08 02:40:47 | [diff] [blame] | 287 | void ScrollOffsetAnimationFinished() override; |
| 288 | gfx::ScrollOffset GetScrollOffsetForAnimation(int layer_id) const override; |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 289 | |
vmpstr | 7919184 | 2015-07-10 20:40:33 | [diff] [blame] | 290 | virtual bool PrepareTiles(); |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 291 | |
[email protected] | 2aae9679 | 2014-05-15 23:10:50 | [diff] [blame] | 292 | // 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); |
mithro | 248d172 | 2015-05-05 05:23:45 | [diff] [blame] | 297 | virtual void DrawLayers(FrameData* frame); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 298 | // Must be called if and only if PrepareToDraw was called. |
| 299 | void DidDrawAllLayers(const FrameData& frame); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 300 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 301 | const LayerTreeSettings& settings() const { return settings_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 302 | |
[email protected] | 0309ba5e0 | 2013-06-26 04:11:08 | [diff] [blame] | 303 | // Evict all textures by enforcing a memory policy with an allocation of 0. |
| 304 | void EvictTexturesForTesting(); |
| 305 | |
[email protected] | 4f48f6e | 2013-08-27 06:33:38 | [diff] [blame] | 306 | // 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] | 34bff212 | 2014-05-16 04:09:34 | [diff] [blame] | 311 | // Resets all of the trees to an empty state. |
| 312 | void ResetTreesForTesting(); |
| 313 | |
vmpstr | 380db09 | 2015-06-02 00:50:18 | [diff] [blame] | 314 | size_t SourceAnimationFrameNumberForTesting() const; |
| 315 | |
aelias | a57c40d12 | 2015-10-08 00:20:09 | [diff] [blame] | 316 | 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] | c05dfbb | 2014-07-10 22:49:04 | [diff] [blame] | 321 | DrawMode GetDrawMode() const; |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 322 | |
| 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] | bd532459 | 2014-07-31 09:09:33 | [diff] [blame] | 327 | // Viewport rect in view space used for tiling prioritization. |
| 328 | const gfx::Rect ViewportRectForTilePriority() const; |
| 329 | |
[email protected] | 59fee30 | 2013-12-10 17:53:30 | [diff] [blame] | 330 | // RendererClient implementation. |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 331 | void SetFullRootLayerDamage() override; |
[email protected] | 8947cbe | 2012-11-28 05:27:43 | [diff] [blame] | 332 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 333 | // TileManagerClient implementation. |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 334 | void NotifyReadyToActivate() override; |
ernstm | dfac03e1 | 2014-11-11 20:18:05 | [diff] [blame] | 335 | void NotifyReadyToDraw() override; |
ericrk | 5804924 | 2015-06-22 20:32:15 | [diff] [blame] | 336 | void NotifyAllTileTasksCompleted() override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 337 | void NotifyTileStateChanged(const Tile* tile) override; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 338 | std::unique_ptr<RasterTilePriorityQueue> BuildRasterQueue( |
vmpstr | b404063 | 2015-01-23 17:53:41 | [diff] [blame] | 339 | TreePriority tree_priority, |
| 340 | RasterTilePriorityQueue::Type type) override; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 341 | std::unique_ptr<EvictionTilePriorityQueue> BuildEvictionQueue( |
vmpstr | 997b00e | 2015-01-23 21:03:07 | [diff] [blame] | 342 | TreePriority tree_priority) override; |
vmpstr | 4973f5b | 2015-02-02 19:27:29 | [diff] [blame] | 343 | void SetIsLikelyToRequireADraw(bool is_likely_to_require_a_draw) override; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 344 | |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 345 | // ScrollbarAnimationControllerClient implementation. |
sunnyps | ae4316a | 2015-02-25 00:54:58 | [diff] [blame] | 346 | void PostDelayedScrollbarAnimationTask(const base::Closure& task, |
| 347 | base::TimeDelta delay) override; |
aelias | a57c40d12 | 2015-10-08 00:20:09 | [diff] [blame] | 348 | void SetNeedsAnimateForScrollbarAnimation() override; |
sunnyps | ae4316a | 2015-02-25 00:54:58 | [diff] [blame] | 349 | void SetNeedsRedrawForScrollbarAnimation() override; |
aelias | a57c40d12 | 2015-10-08 00:20:09 | [diff] [blame] | 350 | ScrollbarSet ScrollbarsFor(int scroll_layer_id) const override; |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 351 | |
sunnyps | 7d073dc | 2015-04-16 23:29:12 | [diff] [blame] | 352 | // VideoBeginFrameSource implementation. |
| 353 | void AddVideoFrameController(VideoFrameController* controller) override; |
| 354 | void RemoveVideoFrameController(VideoFrameController* controller) override; |
| 355 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 356 | // OutputSurfaceClient implementation. |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 357 | void CommitVSyncParameters(base::TimeTicks timebase, |
| 358 | base::TimeDelta interval) override; |
enne | 19c10858 | 2016-04-14 03:35:32 | [diff] [blame] | 359 | void SetBeginFrameSource(BeginFrameSource* source) override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 360 | void SetNeedsRedrawRect(const gfx::Rect& rect) override; |
boliu | 7097ee5b | 2015-12-17 03:16:09 | [diff] [blame] | 361 | void SetExternalTilePriorityConstraints( |
| 362 | const gfx::Rect& viewport_rect, |
| 363 | const gfx::Transform& transform) override; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 364 | 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; |
boliu | 7097ee5b | 2015-12-17 03:16:09 | [diff] [blame] | 370 | void OnDraw(const gfx::Transform& transform, |
| 371 | const gfx::Rect& viewport, |
| 372 | const gfx::Rect& clip, |
| 373 | bool resourceless_software_draw) override; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 374 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 375 | // Called from LayerTreeImpl. |
| 376 | void OnCanDrawStateChangedForTree(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 377 | |
[email protected] | b5174d71 | 2013-08-28 08:10:43 | [diff] [blame] | 378 | // Implementation. |
[email protected] | 12a63da | 2014-06-13 06:06:22 | [diff] [blame] | 379 | int id() const { return id_; } |
[email protected] | 6133cc23 | 2013-07-30 18:47:07 | [diff] [blame] | 380 | bool CanDraw() const; |
reveman | d180dfc3 | 2015-09-24 00:19:43 | [diff] [blame] | 381 | OutputSurface* output_surface() const { return output_surface_; } |
| 382 | void ReleaseOutputSurface(); |
| 383 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 384 | std::string LayerTreeAsJson() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 385 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 386 | void FinishAllRendering(); |
senorblanco | 2a5b0e1 | 2015-08-14 21:55:37 | [diff] [blame] | 387 | int RequestedMSAASampleCount() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 388 | |
reveman | d180dfc3 | 2015-09-24 00:19:43 | [diff] [blame] | 389 | virtual bool InitializeRenderer(OutputSurface* output_surface); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 390 | TileManager* tile_manager() { return tile_manager_.get(); } |
senorblanco | 8d1b3ac | 2015-05-05 00:14:26 | [diff] [blame] | 391 | |
senorblanco | 9c04acb | 2015-05-15 19:41:32 | [diff] [blame] | 392 | void SetHasGpuRasterizationTrigger(bool flag) { |
senorblanco | 8d1b3ac | 2015-05-05 00:14:26 | [diff] [blame] | 393 | has_gpu_rasterization_trigger_ = flag; |
senorblanco | 9c04acb | 2015-05-15 19:41:32 | [diff] [blame] | 394 | UpdateGpuRasterizationStatus(); |
senorblanco | 8d1b3ac | 2015-05-05 00:14:26 | [diff] [blame] | 395 | } |
senorblanco | 9c04acb | 2015-05-15 19:41:32 | [diff] [blame] | 396 | void SetContentIsSuitableForGpuRasterization(bool flag) { |
senorblanco | 8d1b3ac | 2015-05-05 00:14:26 | [diff] [blame] | 397 | content_is_suitable_for_gpu_rasterization_ = flag; |
senorblanco | 9c04acb | 2015-05-15 19:41:32 | [diff] [blame] | 398 | UpdateGpuRasterizationStatus(); |
senorblanco | 8d1b3ac | 2015-05-05 00:14:26 | [diff] [blame] | 399 | } |
vmiura | 4e7e199c | 2015-05-15 16:16:20 | [diff] [blame] | 400 | bool CanUseGpuRasterization(); |
senorblanco | 9c04acb | 2015-05-15 19:41:32 | [diff] [blame] | 401 | void UpdateTreeResourcesForGpuRasterizationIfNeeded(); |
[email protected] | 13525d6 | 2014-05-20 21:22:04 | [diff] [blame] | 402 | bool use_gpu_rasterization() const { return use_gpu_rasterization_; } |
senorblanco | fb88a4e | 2015-05-08 17:28:41 | [diff] [blame] | 403 | bool use_msaa() const { return use_msaa_; } |
hendrikw | c2bbd61 | 2014-12-03 23:49:34 | [diff] [blame] | 404 | |
| 405 | GpuRasterizationStatus gpu_rasterization_status() const { |
| 406 | return gpu_rasterization_status_; |
| 407 | } |
hendrikw | c2bbd61 | 2014-12-03 23:49:34 | [diff] [blame] | 408 | |
[email protected] | 473f1f2 | 2014-05-22 08:19:17 | [diff] [blame] | 409 | bool create_low_res_tiling() const { |
| 410 | return settings_.create_low_res_tiling && !use_gpu_rasterization_; |
| 411 | } |
[email protected] | b7635e0 | 2014-04-28 07:08:43 | [diff] [blame] | 412 | ResourcePool* resource_pool() { return resource_pool_.get(); } |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 413 | Renderer* renderer() { return renderer_.get(); } |
vmpstr | 64cdba3 | 2016-03-03 00:38:40 | [diff] [blame] | 414 | ImageDecodeController* image_decode_controller() { |
| 415 | return image_decode_controller_.get(); |
| 416 | } |
[email protected] | 7a8bcd26 | 2014-01-15 12:54:58 | [diff] [blame] | 417 | const RendererCapabilitiesImpl& GetRendererCapabilities() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 418 | |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 419 | virtual bool SwapBuffers(const FrameData& frame); |
[email protected] | 97e9ccd6 | 2014-04-12 01:07:15 | [diff] [blame] | 420 | virtual void WillBeginImplFrame(const BeginFrameArgs& args); |
mithro | 51693e38 | 2015-05-07 23:52:41 | [diff] [blame] | 421 | virtual void DidFinishImplFrame(); |
[email protected] | c48536a5 | 2013-09-14 00:02:08 | [diff] [blame] | 422 | void DidModifyTilePriorities(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 423 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 424 | 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] | 71618ed | 2014-07-24 02:23:45 | [diff] [blame] | 428 | LayerTreeImpl* recycle_tree() { return recycle_tree_.get(); } |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 429 | const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); } |
[email protected] | 12a63da | 2014-06-13 06:06:22 | [diff] [blame] | 430 | // Returns the tree LTH synchronizes with. |
| 431 | LayerTreeImpl* sync_tree() { |
enne | af5bda3 | 2015-02-19 01:27:36 | [diff] [blame] | 432 | // TODO(enne): This is bogus. It should return based on the value of |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 433 | // CommitToActiveTree() and not whether the pending tree exists. |
[email protected] | fc20d14 | 2014-07-01 00:49:15 | [diff] [blame] | 434 | return pending_tree_ ? pending_tree_.get() : active_tree_.get(); |
[email protected] | 12a63da | 2014-06-13 06:06:22 | [diff] [blame] | 435 | } |
[email protected] | 2f0d92f | 2013-06-11 04:07:20 | [diff] [blame] | 436 | virtual void CreatePendingTree(); |
[email protected] | fc20d14 | 2014-07-01 00:49:15 | [diff] [blame] | 437 | virtual void ActivateSyncTree(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 438 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 439 | // Shortcuts to layers on the active tree. |
| 440 | LayerImpl* RootLayer() const; |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 441 | LayerImpl* InnerViewportScrollLayer() const; |
| 442 | LayerImpl* OuterViewportScrollLayer() const; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 443 | LayerImpl* CurrentlyScrollingLayer() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 444 | |
[email protected] | f161ca9e | 2014-04-01 13:57:01 | [diff] [blame] | 445 | int scroll_layer_id_when_mouse_over_scrollbar() const { |
[email protected] | f620b0e7 | 2013-10-01 21:38:24 | [diff] [blame] | 446 | return scroll_layer_id_when_mouse_over_scrollbar_; |
| 447 | } |
[email protected] | f161ca9e | 2014-04-01 13:57:01 | [diff] [blame] | 448 | bool scroll_affects_scroll_handler() const { |
| 449 | return scroll_affects_scroll_handler_; |
| 450 | } |
[email protected] | dab0a42 | 2014-08-13 16:09:46 | [diff] [blame] | 451 | void QueueSwapPromiseForMainThreadScrollUpdate( |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 452 | std::unique_ptr<SwapPromise> swap_promise); |
[email protected] | f620b0e7 | 2013-10-01 21:38:24 | [diff] [blame] | 453 | |
jdduke | 16dde6e | 2014-10-24 00:22:56 | [diff] [blame] | 454 | bool IsActivelyScrolling() const; |
[email protected] | 251699b | 2013-10-09 00:21:26 | [diff] [blame] | 455 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 456 | virtual void SetVisible(bool visible); |
| 457 | bool visible() const { return visible_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 458 | |
[email protected] | d7eb8c7 | 2013-03-23 22:57:13 | [diff] [blame] | 459 | void SetNeedsCommit() { client_->SetNeedsCommitOnImplThread(); } |
danakj | a18e826a | 2015-12-03 00:27:03 | [diff] [blame] | 460 | void SetNeedsOneBeginImplFrame(); |
[email protected] | 6be422b | 2013-12-08 06:47:31 | [diff] [blame] | 461 | void SetNeedsRedraw(); |
[email protected] | d7eb8c7 | 2013-03-23 22:57:13 | [diff] [blame] | 462 | |
[email protected] | 206a392 | 2013-05-17 06:34:12 | [diff] [blame] | 463 | ManagedMemoryPolicy ActualManagedMemoryPolicy() const; |
| 464 | |
[email protected] | 3f2ff11 | 2013-08-03 02:41:07 | [diff] [blame] | 465 | size_t memory_allocation_limit_bytes() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 466 | |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 467 | void SetViewportSize(const gfx::Size& device_viewport_size); |
[email protected] | 4a6c091d | 2014-04-24 21:06:46 | [diff] [blame] | 468 | gfx::Size device_viewport_size() const { return device_viewport_size_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 469 | |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 470 | const gfx::Transform& DrawTransform() const; |
[email protected] | f224cc9 | 2013-06-06 23:23:32 | [diff] [blame] | 471 | |
majidvp | 96452d0 | 2016-04-11 20:36:04 | [diff] [blame] | 472 | std::unique_ptr<BeginFrameCallbackList> ProcessLayerTreeMutations(); |
| 473 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 474 | std::unique_ptr<ScrollAndScaleSet> ProcessScrollDeltas(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 475 | |
[email protected] | d7626ffd | 2013-03-29 00:17:42 | [diff] [blame] | 476 | void set_max_memory_needed_bytes(size_t bytes) { |
| 477 | max_memory_needed_bytes_ = bytes; |
| 478 | } |
| 479 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 480 | FrameRateCounter* fps_counter() { |
| 481 | return fps_counter_.get(); |
| 482 | } |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 483 | 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] | 4bb0f31 | 2014-02-25 02:02:32 | [diff] [blame] | 495 | const GlobalStateThatImpactsTilePriority& global_tile_state() { |
| 496 | return global_tile_state_; |
| 497 | } |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 498 | |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 499 | TaskRunnerProvider* task_runner_provider() const { |
| 500 | return task_runner_provider_; |
| 501 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 502 | |
loyso | bb93befc | 2015-07-03 00:19:50 | [diff] [blame] | 503 | AnimationHost* animation_host() const { return animation_host_.get(); } |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 504 | |
[email protected] | 6e7fdeb | 2013-07-09 14:28:38 | [diff] [blame] | 505 | void SetDebugState(const LayerTreeDebugState& new_debug_state); |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 506 | const LayerTreeDebugState& debug_state() const { return debug_state_; } |
[email protected] | f511afb | 2012-11-30 01:55:20 | [diff] [blame] | 507 | |
[email protected] | a2b5ded | 2013-05-20 21:32:53 | [diff] [blame] | 508 | gfx::Vector2dF accumulated_root_overscroll() const { |
| 509 | return accumulated_root_overscroll_; |
| 510 | } |
[email protected] | a2b5ded | 2013-05-20 21:32:53 | [diff] [blame] | 511 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 512 | bool pinch_gesture_active() const { return pinch_gesture_active_; } |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 513 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 514 | void SetTreePriority(TreePriority priority); |
vmpstr | 56ace23 | 2014-10-09 20:16:28 | [diff] [blame] | 515 | TreePriority GetTreePriority() const; |
[email protected] | 362f1e8b | 2013-01-21 16:54:30 | [diff] [blame] | 516 | |
mithro | 0bdb49d | 2015-05-27 13:08:01 | [diff] [blame] | 517 | // TODO(mithro): Remove this methods which exposes the internal |
| 518 | // BeginFrameArgs to external callers. |
[email protected] | 04c5900d | 2014-08-18 13:38:36 | [diff] [blame] | 519 | virtual BeginFrameArgs CurrentBeginFrameArgs() const; |
[email protected] | 829ad97 | 2013-01-28 23:36:10 | [diff] [blame] | 520 | |
[email protected] | c92195e | 2014-05-07 18:18:49 | [diff] [blame] | 521 | // Expected time between two begin impl frame calls. |
mithro | 0bdb49d | 2015-05-27 13:08:01 | [diff] [blame] | 522 | base::TimeDelta CurrentBeginFrameInterval() const; |
[email protected] | c92195e | 2014-05-07 18:18:49 | [diff] [blame] | 523 | |
[email protected] | d12aa93 | 2014-08-01 13:10:38 | [diff] [blame] | 524 | void AsValueWithFrameInto(FrameData* frame, |
ssid | 911e40e | 2015-02-09 17:55:20 | [diff] [blame] | 525 | base::trace_event::TracedValue* value) const; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 526 | std::unique_ptr<base::trace_event::ConvertableToTraceFormat> AsValueWithFrame( |
[email protected] | d12aa93 | 2014-08-01 13:10:38 | [diff] [blame] | 527 | FrameData* frame) const; |
ssid | 911e40e | 2015-02-09 17:55:20 | [diff] [blame] | 528 | void ActivationStateAsValueInto(base::trace_event::TracedValue* value) const; |
[email protected] | 131a0c2 | 2013-02-12 18:31:08 | [diff] [blame] | 529 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 530 | bool page_scale_animation_active() const { return !!page_scale_animation_; } |
[email protected] | 498ddd0 | 2013-02-28 23:59:25 | [diff] [blame] | 531 | |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 532 | virtual void CreateUIResource(UIResourceId uid, |
| 533 | const UIResourceBitmap& bitmap); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 534 | // Deletes a UI resource. May safely be called more than once. |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 535 | virtual void DeleteUIResource(UIResourceId uid); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 536 | void EvictAllUIResources(); |
| 537 | bool EvictedUIResourcesExist() const; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 538 | |
jbauman | bbd425e | 2015-05-19 00:33:35 | [diff] [blame] | 539 | virtual ResourceId ResourceIdForUIResource(UIResourceId uid) const; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 540 | |
[email protected] | 709c954 | 2013-10-26 01:43:51 | [diff] [blame] | 541 | virtual bool IsUIResourceOpaque(UIResourceId uid) const; |
| 542 | |
[email protected] | efbdb3a | 2013-10-04 00:35:13 | [diff] [blame] | 543 | struct UIResourceData { |
jbauman | bbd425e | 2015-05-19 00:33:35 | [diff] [blame] | 544 | ResourceId resource_id; |
[email protected] | efbdb3a | 2013-10-04 00:35:13 | [diff] [blame] | 545 | gfx::Size size; |
[email protected] | 709c954 | 2013-10-26 01:43:51 | [diff] [blame] | 546 | bool opaque; |
[email protected] | efbdb3a | 2013-10-04 00:35:13 | [diff] [blame] | 547 | }; |
| 548 | |
ymalik | 99740e85 | 2016-04-07 04:18:13 | [diff] [blame] | 549 | // 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 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 554 | void ScheduleMicroBenchmark(std::unique_ptr<MicroBenchmarkImpl> benchmark); |
[email protected] | 5e5648a | 2013-11-18 00:39:33 | [diff] [blame] | 555 | |
[email protected] | 4a28a61 | 2013-11-27 02:06:33 | [diff] [blame] | 556 | CompositorFrameMetadata MakeCompositorFrameMetadata() const; |
[email protected] | 59fee30 | 2013-12-10 17:53:30 | [diff] [blame] | 557 | // 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] | 4a28a61 | 2013-11-27 02:06:33 | [diff] [blame] | 562 | |
[email protected] | 6be422b | 2013-12-08 06:47:31 | [diff] [blame] | 563 | // 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 | |
weiliangc | 8dac5a6 | 2015-04-02 06:12:35 | [diff] [blame] | 570 | // TODO(weiliangc): Replace RequiresHighResToDraw with scheduler waits for |
| 571 | // ReadyToDraw. crbug.com/469175 |
vmpstr | 61ed94a1 | 2014-10-09 04:49:30 | [diff] [blame] | 572 | 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 | |
enne | 69277cb | 2014-10-29 23:03:40 | [diff] [blame] | 576 | // Only valid for synchronous (non-scheduled) single-threaded case. |
| 577 | void SynchronouslyInitializeAllTiles(); |
| 578 | |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 579 | bool SupportsImplScrolling() const; |
| 580 | bool CommitToActiveTree() const; |
| 581 | |
vmiura | a30e1ea | 2014-12-09 19:23:51 | [diff] [blame] | 582 | virtual void CreateResourceAndTileTaskWorkerPool( |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 583 | std::unique_ptr<TileTaskWorkerPool>* tile_task_worker_pool, |
| 584 | std::unique_ptr<ResourcePool>* resource_pool); |
enne | 03dbe8ae | 2014-10-30 01:32:55 | [diff] [blame] | 585 | |
vmpstr | 5377520a | 2014-12-29 23:26:13 | [diff] [blame] | 586 | bool prepare_tiles_needed() const { return tile_priorities_dirty_; } |
| 587 | |
vmpstr | 99aa853c | 2015-02-03 20:31:22 | [diff] [blame] | 588 | FrameTimingTracker* frame_timing_tracker() { |
| 589 | return frame_timing_tracker_.get(); |
| 590 | } |
| 591 | |
sunxd | 2668bea6 | 2016-03-17 00:49:47 | [diff] [blame] | 592 | 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); |
bokan | aa274831 | 2015-03-26 00:10:37 | [diff] [blame] | 597 | |
dcastagna | 1e6a2bc | 2016-03-22 21:30:50 | [diff] [blame] | 598 | 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 | |
vmpstr | d704c87 | 2015-04-03 20:29:51 | [diff] [blame] | 604 | // 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 | |
mpb | ed24c2c | 2015-06-05 20:57:13 | [diff] [blame] | 617 | // Post the given frame timing events to the requester. |
| 618 | void PostFrameTimingEvents( |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 619 | std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 620 | std::unique_ptr<FrameTimingTracker::MainFrameTimingSet> |
| 621 | main_frame_events); |
mpb | ed24c2c | 2015-06-05 20:57:13 | [diff] [blame] | 622 | |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 623 | 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 | |
sunxd | d1abacf | 2016-02-16 22:08:30 | [diff] [blame] | 630 | InputHandler::ScrollStatus TryScroll(const gfx::PointF& screen_space_point, |
| 631 | InputHandler::ScrollInputType type, |
| 632 | const ScrollTree& scroll_tree, |
| 633 | ScrollNode* scroll_node) const; |
| 634 | |
ymalik | 99740e85 | 2016-04-07 04:18:13 | [diff] [blame] | 635 | // 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 | |
majidvp | 96452d0 | 2016-04-11 20:36:04 | [diff] [blame] | 640 | void SetLayerTreeMutator(LayerTreeMutator* mutator); |
| 641 | LayerTreeMutator* mutator() { return mutator_; } |
| 642 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 643 | protected: |
[email protected] | 372bad5f | 2013-03-21 16:38:43 | [diff] [blame] | 644 | LayerTreeHostImpl( |
| 645 | const LayerTreeSettings& settings, |
| 646 | LayerTreeHostImplClient* client, |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 647 | TaskRunnerProvider* task_runner_provider, |
[email protected] | a7f3568 | 2013-10-22 23:05:57 | [diff] [blame] | 648 | RenderingStatsInstrumentation* rendering_stats_instrumentation, |
reveman | 22dd929 | 2014-10-13 20:52:05 | [diff] [blame] | 649 | SharedBitmapManager* shared_bitmap_manager, |
reveman | f9a8a234 | 2014-10-28 17:54:52 | [diff] [blame] | 650 | gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
reveman | 34b7a152 | 2015-03-23 20:27:47 | [diff] [blame] | 651 | TaskGraphRunner* task_graph_runner, |
[email protected] | dbe759a | 2013-12-02 19:23:02 | [diff] [blame] | 652 | int id); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 653 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 654 | // Virtual for testing. |
danakj | 492344054 | 2015-10-29 19:34:53 | [diff] [blame] | 655 | virtual bool AnimateLayers(base::TimeTicks monotonic_time); |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 656 | |
sunnyps | c61ff519 | 2015-03-18 01:41:25 | [diff] [blame] | 657 | bool is_likely_to_require_a_draw() const { |
| 658 | return is_likely_to_require_a_draw_; |
| 659 | } |
| 660 | |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 661 | // Removes empty or orphan RenderPasses from the frame. |
| 662 | static void RemoveRenderPasses(FrameData* frame); |
| 663 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 664 | LayerTreeHostImplClient* client_; |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 665 | TaskRunnerProvider* task_runner_provider_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 666 | |
mithro | 0bdb49d | 2015-05-27 13:08:01 | [diff] [blame] | 667 | BeginFrameTracker current_begin_frame_tracker_; |
| 668 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 669 | private: |
sunxd | 2668bea6 | 2016-03-17 00:49:47 | [diff] [blame] | 670 | gfx::Vector2dF ScrollNodeWithViewportSpaceDelta( |
| 671 | ScrollNode* scroll_node, |
bokan | aa274831 | 2015-03-26 00:10:37 | [diff] [blame] | 672 | const gfx::PointF& viewport_point, |
sunxd | 2668bea6 | 2016-03-17 00:49:47 | [diff] [blame] | 673 | const gfx::Vector2dF& viewport_delta, |
| 674 | ScrollTree* scroll_tree); |
bokan | aa274831 | 2015-03-26 00:10:37 | [diff] [blame] | 675 | |
[email protected] | ced667b | 2014-05-22 21:49:53 | [diff] [blame] | 676 | void CreateAndSetRenderer(); |
ccameron | f8a370a | 2015-11-18 07:44:36 | [diff] [blame] | 677 | void CleanUpTileManagerAndUIResources(); |
vmpstr | 7919184 | 2015-07-10 20:40:33 | [diff] [blame] | 678 | void CreateTileManagerResources(); |
[email protected] | 5064464 | 2013-06-20 13:58:55 | [diff] [blame] | 679 | void ReleaseTreeResources(); |
vmpstr | 9ce5c66 | 2015-02-05 23:29:26 | [diff] [blame] | 680 | void RecreateTreeResources(); |
[email protected] | 2b154b2 | 2013-06-07 09:03:27 | [diff] [blame] | 681 | |
danakj | 492344054 | 2015-10-29 19:34:53 | [diff] [blame] | 682 | void AnimateInternal(bool active_tree); |
| 683 | |
senorblanco | 9c04acb | 2015-05-15 19:41:32 | [diff] [blame] | 684 | void UpdateGpuRasterizationStatus(); |
| 685 | |
bokan | aa274831 | 2015-03-26 00:10:37 | [diff] [blame] | 686 | Viewport* viewport() { return viewport_.get(); } |
| 687 | |
bokan | 59379b09 | 2014-09-29 13:47:21 | [diff] [blame] | 688 | // Scroll by preferring to move the outer viewport first, only moving the |
| 689 | // inner if the outer is at its scroll extents. |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 690 | void ScrollViewportBy(gfx::Vector2dF scroll_delta); |
bokan | 59379b09 | 2014-09-29 13:47:21 | [diff] [blame] | 691 | // 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); |
sunnyps | 7d073dc | 2015-04-16 23:29:12 | [diff] [blame] | 694 | |
hush | 1c87323 | 2015-06-23 21:22:11 | [diff] [blame] | 695 | InputHandler::ScrollStatus ScrollBeginImpl( |
majidvp | 944a8cd | 2016-01-12 21:05:18 | [diff] [blame] | 696 | ScrollState* scroll_state, |
hush | 1c87323 | 2015-06-23 21:22:11 | [diff] [blame] | 697 | LayerImpl* scrolling_layer_impl, |
| 698 | InputHandler::ScrollInputType type); |
majidvp | 944a8cd | 2016-01-12 21:05:18 | [diff] [blame] | 699 | void DistributeScrollDelta(ScrollState* scroll_state); |
hush | 1c87323 | 2015-06-23 21:22:11 | [diff] [blame] | 700 | |
danakj | 492344054 | 2015-10-29 19:34:53 | [diff] [blame] | 701 | bool AnimatePageScale(base::TimeTicks monotonic_time); |
| 702 | bool AnimateScrollbars(base::TimeTicks monotonic_time); |
| 703 | bool AnimateTopControls(base::TimeTicks monotonic_time); |
[email protected] | 2d69299 | 2012-12-19 01:19:32 | [diff] [blame] | 704 | |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 705 | void TrackDamageForAllSurfaces( |
| 706 | LayerImpl* root_draw_layer, |
| 707 | const LayerImplList& render_surface_layer_list); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 708 | |
[email protected] | 8be1a9bf | 2013-05-01 03:45:19 | [diff] [blame] | 709 | void UpdateTileManagerMemoryPolicy(const ManagedMemoryPolicy& policy); |
| 710 | |
[email protected] | 7ddfe7e8 | 2014-01-30 07:22:11 | [diff] [blame] | 711 | // 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] | 30d8214 | 2014-05-12 04:26:02 | [diff] [blame] | 714 | DrawResult CalculateRenderPasses(FrameData* frame); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 715 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 716 | void ClearCurrentlyScrollingLayer(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 717 | |
aelias | a57c40d12 | 2015-10-08 00:20:09 | [diff] [blame] | 718 | void HandleMouseOverScrollbar(LayerImpl* layer_impl); |
[email protected] | f620b0e7 | 2013-10-01 21:38:24 | [diff] [blame] | 719 | |
[email protected] | f620b0e7 | 2013-10-01 21:38:24 | [diff] [blame] | 720 | LayerImpl* FindScrollLayerForDeviceViewportPoint( |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 721 | const gfx::PointF& device_viewport_point, |
[email protected] | bf1cfd9a | 2013-09-26 05:43:02 | [diff] [blame] | 722 | InputHandler::ScrollInputType type, |
[email protected] | f620b0e7 | 2013-10-01 21:38:24 | [diff] [blame] | 723 | LayerImpl* layer_hit_by_point, |
[email protected] | f161ca9e | 2014-04-01 13:57:01 | [diff] [blame] | 724 | bool* scroll_on_main_thread, |
danakj | 3590476 | 2016-01-21 20:49:40 | [diff] [blame] | 725 | uint32_t* main_thread_scrolling_reason) const; |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 726 | float DeviceSpaceDistanceToLayer(const gfx::PointF& device_viewport_point, |
[email protected] | bf1cfd9a | 2013-09-26 05:43:02 | [diff] [blame] | 727 | LayerImpl* layer_impl); |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 728 | void StartScrollbarFadeRecursive(LayerImpl* layer); |
boliu | 247624d | 2015-04-11 02:04:25 | [diff] [blame] | 729 | void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy); |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 730 | |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 731 | void MarkUIResourceNotEvicted(UIResourceId uid); |
ccameron | f8a370a | 2015-11-18 07:44:36 | [diff] [blame] | 732 | void ClearUIResources(); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 733 | |
[email protected] | 6be422b | 2013-12-08 06:47:31 | [diff] [blame] | 734 | void NotifySwapPromiseMonitorsOfSetNeedsRedraw(); |
[email protected] | dab0a42 | 2014-08-13 16:09:46 | [diff] [blame] | 735 | void NotifySwapPromiseMonitorsOfForwardingToMainThread(); |
danakj | dd74e51 | 2015-09-21 23:07:59 | [diff] [blame] | 736 | |
| 737 | void UpdateRootLayerStateForSynchronousInputHandler(); |
[email protected] | 6be422b | 2013-12-08 06:47:31 | [diff] [blame] | 738 | |
ymalik | 0f419206 | 2016-01-14 17:18:35 | [diff] [blame] | 739 | void ScrollAnimationAbort(LayerImpl* layer_impl); |
| 740 | |
sunxd | 54e08e9d | 2016-02-22 23:01:28 | [diff] [blame] | 741 | bool ScrollAnimationUpdateTarget(ScrollNode* scroll_node, |
loyso | 2c4002d | 2015-03-13 02:31:43 | [diff] [blame] | 742 | const gfx::Vector2dF& scroll_delta); |
| 743 | |
davidben | 5877ffe | 2016-01-28 00:29:51 | [diff] [blame] | 744 | using UIResourceMap = std::unordered_map<UIResourceId, UIResourceData>; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 745 | UIResourceMap ui_resource_map_; |
| 746 | |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 747 | // 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 | |
reveman | d180dfc3 | 2015-09-24 00:19:43 | [diff] [blame] | 752 | OutputSurface* output_surface_; |
[email protected] | fbe89f7 | 2013-05-21 07:24:24 | [diff] [blame] | 753 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 754 | std::unique_ptr<ResourceProvider> resource_provider_; |
senorblanco | 8d1b3ac | 2015-05-05 00:14:26 | [diff] [blame] | 755 | bool content_is_suitable_for_gpu_rasterization_; |
| 756 | bool has_gpu_rasterization_trigger_; |
[email protected] | 13525d6 | 2014-05-20 21:22:04 | [diff] [blame] | 757 | bool use_gpu_rasterization_; |
senorblanco | fb88a4e | 2015-05-08 17:28:41 | [diff] [blame] | 758 | bool use_msaa_; |
hendrikw | c2bbd61 | 2014-12-03 23:49:34 | [diff] [blame] | 759 | GpuRasterizationStatus gpu_rasterization_status_; |
senorblanco | 9c04acb | 2015-05-15 19:41:32 | [diff] [blame] | 760 | bool tree_resources_for_gpu_rasterization_dirty_; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 761 | 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] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 765 | |
[email protected] | 1bcced2 | 2013-09-24 13:51:19 | [diff] [blame] | 766 | GlobalStateThatImpactsTilePriority global_tile_state_; |
| 767 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 768 | // Tree currently being drawn. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 769 | std::unique_ptr<LayerTreeImpl> active_tree_; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 770 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 771 | // In impl-side painting mode, tree with possibly incomplete rasterized |
[email protected] | 4f48f6e | 2013-08-27 06:33:38 | [diff] [blame] | 772 | // content. May be promoted to active by ActivatePendingTree(). |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 773 | std::unique_ptr<LayerTreeImpl> pending_tree_; |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 774 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 775 | // In impl-side painting mode, inert tree with layers that can be recycled |
| 776 | // by the next sync from the main thread. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 777 | std::unique_ptr<LayerTreeImpl> recycle_tree_; |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 778 | |
[email protected] | 200a9c06 | 2013-05-20 04:34:37 | [diff] [blame] | 779 | InputHandlerClient* input_handler_client_; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 780 | bool did_lock_scrolling_layer_; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 781 | bool wheel_scrolling_; |
[email protected] | f161ca9e | 2014-04-01 13:57:01 | [diff] [blame] | 782 | bool scroll_affects_scroll_handler_; |
[email protected] | f620b0e7 | 2013-10-01 21:38:24 | [diff] [blame] | 783 | int scroll_layer_id_when_mouse_over_scrollbar_; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 784 | std::vector<std::unique_ptr<SwapPromise>> |
vmpstr | a370ef5 | 2015-11-18 10:41:28 | [diff] [blame] | 785 | swap_promises_for_main_thread_scroll_update_; |
[email protected] | a23451e | 2013-06-07 20:58:26 | [diff] [blame] | 786 | |
ccameron | 4163cc35 | 2014-11-13 19:06:36 | [diff] [blame] | 787 | // An object to implement the ScrollElasticityHelper interface and |
| 788 | // hold all state related to elasticity. May be NULL if never requested. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 789 | std::unique_ptr<ScrollElasticityHelper> scroll_elasticity_helper_; |
ccameron | 4163cc35 | 2014-11-13 19:06:36 | [diff] [blame] | 790 | |
[email protected] | c48536a5 | 2013-09-14 00:02:08 | [diff] [blame] | 791 | bool tile_priorities_dirty_; |
[email protected] | a23451e | 2013-06-07 20:58:26 | [diff] [blame] | 792 | |
enne | 65dc621 | 2015-04-29 21:44:23 | [diff] [blame] | 793 | const LayerTreeSettings settings_; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 794 | LayerTreeDebugState debug_state_; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 795 | bool visible_; |
[email protected] | 3f2ff11 | 2013-08-03 02:41:07 | [diff] [blame] | 796 | ManagedMemoryPolicy cached_managed_memory_policy_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 797 | |
vmpstr | c57abc8 | 2015-07-14 22:16:19 | [diff] [blame] | 798 | const bool is_synchronous_single_threaded_; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 799 | std::unique_ptr<TileManager> tile_manager_; |
vmpstr | 7919184 | 2015-07-10 20:40:33 | [diff] [blame] | 800 | |
[email protected] | a2b5ded | 2013-05-20 21:32:53 | [diff] [blame] | 801 | gfx::Vector2dF accumulated_root_overscroll_; |
[email protected] | 6e921bd | 2013-04-29 21:10:20 | [diff] [blame] | 802 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 803 | bool pinch_gesture_active_; |
[email protected] | 2fa342b8 | 2013-09-24 03:19:13 | [diff] [blame] | 804 | bool pinch_gesture_end_should_clear_scrolling_layer_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 805 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 806 | std::unique_ptr<TopControlsManager> top_controls_manager_; |
[email protected] | 3ba4cae | 2013-01-16 03:58:38 | [diff] [blame] | 807 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 808 | std::unique_ptr<PageScaleAnimation> page_scale_animation_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 809 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 810 | std::unique_ptr<FrameRateCounter> fps_counter_; |
| 811 | std::unique_ptr<MemoryHistory> memory_history_; |
| 812 | std::unique_ptr<DebugRectHistory> debug_rect_history_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 813 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 814 | std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter_; |
[email protected] | ea468c6c | 2013-09-10 08:25:11 | [diff] [blame] | 815 | |
[email protected] | d7626ffd | 2013-03-29 00:17:42 | [diff] [blame] | 816 | // 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] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 820 | // 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] | f224cc9 | 2013-06-06 23:23:32 | [diff] [blame] | 824 | gfx::Size device_viewport_size_; |
| 825 | |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 826 | // 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] | bd532459 | 2014-07-31 09:09:33 | [diff] [blame] | 831 | // - viewport_rect_for_tile_priority_ is the rect in view space used for |
| 832 | // tiling priority. |
[email protected] | f224cc9 | 2013-06-06 23:23:32 | [diff] [blame] | 833 | gfx::Transform external_transform_; |
| 834 | gfx::Rect external_viewport_; |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 835 | gfx::Rect external_clip_; |
[email protected] | bd532459 | 2014-07-31 09:09:33 | [diff] [blame] | 836 | gfx::Rect viewport_rect_for_tile_priority_; |
[email protected] | c05dfbb | 2014-07-10 22:49:04 | [diff] [blame] | 837 | bool resourceless_software_draw_; |
[email protected] | f224cc9 | 2013-06-06 23:23:32 | [diff] [blame] | 838 | |
dcastagna | 1e6a2bc | 2016-03-22 21:30:50 | [diff] [blame] | 839 | bool output_is_secure_; |
| 840 | |
[email protected] | 878705be | 2013-04-15 22:44:02 | [diff] [blame] | 841 | gfx::Rect viewport_damage_rect_; |
[email protected] | e034135 | 2013-04-06 05:01:20 | [diff] [blame] | 842 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 843 | std::unique_ptr<AnimationHost> animation_host_; |
sunnyps | 7d073dc | 2015-04-16 23:29:12 | [diff] [blame] | 844 | std::set<VideoFrameController*> video_frame_controllers_; |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 845 | |
aelias | a57c40d12 | 2015-10-08 00:20:09 | [diff] [blame] | 846 | // Map from scroll layer ID to scrollbar animation controller. |
| 847 | // There is one animation controller per pair of overlay scrollbars. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 848 | std::unordered_map<int, std::unique_ptr<ScrollbarAnimationController>> |
aelias | a57c40d12 | 2015-10-08 00:20:09 | [diff] [blame] | 849 | scrollbar_animation_controllers_; |
| 850 | |
[email protected] | 372bad5f | 2013-03-21 16:38:43 | [diff] [blame] | 851 | RenderingStatsInstrumentation* rendering_stats_instrumentation_; |
[email protected] | 5e5648a | 2013-11-18 00:39:33 | [diff] [blame] | 852 | MicroBenchmarkControllerImpl micro_benchmark_controller_; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 853 | std::unique_ptr<SynchronousTaskGraphRunner> |
ericrk | 4e3aa5a | 2015-12-01 03:53:56 | [diff] [blame] | 854 | single_thread_synchronous_task_graph_runner_; |
[email protected] | 372bad5f | 2013-03-21 16:38:43 | [diff] [blame] | 855 | |
[email protected] | 5f07afc | 2013-07-19 05:17:18 | [diff] [blame] | 856 | // Optional callback to notify of new tree activations. |
[email protected] | 2022c67 | 2013-07-23 19:55:26 | [diff] [blame] | 857 | base::Closure tree_activation_callback_; |
[email protected] | 5f07afc | 2013-07-19 05:17:18 | [diff] [blame] | 858 | |
[email protected] | a7f3568 | 2013-10-22 23:05:57 | [diff] [blame] | 859 | SharedBitmapManager* shared_bitmap_manager_; |
reveman | f9a8a234 | 2014-10-28 17:54:52 | [diff] [blame] | 860 | gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
reveman | 34b7a152 | 2015-03-23 20:27:47 | [diff] [blame] | 861 | TaskGraphRunner* task_graph_runner_; |
[email protected] | dbe759a | 2013-12-02 19:23:02 | [diff] [blame] | 862 | int id_; |
[email protected] | a7f3568 | 2013-10-22 23:05:57 | [diff] [blame] | 863 | |
[email protected] | 6be422b | 2013-12-08 06:47:31 | [diff] [blame] | 864 | std::set<SwapPromiseMonitor*> swap_promise_monitor_; |
[email protected] | 8aa39ecb | 2014-06-12 14:19:14 | [diff] [blame] | 865 | |
vmpstr | 61ed94a1 | 2014-10-09 04:49:30 | [diff] [blame] | 866 | bool requires_high_res_to_draw_; |
vmpstr | 4973f5b | 2015-02-02 19:27:29 | [diff] [blame] | 867 | bool is_likely_to_require_a_draw_; |
vmpstr | 61ed94a1 | 2014-10-09 04:49:30 | [diff] [blame] | 868 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 869 | std::unique_ptr<FrameTimingTracker> frame_timing_tracker_; |
vmpstr | 99aa853c | 2015-02-03 20:31:22 | [diff] [blame] | 870 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 871 | std::unique_ptr<Viewport> viewport_; |
bokan | aa274831 | 2015-03-26 00:10:37 | [diff] [blame] | 872 | |
majidvp | 96452d0 | 2016-04-11 20:36:04 | [diff] [blame] | 873 | LayerTreeMutator* mutator_; |
| 874 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 875 | DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 876 | }; |
| 877 | |
[email protected] | 0023e8b | 2012-10-15 12:52:45 | [diff] [blame] | 878 | } // namespace cc |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 879 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 880 | #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ |