[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 5 | #include "cc/trees/layer_tree_impl.h" |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 6 | |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 7 | #include <algorithm> |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 8 | #include <limits> |
| 9 | #include <set> |
| 10 | |
primiano | c06e238 | 2015-01-28 04:21:49 | [diff] [blame] | 11 | #include "base/trace_event/trace_event.h" |
| 12 | #include "base/trace_event/trace_event_argument.h" |
[email protected] | 95e4e1a0 | 2013-03-18 07:09:09 | [diff] [blame] | 13 | #include "cc/animation/keyframed_animation_curve.h" |
| 14 | #include "cc/animation/scrollbar_animation_controller.h" |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 15 | #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
| 16 | #include "cc/animation/scrollbar_animation_controller_thinning.h" |
[email protected] | 3744e27b | 2013-11-06 21:44:08 | [diff] [blame] | 17 | #include "cc/base/math_util.h" |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 18 | #include "cc/base/synced_property.h" |
[email protected] | 3744e27b | 2013-11-06 21:44:08 | [diff] [blame] | 19 | #include "cc/base/util.h" |
[email protected] | 12a63da | 2014-06-13 06:06:22 | [diff] [blame] | 20 | #include "cc/debug/devtools_instrumentation.h" |
[email protected] | f6742f5 | 2013-05-08 23:52:22 | [diff] [blame] | 21 | #include "cc/debug/traced_value.h" |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 22 | #include "cc/input/layer_scroll_offset_delegate.h" |
bokan | 915bf35 | 2014-10-02 21:57:14 | [diff] [blame] | 23 | #include "cc/input/page_scale_animation.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 24 | #include "cc/layers/heads_up_display_layer_impl.h" |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 25 | #include "cc/layers/layer.h" |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 26 | #include "cc/layers/layer_iterator.h" |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 27 | #include "cc/layers/render_surface_impl.h" |
[email protected] | 80413d7 | 2013-08-30 20:25:33 | [diff] [blame] | 28 | #include "cc/layers/scrollbar_layer_impl_base.h" |
[email protected] | e104219 | 2013-11-08 05:44:24 | [diff] [blame] | 29 | #include "cc/resources/ui_resource_request.h" |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 30 | #include "cc/trees/layer_tree_host_common.h" |
| 31 | #include "cc/trees/layer_tree_host_impl.h" |
[email protected] | 562b7ad | 2014-06-23 22:17:11 | [diff] [blame] | 32 | #include "cc/trees/occlusion_tracker.h" |
heejin.r.chung | d28506ba | 2014-10-23 16:36:20 | [diff] [blame] | 33 | #include "ui/gfx/geometry/point_conversions.h" |
| 34 | #include "ui/gfx/geometry/size_conversions.h" |
| 35 | #include "ui/gfx/geometry/vector2d_conversions.h" |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 36 | |
| 37 | namespace cc { |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 38 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 39 | LayerTreeImpl::LayerTreeImpl( |
| 40 | LayerTreeHostImpl* layer_tree_host_impl, |
ccameron | b9aec450 | 2014-12-05 19:31:00 | [diff] [blame] | 41 | scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 42 | scoped_refptr<SyncedTopControls> top_controls_shown_ratio, |
ccameron | b9aec450 | 2014-12-05 19:31:00 | [diff] [blame] | 43 | scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) |
[email protected] | db8259f | 2013-02-01 05:25:04 | [diff] [blame] | 44 | : layer_tree_host_impl_(layer_tree_host_impl), |
| 45 | source_frame_number_(-1), |
| 46 | hud_layer_(0), |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 47 | currently_scrolling_layer_(NULL), |
| 48 | root_layer_scroll_offset_delegate_(NULL), |
[email protected] | db8259f | 2013-02-01 05:25:04 | [diff] [blame] | 49 | background_color_(0), |
| 50 | has_transparent_background_(false), |
ccameron | b9aec450 | 2014-12-05 19:31:00 | [diff] [blame] | 51 | overscroll_elasticity_layer_(NULL), |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 52 | page_scale_layer_(NULL), |
| 53 | inner_viewport_scroll_layer_(NULL), |
| 54 | outer_viewport_scroll_layer_(NULL), |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 55 | page_scale_factor_(page_scale_factor), |
[email protected] | db8259f | 2013-02-01 05:25:04 | [diff] [blame] | 56 | min_page_scale_factor_(0), |
| 57 | max_page_scale_factor_(0), |
ccameron | b9aec450 | 2014-12-05 19:31:00 | [diff] [blame] | 58 | elastic_overscroll_(elastic_overscroll), |
[email protected] | db8259f | 2013-02-01 05:25:04 | [diff] [blame] | 59 | scrolling_layer_id_from_previous_tree_(0), |
| 60 | contents_textures_purged_(false), |
[email protected] | 31882285 | 2013-02-14 00:54:27 | [diff] [blame] | 61 | viewport_size_invalid_(false), |
[email protected] | db8259f | 2013-02-01 05:25:04 | [diff] [blame] | 62 | needs_update_draw_properties_(true), |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 63 | needs_full_tree_sync_(true), |
[email protected] | 390bb1ff | 2014-05-09 17:14:40 | [diff] [blame] | 64 | next_activation_forces_redraw_(false), |
[email protected] | 759dc9f | 2014-07-23 19:18:51 | [diff] [blame] | 65 | has_ever_been_drawn_(false), |
bokan | 88eae01 | 2014-09-09 20:40:42 | [diff] [blame] | 66 | render_surface_layer_list_id_(0), |
dtrainor | cb7779b8 | 2014-12-04 01:08:02 | [diff] [blame] | 67 | top_controls_shrink_blink_size_(false), |
| 68 | top_controls_height_(0), |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 69 | top_controls_shown_ratio_(top_controls_shown_ratio) { |
[email protected] | 390bb1ff | 2014-05-09 17:14:40 | [diff] [blame] | 70 | } |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 71 | |
| 72 | LayerTreeImpl::~LayerTreeImpl() { |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 73 | BreakSwapPromises(SwapPromise::SWAP_FAILS); |
| 74 | |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 75 | // Need to explicitly clear the tree prior to destroying this so that |
| 76 | // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. |
[email protected] | df17af5 | 2014-02-06 02:20:40 | [diff] [blame] | 77 | DCHECK(!root_layer_); |
| 78 | DCHECK(layers_with_copy_output_request_.empty()); |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 79 | } |
| 80 | |
danakj | f446a07 | 2014-09-27 21:55:48 | [diff] [blame] | 81 | void LayerTreeImpl::Shutdown() { |
| 82 | root_layer_ = nullptr; |
| 83 | } |
[email protected] | df17af5 | 2014-02-06 02:20:40 | [diff] [blame] | 84 | |
[email protected] | aeef2f0 | 2014-05-10 12:15:48 | [diff] [blame] | 85 | void LayerTreeImpl::ReleaseResources() { |
vmpstr | a73f18d | 2015-03-02 21:04:39 | [diff] [blame] | 86 | if (root_layer_) { |
| 87 | LayerTreeHostCommon::CallFunctionForSubtree( |
| 88 | root_layer_.get(), [](LayerImpl* layer) { layer->ReleaseResources(); }); |
| 89 | } |
vmpstr | 9ce5c66 | 2015-02-05 23:29:26 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | void LayerTreeImpl::RecreateResources() { |
vmpstr | a73f18d | 2015-03-02 21:04:39 | [diff] [blame] | 93 | if (root_layer_) { |
| 94 | LayerTreeHostCommon::CallFunctionForSubtree( |
| 95 | root_layer_.get(), |
| 96 | [](LayerImpl* layer) { layer->RecreateResources(); }); |
| 97 | } |
[email protected] | aeef2f0 | 2014-05-10 12:15:48 | [diff] [blame] | 98 | } |
| 99 | |
vmpstr | d704c87 | 2015-04-03 20:29:51 | [diff] [blame] | 100 | void LayerTreeImpl::GatherFrameTimingRequestIds( |
| 101 | std::vector<int64_t>* request_ids) { |
| 102 | if (!root_layer_) |
| 103 | return; |
| 104 | |
| 105 | // TODO(vmpstr): Early out if there are no requests on any of the layers. For |
| 106 | // that, we need to inform LayerTreeImpl whenever there are requests when we |
| 107 | // get them. |
| 108 | LayerTreeHostCommon::CallFunctionForSubtree( |
| 109 | root_layer_.get(), [request_ids](LayerImpl* layer) { |
| 110 | layer->GatherFrameTimingRequestIds(request_ids); |
| 111 | }); |
| 112 | } |
| 113 | |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 114 | bool LayerTreeImpl::IsExternalFlingActive() const { |
| 115 | return root_layer_scroll_offset_delegate_ && |
| 116 | root_layer_scroll_offset_delegate_->IsExternalFlingActive(); |
| 117 | } |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 118 | |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 119 | void LayerTreeImpl::DidUpdateScrollOffset(int layer_id) { |
| 120 | int inner_layer_id = InnerViewportScrollLayer() |
| 121 | ? InnerViewportScrollLayer()->id() |
| 122 | : Layer::INVALID_ID; |
| 123 | int outer_layer_id = OuterViewportScrollLayer() |
| 124 | ? OuterViewportScrollLayer()->id() |
| 125 | : Layer::INVALID_ID; |
| 126 | if (layer_id != outer_layer_id && layer_id != inner_layer_id) |
| 127 | return; |
| 128 | |
| 129 | if (!root_layer_scroll_offset_delegate_) |
| 130 | return; |
| 131 | |
| 132 | UpdateRootScrollOffsetDelegate(); |
| 133 | } |
| 134 | |
| 135 | void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 136 | root_layer_ = layer.Pass(); |
[email protected] | 5c4824e1 | 2013-01-12 16:34:53 | [diff] [blame] | 137 | currently_scrolling_layer_ = NULL; |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 138 | inner_viewport_scroll_layer_ = NULL; |
| 139 | outer_viewport_scroll_layer_ = NULL; |
| 140 | page_scale_layer_ = NULL; |
[email protected] | 5c4824e1 | 2013-01-12 16:34:53 | [diff] [blame] | 141 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 142 | layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
[email protected] | 5c4824e1 | 2013-01-12 16:34:53 | [diff] [blame] | 143 | } |
| 144 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 145 | LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const { |
| 146 | return inner_viewport_scroll_layer_; |
| 147 | } |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 148 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 149 | LayerImpl* LayerTreeImpl::OuterViewportScrollLayer() const { |
| 150 | return outer_viewport_scroll_layer_; |
| 151 | } |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 152 | |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 153 | gfx::ScrollOffset LayerTreeImpl::TotalScrollOffset() const { |
| 154 | gfx::ScrollOffset offset; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 155 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 156 | if (inner_viewport_scroll_layer_) |
aelias | d0070ba | 2015-01-31 13:44:49 | [diff] [blame] | 157 | offset += inner_viewport_scroll_layer_->CurrentScrollOffset(); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 158 | |
| 159 | if (outer_viewport_scroll_layer_) |
aelias | d0070ba | 2015-01-31 13:44:49 | [diff] [blame] | 160 | offset += outer_viewport_scroll_layer_->CurrentScrollOffset(); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 161 | |
| 162 | return offset; |
| 163 | } |
| 164 | |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 165 | gfx::ScrollOffset LayerTreeImpl::TotalMaxScrollOffset() const { |
| 166 | gfx::ScrollOffset offset; |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 167 | |
| 168 | if (inner_viewport_scroll_layer_) |
| 169 | offset += inner_viewport_scroll_layer_->MaxScrollOffset(); |
| 170 | |
| 171 | if (outer_viewport_scroll_layer_) |
| 172 | offset += outer_viewport_scroll_layer_->MaxScrollOffset(); |
| 173 | |
| 174 | return offset; |
| 175 | } |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 176 | |
| 177 | scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() { |
| 178 | // Clear all data structures that have direct references to the layer tree. |
| 179 | scrolling_layer_id_from_previous_tree_ = |
| 180 | currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0; |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 181 | inner_viewport_scroll_layer_ = NULL; |
| 182 | outer_viewport_scroll_layer_ = NULL; |
| 183 | page_scale_layer_ = NULL; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 184 | currently_scrolling_layer_ = NULL; |
| 185 | |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 186 | render_surface_layer_list_.clear(); |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 187 | set_needs_update_draw_properties(); |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 188 | return root_layer_.Pass(); |
| 189 | } |
| 190 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 191 | void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 192 | // The request queue should have been processed and does not require a push. |
| 193 | DCHECK_EQ(ui_resource_request_queue_.size(), 0u); |
| 194 | |
enne | e95b154 | 2015-04-20 20:35:50 | [diff] [blame^] | 195 | target_tree->SetPropertyTrees(property_trees_); |
| 196 | |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 197 | if (next_activation_forces_redraw_) { |
[email protected] | 12a63da | 2014-06-13 06:06:22 | [diff] [blame] | 198 | target_tree->ForceRedrawNextActivation(); |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 199 | next_activation_forces_redraw_ = false; |
| 200 | } |
| 201 | |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 202 | target_tree->PassSwapPromises(&swap_promise_list_); |
| 203 | |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 204 | target_tree->set_top_controls_shrink_blink_size( |
| 205 | top_controls_shrink_blink_size_); |
| 206 | target_tree->set_top_controls_height(top_controls_height_); |
| 207 | target_tree->PushTopControls(nullptr); |
bokan | 88eae01 | 2014-09-09 20:40:42 | [diff] [blame] | 208 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 209 | // Active tree already shares the page_scale_factor object with pending |
| 210 | // tree so only the limits need to be provided. |
| 211 | target_tree->PushPageScaleFactorAndLimits(nullptr, min_page_scale_factor(), |
| 212 | max_page_scale_factor()); |
ccameron | b9aec450 | 2014-12-05 19:31:00 | [diff] [blame] | 213 | target_tree->elastic_overscroll()->PushPendingToActive(); |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 214 | |
bokan | fcdbc18 | 2014-11-21 21:53:33 | [diff] [blame] | 215 | target_tree->pending_page_scale_animation_ = |
| 216 | pending_page_scale_animation_.Pass(); |
bokan | 915bf35 | 2014-10-02 21:57:14 | [diff] [blame] | 217 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 218 | if (page_scale_layer_ && inner_viewport_scroll_layer_) { |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 219 | target_tree->SetViewportLayersFromIds( |
ccameron | 8230b68b | 2014-11-21 19:25:18 | [diff] [blame] | 220 | overscroll_elasticity_layer_ ? overscroll_elasticity_layer_->id() |
| 221 | : Layer::INVALID_ID, |
| 222 | page_scale_layer_->id(), inner_viewport_scroll_layer_->id(), |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 223 | outer_viewport_scroll_layer_ ? outer_viewport_scroll_layer_->id() |
| 224 | : Layer::INVALID_ID); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 225 | } else { |
| 226 | target_tree->ClearViewportLayers(); |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 227 | } |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 228 | |
[email protected] | ebb179b | 2014-07-16 17:54:41 | [diff] [blame] | 229 | target_tree->RegisterSelection(selection_start_, selection_end_); |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 230 | |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 231 | // This should match the property synchronization in |
| 232 | // LayerTreeHost::finishCommitOnImplThread(). |
| 233 | target_tree->set_source_frame_number(source_frame_number()); |
| 234 | target_tree->set_background_color(background_color()); |
| 235 | target_tree->set_has_transparent_background(has_transparent_background()); |
| 236 | |
| 237 | if (ContentsTexturesPurged()) |
| 238 | target_tree->SetContentsTexturesPurged(); |
| 239 | else |
| 240 | target_tree->ResetContentsTexturesPurged(); |
| 241 | |
[email protected] | 31882285 | 2013-02-14 00:54:27 | [diff] [blame] | 242 | if (ViewportSizeInvalid()) |
| 243 | target_tree->SetViewportSizeInvalid(); |
| 244 | else |
| 245 | target_tree->ResetViewportSizeInvalid(); |
| 246 | |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 247 | if (hud_layer()) |
| 248 | target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( |
[email protected] | 6ba91412 | 2013-03-22 16:26:39 | [diff] [blame] | 249 | LayerTreeHostCommon::FindLayerInSubtree( |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 250 | target_tree->root_layer(), hud_layer()->id()))); |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 251 | else |
| 252 | target_tree->set_hud_layer(NULL); |
[email protected] | 759dc9f | 2014-07-23 19:18:51 | [diff] [blame] | 253 | |
| 254 | target_tree->has_ever_been_drawn_ = false; |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 255 | } |
| 256 | |
[email protected] | fef74fd | 2014-02-27 06:28:17 | [diff] [blame] | 257 | LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { |
| 258 | return inner_viewport_scroll_layer_ |
| 259 | ? inner_viewport_scroll_layer_->scroll_clip_layer() |
| 260 | : NULL; |
[email protected] | ffb2720f | 2013-03-15 19:18:37 | [diff] [blame] | 261 | } |
| 262 | |
bokan | ef97146 | 2014-10-13 22:58:32 | [diff] [blame] | 263 | LayerImpl* LayerTreeImpl::OuterViewportContainerLayer() const { |
| 264 | return outer_viewport_scroll_layer_ |
| 265 | ? outer_viewport_scroll_layer_->scroll_clip_layer() |
| 266 | : NULL; |
| 267 | } |
| 268 | |
[email protected] | ffb2720f | 2013-03-15 19:18:37 | [diff] [blame] | 269 | LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() const { |
[email protected] | 69b50ec | 2013-01-19 04:58:01 | [diff] [blame] | 270 | DCHECK(IsActiveTree()); |
| 271 | return currently_scrolling_layer_; |
| 272 | } |
| 273 | |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 274 | void LayerTreeImpl::SetCurrentlyScrollingLayer(LayerImpl* layer) { |
| 275 | if (currently_scrolling_layer_ == layer) |
| 276 | return; |
| 277 | |
| 278 | if (currently_scrolling_layer_ && |
| 279 | currently_scrolling_layer_->scrollbar_animation_controller()) |
[email protected] | 1dc0616 | 2014-03-26 22:54:45 | [diff] [blame] | 280 | currently_scrolling_layer_->scrollbar_animation_controller() |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 281 | ->DidScrollEnd(); |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 282 | currently_scrolling_layer_ = layer; |
| 283 | if (layer && layer->scrollbar_animation_controller()) |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 284 | layer->scrollbar_animation_controller()->DidScrollBegin(); |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 285 | } |
| 286 | |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 287 | void LayerTreeImpl::ClearCurrentlyScrollingLayer() { |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 288 | SetCurrentlyScrollingLayer(NULL); |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 289 | scrolling_layer_id_from_previous_tree_ = 0; |
| 290 | } |
| 291 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 292 | namespace { |
| 293 | |
| 294 | void ForceScrollbarParameterUpdateAfterScaleChange(LayerImpl* current_layer) { |
| 295 | if (!current_layer) |
| 296 | return; |
| 297 | |
| 298 | while (current_layer) { |
sataya.m | 07f11a8 | 2014-10-07 14:29:18 | [diff] [blame] | 299 | current_layer->ScrollbarParametersDidChange(false); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 300 | current_layer = current_layer->parent(); |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | } // namespace |
| 305 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 306 | float LayerTreeImpl::ClampPageScaleFactorToLimits( |
| 307 | float page_scale_factor) const { |
| 308 | if (min_page_scale_factor_ && page_scale_factor < min_page_scale_factor_) |
| 309 | page_scale_factor = min_page_scale_factor_; |
| 310 | else if (max_page_scale_factor_ && page_scale_factor > max_page_scale_factor_) |
| 311 | page_scale_factor = max_page_scale_factor_; |
| 312 | return page_scale_factor; |
[email protected] | d6021f6a | 2014-06-12 21:15:24 | [diff] [blame] | 313 | } |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 314 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 315 | void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { |
| 316 | DCHECK(IsActiveTree()); |
| 317 | if (page_scale_factor()->SetCurrent( |
| 318 | ClampPageScaleFactorToLimits(active_page_scale))) |
| 319 | DidUpdatePageScale(); |
[email protected] | d6021f6a | 2014-06-12 21:15:24 | [diff] [blame] | 320 | } |
| 321 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 322 | void LayerTreeImpl::PushPageScaleFromMainThread(float page_scale_factor, |
| 323 | float min_page_scale_factor, |
| 324 | float max_page_scale_factor) { |
| 325 | PushPageScaleFactorAndLimits(&page_scale_factor, min_page_scale_factor, |
| 326 | max_page_scale_factor); |
| 327 | } |
| 328 | |
| 329 | void LayerTreeImpl::PushPageScaleFactorAndLimits(const float* page_scale_factor, |
| 330 | float min_page_scale_factor, |
| 331 | float max_page_scale_factor) { |
| 332 | DCHECK(page_scale_factor || IsActiveTree()); |
| 333 | bool changed_page_scale = false; |
| 334 | if (page_scale_factor) { |
| 335 | DCHECK(!IsActiveTree() || !layer_tree_host_impl_->pending_tree()); |
| 336 | changed_page_scale |= |
| 337 | page_scale_factor_->PushFromMainThread(*page_scale_factor); |
| 338 | } |
| 339 | if (IsActiveTree()) |
| 340 | changed_page_scale |= page_scale_factor_->PushPendingToActive(); |
| 341 | changed_page_scale |= |
| 342 | SetPageScaleFactorLimits(min_page_scale_factor, max_page_scale_factor); |
| 343 | |
| 344 | if (changed_page_scale) |
| 345 | DidUpdatePageScale(); |
| 346 | } |
| 347 | |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 348 | void LayerTreeImpl::set_top_controls_shrink_blink_size(bool shrink) { |
| 349 | if (top_controls_shrink_blink_size_ == shrink) |
| 350 | return; |
| 351 | |
| 352 | top_controls_shrink_blink_size_ = shrink; |
| 353 | if (IsActiveTree()) |
| 354 | layer_tree_host_impl_->UpdateViewportContainerSizes(); |
| 355 | } |
| 356 | |
| 357 | void LayerTreeImpl::set_top_controls_height(float top_controls_height) { |
| 358 | if (top_controls_height_ == top_controls_height) |
| 359 | return; |
| 360 | |
| 361 | top_controls_height_ = top_controls_height; |
| 362 | if (IsActiveTree()) |
| 363 | layer_tree_host_impl_->UpdateViewportContainerSizes(); |
| 364 | } |
| 365 | |
| 366 | bool LayerTreeImpl::SetCurrentTopControlsShownRatio(float ratio) { |
| 367 | ratio = std::max(ratio, 0.f); |
| 368 | ratio = std::min(ratio, 1.f); |
| 369 | return top_controls_shown_ratio_->SetCurrent(ratio); |
| 370 | } |
| 371 | |
| 372 | void LayerTreeImpl::PushTopControlsFromMainThread( |
| 373 | float top_controls_shown_ratio) { |
| 374 | PushTopControls(&top_controls_shown_ratio); |
| 375 | } |
| 376 | |
| 377 | void LayerTreeImpl::PushTopControls(const float* top_controls_shown_ratio) { |
| 378 | DCHECK(top_controls_shown_ratio || IsActiveTree()); |
| 379 | |
| 380 | if (top_controls_shown_ratio) { |
| 381 | DCHECK(!IsActiveTree() || !layer_tree_host_impl_->pending_tree()); |
| 382 | top_controls_shown_ratio_->PushFromMainThread(*top_controls_shown_ratio); |
| 383 | } |
| 384 | if (IsActiveTree()) { |
| 385 | if (top_controls_shown_ratio_->PushPendingToActive()) |
| 386 | layer_tree_host_impl_->DidChangeTopControlsPosition(); |
| 387 | } |
| 388 | } |
| 389 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 390 | bool LayerTreeImpl::SetPageScaleFactorLimits(float min_page_scale_factor, |
| 391 | float max_page_scale_factor) { |
| 392 | if (min_page_scale_factor == min_page_scale_factor_ && |
| 393 | max_page_scale_factor == max_page_scale_factor_) |
| 394 | return false; |
[email protected] | 7265e74e | 2014-02-07 23:43:06 | [diff] [blame] | 395 | |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 396 | min_page_scale_factor_ = min_page_scale_factor; |
| 397 | max_page_scale_factor_ = max_page_scale_factor; |
[email protected] | 20d2b74 | 2013-09-26 05:41:34 | [diff] [blame] | 398 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 399 | return true; |
| 400 | } |
[email protected] | d6021f6a | 2014-06-12 21:15:24 | [diff] [blame] | 401 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 402 | void LayerTreeImpl::DidUpdatePageScale() { |
| 403 | if (IsActiveTree()) |
| 404 | page_scale_factor()->SetCurrent( |
| 405 | ClampPageScaleFactorToLimits(current_page_scale_factor())); |
[email protected] | d6021f6a | 2014-06-12 21:15:24 | [diff] [blame] | 406 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 407 | set_needs_update_draw_properties(); |
[email protected] | d6021f6a | 2014-06-12 21:15:24 | [diff] [blame] | 408 | |
[email protected] | 22f200a | 2013-10-09 18:08:29 | [diff] [blame] | 409 | if (root_layer_scroll_offset_delegate_) { |
[email protected] | ec2322e | 2014-05-15 16:32:00 | [diff] [blame] | 410 | root_layer_scroll_offset_delegate_->UpdateRootLayerState( |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 411 | TotalScrollOffset(), TotalMaxScrollOffset(), ScrollableSize(), |
| 412 | current_page_scale_factor(), min_page_scale_factor_, |
[email protected] | d6021f6a | 2014-06-12 21:15:24 | [diff] [blame] | 413 | max_page_scale_factor_); |
[email protected] | 22f200a | 2013-10-09 18:08:29 | [diff] [blame] | 414 | } |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 415 | |
| 416 | ForceScrollbarParameterUpdateAfterScaleChange(page_scale_layer()); |
bokan | c784a6f | 2015-01-28 04:11:50 | [diff] [blame] | 417 | |
| 418 | HideInnerViewportScrollbarsIfNearMinimumScale(); |
| 419 | } |
| 420 | |
| 421 | void LayerTreeImpl::HideInnerViewportScrollbarsIfNearMinimumScale() { |
| 422 | if (!InnerViewportContainerLayer()) |
| 423 | return; |
| 424 | |
| 425 | LayerImpl::ScrollbarSet* scrollbars = |
| 426 | InnerViewportContainerLayer()->scrollbars(); |
| 427 | |
| 428 | if (!scrollbars) |
| 429 | return; |
| 430 | |
| 431 | for (LayerImpl::ScrollbarSet::iterator it = scrollbars->begin(); |
| 432 | it != scrollbars->end(); |
| 433 | ++it) { |
| 434 | ScrollbarLayerImplBase* scrollbar = *it; |
| 435 | float minimum_scale_to_show_at = |
| 436 | min_page_scale_factor() * settings().scrollbar_show_scale_threshold; |
| 437 | scrollbar->SetHideLayerAndSubtree( |
| 438 | current_page_scale_factor() < minimum_scale_to_show_at); |
| 439 | } |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 440 | } |
| 441 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 442 | SyncedProperty<ScaleGroup>* LayerTreeImpl::page_scale_factor() { |
| 443 | return page_scale_factor_.get(); |
| 444 | } |
| 445 | |
| 446 | const SyncedProperty<ScaleGroup>* LayerTreeImpl::page_scale_factor() const { |
| 447 | return page_scale_factor_.get(); |
| 448 | } |
| 449 | |
[email protected] | 257abfa8 | 2013-01-29 23:47:24 | [diff] [blame] | 450 | gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const { |
[email protected] | 587941d | 2014-08-22 01:40:01 | [diff] [blame] | 451 | if (!InnerViewportContainerLayer()) |
| 452 | return gfx::SizeF(); |
| 453 | |
bokan | ef97146 | 2014-10-13 22:58:32 | [diff] [blame] | 454 | return gfx::ScaleSize(InnerViewportContainerLayer()->BoundsForScrolling(), |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 455 | 1.0f / current_page_scale_factor()); |
[email protected] | 257abfa8 | 2013-01-29 23:47:24 | [diff] [blame] | 456 | } |
| 457 | |
[email protected] | 3744e27b | 2013-11-06 21:44:08 | [diff] [blame] | 458 | gfx::Rect LayerTreeImpl::RootScrollLayerDeviceViewportBounds() const { |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 459 | LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
| 460 | ? OuterViewportScrollLayer() |
| 461 | : InnerViewportScrollLayer(); |
| 462 | if (!root_scroll_layer || root_scroll_layer->children().empty()) |
[email protected] | 3744e27b | 2013-11-06 21:44:08 | [diff] [blame] | 463 | return gfx::Rect(); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 464 | LayerImpl* layer = root_scroll_layer->children()[0]; |
[email protected] | 8a82269 | 2014-02-12 17:30:55 | [diff] [blame] | 465 | return MathUtil::MapEnclosingClippedRect(layer->screen_space_transform(), |
| 466 | gfx::Rect(layer->content_bounds())); |
[email protected] | 3744e27b | 2013-11-06 21:44:08 | [diff] [blame] | 467 | } |
| 468 | |
[email protected] | 58241dc | 2013-08-20 01:39:25 | [diff] [blame] | 469 | void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() { |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 470 | DCHECK(IsActiveTree()); |
| 471 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 472 | page_scale_factor()->AbortCommit(); |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 473 | top_controls_shown_ratio()->AbortCommit(); |
ccameron | b9aec450 | 2014-12-05 19:31:00 | [diff] [blame] | 474 | elastic_overscroll()->AbortCommit(); |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 475 | |
| 476 | if (!root_layer()) |
| 477 | return; |
| 478 | |
| 479 | LayerTreeHostCommon::CallFunctionForSubtree( |
vmpstr | a73f18d | 2015-03-02 21:04:39 | [diff] [blame] | 480 | root_layer(), [](LayerImpl* layer) { |
| 481 | layer->ApplySentScrollDeltasFromAbortedCommit(); |
| 482 | }); |
[email protected] | 58241dc | 2013-08-20 01:39:25 | [diff] [blame] | 483 | } |
| 484 | |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 485 | void LayerTreeImpl::SetViewportLayersFromIds( |
ccameron | 8230b68b | 2014-11-21 19:25:18 | [diff] [blame] | 486 | int overscroll_elasticity_layer_id, |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 487 | int page_scale_layer_id, |
| 488 | int inner_viewport_scroll_layer_id, |
| 489 | int outer_viewport_scroll_layer_id) { |
ccameron | 8230b68b | 2014-11-21 19:25:18 | [diff] [blame] | 490 | overscroll_elasticity_layer_ = LayerById(overscroll_elasticity_layer_id); |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 491 | page_scale_layer_ = LayerById(page_scale_layer_id); |
| 492 | DCHECK(page_scale_layer_); |
| 493 | |
| 494 | inner_viewport_scroll_layer_ = |
| 495 | LayerById(inner_viewport_scroll_layer_id); |
| 496 | DCHECK(inner_viewport_scroll_layer_); |
| 497 | |
| 498 | outer_viewport_scroll_layer_ = |
| 499 | LayerById(outer_viewport_scroll_layer_id); |
| 500 | DCHECK(outer_viewport_scroll_layer_ || |
| 501 | outer_viewport_scroll_layer_id == Layer::INVALID_ID); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 502 | |
bokan | c784a6f | 2015-01-28 04:11:50 | [diff] [blame] | 503 | HideInnerViewportScrollbarsIfNearMinimumScale(); |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | void LayerTreeImpl::ClearViewportLayers() { |
| 507 | page_scale_layer_ = NULL; |
| 508 | inner_viewport_scroll_layer_ = NULL; |
| 509 | outer_viewport_scroll_layer_ = NULL; |
| 510 | } |
| 511 | |
enne | af5bda3 | 2015-02-19 01:27:36 | [diff] [blame] | 512 | bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) { |
[email protected] | 8f7f29882 | 2014-06-13 00:23:32 | [diff] [blame] | 513 | if (!needs_update_draw_properties_) |
| 514 | return true; |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 515 | |
enne | 0acea6ae | 2015-02-19 20:01:51 | [diff] [blame] | 516 | // Calling UpdateDrawProperties must clear this flag, so there can be no |
| 517 | // early outs before this. |
| 518 | needs_update_draw_properties_ = false; |
| 519 | |
| 520 | // For max_texture_size. When the renderer is re-created in |
| 521 | // CreateAndSetRenderer, the needs update draw properties flag is set |
| 522 | // again. |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 523 | if (!layer_tree_host_impl_->renderer()) |
[email protected] | 8f7f29882 | 2014-06-13 00:23:32 | [diff] [blame] | 524 | return false; |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 525 | |
enne | 0acea6ae | 2015-02-19 20:01:51 | [diff] [blame] | 526 | // Clear this after the renderer early out, as it should still be |
| 527 | // possible to hit test even without a renderer. |
| 528 | render_surface_layer_list_.clear(); |
| 529 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 530 | if (!root_layer()) |
[email protected] | 8f7f29882 | 2014-06-13 00:23:32 | [diff] [blame] | 531 | return false; |
| 532 | |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 533 | { |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 534 | TRACE_EVENT2( |
| 535 | "cc", "LayerTreeImpl::UpdateDrawProperties::CalculateDrawProperties", |
| 536 | "IsActive", IsActiveTree(), "SourceFrameNumber", source_frame_number_); |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 537 | LayerImpl* page_scale_layer = |
[email protected] | fef74fd | 2014-02-27 06:28:17 | [diff] [blame] | 538 | page_scale_layer_ ? page_scale_layer_ : InnerViewportContainerLayer(); |
hush | 367d7dd | 2014-08-29 23:56:01 | [diff] [blame] | 539 | bool can_render_to_separate_surface = |
| 540 | (layer_tree_host_impl_->GetDrawMode() != |
| 541 | DRAW_MODE_RESOURCELESS_SOFTWARE); |
[email protected] | 390bb1ff | 2014-05-09 17:14:40 | [diff] [blame] | 542 | |
| 543 | ++render_surface_layer_list_id_; |
enne | c301147 | 2015-04-09 01:27:25 | [diff] [blame] | 544 | |
[email protected] | 7aad55f | 2013-07-26 11:25:53 | [diff] [blame] | 545 | LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( |
danakj | 3f76ace | 2014-11-18 16:56:00 | [diff] [blame] | 546 | root_layer(), DrawViewportSize(), |
| 547 | layer_tree_host_impl_->DrawTransform(), device_scale_factor(), |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 548 | current_page_scale_factor(), page_scale_layer, |
ccameron | b9aec450 | 2014-12-05 19:31:00 | [diff] [blame] | 549 | elastic_overscroll()->Current(IsActiveTree()), |
| 550 | overscroll_elasticity_layer_, resource_provider()->max_texture_size(), |
| 551 | settings().can_use_lcd_text, settings().layers_always_allowed_lcd_text, |
[email protected] | 4594871 | 2013-09-27 02:46:48 | [diff] [blame] | 552 | can_render_to_separate_surface, |
[email protected] | 35a99a1 | 2013-05-09 23:52:29 | [diff] [blame] | 553 | settings().layer_transforms_should_scale_layer_contents, |
enne | c301147 | 2015-04-09 01:27:25 | [diff] [blame] | 554 | settings().verify_property_trees, &render_surface_layer_list_, |
enne | e95b154 | 2015-04-20 20:35:50 | [diff] [blame^] | 555 | render_surface_layer_list_id_, &property_trees_); |
[email protected] | 7aad55f | 2013-07-26 11:25:53 | [diff] [blame] | 556 | LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 557 | } |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 558 | |
[email protected] | e4be026 | 2013-10-19 16:54:28 | [diff] [blame] | 559 | { |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 560 | TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", |
| 561 | "IsActive", IsActiveTree(), "SourceFrameNumber", |
| 562 | source_frame_number_); |
| 563 | OcclusionTracker<LayerImpl> occlusion_tracker( |
| 564 | root_layer()->render_surface()->content_rect()); |
| 565 | occlusion_tracker.set_minimum_tracking_size( |
| 566 | settings().minimum_occlusion_tracking_size); |
boliu | 7473f7f5 | 2014-10-01 16:54:56 | [diff] [blame] | 567 | |
[email protected] | e4be026 | 2013-10-19 16:54:28 | [diff] [blame] | 568 | // LayerIterator is used here instead of CallFunctionForSubtree to only |
| 569 | // UpdateTilePriorities on layers that will be visible (and thus have valid |
| 570 | // draw properties) and not because any ordering is required. |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 571 | auto end = LayerIterator<LayerImpl>::End(&render_surface_layer_list_); |
| 572 | for (auto it = LayerIterator<LayerImpl>::Begin(&render_surface_layer_list_); |
| 573 | it != end; ++it) { |
| 574 | occlusion_tracker.EnterLayer(it); |
[email protected] | 562b7ad | 2014-06-23 22:17:11 | [diff] [blame] | 575 | |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 576 | // There are very few render targets so this should be cheap to do for |
| 577 | // each layer instead of something more complicated. |
| 578 | bool inside_replica = false; |
| 579 | LayerImpl* layer = it->render_target(); |
| 580 | while (layer && !inside_replica) { |
| 581 | if (layer->render_target()->has_replica()) |
| 582 | inside_replica = true; |
| 583 | layer = layer->render_target()->parent(); |
| 584 | } |
| 585 | |
| 586 | // Don't use occlusion if a layer will appear in a replica, since the |
| 587 | // tile raster code does not know how to look for the replica and would |
| 588 | // consider it occluded even though the replica is visible. |
| 589 | // Since occlusion is only used for browser compositor (i.e. |
| 590 | // use_occlusion_for_tile_prioritization) and it won't use replicas, |
| 591 | // this should matter not. |
vmpstr | cdcb5f7 | 2014-09-11 00:58:37 | [diff] [blame] | 592 | |
boliu | 7473f7f5 | 2014-10-01 16:54:56 | [diff] [blame] | 593 | if (it.represents_itself()) { |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 594 | Occlusion occlusion = |
| 595 | inside_replica ? Occlusion() |
| 596 | : occlusion_tracker.GetCurrentOcclusionForLayer( |
| 597 | it->draw_transform()); |
| 598 | it->draw_properties().occlusion_in_content_space = occlusion; |
boliu | 7473f7f5 | 2014-10-01 16:54:56 | [diff] [blame] | 599 | } |
[email protected] | e4be026 | 2013-10-19 16:54:28 | [diff] [blame] | 600 | |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 601 | if (it.represents_contributing_render_surface()) { |
| 602 | // Surfaces aren't used by the tile raster code, so they can have |
| 603 | // occlusion regardless of replicas. |
| 604 | Occlusion occlusion = |
| 605 | occlusion_tracker.GetCurrentOcclusionForContributingSurface( |
| 606 | it->render_surface()->draw_transform()); |
| 607 | it->render_surface()->set_occlusion_in_content_space(occlusion); |
| 608 | // Masks are used to draw the contributing surface, so should have |
| 609 | // the same occlusion as the surface (nothing inside the surface |
| 610 | // occludes them). |
| 611 | if (LayerImpl* mask = it->mask_layer()) { |
| 612 | Occlusion mask_occlusion = |
| 613 | inside_replica |
| 614 | ? Occlusion() |
| 615 | : occlusion_tracker.GetCurrentOcclusionForContributingSurface( |
| 616 | it->render_surface()->draw_transform() * |
| 617 | it->draw_transform()); |
| 618 | mask->draw_properties().occlusion_in_content_space = mask_occlusion; |
| 619 | } |
| 620 | if (LayerImpl* replica = it->replica_layer()) { |
| 621 | if (LayerImpl* mask = replica->mask_layer()) |
| 622 | mask->draw_properties().occlusion_in_content_space = Occlusion(); |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | occlusion_tracker.LeaveLayer(it); |
| 627 | } |
| 628 | |
| 629 | unoccluded_screen_space_region_ = |
| 630 | occlusion_tracker.ComputeVisibleRegionInScreen(); |
| 631 | } |
| 632 | |
enne | af5bda3 | 2015-02-19 01:27:36 | [diff] [blame] | 633 | // It'd be ideal if this could be done earlier, but when the raster source |
| 634 | // is updated from the main thread during push properties, update draw |
| 635 | // properties has not occurred yet and so it's not clear whether or not the |
| 636 | // layer can or cannot use lcd text. So, this is the cleanup pass to |
| 637 | // determine if the raster source needs to be replaced with a non-lcd |
| 638 | // raster source due to draw properties. |
| 639 | if (update_lcd_text) { |
| 640 | // TODO(enne): Make LTHI::sync_tree return this value. |
| 641 | LayerTreeImpl* sync_tree = |
| 642 | layer_tree_host_impl_->proxy()->CommitToActiveTree() |
| 643 | ? layer_tree_host_impl_->active_tree() |
| 644 | : layer_tree_host_impl_->pending_tree(); |
| 645 | // If this is not the sync tree, then it is not safe to update lcd text |
| 646 | // as it causes invalidations and the tiles may be in use. |
| 647 | DCHECK_EQ(this, sync_tree); |
| 648 | for (const auto& layer : picture_layers_) |
| 649 | layer->UpdateCanUseLCDTextAfterCommit(); |
| 650 | } |
| 651 | |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 652 | { |
| 653 | TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateDrawProperties::UpdateTiles", |
| 654 | "IsActive", IsActiveTree(), "SourceFrameNumber", |
| 655 | source_frame_number_); |
| 656 | const bool resourceless_software_draw = |
| 657 | (layer_tree_host_impl_->GetDrawMode() == |
| 658 | DRAW_MODE_RESOURCELESS_SOFTWARE); |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 659 | size_t layers_updated_count = 0; |
| 660 | bool tile_priorities_updated = false; |
| 661 | for (PictureLayerImpl* layer : picture_layers_) { |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 662 | if (!layer->IsDrawnRenderSurfaceLayerListMember()) |
[email protected] | 6355d2d | 2014-05-07 15:07:27 | [diff] [blame] | 663 | continue; |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 664 | ++layers_updated_count; |
danakj | 83c3d4a8 | 2015-02-14 01:42:57 | [diff] [blame] | 665 | tile_priorities_updated |= layer->UpdateTiles(resourceless_software_draw); |
[email protected] | e4be026 | 2013-10-19 16:54:28 | [diff] [blame] | 666 | } |
vmpstr | d616620 | 2014-11-05 18:45:40 | [diff] [blame] | 667 | |
vmpstr | 5377520a | 2014-12-29 23:26:13 | [diff] [blame] | 668 | if (tile_priorities_updated) |
| 669 | DidModifyTilePriorities(); |
| 670 | |
vmpstr | d616620 | 2014-11-05 18:45:40 | [diff] [blame] | 671 | TRACE_EVENT_END1("cc", "LayerTreeImpl::UpdateTilePriorities", |
| 672 | "layers_updated_count", layers_updated_count); |
[email protected] | e4be026 | 2013-10-19 16:54:28 | [diff] [blame] | 673 | } |
| 674 | |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 675 | DCHECK(!needs_update_draw_properties_) << |
[email protected] | 7d19dc34 | 2013-05-02 22:02:04 | [diff] [blame] | 676 | "CalcDrawProperties should not set_needs_update_draw_properties()"; |
[email protected] | 8f7f29882 | 2014-06-13 00:23:32 | [diff] [blame] | 677 | return true; |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 678 | } |
| 679 | |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 680 | const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const { |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 681 | // If this assert triggers, then the list is dirty. |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 682 | DCHECK(!needs_update_draw_properties_); |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 683 | return render_surface_layer_list_; |
| 684 | } |
| 685 | |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 686 | const Region& LayerTreeImpl::UnoccludedScreenSpaceRegion() const { |
| 687 | // If this assert triggers, then the render_surface_layer_list_ is dirty, so |
| 688 | // the unoccluded_screen_space_region_ is not valid anymore. |
| 689 | DCHECK(!needs_update_draw_properties_); |
| 690 | return unoccluded_screen_space_region_; |
| 691 | } |
| 692 | |
bokan | cccfde7 | 2014-10-08 15:15:22 | [diff] [blame] | 693 | gfx::Size LayerTreeImpl::ScrollableSize() const { |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 694 | LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
| 695 | ? OuterViewportScrollLayer() |
| 696 | : InnerViewportScrollLayer(); |
| 697 | if (!root_scroll_layer || root_scroll_layer->children().empty()) |
bokan | cccfde7 | 2014-10-08 15:15:22 | [diff] [blame] | 698 | return gfx::Size(); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 699 | return root_scroll_layer->children()[0]->bounds(); |
[email protected] | caa567d | 2012-12-20 07:56:16 | [diff] [blame] | 700 | } |
| 701 | |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 702 | LayerImpl* LayerTreeImpl::LayerById(int id) { |
| 703 | LayerIdMap::iterator iter = layer_id_map_.find(id); |
| 704 | return iter != layer_id_map_.end() ? iter->second : NULL; |
| 705 | } |
| 706 | |
| 707 | void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { |
| 708 | DCHECK(!LayerById(layer->id())); |
| 709 | layer_id_map_[layer->id()] = layer; |
| 710 | } |
| 711 | |
| 712 | void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
| 713 | DCHECK(LayerById(layer->id())); |
| 714 | layer_id_map_.erase(layer->id()); |
| 715 | } |
| 716 | |
[email protected] | aebf462 | 2014-07-14 16:57:59 | [diff] [blame] | 717 | size_t LayerTreeImpl::NumLayers() { |
| 718 | return layer_id_map_.size(); |
| 719 | } |
| 720 | |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 721 | void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) { |
[email protected] | a90fac7 | 2013-06-06 18:56:13 | [diff] [blame] | 722 | pending_tree->SetCurrentlyScrollingLayer( |
| 723 | LayerTreeHostCommon::FindLayerInSubtree(pending_tree->root_layer(), |
| 724 | currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0)); |
[email protected] | 1e0f8d6 | 2013-01-09 07:41:35 | [diff] [blame] | 725 | } |
| 726 | |
[email protected] | 37386f05 | 2013-01-13 00:42:22 | [diff] [blame] | 727 | void LayerTreeImpl::DidBecomeActive() { |
[email protected] | 12a63da | 2014-06-13 06:06:22 | [diff] [blame] | 728 | if (next_activation_forces_redraw_) { |
| 729 | layer_tree_host_impl_->SetFullRootLayerDamage(); |
| 730 | next_activation_forces_redraw_ = false; |
| 731 | } |
| 732 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 733 | if (scrolling_layer_id_from_previous_tree_) { |
| 734 | currently_scrolling_layer_ = LayerTreeHostCommon::FindLayerInSubtree( |
[email protected] | 7dcf563 | 2014-06-25 01:11:55 | [diff] [blame] | 735 | root_layer(), scrolling_layer_id_from_previous_tree_); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 736 | } |
| 737 | |
[email protected] | 7dcf563 | 2014-06-25 01:11:55 | [diff] [blame] | 738 | // Always reset this flag on activation, as we would only have activated |
| 739 | // if we were in a good state. |
vmpstr | 61ed94a1 | 2014-10-09 04:49:30 | [diff] [blame] | 740 | layer_tree_host_impl_->ResetRequiresHighResToDraw(); |
[email protected] | 7dcf563 | 2014-06-25 01:11:55 | [diff] [blame] | 741 | |
vmpstr | a73f18d | 2015-03-02 21:04:39 | [diff] [blame] | 742 | if (root_layer()) { |
| 743 | LayerTreeHostCommon::CallFunctionForSubtree( |
| 744 | root_layer(), [](LayerImpl* layer) { layer->DidBecomeActive(); }); |
| 745 | } |
[email protected] | 7dcf563 | 2014-06-25 01:11:55 | [diff] [blame] | 746 | |
[email protected] | 12a63da | 2014-06-13 06:06:22 | [diff] [blame] | 747 | devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), |
| 748 | source_frame_number_); |
[email protected] | 37386f05 | 2013-01-13 00:42:22 | [diff] [blame] | 749 | } |
| 750 | |
[email protected] | 6f90b9e | 2013-01-17 23:42:00 | [diff] [blame] | 751 | bool LayerTreeImpl::ContentsTexturesPurged() const { |
| 752 | return contents_textures_purged_; |
| 753 | } |
| 754 | |
| 755 | void LayerTreeImpl::SetContentsTexturesPurged() { |
[email protected] | 94bf75c | 2013-06-12 13:20:04 | [diff] [blame] | 756 | if (contents_textures_purged_) |
| 757 | return; |
[email protected] | 6f90b9e | 2013-01-17 23:42:00 | [diff] [blame] | 758 | contents_textures_purged_ = true; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 759 | layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
[email protected] | 6f90b9e | 2013-01-17 23:42:00 | [diff] [blame] | 760 | } |
| 761 | |
| 762 | void LayerTreeImpl::ResetContentsTexturesPurged() { |
[email protected] | 94bf75c | 2013-06-12 13:20:04 | [diff] [blame] | 763 | if (!contents_textures_purged_) |
| 764 | return; |
[email protected] | 6f90b9e | 2013-01-17 23:42:00 | [diff] [blame] | 765 | contents_textures_purged_ = false; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 766 | layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
[email protected] | 6f90b9e | 2013-01-17 23:42:00 | [diff] [blame] | 767 | } |
| 768 | |
[email protected] | 3d609bb | 2014-02-01 01:10:23 | [diff] [blame] | 769 | bool LayerTreeImpl::RequiresHighResToDraw() const { |
vmpstr | 61ed94a1 | 2014-10-09 04:49:30 | [diff] [blame] | 770 | return layer_tree_host_impl_->RequiresHighResToDraw(); |
[email protected] | 3d609bb | 2014-02-01 01:10:23 | [diff] [blame] | 771 | } |
| 772 | |
[email protected] | 31882285 | 2013-02-14 00:54:27 | [diff] [blame] | 773 | bool LayerTreeImpl::ViewportSizeInvalid() const { |
| 774 | return viewport_size_invalid_; |
| 775 | } |
| 776 | |
| 777 | void LayerTreeImpl::SetViewportSizeInvalid() { |
| 778 | viewport_size_invalid_ = true; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 779 | layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
[email protected] | 31882285 | 2013-02-14 00:54:27 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | void LayerTreeImpl::ResetViewportSizeInvalid() { |
| 783 | viewport_size_invalid_ = false; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 784 | layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
[email protected] | 31882285 | 2013-02-14 00:54:27 | [diff] [blame] | 785 | } |
| 786 | |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 787 | Proxy* LayerTreeImpl::proxy() const { |
| 788 | return layer_tree_host_impl_->proxy(); |
| 789 | } |
| 790 | |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 791 | const LayerTreeSettings& LayerTreeImpl::settings() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 792 | return layer_tree_host_impl_->settings(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 793 | } |
| 794 | |
danakj | 875efa4 | 2015-02-10 22:18:23 | [diff] [blame] | 795 | const LayerTreeDebugState& LayerTreeImpl::debug_state() const { |
| 796 | return layer_tree_host_impl_->debug_state(); |
| 797 | } |
| 798 | |
[email protected] | 7a8bcd26 | 2014-01-15 12:54:58 | [diff] [blame] | 799 | const RendererCapabilitiesImpl& LayerTreeImpl::GetRendererCapabilities() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 800 | return layer_tree_host_impl_->GetRendererCapabilities(); |
[email protected] | bf5b3a0 | 2013-02-13 02:02:52 | [diff] [blame] | 801 | } |
| 802 | |
[email protected] | 0634cdd4 | 2013-08-16 00:46:09 | [diff] [blame] | 803 | ContextProvider* LayerTreeImpl::context_provider() const { |
dcheng | 6afa1700 | 2014-08-26 19:11:31 | [diff] [blame] | 804 | return output_surface()->context_provider(); |
[email protected] | 0634cdd4 | 2013-08-16 00:46:09 | [diff] [blame] | 805 | } |
| 806 | |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 807 | OutputSurface* LayerTreeImpl::output_surface() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 808 | return layer_tree_host_impl_->output_surface(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | ResourceProvider* LayerTreeImpl::resource_provider() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 812 | return layer_tree_host_impl_->resource_provider(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | TileManager* LayerTreeImpl::tile_manager() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 816 | return layer_tree_host_impl_->tile_manager(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | FrameRateCounter* LayerTreeImpl::frame_rate_counter() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 820 | return layer_tree_host_impl_->fps_counter(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 821 | } |
| 822 | |
[email protected] | 71691c2 | 2013-01-18 03:14:22 | [diff] [blame] | 823 | PaintTimeCounter* LayerTreeImpl::paint_time_counter() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 824 | return layer_tree_host_impl_->paint_time_counter(); |
[email protected] | 71691c2 | 2013-01-18 03:14:22 | [diff] [blame] | 825 | } |
| 826 | |
[email protected] | 1191d9d | 2013-02-02 06:00:33 | [diff] [blame] | 827 | MemoryHistory* LayerTreeImpl::memory_history() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 828 | return layer_tree_host_impl_->memory_history(); |
[email protected] | 1191d9d | 2013-02-02 06:00:33 | [diff] [blame] | 829 | } |
| 830 | |
[email protected] | 4a6c091d | 2014-04-24 21:06:46 | [diff] [blame] | 831 | gfx::Size LayerTreeImpl::device_viewport_size() const { |
| 832 | return layer_tree_host_impl_->device_viewport_size(); |
| 833 | } |
| 834 | |
danakj | 875efa4 | 2015-02-10 22:18:23 | [diff] [blame] | 835 | float LayerTreeImpl::device_scale_factor() const { |
| 836 | return layer_tree_host_impl_->device_scale_factor(); |
| 837 | } |
| 838 | |
| 839 | DebugRectHistory* LayerTreeImpl::debug_rect_history() const { |
| 840 | return layer_tree_host_impl_->debug_rect_history(); |
| 841 | } |
| 842 | |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 843 | bool LayerTreeImpl::IsActiveTree() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 844 | return layer_tree_host_impl_->active_tree() == this; |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | bool LayerTreeImpl::IsPendingTree() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 848 | return layer_tree_host_impl_->pending_tree() == this; |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 849 | } |
| 850 | |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 851 | bool LayerTreeImpl::IsRecycleTree() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 852 | return layer_tree_host_impl_->recycle_tree() == this; |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 853 | } |
| 854 | |
enne | af5bda3 | 2015-02-19 01:27:36 | [diff] [blame] | 855 | bool LayerTreeImpl::IsSyncTree() const { |
| 856 | return layer_tree_host_impl_->sync_tree() == this; |
| 857 | } |
| 858 | |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 859 | LayerImpl* LayerTreeImpl::FindActiveTreeLayerById(int id) { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 860 | LayerTreeImpl* tree = layer_tree_host_impl_->active_tree(); |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 861 | if (!tree) |
| 862 | return NULL; |
| 863 | return tree->LayerById(id); |
| 864 | } |
| 865 | |
| 866 | LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 867 | LayerTreeImpl* tree = layer_tree_host_impl_->pending_tree(); |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 868 | if (!tree) |
| 869 | return NULL; |
| 870 | return tree->LayerById(id); |
| 871 | } |
| 872 | |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 873 | bool LayerTreeImpl::PinchGestureActive() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 874 | return layer_tree_host_impl_->pinch_gesture_active(); |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 875 | } |
| 876 | |
[email protected] | 04c5900d | 2014-08-18 13:38:36 | [diff] [blame] | 877 | BeginFrameArgs LayerTreeImpl::CurrentBeginFrameArgs() const { |
| 878 | return layer_tree_host_impl_->CurrentBeginFrameArgs(); |
[email protected] | fb7425a | 2013-04-22 16:28:55 | [diff] [blame] | 879 | } |
| 880 | |
[email protected] | c92195e | 2014-05-07 18:18:49 | [diff] [blame] | 881 | base::TimeDelta LayerTreeImpl::begin_impl_frame_interval() const { |
| 882 | return layer_tree_host_impl_->begin_impl_frame_interval(); |
| 883 | } |
| 884 | |
[email protected] | d7eb8c7 | 2013-03-23 22:57:13 | [diff] [blame] | 885 | void LayerTreeImpl::SetNeedsCommit() { |
| 886 | layer_tree_host_impl_->SetNeedsCommit(); |
| 887 | } |
| 888 | |
[email protected] | bd532459 | 2014-07-31 09:09:33 | [diff] [blame] | 889 | gfx::Rect LayerTreeImpl::DeviceViewport() const { |
| 890 | return layer_tree_host_impl_->DeviceViewport(); |
| 891 | } |
| 892 | |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 893 | gfx::Size LayerTreeImpl::DrawViewportSize() const { |
| 894 | return layer_tree_host_impl_->DrawViewportSize(); |
| 895 | } |
| 896 | |
[email protected] | bd532459 | 2014-07-31 09:09:33 | [diff] [blame] | 897 | const gfx::Rect LayerTreeImpl::ViewportRectForTilePriority() const { |
| 898 | return layer_tree_host_impl_->ViewportRectForTilePriority(); |
| 899 | } |
| 900 | |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 901 | scoped_ptr<ScrollbarAnimationController> |
| 902 | LayerTreeImpl::CreateScrollbarAnimationController(LayerImpl* scrolling_layer) { |
| 903 | DCHECK(settings().scrollbar_fade_delay_ms); |
| 904 | DCHECK(settings().scrollbar_fade_duration_ms); |
| 905 | base::TimeDelta delay = |
| 906 | base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_delay_ms); |
sataya.m | 07f11a8 | 2014-10-07 14:29:18 | [diff] [blame] | 907 | base::TimeDelta resize_delay = base::TimeDelta::FromMilliseconds( |
| 908 | settings().scrollbar_fade_resize_delay_ms); |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 909 | base::TimeDelta duration = |
| 910 | base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_duration_ms); |
| 911 | switch (settings().scrollbar_animator) { |
ericrk | 7c03099 | 2015-02-20 01:39:38 | [diff] [blame] | 912 | case LayerTreeSettings::LINEAR_FADE: { |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 913 | return ScrollbarAnimationControllerLinearFade::Create( |
sataya.m | 07f11a8 | 2014-10-07 14:29:18 | [diff] [blame] | 914 | scrolling_layer, |
| 915 | layer_tree_host_impl_, |
| 916 | delay, |
| 917 | resize_delay, |
| 918 | duration); |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 919 | } |
ericrk | 7c03099 | 2015-02-20 01:39:38 | [diff] [blame] | 920 | case LayerTreeSettings::THINNING: { |
sataya.m | 07f11a8 | 2014-10-07 14:29:18 | [diff] [blame] | 921 | return ScrollbarAnimationControllerThinning::Create(scrolling_layer, |
| 922 | layer_tree_host_impl_, |
| 923 | delay, |
| 924 | resize_delay, |
| 925 | duration); |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 926 | } |
ericrk | 7c03099 | 2015-02-20 01:39:38 | [diff] [blame] | 927 | case LayerTreeSettings::NO_ANIMATOR: |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 928 | NOTREACHED(); |
| 929 | break; |
| 930 | } |
danakj | f446a07 | 2014-09-27 21:55:48 | [diff] [blame] | 931 | return nullptr; |
[email protected] | 2ea5aba | 2013-09-11 14:26:56 | [diff] [blame] | 932 | } |
| 933 | |
[email protected] | b8384e2 | 2013-12-03 02:20:48 | [diff] [blame] | 934 | void LayerTreeImpl::DidAnimateScrollOffset() { |
| 935 | layer_tree_host_impl_->DidAnimateScrollOffset(); |
| 936 | } |
| 937 | |
[email protected] | 13525d6 | 2014-05-20 21:22:04 | [diff] [blame] | 938 | bool LayerTreeImpl::use_gpu_rasterization() const { |
| 939 | return layer_tree_host_impl_->use_gpu_rasterization(); |
| 940 | } |
| 941 | |
hendrikw | c2bbd61 | 2014-12-03 23:49:34 | [diff] [blame] | 942 | GpuRasterizationStatus LayerTreeImpl::GetGpuRasterizationStatus() const { |
| 943 | return layer_tree_host_impl_->gpu_rasterization_status(); |
| 944 | } |
| 945 | |
[email protected] | 473f1f2 | 2014-05-22 08:19:17 | [diff] [blame] | 946 | bool LayerTreeImpl::create_low_res_tiling() const { |
| 947 | return layer_tree_host_impl_->create_low_res_tiling(); |
| 948 | } |
| 949 | |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 950 | void LayerTreeImpl::SetNeedsRedraw() { |
[email protected] | 59adb11 | 2013-04-09 04:48:44 | [diff] [blame] | 951 | layer_tree_host_impl_->SetNeedsRedraw(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 952 | } |
| 953 | |
sunnyps | ea328be1 | 2015-02-26 06:03:27 | [diff] [blame] | 954 | AnimationRegistrar* LayerTreeImpl::GetAnimationRegistrar() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 955 | return layer_tree_host_impl_->animation_registrar(); |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 956 | } |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 957 | |
vmpstr | dcf21da | 2015-03-23 19:16:32 | [diff] [blame] | 958 | void LayerTreeImpl::GetAllTilesAndPrioritiesForTracing( |
| 959 | std::map<const Tile*, TilePriority>* tile_map) const { |
vmpstr | d7de03c | 2014-08-27 18:11:01 | [diff] [blame] | 960 | typedef LayerIterator<LayerImpl> LayerIteratorType; |
| 961 | LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); |
| 962 | for (LayerIteratorType it = |
| 963 | LayerIteratorType::Begin(&render_surface_layer_list_); |
| 964 | it != end; |
| 965 | ++it) { |
| 966 | if (!it.represents_itself()) |
| 967 | continue; |
| 968 | LayerImpl* layer_impl = *it; |
vmpstr | dcf21da | 2015-03-23 19:16:32 | [diff] [blame] | 969 | layer_impl->GetAllTilesAndPrioritiesForTracing(tile_map); |
vmpstr | d7de03c | 2014-08-27 18:11:01 | [diff] [blame] | 970 | } |
| 971 | } |
| 972 | |
ssid | 911e40e | 2015-02-09 17:55:20 | [diff] [blame] | 973 | void LayerTreeImpl::AsValueInto(base::trace_event::TracedValue* state) const { |
[email protected] | d12aa93 | 2014-08-01 13:10:38 | [diff] [blame] | 974 | TracedValue::MakeDictIntoImplicitSnapshot(state, "cc::LayerTreeImpl", this); |
nduca | 929378a0 | 2014-08-23 19:48:52 | [diff] [blame] | 975 | state->SetInteger("source_frame_number", source_frame_number_); |
[email protected] | f6742f5 | 2013-05-08 23:52:22 | [diff] [blame] | 976 | |
[email protected] | d12aa93 | 2014-08-01 13:10:38 | [diff] [blame] | 977 | state->BeginDictionary("root_layer"); |
| 978 | root_layer_->AsValueInto(state); |
| 979 | state->EndDictionary(); |
[email protected] | f6742f5 | 2013-05-08 23:52:22 | [diff] [blame] | 980 | |
[email protected] | d12aa93 | 2014-08-01 13:10:38 | [diff] [blame] | 981 | state->BeginArray("render_surface_layer_list"); |
[email protected] | ba1b33e | 2014-02-28 16:44:51 | [diff] [blame] | 982 | typedef LayerIterator<LayerImpl> LayerIteratorType; |
[email protected] | 71dfcc7 | 2013-03-20 21:30:09 | [diff] [blame] | 983 | LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); |
| 984 | for (LayerIteratorType it = LayerIteratorType::Begin( |
[email protected] | 8c569022 | 2013-02-15 17:36:43 | [diff] [blame] | 985 | &render_surface_layer_list_); it != end; ++it) { |
[email protected] | 71dfcc7 | 2013-03-20 21:30:09 | [diff] [blame] | 986 | if (!it.represents_itself()) |
[email protected] | 8c569022 | 2013-02-15 17:36:43 | [diff] [blame] | 987 | continue; |
[email protected] | d12aa93 | 2014-08-01 13:10:38 | [diff] [blame] | 988 | TracedValue::AppendIDRef(*it, state); |
[email protected] | 8c569022 | 2013-02-15 17:36:43 | [diff] [blame] | 989 | } |
[email protected] | d12aa93 | 2014-08-01 13:10:38 | [diff] [blame] | 990 | state->EndArray(); |
skyostil | 43c330f7 | 2014-09-22 16:49:11 | [diff] [blame] | 991 | |
| 992 | state->BeginArray("swap_promise_trace_ids"); |
| 993 | for (size_t i = 0; i < swap_promise_list_.size(); i++) |
| 994 | state->AppendDouble(swap_promise_list_[i]->TraceId()); |
| 995 | state->EndArray(); |
[email protected] | 8c569022 | 2013-02-15 17:36:43 | [diff] [blame] | 996 | } |
| 997 | |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 998 | void LayerTreeImpl::SetRootLayerScrollOffsetDelegate( |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 999 | LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) { |
[email protected] | 20d2b74 | 2013-09-26 05:41:34 | [diff] [blame] | 1000 | if (root_layer_scroll_offset_delegate_ == root_layer_scroll_offset_delegate) |
| 1001 | return; |
| 1002 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1003 | root_layer_scroll_offset_delegate_ = root_layer_scroll_offset_delegate; |
| 1004 | |
[email protected] | 20d2b74 | 2013-09-26 05:41:34 | [diff] [blame] | 1005 | if (root_layer_scroll_offset_delegate_) { |
[email protected] | ec2322e | 2014-05-15 16:32:00 | [diff] [blame] | 1006 | root_layer_scroll_offset_delegate_->UpdateRootLayerState( |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 1007 | TotalScrollOffset(), TotalMaxScrollOffset(), ScrollableSize(), |
| 1008 | current_page_scale_factor(), min_page_scale_factor(), |
[email protected] | 68fe60f | 2014-02-12 13:49:11 | [diff] [blame] | 1009 | max_page_scale_factor()); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1010 | |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 1011 | DistributeRootScrollOffset(); |
[email protected] | 20d2b74 | 2013-09-26 05:41:34 | [diff] [blame] | 1012 | } |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 1013 | } |
| 1014 | |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 1015 | void LayerTreeImpl::UpdateRootScrollOffsetDelegate() { |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1016 | DCHECK(root_layer_scroll_offset_delegate_); |
| 1017 | |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 1018 | gfx::ScrollOffset offset = InnerViewportScrollLayer()->CurrentScrollOffset(); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1019 | |
| 1020 | if (OuterViewportScrollLayer()) |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 1021 | offset += OuterViewportScrollLayer()->CurrentScrollOffset(); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1022 | |
[email protected] | ec2322e | 2014-05-15 16:32:00 | [diff] [blame] | 1023 | root_layer_scroll_offset_delegate_->UpdateRootLayerState( |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 1024 | offset, TotalMaxScrollOffset(), ScrollableSize(), |
| 1025 | current_page_scale_factor(), min_page_scale_factor(), |
[email protected] | ec2322e | 2014-05-15 16:32:00 | [diff] [blame] | 1026 | max_page_scale_factor()); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1027 | } |
| 1028 | |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 1029 | void LayerTreeImpl::DistributeRootScrollOffset() { |
| 1030 | if (!root_layer_scroll_offset_delegate_) |
| 1031 | return; |
| 1032 | |
| 1033 | gfx::ScrollOffset root_offset = |
| 1034 | root_layer_scroll_offset_delegate_->GetTotalScrollOffset(); |
| 1035 | |
| 1036 | if (!InnerViewportScrollLayer()) |
| 1037 | return; |
| 1038 | |
| 1039 | DCHECK(OuterViewportScrollLayer()); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1040 | |
| 1041 | // If we get here, we have both inner/outer viewports, and need to distribute |
| 1042 | // the scroll offset between them. |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 1043 | gfx::ScrollOffset inner_viewport_offset = |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 1044 | InnerViewportScrollLayer()->CurrentScrollOffset(); |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 1045 | gfx::ScrollOffset outer_viewport_offset = |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 1046 | OuterViewportScrollLayer()->CurrentScrollOffset(); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1047 | |
| 1048 | // It may be nothing has changed. |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 1049 | if (inner_viewport_offset + outer_viewport_offset == root_offset) |
| 1050 | return; |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1051 | |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 1052 | gfx::ScrollOffset max_outer_viewport_scroll_offset = |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1053 | OuterViewportScrollLayer()->MaxScrollOffset(); |
| 1054 | |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 1055 | outer_viewport_offset = root_offset - inner_viewport_offset; |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1056 | outer_viewport_offset.SetToMin(max_outer_viewport_scroll_offset); |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 1057 | outer_viewport_offset.SetToMax(gfx::ScrollOffset()); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1058 | |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 1059 | OuterViewportScrollLayer()->SetCurrentScrollOffsetFromDelegate( |
| 1060 | outer_viewport_offset); |
| 1061 | inner_viewport_offset = root_offset - outer_viewport_offset; |
| 1062 | InnerViewportScrollLayer()->SetCurrentScrollOffsetFromDelegate( |
| 1063 | inner_viewport_offset); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1064 | |
hush | 33370e1 | 2015-04-07 03:49:50 | [diff] [blame] | 1065 | UpdateRootScrollOffsetDelegate(); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 1066 | } |
| 1067 | |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 1068 | void LayerTreeImpl::QueueSwapPromise(scoped_ptr<SwapPromise> swap_promise) { |
| 1069 | DCHECK(swap_promise); |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 1070 | swap_promise_list_.push_back(swap_promise.Pass()); |
| 1071 | } |
| 1072 | |
| 1073 | void LayerTreeImpl::PassSwapPromises( |
| 1074 | ScopedPtrVector<SwapPromise>* new_swap_promise) { |
| 1075 | swap_promise_list_.insert_and_take(swap_promise_list_.end(), |
weiliangc | c1878c6 | 2014-09-02 22:43:17 | [diff] [blame] | 1076 | new_swap_promise); |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 1077 | new_swap_promise->clear(); |
| 1078 | } |
| 1079 | |
[email protected] | d359203a | 2013-11-29 06:16:55 | [diff] [blame] | 1080 | void LayerTreeImpl::FinishSwapPromises(CompositorFrameMetadata* metadata) { |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 1081 | for (size_t i = 0; i < swap_promise_list_.size(); i++) |
[email protected] | d359203a | 2013-11-29 06:16:55 | [diff] [blame] | 1082 | swap_promise_list_[i]->DidSwap(metadata); |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 1083 | swap_promise_list_.clear(); |
| 1084 | } |
| 1085 | |
| 1086 | void LayerTreeImpl::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { |
| 1087 | for (size_t i = 0; i < swap_promise_list_.size(); i++) |
| 1088 | swap_promise_list_[i]->DidNotSwap(reason); |
| 1089 | swap_promise_list_.clear(); |
| 1090 | } |
| 1091 | |
[email protected] | c48536a5 | 2013-09-14 00:02:08 | [diff] [blame] | 1092 | void LayerTreeImpl::DidModifyTilePriorities() { |
| 1093 | layer_tree_host_impl_->DidModifyTilePriorities(); |
[email protected] | fcb846d | 2013-05-22 01:42:36 | [diff] [blame] | 1094 | } |
| 1095 | |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1096 | void LayerTreeImpl::set_ui_resource_request_queue( |
| 1097 | const UIResourceRequestQueue& queue) { |
| 1098 | ui_resource_request_queue_ = queue; |
| 1099 | } |
| 1100 | |
| 1101 | ResourceProvider::ResourceId LayerTreeImpl::ResourceIdForUIResource( |
| 1102 | UIResourceId uid) const { |
| 1103 | return layer_tree_host_impl_->ResourceIdForUIResource(uid); |
| 1104 | } |
| 1105 | |
[email protected] | 709c954 | 2013-10-26 01:43:51 | [diff] [blame] | 1106 | bool LayerTreeImpl::IsUIResourceOpaque(UIResourceId uid) const { |
| 1107 | return layer_tree_host_impl_->IsUIResourceOpaque(uid); |
| 1108 | } |
| 1109 | |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1110 | void LayerTreeImpl::ProcessUIResourceRequestQueue() { |
jdduke | 5ad3681 | 2015-01-02 17:59:32 | [diff] [blame] | 1111 | for (const auto& req : ui_resource_request_queue_) { |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 1112 | switch (req.GetType()) { |
ericrk | 7c03099 | 2015-02-20 01:39:38 | [diff] [blame] | 1113 | case UIResourceRequest::UI_RESOURCE_CREATE: |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 1114 | layer_tree_host_impl_->CreateUIResource(req.GetId(), req.GetBitmap()); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1115 | break; |
ericrk | 7c03099 | 2015-02-20 01:39:38 | [diff] [blame] | 1116 | case UIResourceRequest::UI_RESOURCE_DELETE: |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 1117 | layer_tree_host_impl_->DeleteUIResource(req.GetId()); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1118 | break; |
ericrk | 7c03099 | 2015-02-20 01:39:38 | [diff] [blame] | 1119 | case UIResourceRequest::UI_RESOURCE_INVALID_REQUEST: |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1120 | NOTREACHED(); |
| 1121 | break; |
| 1122 | } |
| 1123 | } |
jdduke | 5ad3681 | 2015-01-02 17:59:32 | [diff] [blame] | 1124 | ui_resource_request_queue_.clear(); |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 1125 | |
| 1126 | // If all UI resource evictions were not recreated by processing this queue, |
| 1127 | // then another commit is required. |
| 1128 | if (layer_tree_host_impl_->EvictedUIResourcesExist()) |
| 1129 | layer_tree_host_impl_->SetNeedsCommit(); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 1130 | } |
| 1131 | |
danakj | 7383c55 | 2015-02-11 18:01:48 | [diff] [blame] | 1132 | void LayerTreeImpl::RegisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 1133 | DCHECK(std::find(picture_layers_.begin(), picture_layers_.end(), layer) == |
| 1134 | picture_layers_.end()); |
| 1135 | picture_layers_.push_back(layer); |
| 1136 | } |
| 1137 | |
| 1138 | void LayerTreeImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 1139 | std::vector<PictureLayerImpl*>::iterator it = |
| 1140 | std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 1141 | DCHECK(it != picture_layers_.end()); |
| 1142 | picture_layers_.erase(it); |
| 1143 | } |
| 1144 | |
[email protected] | 30fe19ff | 2013-07-04 00:54:45 | [diff] [blame] | 1145 | void LayerTreeImpl::AddLayerWithCopyOutputRequest(LayerImpl* layer) { |
| 1146 | // Only the active tree needs to know about layers with copy requests, as |
| 1147 | // they are aborted if not serviced during draw. |
| 1148 | DCHECK(IsActiveTree()); |
| 1149 | |
[email protected] | a4ee1281 | 2014-02-06 17:33:38 | [diff] [blame] | 1150 | // DCHECK(std::find(layers_with_copy_output_request_.begin(), |
| 1151 | // layers_with_copy_output_request_.end(), |
| 1152 | // layer) == layers_with_copy_output_request_.end()); |
| 1153 | // TODO(danakj): Remove this once crash is found crbug.com/309777 |
| 1154 | for (size_t i = 0; i < layers_with_copy_output_request_.size(); ++i) { |
| 1155 | CHECK(layers_with_copy_output_request_[i] != layer) |
| 1156 | << i << " of " << layers_with_copy_output_request_.size(); |
| 1157 | } |
[email protected] | 30fe19ff | 2013-07-04 00:54:45 | [diff] [blame] | 1158 | layers_with_copy_output_request_.push_back(layer); |
| 1159 | } |
| 1160 | |
| 1161 | void LayerTreeImpl::RemoveLayerWithCopyOutputRequest(LayerImpl* layer) { |
| 1162 | // Only the active tree needs to know about layers with copy requests, as |
| 1163 | // they are aborted if not serviced during draw. |
| 1164 | DCHECK(IsActiveTree()); |
| 1165 | |
| 1166 | std::vector<LayerImpl*>::iterator it = std::find( |
| 1167 | layers_with_copy_output_request_.begin(), |
| 1168 | layers_with_copy_output_request_.end(), |
| 1169 | layer); |
| 1170 | DCHECK(it != layers_with_copy_output_request_.end()); |
[email protected] | f5de9e5b | 2013-07-30 22:26:57 | [diff] [blame] | 1171 | layers_with_copy_output_request_.erase(it); |
[email protected] | a4ee1281 | 2014-02-06 17:33:38 | [diff] [blame] | 1172 | |
| 1173 | // TODO(danakj): Remove this once crash is found crbug.com/309777 |
| 1174 | for (size_t i = 0; i < layers_with_copy_output_request_.size(); ++i) { |
| 1175 | CHECK(layers_with_copy_output_request_[i] != layer) |
| 1176 | << i << " of " << layers_with_copy_output_request_.size(); |
| 1177 | } |
[email protected] | 30fe19ff | 2013-07-04 00:54:45 | [diff] [blame] | 1178 | } |
| 1179 | |
[email protected] | 5352637 | 2013-12-07 04:31:50 | [diff] [blame] | 1180 | const std::vector<LayerImpl*>& LayerTreeImpl::LayersWithCopyOutputRequest() |
[email protected] | 30fe19ff | 2013-07-04 00:54:45 | [diff] [blame] | 1181 | const { |
| 1182 | // Only the active tree needs to know about layers with copy requests, as |
| 1183 | // they are aborted if not serviced during draw. |
| 1184 | DCHECK(IsActiveTree()); |
| 1185 | |
| 1186 | return layers_with_copy_output_request_; |
| 1187 | } |
| 1188 | |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1189 | template <typename LayerType> |
| 1190 | static inline bool LayerClipsSubtree(LayerType* layer) { |
| 1191 | return layer->masks_to_bounds() || layer->mask_layer(); |
| 1192 | } |
| 1193 | |
| 1194 | static bool PointHitsRect( |
| 1195 | const gfx::PointF& screen_space_point, |
| 1196 | const gfx::Transform& local_space_to_screen_space_transform, |
| 1197 | const gfx::RectF& local_space_rect, |
| 1198 | float* distance_to_camera) { |
| 1199 | // If the transform is not invertible, then assume that this point doesn't hit |
| 1200 | // this rect. |
| 1201 | gfx::Transform inverse_local_space_to_screen_space( |
| 1202 | gfx::Transform::kSkipInitialization); |
| 1203 | if (!local_space_to_screen_space_transform.GetInverse( |
| 1204 | &inverse_local_space_to_screen_space)) |
| 1205 | return false; |
| 1206 | |
| 1207 | // Transform the hit test point from screen space to the local space of the |
| 1208 | // given rect. |
| 1209 | bool clipped = false; |
| 1210 | gfx::Point3F planar_point = MathUtil::ProjectPoint3D( |
| 1211 | inverse_local_space_to_screen_space, screen_space_point, &clipped); |
| 1212 | gfx::PointF hit_test_point_in_local_space = |
| 1213 | gfx::PointF(planar_point.x(), planar_point.y()); |
| 1214 | |
| 1215 | // If ProjectPoint could not project to a valid value, then we assume that |
| 1216 | // this point doesn't hit this rect. |
| 1217 | if (clipped) |
| 1218 | return false; |
| 1219 | |
| 1220 | if (!local_space_rect.Contains(hit_test_point_in_local_space)) |
| 1221 | return false; |
| 1222 | |
| 1223 | if (distance_to_camera) { |
| 1224 | // To compute the distance to the camera, we have to take the planar point |
| 1225 | // and pull it back to world space and compute the displacement along the |
| 1226 | // z-axis. |
| 1227 | gfx::Point3F planar_point_in_screen_space(planar_point); |
| 1228 | local_space_to_screen_space_transform.TransformPoint( |
| 1229 | &planar_point_in_screen_space); |
| 1230 | *distance_to_camera = planar_point_in_screen_space.z(); |
| 1231 | } |
| 1232 | |
| 1233 | return true; |
| 1234 | } |
| 1235 | |
| 1236 | static bool PointHitsRegion(const gfx::PointF& screen_space_point, |
| 1237 | const gfx::Transform& screen_space_transform, |
| 1238 | const Region& layer_space_region, |
| 1239 | float layer_content_scale_x, |
| 1240 | float layer_content_scale_y) { |
| 1241 | // If the transform is not invertible, then assume that this point doesn't hit |
| 1242 | // this region. |
| 1243 | gfx::Transform inverse_screen_space_transform( |
| 1244 | gfx::Transform::kSkipInitialization); |
| 1245 | if (!screen_space_transform.GetInverse(&inverse_screen_space_transform)) |
| 1246 | return false; |
| 1247 | |
| 1248 | // Transform the hit test point from screen space to the local space of the |
| 1249 | // given region. |
| 1250 | bool clipped = false; |
| 1251 | gfx::PointF hit_test_point_in_content_space = MathUtil::ProjectPoint( |
| 1252 | inverse_screen_space_transform, screen_space_point, &clipped); |
| 1253 | gfx::PointF hit_test_point_in_layer_space = |
| 1254 | gfx::ScalePoint(hit_test_point_in_content_space, |
| 1255 | 1.f / layer_content_scale_x, |
| 1256 | 1.f / layer_content_scale_y); |
| 1257 | |
| 1258 | // If ProjectPoint could not project to a valid value, then we assume that |
| 1259 | // this point doesn't hit this region. |
| 1260 | if (clipped) |
| 1261 | return false; |
| 1262 | |
| 1263 | return layer_space_region.Contains( |
| 1264 | gfx::ToRoundedPoint(hit_test_point_in_layer_space)); |
| 1265 | } |
| 1266 | |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1267 | static const LayerImpl* GetNextClippingLayer(const LayerImpl* layer) { |
[email protected] | 0ec86f5 | 2014-06-12 20:54:03 | [diff] [blame] | 1268 | if (layer->scroll_parent()) |
| 1269 | return layer->scroll_parent(); |
| 1270 | if (layer->clip_parent()) |
| 1271 | return layer->clip_parent(); |
| 1272 | return layer->parent(); |
| 1273 | } |
| 1274 | |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1275 | static bool PointIsClippedBySurfaceOrClipRect( |
| 1276 | const gfx::PointF& screen_space_point, |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1277 | const LayerImpl* layer) { |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1278 | // Walk up the layer tree and hit-test any render_surfaces and any layer |
| 1279 | // clip rects that are active. |
[email protected] | 0ec86f5 | 2014-06-12 20:54:03 | [diff] [blame] | 1280 | for (; layer; layer = GetNextClippingLayer(layer)) { |
| 1281 | if (layer->render_surface() && |
| 1282 | !PointHitsRect(screen_space_point, |
| 1283 | layer->render_surface()->screen_space_transform(), |
| 1284 | layer->render_surface()->content_rect(), |
| 1285 | NULL)) |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1286 | return true; |
| 1287 | |
[email protected] | 0ec86f5 | 2014-06-12 20:54:03 | [diff] [blame] | 1288 | if (LayerClipsSubtree(layer) && |
| 1289 | !PointHitsRect(screen_space_point, |
| 1290 | layer->screen_space_transform(), |
| 1291 | gfx::Rect(layer->content_bounds()), |
| 1292 | NULL)) |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1293 | return true; |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1294 | } |
| 1295 | |
| 1296 | // If we have finished walking all ancestors without having already exited, |
| 1297 | // then the point is not clipped by any ancestors. |
| 1298 | return false; |
| 1299 | } |
| 1300 | |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1301 | static bool PointHitsLayer(const LayerImpl* layer, |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1302 | const gfx::PointF& screen_space_point, |
| 1303 | float* distance_to_intersection) { |
| 1304 | gfx::RectF content_rect(layer->content_bounds()); |
| 1305 | if (!PointHitsRect(screen_space_point, |
| 1306 | layer->screen_space_transform(), |
| 1307 | content_rect, |
| 1308 | distance_to_intersection)) |
| 1309 | return false; |
| 1310 | |
| 1311 | // At this point, we think the point does hit the layer, but we need to walk |
| 1312 | // up the parents to ensure that the layer was not clipped in such a way |
| 1313 | // that the hit point actually should not hit the layer. |
| 1314 | if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer)) |
| 1315 | return false; |
| 1316 | |
| 1317 | // Skip the HUD layer. |
| 1318 | if (layer == layer->layer_tree_impl()->hud_layer()) |
| 1319 | return false; |
| 1320 | |
| 1321 | return true; |
| 1322 | } |
| 1323 | |
| 1324 | struct FindClosestMatchingLayerDataForRecursion { |
| 1325 | FindClosestMatchingLayerDataForRecursion() |
| 1326 | : closest_match(NULL), |
| 1327 | closest_distance(-std::numeric_limits<float>::infinity()) {} |
| 1328 | LayerImpl* closest_match; |
| 1329 | // Note that the positive z-axis points towards the camera, so bigger means |
| 1330 | // closer in this case, counterintuitively. |
| 1331 | float closest_distance; |
| 1332 | }; |
| 1333 | |
| 1334 | template <typename Functor> |
| 1335 | static void FindClosestMatchingLayer( |
| 1336 | const gfx::PointF& screen_space_point, |
| 1337 | LayerImpl* layer, |
| 1338 | const Functor& func, |
| 1339 | FindClosestMatchingLayerDataForRecursion* data_for_recursion) { |
| 1340 | for (int i = layer->children().size() - 1; i >= 0; --i) { |
| 1341 | FindClosestMatchingLayer( |
| 1342 | screen_space_point, layer->children()[i], func, data_for_recursion); |
| 1343 | } |
| 1344 | |
| 1345 | float distance_to_intersection = 0.f; |
| 1346 | if (func(layer) && |
| 1347 | PointHitsLayer(layer, screen_space_point, &distance_to_intersection) && |
| 1348 | ((!data_for_recursion->closest_match || |
| 1349 | distance_to_intersection > data_for_recursion->closest_distance))) { |
| 1350 | data_for_recursion->closest_distance = distance_to_intersection; |
| 1351 | data_for_recursion->closest_match = layer; |
| 1352 | } |
| 1353 | } |
| 1354 | |
| 1355 | static bool ScrollsAnyDrawnRenderSurfaceLayerListMember(LayerImpl* layer) { |
| 1356 | if (!layer->scrollable()) |
| 1357 | return false; |
majidvp | 6cfcc36 | 2015-03-06 20:46:39 | [diff] [blame] | 1358 | if (layer->draw_properties().layer_or_descendant_is_drawn) |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1359 | return true; |
majidvp | 6cfcc36 | 2015-03-06 20:46:39 | [diff] [blame] | 1360 | |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1361 | if (!layer->scroll_children()) |
| 1362 | return false; |
| 1363 | for (std::set<LayerImpl*>::const_iterator it = |
| 1364 | layer->scroll_children()->begin(); |
| 1365 | it != layer->scroll_children()->end(); |
| 1366 | ++it) { |
majidvp | 6cfcc36 | 2015-03-06 20:46:39 | [diff] [blame] | 1367 | if ((*it)->draw_properties().layer_or_descendant_is_drawn) |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1368 | return true; |
| 1369 | } |
| 1370 | return false; |
| 1371 | } |
| 1372 | |
| 1373 | struct FindScrollingLayerFunctor { |
| 1374 | bool operator()(LayerImpl* layer) const { |
| 1375 | return ScrollsAnyDrawnRenderSurfaceLayerListMember(layer); |
| 1376 | } |
| 1377 | }; |
| 1378 | |
| 1379 | LayerImpl* LayerTreeImpl::FindFirstScrollingLayerThatIsHitByPoint( |
| 1380 | const gfx::PointF& screen_space_point) { |
| 1381 | FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1382 | FindClosestMatchingLayer(screen_space_point, |
| 1383 | root_layer(), |
| 1384 | FindScrollingLayerFunctor(), |
| 1385 | &data_for_recursion); |
| 1386 | return data_for_recursion.closest_match; |
| 1387 | } |
| 1388 | |
| 1389 | struct HitTestVisibleScrollableOrTouchableFunctor { |
| 1390 | bool operator()(LayerImpl* layer) const { |
| 1391 | return layer->IsDrawnRenderSurfaceLayerListMember() || |
| 1392 | ScrollsAnyDrawnRenderSurfaceLayerListMember(layer) || |
| 1393 | !layer->touch_event_handler_region().IsEmpty() || |
| 1394 | layer->have_wheel_event_handlers(); |
| 1395 | } |
| 1396 | }; |
| 1397 | |
| 1398 | LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( |
| 1399 | const gfx::PointF& screen_space_point) { |
[email protected] | 8f7f29882 | 2014-06-13 00:23:32 | [diff] [blame] | 1400 | if (!root_layer()) |
| 1401 | return NULL; |
enne | af5bda3 | 2015-02-19 01:27:36 | [diff] [blame] | 1402 | bool update_lcd_text = false; |
| 1403 | if (!UpdateDrawProperties(update_lcd_text)) |
[email protected] | 8f7f29882 | 2014-06-13 00:23:32 | [diff] [blame] | 1404 | return NULL; |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1405 | FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1406 | FindClosestMatchingLayer(screen_space_point, |
| 1407 | root_layer(), |
| 1408 | HitTestVisibleScrollableOrTouchableFunctor(), |
| 1409 | &data_for_recursion); |
| 1410 | return data_for_recursion.closest_match; |
| 1411 | } |
| 1412 | |
| 1413 | static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, |
| 1414 | LayerImpl* layer_impl) { |
| 1415 | if (layer_impl->touch_event_handler_region().IsEmpty()) |
| 1416 | return false; |
| 1417 | |
| 1418 | if (!PointHitsRegion(screen_space_point, |
| 1419 | layer_impl->screen_space_transform(), |
| 1420 | layer_impl->touch_event_handler_region(), |
| 1421 | layer_impl->contents_scale_x(), |
| 1422 | layer_impl->contents_scale_y())) |
| 1423 | return false; |
| 1424 | |
| 1425 | // At this point, we think the point does hit the touch event handler region |
| 1426 | // on the layer, but we need to walk up the parents to ensure that the layer |
| 1427 | // was not clipped in such a way that the hit point actually should not hit |
| 1428 | // the layer. |
| 1429 | if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
| 1430 | return false; |
| 1431 | |
| 1432 | return true; |
| 1433 | } |
| 1434 | |
ccameron | 3b60736 | 2015-02-02 22:46:29 | [diff] [blame] | 1435 | struct FindWheelEventLayerFunctor { |
| 1436 | bool operator()(LayerImpl* layer) const { |
| 1437 | return layer->have_wheel_event_handlers(); |
| 1438 | } |
| 1439 | }; |
| 1440 | |
| 1441 | LayerImpl* LayerTreeImpl::FindLayerWithWheelHandlerThatIsHitByPoint( |
| 1442 | const gfx::PointF& screen_space_point) { |
| 1443 | if (!root_layer()) |
| 1444 | return NULL; |
enne | af5bda3 | 2015-02-19 01:27:36 | [diff] [blame] | 1445 | bool update_lcd_text = false; |
| 1446 | if (!UpdateDrawProperties(update_lcd_text)) |
ccameron | 3b60736 | 2015-02-02 22:46:29 | [diff] [blame] | 1447 | return NULL; |
| 1448 | FindWheelEventLayerFunctor func; |
| 1449 | FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1450 | FindClosestMatchingLayer(screen_space_point, root_layer(), func, |
| 1451 | &data_for_recursion); |
| 1452 | return data_for_recursion.closest_match; |
| 1453 | } |
| 1454 | |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1455 | struct FindTouchEventLayerFunctor { |
| 1456 | bool operator()(LayerImpl* layer) const { |
| 1457 | return LayerHasTouchEventHandlersAt(screen_space_point, layer); |
| 1458 | } |
| 1459 | const gfx::PointF screen_space_point; |
| 1460 | }; |
| 1461 | |
| 1462 | LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 1463 | const gfx::PointF& screen_space_point) { |
[email protected] | 8f7f29882 | 2014-06-13 00:23:32 | [diff] [blame] | 1464 | if (!root_layer()) |
| 1465 | return NULL; |
enne | af5bda3 | 2015-02-19 01:27:36 | [diff] [blame] | 1466 | bool update_lcd_text = false; |
| 1467 | if (!UpdateDrawProperties(update_lcd_text)) |
[email protected] | 8f7f29882 | 2014-06-13 00:23:32 | [diff] [blame] | 1468 | return NULL; |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 1469 | FindTouchEventLayerFunctor func = {screen_space_point}; |
| 1470 | FindClosestMatchingLayerDataForRecursion data_for_recursion; |
| 1471 | FindClosestMatchingLayer( |
| 1472 | screen_space_point, root_layer(), func, &data_for_recursion); |
| 1473 | return data_for_recursion.closest_match; |
| 1474 | } |
| 1475 | |
[email protected] | ebb179b | 2014-07-16 17:54:41 | [diff] [blame] | 1476 | void LayerTreeImpl::RegisterSelection(const LayerSelectionBound& start, |
| 1477 | const LayerSelectionBound& end) { |
| 1478 | selection_start_ = start; |
| 1479 | selection_end_ = end; |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1480 | } |
| 1481 | |
| 1482 | static ViewportSelectionBound ComputeViewportSelection( |
[email protected] | 6ef94873 | 2014-08-22 18:57:44 | [diff] [blame] | 1483 | const LayerSelectionBound& layer_bound, |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1484 | LayerImpl* layer, |
| 1485 | float device_scale_factor) { |
[email protected] | 6ef94873 | 2014-08-22 18:57:44 | [diff] [blame] | 1486 | ViewportSelectionBound viewport_bound; |
| 1487 | viewport_bound.type = layer_bound.type; |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1488 | |
[email protected] | 6ef94873 | 2014-08-22 18:57:44 | [diff] [blame] | 1489 | if (!layer || layer_bound.type == SELECTION_BOUND_EMPTY) |
| 1490 | return viewport_bound; |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1491 | |
[email protected] | 6ef94873 | 2014-08-22 18:57:44 | [diff] [blame] | 1492 | gfx::PointF layer_scaled_top = gfx::ScalePoint(layer_bound.edge_top, |
| 1493 | layer->contents_scale_x(), |
| 1494 | layer->contents_scale_y()); |
| 1495 | gfx::PointF layer_scaled_bottom = gfx::ScalePoint(layer_bound.edge_bottom, |
| 1496 | layer->contents_scale_x(), |
| 1497 | layer->contents_scale_y()); |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1498 | |
[email protected] | 6ef94873 | 2014-08-22 18:57:44 | [diff] [blame] | 1499 | bool clipped = false; |
| 1500 | gfx::PointF screen_top = MathUtil::MapPoint( |
| 1501 | layer->screen_space_transform(), layer_scaled_top, &clipped); |
| 1502 | gfx::PointF screen_bottom = MathUtil::MapPoint( |
| 1503 | layer->screen_space_transform(), layer_scaled_bottom, &clipped); |
| 1504 | |
| 1505 | const float inv_scale = 1.f / device_scale_factor; |
| 1506 | viewport_bound.edge_top = gfx::ScalePoint(screen_top, inv_scale); |
| 1507 | viewport_bound.edge_bottom = gfx::ScalePoint(screen_bottom, inv_scale); |
| 1508 | |
| 1509 | // The bottom edge point is used for visibility testing as it is the logical |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1510 | // focal point for bound selection handles (this may change in the future). |
[email protected] | 6ef94873 | 2014-08-22 18:57:44 | [diff] [blame] | 1511 | // Shifting the visibility point fractionally inward ensures that neighboring |
| 1512 | // or logically coincident layers aligned to integral DPI coordinates will not |
| 1513 | // spuriously occlude the bound. |
| 1514 | gfx::Vector2dF visibility_offset = layer_scaled_top - layer_scaled_bottom; |
| 1515 | visibility_offset.Scale(device_scale_factor / visibility_offset.Length()); |
| 1516 | gfx::PointF visibility_point = layer_scaled_bottom + visibility_offset; |
| 1517 | if (visibility_point.x() <= 0) |
| 1518 | visibility_point.set_x(visibility_point.x() + device_scale_factor); |
| 1519 | visibility_point = MathUtil::MapPoint( |
| 1520 | layer->screen_space_transform(), visibility_point, &clipped); |
| 1521 | |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1522 | float intersect_distance = 0.f; |
[email protected] | 6ef94873 | 2014-08-22 18:57:44 | [diff] [blame] | 1523 | viewport_bound.visible = |
| 1524 | PointHitsLayer(layer, visibility_point, &intersect_distance); |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1525 | |
[email protected] | 6ef94873 | 2014-08-22 18:57:44 | [diff] [blame] | 1526 | return viewport_bound; |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1527 | } |
| 1528 | |
[email protected] | ebb179b | 2014-07-16 17:54:41 | [diff] [blame] | 1529 | void LayerTreeImpl::GetViewportSelection(ViewportSelectionBound* start, |
| 1530 | ViewportSelectionBound* end) { |
| 1531 | DCHECK(start); |
| 1532 | DCHECK(end); |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1533 | |
[email protected] | ebb179b | 2014-07-16 17:54:41 | [diff] [blame] | 1534 | *start = ComputeViewportSelection( |
| 1535 | selection_start_, |
| 1536 | selection_start_.layer_id ? LayerById(selection_start_.layer_id) : NULL, |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1537 | device_scale_factor()); |
[email protected] | ebb179b | 2014-07-16 17:54:41 | [diff] [blame] | 1538 | if (start->type == SELECTION_BOUND_CENTER || |
| 1539 | start->type == SELECTION_BOUND_EMPTY) { |
| 1540 | *end = *start; |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1541 | } else { |
[email protected] | ebb179b | 2014-07-16 17:54:41 | [diff] [blame] | 1542 | *end = ComputeViewportSelection( |
| 1543 | selection_end_, |
| 1544 | selection_end_.layer_id ? LayerById(selection_end_.layer_id) : NULL, |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 1545 | device_scale_factor()); |
| 1546 | } |
| 1547 | } |
| 1548 | |
[email protected] | 749cbc6 | 2014-07-10 01:06:35 | [diff] [blame] | 1549 | void LayerTreeImpl::InputScrollAnimationFinished() { |
| 1550 | layer_tree_host_impl_->ScrollEnd(); |
| 1551 | } |
| 1552 | |
vmpstr | 56ace23 | 2014-10-09 20:16:28 | [diff] [blame] | 1553 | bool LayerTreeImpl::SmoothnessTakesPriority() const { |
| 1554 | return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY; |
| 1555 | } |
| 1556 | |
skyostil | 3976a3f | 2014-09-04 22:07:23 | [diff] [blame] | 1557 | BlockingTaskRunner* LayerTreeImpl::BlockingMainThreadTaskRunner() const { |
| 1558 | return proxy()->blocking_main_thread_task_runner(); |
| 1559 | } |
| 1560 | |
sunnyps | 7d073dc | 2015-04-16 23:29:12 | [diff] [blame] | 1561 | VideoFrameControllerClient* LayerTreeImpl::GetVideoFrameControllerClient() |
| 1562 | const { |
| 1563 | return layer_tree_host_impl_; |
| 1564 | } |
| 1565 | |
bokan | fcdbc18 | 2014-11-21 21:53:33 | [diff] [blame] | 1566 | void LayerTreeImpl::SetPendingPageScaleAnimation( |
| 1567 | scoped_ptr<PendingPageScaleAnimation> pending_animation) { |
| 1568 | pending_page_scale_animation_ = pending_animation.Pass(); |
bokan | 915bf35 | 2014-10-02 21:57:14 | [diff] [blame] | 1569 | } |
| 1570 | |
bokan | fcdbc18 | 2014-11-21 21:53:33 | [diff] [blame] | 1571 | scoped_ptr<PendingPageScaleAnimation> |
| 1572 | LayerTreeImpl::TakePendingPageScaleAnimation() { |
| 1573 | return pending_page_scale_animation_.Pass(); |
bokan | 915bf35 | 2014-10-02 21:57:14 | [diff] [blame] | 1574 | } |
| 1575 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 1576 | } // namespace cc |