[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 | |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 7 | #include "base/debug/trace_event.h" |
[email protected] | 95e4e1a0 | 2013-03-18 07:09:09 | [diff] [blame] | 8 | #include "cc/animation/keyframed_animation_curve.h" |
| 9 | #include "cc/animation/scrollbar_animation_controller.h" |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 10 | #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
| 11 | #include "cc/animation/scrollbar_animation_controller_thinning.h" |
[email protected] | 3744e27b | 2013-11-06 21:44:08 | [diff] [blame] | 12 | #include "cc/base/math_util.h" |
| 13 | #include "cc/base/util.h" |
[email protected] | f6742f5 | 2013-05-08 23:52:22 | [diff] [blame] | 14 | #include "cc/debug/traced_value.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 15 | #include "cc/layers/heads_up_display_layer_impl.h" |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 16 | #include "cc/layers/layer.h" |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 17 | #include "cc/layers/layer_iterator.h" |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 18 | #include "cc/layers/render_surface_impl.h" |
[email protected] | 80413d7 | 2013-08-30 20:25:33 | [diff] [blame] | 19 | #include "cc/layers/scrollbar_layer_impl_base.h" |
[email protected] | e104219 | 2013-11-08 05:44:24 | [diff] [blame] | 20 | #include "cc/resources/ui_resource_request.h" |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 21 | #include "cc/trees/layer_tree_host_common.h" |
| 22 | #include "cc/trees/layer_tree_host_impl.h" |
[email protected] | ffb2720f | 2013-03-15 19:18:37 | [diff] [blame] | 23 | #include "ui/gfx/size_conversions.h" |
[email protected] | caa567d | 2012-12-20 07:56:16 | [diff] [blame] | 24 | #include "ui/gfx/vector2d_conversions.h" |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 25 | |
| 26 | namespace cc { |
| 27 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 28 | // This class exists to split the LayerScrollOffsetDelegate between the |
| 29 | // InnerViewportScrollLayer and the OuterViewportScrollLayer in a manner |
| 30 | // that never requires the embedder or LayerImpl to know about. |
| 31 | class LayerScrollOffsetDelegateProxy : public LayerScrollOffsetDelegate { |
| 32 | public: |
| 33 | LayerScrollOffsetDelegateProxy(LayerImpl* layer, |
| 34 | LayerScrollOffsetDelegate* delegate, |
| 35 | LayerTreeImpl* layer_tree) |
| 36 | : layer_(layer), delegate_(delegate), layer_tree_impl_(layer_tree) {} |
| 37 | |
| 38 | gfx::Vector2dF last_set_scroll_offset() const { |
| 39 | return last_set_scroll_offset_; |
| 40 | } |
| 41 | |
| 42 | // LayerScrollOffsetDelegate implementation. |
| 43 | |
| 44 | virtual void SetTotalScrollOffset(const gfx::Vector2dF& new_offset) OVERRIDE { |
| 45 | last_set_scroll_offset_ = new_offset; |
| 46 | layer_tree_impl_->UpdateScrollOffsetDelegate(); |
| 47 | } |
| 48 | |
| 49 | virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE { |
| 50 | return layer_tree_impl_->GetDelegatedScrollOffset(layer_); |
| 51 | } |
| 52 | |
| 53 | virtual bool IsExternalFlingActive() const OVERRIDE { |
| 54 | return delegate_->IsExternalFlingActive(); |
| 55 | } |
| 56 | |
| 57 | // Functions below this point are never called by LayerImpl on its |
| 58 | // LayerScrollOffsetDelegate, and so are not implemented. |
| 59 | virtual void SetMaxScrollOffset(const gfx::Vector2dF&) OVERRIDE { |
| 60 | NOTIMPLEMENTED(); |
| 61 | } |
| 62 | |
[email protected] | 68fe60f | 2014-02-12 13:49:11 | [diff] [blame] | 63 | virtual void SetTotalPageScaleFactorAndLimits(float, float, float) OVERRIDE { |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 64 | NOTIMPLEMENTED(); |
| 65 | } |
| 66 | |
| 67 | virtual void SetScrollableSize(const gfx::SizeF& scrollable_size) OVERRIDE { |
| 68 | NOTIMPLEMENTED(); |
| 69 | } |
| 70 | |
| 71 | private: |
| 72 | LayerImpl* layer_; |
| 73 | LayerScrollOffsetDelegate* delegate_; |
| 74 | LayerTreeImpl* layer_tree_impl_; |
| 75 | gfx::Vector2dF last_set_scroll_offset_; |
| 76 | }; |
| 77 | |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 78 | LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl) |
[email protected] | db8259f | 2013-02-01 05:25:04 | [diff] [blame] | 79 | : layer_tree_host_impl_(layer_tree_host_impl), |
| 80 | source_frame_number_(-1), |
| 81 | hud_layer_(0), |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 82 | currently_scrolling_layer_(NULL), |
| 83 | root_layer_scroll_offset_delegate_(NULL), |
[email protected] | db8259f | 2013-02-01 05:25:04 | [diff] [blame] | 84 | background_color_(0), |
| 85 | has_transparent_background_(false), |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 86 | page_scale_layer_(NULL), |
| 87 | inner_viewport_scroll_layer_(NULL), |
| 88 | outer_viewport_scroll_layer_(NULL), |
[email protected] | db8259f | 2013-02-01 05:25:04 | [diff] [blame] | 89 | page_scale_factor_(1), |
| 90 | page_scale_delta_(1), |
| 91 | sent_page_scale_delta_(1), |
| 92 | min_page_scale_factor_(0), |
| 93 | max_page_scale_factor_(0), |
| 94 | scrolling_layer_id_from_previous_tree_(0), |
| 95 | contents_textures_purged_(false), |
[email protected] | 3d609bb | 2014-02-01 01:10:23 | [diff] [blame] | 96 | requires_high_res_to_draw_(false), |
[email protected] | 31882285 | 2013-02-14 00:54:27 | [diff] [blame] | 97 | viewport_size_invalid_(false), |
[email protected] | db8259f | 2013-02-01 05:25:04 | [diff] [blame] | 98 | needs_update_draw_properties_(true), |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 99 | needs_full_tree_sync_(true), |
[email protected] | 390bb1ff | 2014-05-09 17:14:40 | [diff] [blame^] | 100 | next_activation_forces_redraw_(false), |
| 101 | render_surface_layer_list_id_(0) { |
| 102 | } |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 103 | |
| 104 | LayerTreeImpl::~LayerTreeImpl() { |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 105 | // Need to explicitly clear the tree prior to destroying this so that |
| 106 | // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. |
[email protected] | df17af5 | 2014-02-06 02:20:40 | [diff] [blame] | 107 | DCHECK(!root_layer_); |
| 108 | DCHECK(layers_with_copy_output_request_.empty()); |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 109 | } |
| 110 | |
[email protected] | df17af5 | 2014-02-06 02:20:40 | [diff] [blame] | 111 | void LayerTreeImpl::Shutdown() { root_layer_.reset(); } |
| 112 | |
[email protected] | d35cd7b2 | 2014-01-29 14:32:46 | [diff] [blame] | 113 | void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 114 | if (inner_viewport_scroll_layer_) |
| 115 | inner_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); |
| 116 | if (outer_viewport_scroll_layer_) |
| 117 | outer_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); |
| 118 | inner_viewport_scroll_delegate_proxy_.reset(); |
| 119 | outer_viewport_scroll_delegate_proxy_.reset(); |
| 120 | |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 121 | root_layer_ = layer.Pass(); |
[email protected] | 5c4824e1 | 2013-01-12 16:34:53 | [diff] [blame] | 122 | currently_scrolling_layer_ = NULL; |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 123 | inner_viewport_scroll_layer_ = NULL; |
| 124 | outer_viewport_scroll_layer_ = NULL; |
| 125 | page_scale_layer_ = NULL; |
[email protected] | 5c4824e1 | 2013-01-12 16:34:53 | [diff] [blame] | 126 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 127 | layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
[email protected] | 5c4824e1 | 2013-01-12 16:34:53 | [diff] [blame] | 128 | } |
| 129 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 130 | LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const { |
| 131 | return inner_viewport_scroll_layer_; |
| 132 | } |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 133 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 134 | LayerImpl* LayerTreeImpl::OuterViewportScrollLayer() const { |
| 135 | return outer_viewport_scroll_layer_; |
| 136 | } |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 137 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 138 | gfx::Vector2dF LayerTreeImpl::TotalScrollOffset() const { |
| 139 | gfx::Vector2dF offset; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 140 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 141 | if (inner_viewport_scroll_layer_) |
| 142 | offset += inner_viewport_scroll_layer_->TotalScrollOffset(); |
| 143 | |
| 144 | if (outer_viewport_scroll_layer_) |
| 145 | offset += outer_viewport_scroll_layer_->TotalScrollOffset(); |
| 146 | |
| 147 | return offset; |
| 148 | } |
| 149 | |
| 150 | gfx::Vector2dF LayerTreeImpl::TotalMaxScrollOffset() const { |
| 151 | gfx::Vector2dF offset; |
| 152 | |
| 153 | if (inner_viewport_scroll_layer_) |
| 154 | offset += inner_viewport_scroll_layer_->MaxScrollOffset(); |
| 155 | |
| 156 | if (outer_viewport_scroll_layer_) |
| 157 | offset += outer_viewport_scroll_layer_->MaxScrollOffset(); |
| 158 | |
| 159 | return offset; |
| 160 | } |
| 161 | gfx::Vector2dF LayerTreeImpl::TotalScrollDelta() const { |
| 162 | DCHECK(inner_viewport_scroll_layer_); |
| 163 | gfx::Vector2dF delta = inner_viewport_scroll_layer_->ScrollDelta(); |
| 164 | |
| 165 | if (outer_viewport_scroll_layer_) |
| 166 | delta += outer_viewport_scroll_layer_->ScrollDelta(); |
| 167 | |
| 168 | return delta; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() { |
| 172 | // Clear all data structures that have direct references to the layer tree. |
| 173 | scrolling_layer_id_from_previous_tree_ = |
| 174 | currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0; |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 175 | if (inner_viewport_scroll_layer_) |
| 176 | inner_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); |
| 177 | if (outer_viewport_scroll_layer_) |
| 178 | outer_viewport_scroll_layer_->SetScrollOffsetDelegate(NULL); |
| 179 | inner_viewport_scroll_delegate_proxy_.reset(); |
| 180 | outer_viewport_scroll_delegate_proxy_.reset(); |
| 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 | |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 195 | if (next_activation_forces_redraw_) { |
| 196 | layer_tree_host_impl_->SetFullRootLayerDamage(); |
| 197 | next_activation_forces_redraw_ = false; |
| 198 | } |
| 199 | |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 200 | target_tree->PassSwapPromises(&swap_promise_list_); |
| 201 | |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 202 | target_tree->SetPageScaleFactorAndLimits( |
| 203 | page_scale_factor(), min_page_scale_factor(), max_page_scale_factor()); |
| 204 | target_tree->SetPageScaleDelta( |
| 205 | target_tree->page_scale_delta() / target_tree->sent_page_scale_delta()); |
| 206 | target_tree->set_sent_page_scale_delta(1); |
| 207 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 208 | if (page_scale_layer_ && inner_viewport_scroll_layer_) { |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 209 | target_tree->SetViewportLayersFromIds( |
| 210 | page_scale_layer_->id(), |
| 211 | inner_viewport_scroll_layer_->id(), |
| 212 | outer_viewport_scroll_layer_ ? outer_viewport_scroll_layer_->id() |
| 213 | : Layer::INVALID_ID); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 214 | } else { |
| 215 | target_tree->ClearViewportLayers(); |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 216 | } |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 217 | // This should match the property synchronization in |
| 218 | // LayerTreeHost::finishCommitOnImplThread(). |
| 219 | target_tree->set_source_frame_number(source_frame_number()); |
| 220 | target_tree->set_background_color(background_color()); |
| 221 | target_tree->set_has_transparent_background(has_transparent_background()); |
| 222 | |
| 223 | if (ContentsTexturesPurged()) |
| 224 | target_tree->SetContentsTexturesPurged(); |
| 225 | else |
| 226 | target_tree->ResetContentsTexturesPurged(); |
| 227 | |
[email protected] | 3d609bb | 2014-02-01 01:10:23 | [diff] [blame] | 228 | // Always reset this flag on activation, as we would only have activated |
| 229 | // if we were in a good state. |
| 230 | target_tree->ResetRequiresHighResToDraw(); |
| 231 | |
[email protected] | 31882285 | 2013-02-14 00:54:27 | [diff] [blame] | 232 | if (ViewportSizeInvalid()) |
| 233 | target_tree->SetViewportSizeInvalid(); |
| 234 | else |
| 235 | target_tree->ResetViewportSizeInvalid(); |
| 236 | |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 237 | if (hud_layer()) |
| 238 | target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( |
[email protected] | 6ba91412 | 2013-03-22 16:26:39 | [diff] [blame] | 239 | LayerTreeHostCommon::FindLayerInSubtree( |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 240 | target_tree->root_layer(), hud_layer()->id()))); |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 241 | else |
| 242 | target_tree->set_hud_layer(NULL); |
| 243 | } |
| 244 | |
[email protected] | fef74fd | 2014-02-27 06:28:17 | [diff] [blame] | 245 | LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { |
| 246 | return inner_viewport_scroll_layer_ |
| 247 | ? inner_viewport_scroll_layer_->scroll_clip_layer() |
| 248 | : NULL; |
[email protected] | ffb2720f | 2013-03-15 19:18:37 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() const { |
[email protected] | 69b50ec | 2013-01-19 04:58:01 | [diff] [blame] | 252 | DCHECK(IsActiveTree()); |
| 253 | return currently_scrolling_layer_; |
| 254 | } |
| 255 | |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 256 | void LayerTreeImpl::SetCurrentlyScrollingLayer(LayerImpl* layer) { |
| 257 | if (currently_scrolling_layer_ == layer) |
| 258 | return; |
| 259 | |
| 260 | if (currently_scrolling_layer_ && |
| 261 | currently_scrolling_layer_->scrollbar_animation_controller()) |
[email protected] | 1dc0616 | 2014-03-26 22:54:45 | [diff] [blame] | 262 | currently_scrolling_layer_->scrollbar_animation_controller() |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 263 | ->DidScrollEnd(); |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 264 | currently_scrolling_layer_ = layer; |
| 265 | if (layer && layer->scrollbar_animation_controller()) |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 266 | layer->scrollbar_animation_controller()->DidScrollBegin(); |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 267 | } |
| 268 | |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 269 | void LayerTreeImpl::ClearCurrentlyScrollingLayer() { |
[email protected] | 0fc818e | 2013-03-18 06:45:20 | [diff] [blame] | 270 | SetCurrentlyScrollingLayer(NULL); |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 271 | scrolling_layer_id_from_previous_tree_ = 0; |
| 272 | } |
| 273 | |
[email protected] | 1f15bed | 2014-03-11 02:50:44 | [diff] [blame] | 274 | float LayerTreeImpl::VerticalAdjust(const int clip_layer_id) const { |
| 275 | LayerImpl* container_layer = InnerViewportContainerLayer(); |
| 276 | if (!container_layer || clip_layer_id != container_layer->id()) |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 277 | return 0.f; |
| 278 | |
[email protected] | fef74fd | 2014-02-27 06:28:17 | [diff] [blame] | 279 | return layer_tree_host_impl_->VerticalAdjust(); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | namespace { |
| 283 | |
| 284 | void ForceScrollbarParameterUpdateAfterScaleChange(LayerImpl* current_layer) { |
| 285 | if (!current_layer) |
| 286 | return; |
| 287 | |
| 288 | while (current_layer) { |
| 289 | current_layer->ScrollbarParametersDidChange(); |
| 290 | current_layer = current_layer->parent(); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | } // namespace |
| 295 | |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 296 | void LayerTreeImpl::SetPageScaleFactorAndLimits(float page_scale_factor, |
[email protected] | 3c0a325 | 2013-03-18 04:24:36 | [diff] [blame] | 297 | float min_page_scale_factor, float max_page_scale_factor) { |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 298 | if (!page_scale_factor) |
| 299 | return; |
| 300 | |
[email protected] | 7265e74e | 2014-02-07 23:43:06 | [diff] [blame] | 301 | if (min_page_scale_factor == min_page_scale_factor_ && |
| 302 | max_page_scale_factor == max_page_scale_factor_ && |
| 303 | page_scale_factor == page_scale_factor_) |
| 304 | return; |
| 305 | |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 306 | min_page_scale_factor_ = min_page_scale_factor; |
| 307 | max_page_scale_factor_ = max_page_scale_factor; |
| 308 | page_scale_factor_ = page_scale_factor; |
[email protected] | 20d2b74 | 2013-09-26 05:41:34 | [diff] [blame] | 309 | |
[email protected] | 22f200a | 2013-10-09 18:08:29 | [diff] [blame] | 310 | if (root_layer_scroll_offset_delegate_) { |
[email protected] | 68fe60f | 2014-02-12 13:49:11 | [diff] [blame] | 311 | root_layer_scroll_offset_delegate_->SetTotalPageScaleFactorAndLimits( |
| 312 | total_page_scale_factor(), |
| 313 | this->min_page_scale_factor(), |
| 314 | this->max_page_scale_factor()); |
[email protected] | 22f200a | 2013-10-09 18:08:29 | [diff] [blame] | 315 | } |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 316 | |
| 317 | ForceScrollbarParameterUpdateAfterScaleChange(page_scale_layer()); |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 318 | } |
| 319 | |
[email protected] | 3c0a325 | 2013-03-18 04:24:36 | [diff] [blame] | 320 | void LayerTreeImpl::SetPageScaleDelta(float delta) { |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 321 | // Clamp to the current min/max limits. |
| 322 | float total = page_scale_factor_ * delta; |
| 323 | if (min_page_scale_factor_ && total < min_page_scale_factor_) |
| 324 | delta = min_page_scale_factor_ / page_scale_factor_; |
| 325 | else if (max_page_scale_factor_ && total > max_page_scale_factor_) |
| 326 | delta = max_page_scale_factor_ / page_scale_factor_; |
| 327 | |
| 328 | if (delta == page_scale_delta_) |
| 329 | return; |
| 330 | |
| 331 | page_scale_delta_ = delta; |
| 332 | |
| 333 | if (IsActiveTree()) { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 334 | LayerTreeImpl* pending_tree = layer_tree_host_impl_->pending_tree(); |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 335 | if (pending_tree) { |
| 336 | DCHECK_EQ(1, pending_tree->sent_page_scale_delta()); |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 337 | pending_tree->SetPageScaleDelta( |
| 338 | page_scale_delta_ / sent_page_scale_delta_); |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 339 | } |
| 340 | } |
| 341 | |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 342 | set_needs_update_draw_properties(); |
[email protected] | 22f200a | 2013-10-09 18:08:29 | [diff] [blame] | 343 | |
| 344 | if (root_layer_scroll_offset_delegate_) { |
[email protected] | 68fe60f | 2014-02-12 13:49:11 | [diff] [blame] | 345 | root_layer_scroll_offset_delegate_->SetTotalPageScaleFactorAndLimits( |
| 346 | total_page_scale_factor(), |
| 347 | min_page_scale_factor(), |
| 348 | max_page_scale_factor()); |
[email protected] | 22f200a | 2013-10-09 18:08:29 | [diff] [blame] | 349 | } |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 350 | } |
| 351 | |
[email protected] | 257abfa8 | 2013-01-29 23:47:24 | [diff] [blame] | 352 | gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const { |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 353 | if (outer_viewport_scroll_layer_) |
| 354 | return layer_tree_host_impl_->UnscaledScrollableViewportSize(); |
| 355 | else |
| 356 | return gfx::ScaleSize( |
| 357 | layer_tree_host_impl_->UnscaledScrollableViewportSize(), |
| 358 | 1.0f / total_page_scale_factor()); |
[email protected] | 257abfa8 | 2013-01-29 23:47:24 | [diff] [blame] | 359 | } |
| 360 | |
[email protected] | 3744e27b | 2013-11-06 21:44:08 | [diff] [blame] | 361 | gfx::Rect LayerTreeImpl::RootScrollLayerDeviceViewportBounds() const { |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 362 | LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
| 363 | ? OuterViewportScrollLayer() |
| 364 | : InnerViewportScrollLayer(); |
| 365 | if (!root_scroll_layer || root_scroll_layer->children().empty()) |
[email protected] | 3744e27b | 2013-11-06 21:44:08 | [diff] [blame] | 366 | return gfx::Rect(); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 367 | LayerImpl* layer = root_scroll_layer->children()[0]; |
[email protected] | 8a82269 | 2014-02-12 17:30:55 | [diff] [blame] | 368 | return MathUtil::MapEnclosingClippedRect(layer->screen_space_transform(), |
| 369 | gfx::Rect(layer->content_bounds())); |
[email protected] | 3744e27b | 2013-11-06 21:44:08 | [diff] [blame] | 370 | } |
| 371 | |
[email protected] | 58241dc | 2013-08-20 01:39:25 | [diff] [blame] | 372 | static void ApplySentScrollDeltasFromAbortedCommitTo(LayerImpl* layer) { |
| 373 | layer->ApplySentScrollDeltasFromAbortedCommit(); |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 374 | } |
| 375 | |
[email protected] | 58241dc | 2013-08-20 01:39:25 | [diff] [blame] | 376 | void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() { |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 377 | DCHECK(IsActiveTree()); |
| 378 | |
| 379 | page_scale_factor_ *= sent_page_scale_delta_; |
| 380 | page_scale_delta_ /= sent_page_scale_delta_; |
| 381 | sent_page_scale_delta_ = 1.f; |
| 382 | |
| 383 | if (!root_layer()) |
| 384 | return; |
| 385 | |
| 386 | LayerTreeHostCommon::CallFunctionForSubtree( |
[email protected] | 58241dc | 2013-08-20 01:39:25 | [diff] [blame] | 387 | root_layer(), base::Bind(&ApplySentScrollDeltasFromAbortedCommitTo)); |
| 388 | } |
| 389 | |
[email protected] | daea3d4 | 2013-10-23 17:04:50 | [diff] [blame] | 390 | static void ApplyScrollDeltasSinceBeginMainFrameTo(LayerImpl* layer) { |
| 391 | layer->ApplyScrollDeltasSinceBeginMainFrame(); |
[email protected] | 58241dc | 2013-08-20 01:39:25 | [diff] [blame] | 392 | } |
| 393 | |
[email protected] | daea3d4 | 2013-10-23 17:04:50 | [diff] [blame] | 394 | void LayerTreeImpl::ApplyScrollDeltasSinceBeginMainFrame() { |
[email protected] | 58241dc | 2013-08-20 01:39:25 | [diff] [blame] | 395 | DCHECK(IsPendingTree()); |
| 396 | if (!root_layer()) |
| 397 | return; |
| 398 | |
| 399 | LayerTreeHostCommon::CallFunctionForSubtree( |
[email protected] | daea3d4 | 2013-10-23 17:04:50 | [diff] [blame] | 400 | root_layer(), base::Bind(&ApplyScrollDeltasSinceBeginMainFrameTo)); |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 401 | } |
| 402 | |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 403 | void LayerTreeImpl::SetViewportLayersFromIds( |
| 404 | int page_scale_layer_id, |
| 405 | int inner_viewport_scroll_layer_id, |
| 406 | int outer_viewport_scroll_layer_id) { |
| 407 | page_scale_layer_ = LayerById(page_scale_layer_id); |
| 408 | DCHECK(page_scale_layer_); |
| 409 | |
| 410 | inner_viewport_scroll_layer_ = |
| 411 | LayerById(inner_viewport_scroll_layer_id); |
| 412 | DCHECK(inner_viewport_scroll_layer_); |
| 413 | |
| 414 | outer_viewport_scroll_layer_ = |
| 415 | LayerById(outer_viewport_scroll_layer_id); |
| 416 | DCHECK(outer_viewport_scroll_layer_ || |
| 417 | outer_viewport_scroll_layer_id == Layer::INVALID_ID); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 418 | |
| 419 | if (!root_layer_scroll_offset_delegate_) |
| 420 | return; |
| 421 | |
| 422 | inner_viewport_scroll_delegate_proxy_ = make_scoped_ptr( |
| 423 | new LayerScrollOffsetDelegateProxy(inner_viewport_scroll_layer_, |
| 424 | root_layer_scroll_offset_delegate_, |
| 425 | this)); |
| 426 | |
| 427 | if (outer_viewport_scroll_layer_) |
| 428 | outer_viewport_scroll_delegate_proxy_ = make_scoped_ptr( |
| 429 | new LayerScrollOffsetDelegateProxy(outer_viewport_scroll_layer_, |
| 430 | root_layer_scroll_offset_delegate_, |
| 431 | this)); |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | void LayerTreeImpl::ClearViewportLayers() { |
| 435 | page_scale_layer_ = NULL; |
| 436 | inner_viewport_scroll_layer_ = NULL; |
| 437 | outer_viewport_scroll_layer_ = NULL; |
| 438 | } |
| 439 | |
[email protected] | 7d19dc34 | 2013-05-02 22:02:04 | [diff] [blame] | 440 | void LayerTreeImpl::UpdateDrawProperties() { |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 441 | needs_update_draw_properties_ = false; |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 442 | render_surface_layer_list_.clear(); |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 443 | |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 444 | // For max_texture_size. |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 445 | if (!layer_tree_host_impl_->renderer()) |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 446 | return; |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 447 | |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 448 | if (!root_layer()) |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 449 | return; |
| 450 | |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 451 | { |
[email protected] | 7a52f43e | 2013-07-10 01:58:47 | [diff] [blame] | 452 | TRACE_EVENT2("cc", |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 453 | "LayerTreeImpl::UpdateDrawProperties", |
| 454 | "IsActive", |
[email protected] | 7a52f43e | 2013-07-10 01:58:47 | [diff] [blame] | 455 | IsActiveTree(), |
| 456 | "SourceFrameNumber", |
| 457 | source_frame_number_); |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 458 | LayerImpl* page_scale_layer = |
[email protected] | fef74fd | 2014-02-27 06:28:17 | [diff] [blame] | 459 | page_scale_layer_ ? page_scale_layer_ : InnerViewportContainerLayer(); |
[email protected] | 4594871 | 2013-09-27 02:46:48 | [diff] [blame] | 460 | bool can_render_to_separate_surface = |
| 461 | !output_surface()->ForcedDrawToSoftwareDevice(); |
[email protected] | 390bb1ff | 2014-05-09 17:14:40 | [diff] [blame^] | 462 | |
| 463 | ++render_surface_layer_list_id_; |
[email protected] | 7aad55f | 2013-07-26 11:25:53 | [diff] [blame] | 464 | LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 465 | root_layer(), |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 466 | DrawViewportSize(), |
| 467 | layer_tree_host_impl_->DrawTransform(), |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 468 | device_scale_factor(), |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 469 | total_page_scale_factor(), |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 470 | page_scale_layer, |
[email protected] | f677653 | 2012-12-21 20:24:33 | [diff] [blame] | 471 | MaxTextureSize(), |
[email protected] | 8e0176d | 2013-03-21 03:14:52 | [diff] [blame] | 472 | settings().can_use_lcd_text, |
[email protected] | 4594871 | 2013-09-27 02:46:48 | [diff] [blame] | 473 | can_render_to_separate_surface, |
[email protected] | 35a99a1 | 2013-05-09 23:52:29 | [diff] [blame] | 474 | settings().layer_transforms_should_scale_layer_contents, |
[email protected] | 390bb1ff | 2014-05-09 17:14:40 | [diff] [blame^] | 475 | &render_surface_layer_list_, |
| 476 | render_surface_layer_list_id_); |
[email protected] | 7aad55f | 2013-07-26 11:25:53 | [diff] [blame] | 477 | LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 478 | } |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 479 | |
[email protected] | e4be026 | 2013-10-19 16:54:28 | [diff] [blame] | 480 | { |
| 481 | TRACE_EVENT2("cc", |
| 482 | "LayerTreeImpl::UpdateTilePriorities", |
| 483 | "IsActive", |
| 484 | IsActiveTree(), |
| 485 | "SourceFrameNumber", |
| 486 | source_frame_number_); |
| 487 | // LayerIterator is used here instead of CallFunctionForSubtree to only |
| 488 | // UpdateTilePriorities on layers that will be visible (and thus have valid |
| 489 | // draw properties) and not because any ordering is required. |
[email protected] | ba1b33e | 2014-02-28 16:44:51 | [diff] [blame] | 490 | typedef LayerIterator<LayerImpl> LayerIteratorType; |
[email protected] | e4be026 | 2013-10-19 16:54:28 | [diff] [blame] | 491 | LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); |
| 492 | for (LayerIteratorType it = |
| 493 | LayerIteratorType::Begin(&render_surface_layer_list_); |
| 494 | it != end; |
| 495 | ++it) { |
[email protected] | e4be026 | 2013-10-19 16:54:28 | [diff] [blame] | 496 | LayerImpl* layer = *it; |
[email protected] | 6355d2d | 2014-05-07 15:07:27 | [diff] [blame] | 497 | if (it.represents_itself()) |
| 498 | layer->UpdateTilePriorities(); |
[email protected] | e4be026 | 2013-10-19 16:54:28 | [diff] [blame] | 499 | |
[email protected] | 6355d2d | 2014-05-07 15:07:27 | [diff] [blame] | 500 | if (!it.represents_contributing_render_surface()) |
| 501 | continue; |
| 502 | |
[email protected] | e4be026 | 2013-10-19 16:54:28 | [diff] [blame] | 503 | if (layer->mask_layer()) |
| 504 | layer->mask_layer()->UpdateTilePriorities(); |
| 505 | if (layer->replica_layer() && layer->replica_layer()->mask_layer()) |
| 506 | layer->replica_layer()->mask_layer()->UpdateTilePriorities(); |
| 507 | } |
| 508 | } |
| 509 | |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 510 | DCHECK(!needs_update_draw_properties_) << |
[email protected] | 7d19dc34 | 2013-05-02 22:02:04 | [diff] [blame] | 511 | "CalcDrawProperties should not set_needs_update_draw_properties()"; |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 512 | } |
| 513 | |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 514 | const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const { |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 515 | // If this assert triggers, then the list is dirty. |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 516 | DCHECK(!needs_update_draw_properties_); |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 517 | return render_surface_layer_list_; |
| 518 | } |
| 519 | |
[email protected] | 42ccdbef | 2013-01-21 07:54:54 | [diff] [blame] | 520 | gfx::Size LayerTreeImpl::ScrollableSize() const { |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 521 | LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
| 522 | ? OuterViewportScrollLayer() |
| 523 | : InnerViewportScrollLayer(); |
| 524 | if (!root_scroll_layer || root_scroll_layer->children().empty()) |
[email protected] | caa567d | 2012-12-20 07:56:16 | [diff] [blame] | 525 | return gfx::Size(); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 526 | return root_scroll_layer->children()[0]->bounds(); |
[email protected] | caa567d | 2012-12-20 07:56:16 | [diff] [blame] | 527 | } |
| 528 | |
[email protected] | 361bc00d | 2012-12-14 07:03:24 | [diff] [blame] | 529 | LayerImpl* LayerTreeImpl::LayerById(int id) { |
| 530 | LayerIdMap::iterator iter = layer_id_map_.find(id); |
| 531 | return iter != layer_id_map_.end() ? iter->second : NULL; |
| 532 | } |
| 533 | |
| 534 | void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { |
| 535 | DCHECK(!LayerById(layer->id())); |
| 536 | layer_id_map_[layer->id()] = layer; |
| 537 | } |
| 538 | |
| 539 | void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
| 540 | DCHECK(LayerById(layer->id())); |
| 541 | layer_id_map_.erase(layer->id()); |
| 542 | } |
| 543 | |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 544 | void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) { |
[email protected] | a90fac7 | 2013-06-06 18:56:13 | [diff] [blame] | 545 | pending_tree->SetCurrentlyScrollingLayer( |
| 546 | LayerTreeHostCommon::FindLayerInSubtree(pending_tree->root_layer(), |
| 547 | currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0)); |
[email protected] | 1e0f8d6 | 2013-01-09 07:41:35 | [diff] [blame] | 548 | } |
| 549 | |
[email protected] | ff1211d | 2013-06-07 01:58:35 | [diff] [blame] | 550 | static void DidBecomeActiveRecursive(LayerImpl* layer) { |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 551 | layer->DidBecomeActive(); |
[email protected] | ff1211d | 2013-06-07 01:58:35 | [diff] [blame] | 552 | for (size_t i = 0; i < layer->children().size(); ++i) |
| 553 | DidBecomeActiveRecursive(layer->children()[i]); |
[email protected] | 37386f05 | 2013-01-13 00:42:22 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | void LayerTreeImpl::DidBecomeActive() { |
[email protected] | d30700f1 | 2013-07-31 08:21:01 | [diff] [blame] | 557 | if (!root_layer()) |
| 558 | return; |
| 559 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 560 | if (scrolling_layer_id_from_previous_tree_) { |
| 561 | currently_scrolling_layer_ = LayerTreeHostCommon::FindLayerInSubtree( |
| 562 | root_layer_.get(), scrolling_layer_id_from_previous_tree_); |
| 563 | } |
| 564 | |
[email protected] | d30700f1 | 2013-07-31 08:21:01 | [diff] [blame] | 565 | DidBecomeActiveRecursive(root_layer()); |
[email protected] | 37386f05 | 2013-01-13 00:42:22 | [diff] [blame] | 566 | } |
| 567 | |
[email protected] | 6f90b9e | 2013-01-17 23:42:00 | [diff] [blame] | 568 | bool LayerTreeImpl::ContentsTexturesPurged() const { |
| 569 | return contents_textures_purged_; |
| 570 | } |
| 571 | |
| 572 | void LayerTreeImpl::SetContentsTexturesPurged() { |
[email protected] | 94bf75c | 2013-06-12 13:20:04 | [diff] [blame] | 573 | if (contents_textures_purged_) |
| 574 | return; |
[email protected] | 6f90b9e | 2013-01-17 23:42:00 | [diff] [blame] | 575 | contents_textures_purged_ = true; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 576 | layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
[email protected] | 6f90b9e | 2013-01-17 23:42:00 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | void LayerTreeImpl::ResetContentsTexturesPurged() { |
[email protected] | 94bf75c | 2013-06-12 13:20:04 | [diff] [blame] | 580 | if (!contents_textures_purged_) |
| 581 | return; |
[email protected] | 6f90b9e | 2013-01-17 23:42:00 | [diff] [blame] | 582 | contents_textures_purged_ = false; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 583 | layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
[email protected] | 6f90b9e | 2013-01-17 23:42:00 | [diff] [blame] | 584 | } |
| 585 | |
[email protected] | 3d609bb | 2014-02-01 01:10:23 | [diff] [blame] | 586 | void LayerTreeImpl::SetRequiresHighResToDraw() { |
| 587 | requires_high_res_to_draw_ = true; |
| 588 | } |
| 589 | |
| 590 | void LayerTreeImpl::ResetRequiresHighResToDraw() { |
| 591 | requires_high_res_to_draw_ = false; |
| 592 | } |
| 593 | |
| 594 | bool LayerTreeImpl::RequiresHighResToDraw() const { |
| 595 | return requires_high_res_to_draw_; |
| 596 | } |
| 597 | |
[email protected] | 31882285 | 2013-02-14 00:54:27 | [diff] [blame] | 598 | bool LayerTreeImpl::ViewportSizeInvalid() const { |
| 599 | return viewport_size_invalid_; |
| 600 | } |
| 601 | |
| 602 | void LayerTreeImpl::SetViewportSizeInvalid() { |
| 603 | viewport_size_invalid_ = true; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 604 | layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
[email protected] | 31882285 | 2013-02-14 00:54:27 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | void LayerTreeImpl::ResetViewportSizeInvalid() { |
| 608 | viewport_size_invalid_ = false; |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 609 | layer_tree_host_impl_->OnCanDrawStateChangedForTree(); |
[email protected] | 31882285 | 2013-02-14 00:54:27 | [diff] [blame] | 610 | } |
| 611 | |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 612 | Proxy* LayerTreeImpl::proxy() const { |
| 613 | return layer_tree_host_impl_->proxy(); |
| 614 | } |
| 615 | |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 616 | const LayerTreeSettings& LayerTreeImpl::settings() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 617 | return layer_tree_host_impl_->settings(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 618 | } |
| 619 | |
[email protected] | 7a8bcd26 | 2014-01-15 12:54:58 | [diff] [blame] | 620 | const RendererCapabilitiesImpl& LayerTreeImpl::GetRendererCapabilities() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 621 | return layer_tree_host_impl_->GetRendererCapabilities(); |
[email protected] | bf5b3a0 | 2013-02-13 02:02:52 | [diff] [blame] | 622 | } |
| 623 | |
[email protected] | 0634cdd4 | 2013-08-16 00:46:09 | [diff] [blame] | 624 | ContextProvider* LayerTreeImpl::context_provider() const { |
| 625 | return output_surface()->context_provider(); |
| 626 | } |
| 627 | |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 628 | OutputSurface* LayerTreeImpl::output_surface() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 629 | return layer_tree_host_impl_->output_surface(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | ResourceProvider* LayerTreeImpl::resource_provider() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 633 | return layer_tree_host_impl_->resource_provider(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | TileManager* LayerTreeImpl::tile_manager() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 637 | return layer_tree_host_impl_->tile_manager(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | FrameRateCounter* LayerTreeImpl::frame_rate_counter() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 641 | return layer_tree_host_impl_->fps_counter(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 642 | } |
| 643 | |
[email protected] | 71691c2 | 2013-01-18 03:14:22 | [diff] [blame] | 644 | PaintTimeCounter* LayerTreeImpl::paint_time_counter() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 645 | return layer_tree_host_impl_->paint_time_counter(); |
[email protected] | 71691c2 | 2013-01-18 03:14:22 | [diff] [blame] | 646 | } |
| 647 | |
[email protected] | 1191d9d | 2013-02-02 06:00:33 | [diff] [blame] | 648 | MemoryHistory* LayerTreeImpl::memory_history() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 649 | return layer_tree_host_impl_->memory_history(); |
[email protected] | 1191d9d | 2013-02-02 06:00:33 | [diff] [blame] | 650 | } |
| 651 | |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 652 | bool LayerTreeImpl::device_viewport_valid_for_tile_management() const { |
| 653 | return layer_tree_host_impl_->device_viewport_valid_for_tile_management(); |
| 654 | } |
| 655 | |
[email protected] | 4a6c091d | 2014-04-24 21:06:46 | [diff] [blame] | 656 | gfx::Size LayerTreeImpl::device_viewport_size() const { |
| 657 | return layer_tree_host_impl_->device_viewport_size(); |
| 658 | } |
| 659 | |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 660 | bool LayerTreeImpl::IsActiveTree() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 661 | return layer_tree_host_impl_->active_tree() == this; |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | bool LayerTreeImpl::IsPendingTree() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 665 | return layer_tree_host_impl_->pending_tree() == this; |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 666 | } |
| 667 | |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 668 | bool LayerTreeImpl::IsRecycleTree() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 669 | return layer_tree_host_impl_->recycle_tree() == this; |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 670 | } |
| 671 | |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 672 | LayerImpl* LayerTreeImpl::FindActiveTreeLayerById(int id) { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 673 | LayerTreeImpl* tree = layer_tree_host_impl_->active_tree(); |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 674 | if (!tree) |
| 675 | return NULL; |
| 676 | return tree->LayerById(id); |
| 677 | } |
| 678 | |
| 679 | LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 680 | LayerTreeImpl* tree = layer_tree_host_impl_->pending_tree(); |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 681 | if (!tree) |
| 682 | return NULL; |
| 683 | return tree->LayerById(id); |
| 684 | } |
| 685 | |
[email protected] | f677653 | 2012-12-21 20:24:33 | [diff] [blame] | 686 | int LayerTreeImpl::MaxTextureSize() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 687 | return layer_tree_host_impl_->GetRendererCapabilities().max_texture_size; |
[email protected] | f677653 | 2012-12-21 20:24:33 | [diff] [blame] | 688 | } |
| 689 | |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 690 | bool LayerTreeImpl::PinchGestureActive() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 691 | return layer_tree_host_impl_->pinch_gesture_active(); |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 692 | } |
| 693 | |
[email protected] | fb7425a | 2013-04-22 16:28:55 | [diff] [blame] | 694 | base::TimeTicks LayerTreeImpl::CurrentFrameTimeTicks() const { |
| 695 | return layer_tree_host_impl_->CurrentFrameTimeTicks(); |
| 696 | } |
| 697 | |
[email protected] | c92195e | 2014-05-07 18:18:49 | [diff] [blame] | 698 | base::TimeDelta LayerTreeImpl::begin_impl_frame_interval() const { |
| 699 | return layer_tree_host_impl_->begin_impl_frame_interval(); |
| 700 | } |
| 701 | |
[email protected] | d7eb8c7 | 2013-03-23 22:57:13 | [diff] [blame] | 702 | void LayerTreeImpl::SetNeedsCommit() { |
| 703 | layer_tree_host_impl_->SetNeedsCommit(); |
| 704 | } |
| 705 | |
[email protected] | 54af0352 | 2013-09-05 00:43:28 | [diff] [blame] | 706 | gfx::Size LayerTreeImpl::DrawViewportSize() const { |
| 707 | return layer_tree_host_impl_->DrawViewportSize(); |
| 708 | } |
| 709 | |
[email protected] | 930ff43b | 2014-05-02 05:24:00 | [diff] [blame] | 710 | scoped_ptr<ScrollbarAnimationController> |
| 711 | LayerTreeImpl::CreateScrollbarAnimationController(LayerImpl* scrolling_layer) { |
| 712 | DCHECK(settings().scrollbar_fade_delay_ms); |
| 713 | DCHECK(settings().scrollbar_fade_duration_ms); |
| 714 | base::TimeDelta delay = |
| 715 | base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_delay_ms); |
| 716 | base::TimeDelta duration = |
| 717 | base::TimeDelta::FromMilliseconds(settings().scrollbar_fade_duration_ms); |
| 718 | switch (settings().scrollbar_animator) { |
| 719 | case LayerTreeSettings::LinearFade: { |
| 720 | return ScrollbarAnimationControllerLinearFade::Create( |
| 721 | scrolling_layer, layer_tree_host_impl_, delay, duration) |
| 722 | .PassAs<ScrollbarAnimationController>(); |
| 723 | } |
| 724 | case LayerTreeSettings::Thinning: { |
| 725 | return ScrollbarAnimationControllerThinning::Create( |
| 726 | scrolling_layer, layer_tree_host_impl_, delay, duration) |
| 727 | .PassAs<ScrollbarAnimationController>(); |
| 728 | } |
| 729 | case LayerTreeSettings::NoAnimator: |
| 730 | NOTREACHED(); |
| 731 | break; |
| 732 | } |
| 733 | return scoped_ptr<ScrollbarAnimationController>(); |
[email protected] | 2ea5aba | 2013-09-11 14:26:56 | [diff] [blame] | 734 | } |
| 735 | |
[email protected] | b8384e2 | 2013-12-03 02:20:48 | [diff] [blame] | 736 | void LayerTreeImpl::DidAnimateScrollOffset() { |
| 737 | layer_tree_host_impl_->DidAnimateScrollOffset(); |
| 738 | } |
| 739 | |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 740 | void LayerTreeImpl::SetNeedsRedraw() { |
[email protected] | 59adb11 | 2013-04-09 04:48:44 | [diff] [blame] | 741 | layer_tree_host_impl_->SetNeedsRedraw(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 742 | } |
| 743 | |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 744 | const LayerTreeDebugState& LayerTreeImpl::debug_state() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 745 | return layer_tree_host_impl_->debug_state(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | float LayerTreeImpl::device_scale_factor() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 749 | return layer_tree_host_impl_->device_scale_factor(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 750 | } |
| 751 | |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 752 | DebugRectHistory* LayerTreeImpl::debug_rect_history() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 753 | return layer_tree_host_impl_->debug_rect_history(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 754 | } |
| 755 | |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 756 | AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { |
[email protected] | c1bb5af | 2013-03-13 19:06:27 | [diff] [blame] | 757 | return layer_tree_host_impl_->animation_registrar(); |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 758 | } |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 759 | |
[email protected] | 8c569022 | 2013-02-15 17:36:43 | [diff] [blame] | 760 | scoped_ptr<base::Value> LayerTreeImpl::AsValue() const { |
[email protected] | f6742f5 | 2013-05-08 23:52:22 | [diff] [blame] | 761 | scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 762 | TracedValue::MakeDictIntoImplicitSnapshot( |
| 763 | state.get(), "cc::LayerTreeImpl", this); |
| 764 | |
| 765 | state->Set("root_layer", root_layer_->AsValue().release()); |
| 766 | |
| 767 | scoped_ptr<base::ListValue> render_surface_layer_list(new base::ListValue()); |
[email protected] | ba1b33e | 2014-02-28 16:44:51 | [diff] [blame] | 768 | typedef LayerIterator<LayerImpl> LayerIteratorType; |
[email protected] | 71dfcc7 | 2013-03-20 21:30:09 | [diff] [blame] | 769 | LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); |
| 770 | for (LayerIteratorType it = LayerIteratorType::Begin( |
[email protected] | 8c569022 | 2013-02-15 17:36:43 | [diff] [blame] | 771 | &render_surface_layer_list_); it != end; ++it) { |
[email protected] | 71dfcc7 | 2013-03-20 21:30:09 | [diff] [blame] | 772 | if (!it.represents_itself()) |
[email protected] | 8c569022 | 2013-02-15 17:36:43 | [diff] [blame] | 773 | continue; |
[email protected] | f6742f5 | 2013-05-08 23:52:22 | [diff] [blame] | 774 | render_surface_layer_list->Append(TracedValue::CreateIDRef(*it).release()); |
[email protected] | 8c569022 | 2013-02-15 17:36:43 | [diff] [blame] | 775 | } |
[email protected] | f6742f5 | 2013-05-08 23:52:22 | [diff] [blame] | 776 | |
| 777 | state->Set("render_surface_layer_list", |
| 778 | render_surface_layer_list.release()); |
[email protected] | 8c569022 | 2013-02-15 17:36:43 | [diff] [blame] | 779 | return state.PassAs<base::Value>(); |
| 780 | } |
| 781 | |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 782 | void LayerTreeImpl::SetRootLayerScrollOffsetDelegate( |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 783 | LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) { |
[email protected] | 20d2b74 | 2013-09-26 05:41:34 | [diff] [blame] | 784 | if (root_layer_scroll_offset_delegate_ == root_layer_scroll_offset_delegate) |
| 785 | return; |
| 786 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 787 | if (!root_layer_scroll_offset_delegate) { |
| 788 | // Make sure we remove the proxies from their layers before |
| 789 | // releasing them. |
| 790 | if (InnerViewportScrollLayer()) |
| 791 | InnerViewportScrollLayer()->SetScrollOffsetDelegate(NULL); |
| 792 | if (OuterViewportScrollLayer()) |
| 793 | OuterViewportScrollLayer()->SetScrollOffsetDelegate(NULL); |
| 794 | inner_viewport_scroll_delegate_proxy_.reset(); |
| 795 | outer_viewport_scroll_delegate_proxy_.reset(); |
[email protected] | d35cd7b2 | 2014-01-29 14:32:46 | [diff] [blame] | 796 | } |
| 797 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 798 | root_layer_scroll_offset_delegate_ = root_layer_scroll_offset_delegate; |
| 799 | |
[email protected] | 20d2b74 | 2013-09-26 05:41:34 | [diff] [blame] | 800 | if (root_layer_scroll_offset_delegate_) { |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 801 | root_layer_scroll_offset_delegate_->SetTotalScrollOffset( |
| 802 | TotalScrollOffset()); |
| 803 | root_layer_scroll_offset_delegate_->SetMaxScrollOffset( |
| 804 | TotalMaxScrollOffset()); |
[email protected] | 20d2b74 | 2013-09-26 05:41:34 | [diff] [blame] | 805 | root_layer_scroll_offset_delegate_->SetScrollableSize(ScrollableSize()); |
[email protected] | 68fe60f | 2014-02-12 13:49:11 | [diff] [blame] | 806 | root_layer_scroll_offset_delegate_->SetTotalPageScaleFactorAndLimits( |
| 807 | total_page_scale_factor(), |
| 808 | min_page_scale_factor(), |
| 809 | max_page_scale_factor()); |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 810 | |
| 811 | if (inner_viewport_scroll_layer_) { |
| 812 | inner_viewport_scroll_delegate_proxy_ = make_scoped_ptr( |
| 813 | new LayerScrollOffsetDelegateProxy(InnerViewportScrollLayer(), |
| 814 | root_layer_scroll_offset_delegate_, |
| 815 | this)); |
| 816 | inner_viewport_scroll_layer_->SetScrollOffsetDelegate( |
| 817 | inner_viewport_scroll_delegate_proxy_.get()); |
| 818 | } |
| 819 | |
| 820 | if (outer_viewport_scroll_layer_) { |
| 821 | outer_viewport_scroll_delegate_proxy_ = make_scoped_ptr( |
| 822 | new LayerScrollOffsetDelegateProxy(OuterViewportScrollLayer(), |
| 823 | root_layer_scroll_offset_delegate_, |
| 824 | this)); |
| 825 | outer_viewport_scroll_layer_->SetScrollOffsetDelegate( |
| 826 | outer_viewport_scroll_delegate_proxy_.get()); |
| 827 | } |
[email protected] | 20d2b74 | 2013-09-26 05:41:34 | [diff] [blame] | 828 | } |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 829 | } |
| 830 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 831 | void LayerTreeImpl::UpdateScrollOffsetDelegate() { |
| 832 | DCHECK(InnerViewportScrollLayer()); |
| 833 | DCHECK(root_layer_scroll_offset_delegate_); |
| 834 | |
| 835 | gfx::Vector2dF offset = |
| 836 | inner_viewport_scroll_delegate_proxy_->last_set_scroll_offset(); |
| 837 | |
| 838 | if (OuterViewportScrollLayer()) |
| 839 | offset += outer_viewport_scroll_delegate_proxy_->last_set_scroll_offset(); |
| 840 | |
| 841 | root_layer_scroll_offset_delegate_->SetTotalScrollOffset(offset); |
| 842 | root_layer_scroll_offset_delegate_->SetMaxScrollOffset( |
| 843 | TotalMaxScrollOffset()); |
| 844 | } |
| 845 | |
| 846 | gfx::Vector2dF LayerTreeImpl::GetDelegatedScrollOffset(LayerImpl* layer) { |
| 847 | DCHECK(root_layer_scroll_offset_delegate_); |
| 848 | DCHECK(InnerViewportScrollLayer()); |
| 849 | if (layer == InnerViewportScrollLayer() && !OuterViewportScrollLayer()) |
| 850 | return root_layer_scroll_offset_delegate_->GetTotalScrollOffset(); |
| 851 | |
| 852 | // If we get here, we have both inner/outer viewports, and need to distribute |
| 853 | // the scroll offset between them. |
| 854 | DCHECK(inner_viewport_scroll_delegate_proxy_); |
| 855 | DCHECK(outer_viewport_scroll_delegate_proxy_); |
| 856 | gfx::Vector2dF inner_viewport_offset = |
| 857 | inner_viewport_scroll_delegate_proxy_->last_set_scroll_offset(); |
| 858 | gfx::Vector2dF outer_viewport_offset = |
| 859 | outer_viewport_scroll_delegate_proxy_->last_set_scroll_offset(); |
| 860 | |
| 861 | // It may be nothing has changed. |
| 862 | gfx::Vector2dF delegate_offset = |
| 863 | root_layer_scroll_offset_delegate_->GetTotalScrollOffset(); |
| 864 | if (inner_viewport_offset + outer_viewport_offset == delegate_offset) { |
| 865 | if (layer == InnerViewportScrollLayer()) |
| 866 | return inner_viewport_offset; |
| 867 | else |
| 868 | return outer_viewport_offset; |
| 869 | } |
| 870 | |
| 871 | gfx::Vector2d max_outer_viewport_scroll_offset = |
| 872 | OuterViewportScrollLayer()->MaxScrollOffset(); |
| 873 | |
| 874 | outer_viewport_offset = delegate_offset - inner_viewport_offset; |
| 875 | outer_viewport_offset.SetToMin(max_outer_viewport_scroll_offset); |
| 876 | outer_viewport_offset.SetToMax(gfx::Vector2d()); |
| 877 | |
| 878 | if (layer == OuterViewportScrollLayer()) |
| 879 | return outer_viewport_offset; |
| 880 | |
| 881 | inner_viewport_offset = delegate_offset - outer_viewport_offset; |
| 882 | |
| 883 | return inner_viewport_offset; |
| 884 | } |
| 885 | |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 886 | void LayerTreeImpl::QueueSwapPromise(scoped_ptr<SwapPromise> swap_promise) { |
| 887 | DCHECK(swap_promise); |
| 888 | if (swap_promise_list_.size() > kMaxQueuedSwapPromiseNumber) |
| 889 | BreakSwapPromises(SwapPromise::SWAP_PROMISE_LIST_OVERFLOW); |
| 890 | swap_promise_list_.push_back(swap_promise.Pass()); |
| 891 | } |
| 892 | |
| 893 | void LayerTreeImpl::PassSwapPromises( |
| 894 | ScopedPtrVector<SwapPromise>* new_swap_promise) { |
| 895 | swap_promise_list_.insert_and_take(swap_promise_list_.end(), |
| 896 | *new_swap_promise); |
| 897 | new_swap_promise->clear(); |
| 898 | } |
| 899 | |
[email protected] | d359203a | 2013-11-29 06:16:55 | [diff] [blame] | 900 | void LayerTreeImpl::FinishSwapPromises(CompositorFrameMetadata* metadata) { |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 901 | for (size_t i = 0; i < swap_promise_list_.size(); i++) |
[email protected] | d359203a | 2013-11-29 06:16:55 | [diff] [blame] | 902 | swap_promise_list_[i]->DidSwap(metadata); |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 903 | swap_promise_list_.clear(); |
| 904 | } |
| 905 | |
| 906 | void LayerTreeImpl::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { |
| 907 | for (size_t i = 0; i < swap_promise_list_.size(); i++) |
| 908 | swap_promise_list_[i]->DidNotSwap(reason); |
| 909 | swap_promise_list_.clear(); |
| 910 | } |
| 911 | |
[email protected] | c48536a5 | 2013-09-14 00:02:08 | [diff] [blame] | 912 | void LayerTreeImpl::DidModifyTilePriorities() { |
| 913 | layer_tree_host_impl_->DidModifyTilePriorities(); |
[email protected] | fcb846d | 2013-05-22 01:42:36 | [diff] [blame] | 914 | } |
| 915 | |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 916 | void LayerTreeImpl::set_ui_resource_request_queue( |
| 917 | const UIResourceRequestQueue& queue) { |
| 918 | ui_resource_request_queue_ = queue; |
| 919 | } |
| 920 | |
| 921 | ResourceProvider::ResourceId LayerTreeImpl::ResourceIdForUIResource( |
| 922 | UIResourceId uid) const { |
| 923 | return layer_tree_host_impl_->ResourceIdForUIResource(uid); |
| 924 | } |
| 925 | |
[email protected] | 709c954 | 2013-10-26 01:43:51 | [diff] [blame] | 926 | bool LayerTreeImpl::IsUIResourceOpaque(UIResourceId uid) const { |
| 927 | return layer_tree_host_impl_->IsUIResourceOpaque(uid); |
| 928 | } |
| 929 | |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 930 | void LayerTreeImpl::ProcessUIResourceRequestQueue() { |
| 931 | while (ui_resource_request_queue_.size() > 0) { |
| 932 | UIResourceRequest req = ui_resource_request_queue_.front(); |
| 933 | ui_resource_request_queue_.pop_front(); |
| 934 | |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 935 | switch (req.GetType()) { |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 936 | case UIResourceRequest::UIResourceCreate: |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 937 | layer_tree_host_impl_->CreateUIResource(req.GetId(), req.GetBitmap()); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 938 | break; |
| 939 | case UIResourceRequest::UIResourceDelete: |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 940 | layer_tree_host_impl_->DeleteUIResource(req.GetId()); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 941 | break; |
[email protected] | f28d64d | 2013-08-27 04:17:45 | [diff] [blame] | 942 | case UIResourceRequest::UIResourceInvalidRequest: |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 943 | NOTREACHED(); |
| 944 | break; |
| 945 | } |
| 946 | } |
[email protected] | 127bdc1a | 2013-09-11 01:44:48 | [diff] [blame] | 947 | |
| 948 | // If all UI resource evictions were not recreated by processing this queue, |
| 949 | // then another commit is required. |
| 950 | if (layer_tree_host_impl_->EvictedUIResourcesExist()) |
| 951 | layer_tree_host_impl_->SetNeedsCommit(); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 952 | } |
| 953 | |
[email protected] | 30fe19ff | 2013-07-04 00:54:45 | [diff] [blame] | 954 | void LayerTreeImpl::AddLayerWithCopyOutputRequest(LayerImpl* layer) { |
| 955 | // Only the active tree needs to know about layers with copy requests, as |
| 956 | // they are aborted if not serviced during draw. |
| 957 | DCHECK(IsActiveTree()); |
| 958 | |
[email protected] | a4ee1281 | 2014-02-06 17:33:38 | [diff] [blame] | 959 | // DCHECK(std::find(layers_with_copy_output_request_.begin(), |
| 960 | // layers_with_copy_output_request_.end(), |
| 961 | // layer) == layers_with_copy_output_request_.end()); |
| 962 | // TODO(danakj): Remove this once crash is found crbug.com/309777 |
| 963 | for (size_t i = 0; i < layers_with_copy_output_request_.size(); ++i) { |
| 964 | CHECK(layers_with_copy_output_request_[i] != layer) |
| 965 | << i << " of " << layers_with_copy_output_request_.size(); |
| 966 | } |
[email protected] | 30fe19ff | 2013-07-04 00:54:45 | [diff] [blame] | 967 | layers_with_copy_output_request_.push_back(layer); |
| 968 | } |
| 969 | |
| 970 | void LayerTreeImpl::RemoveLayerWithCopyOutputRequest(LayerImpl* layer) { |
| 971 | // Only the active tree needs to know about layers with copy requests, as |
| 972 | // they are aborted if not serviced during draw. |
| 973 | DCHECK(IsActiveTree()); |
| 974 | |
| 975 | std::vector<LayerImpl*>::iterator it = std::find( |
| 976 | layers_with_copy_output_request_.begin(), |
| 977 | layers_with_copy_output_request_.end(), |
| 978 | layer); |
| 979 | DCHECK(it != layers_with_copy_output_request_.end()); |
[email protected] | f5de9e5b | 2013-07-30 22:26:57 | [diff] [blame] | 980 | layers_with_copy_output_request_.erase(it); |
[email protected] | a4ee1281 | 2014-02-06 17:33:38 | [diff] [blame] | 981 | |
| 982 | // TODO(danakj): Remove this once crash is found crbug.com/309777 |
| 983 | for (size_t i = 0; i < layers_with_copy_output_request_.size(); ++i) { |
| 984 | CHECK(layers_with_copy_output_request_[i] != layer) |
| 985 | << i << " of " << layers_with_copy_output_request_.size(); |
| 986 | } |
[email protected] | 30fe19ff | 2013-07-04 00:54:45 | [diff] [blame] | 987 | } |
| 988 | |
[email protected] | 5352637 | 2013-12-07 04:31:50 | [diff] [blame] | 989 | const std::vector<LayerImpl*>& LayerTreeImpl::LayersWithCopyOutputRequest() |
[email protected] | 30fe19ff | 2013-07-04 00:54:45 | [diff] [blame] | 990 | const { |
| 991 | // Only the active tree needs to know about layers with copy requests, as |
| 992 | // they are aborted if not serviced during draw. |
| 993 | DCHECK(IsActiveTree()); |
| 994 | |
| 995 | return layers_with_copy_output_request_; |
| 996 | } |
| 997 | |
[email protected] | ca2902e9 | 2013-03-28 01:45:35 | [diff] [blame] | 998 | } // namespace cc |