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