blob: e58119cd1060013e2dc4496b5928caafd203501a [file] [log] [blame]
[email protected]3b31c6ac2012-12-06 21:27:291// 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]556fd292013-03-18 08:03:045#include "cc/trees/layer_tree_impl.h"
[email protected]3b31c6ac2012-12-06 21:27:296
[email protected]76ffd9e2012-12-20 19:12:477#include "base/debug/trace_event.h"
[email protected]95e4e1a02013-03-18 07:09:098#include "cc/animation/keyframed_animation_curve.h"
9#include "cc/animation/scrollbar_animation_controller.h"
[email protected]f6742f52013-05-08 23:52:2210#include "cc/debug/traced_value.h"
[email protected]cc3cfaa2013-03-18 09:05:5211#include "cc/layers/heads_up_display_layer_impl.h"
[email protected]50761e92013-03-29 20:51:2812#include "cc/layers/render_surface_impl.h"
[email protected]cc3cfaa2013-03-18 09:05:5213#include "cc/layers/scrollbar_layer_impl.h"
[email protected]556fd292013-03-18 08:03:0414#include "cc/trees/layer_tree_host_common.h"
15#include "cc/trees/layer_tree_host_impl.h"
[email protected]ffb2720f2013-03-15 19:18:3716#include "ui/gfx/size_conversions.h"
[email protected]caa567d2012-12-20 07:56:1617#include "ui/gfx/vector2d_conversions.h"
[email protected]3b31c6ac2012-12-06 21:27:2918
19namespace cc {
20
[email protected]8bef40572012-12-11 21:38:0821LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl)
[email protected]db8259f2013-02-01 05:25:0422 : layer_tree_host_impl_(layer_tree_host_impl),
23 source_frame_number_(-1),
24 hud_layer_(0),
[email protected]1960a712013-04-30 17:06:4725 root_scroll_layer_(NULL),
26 currently_scrolling_layer_(NULL),
27 root_layer_scroll_offset_delegate_(NULL),
[email protected]db8259f2013-02-01 05:25:0428 background_color_(0),
29 has_transparent_background_(false),
30 page_scale_factor_(1),
31 page_scale_delta_(1),
32 sent_page_scale_delta_(1),
33 min_page_scale_factor_(0),
34 max_page_scale_factor_(0),
35 scrolling_layer_id_from_previous_tree_(0),
36 contents_textures_purged_(false),
[email protected]318822852013-02-14 00:54:2737 viewport_size_invalid_(false),
[email protected]db8259f2013-02-01 05:25:0438 needs_update_draw_properties_(true),
39 needs_full_tree_sync_(true) {
[email protected]3b31c6ac2012-12-06 21:27:2940}
41
42LayerTreeImpl::~LayerTreeImpl() {
[email protected]361bc00d2012-12-14 07:03:2443 // Need to explicitly clear the tree prior to destroying this so that
44 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor.
45 root_layer_.reset();
[email protected]3b31c6ac2012-12-06 21:27:2946}
47
[email protected]3c0a3252013-03-18 04:24:3648static LayerImpl* FindRootScrollLayerRecursive(LayerImpl* layer) {
49 if (!layer)
50 return NULL;
[email protected]3b31c6ac2012-12-06 21:27:2951
[email protected]3c0a3252013-03-18 04:24:3652 if (layer->scrollable())
53 return layer;
[email protected]3b31c6ac2012-12-06 21:27:2954
[email protected]3c0a3252013-03-18 04:24:3655 for (size_t i = 0; i < layer->children().size(); ++i) {
56 LayerImpl* found = FindRootScrollLayerRecursive(layer->children()[i]);
57 if (found)
58 return found;
59 }
[email protected]3b31c6ac2012-12-06 21:27:2960
[email protected]3c0a3252013-03-18 04:24:3661 return NULL;
[email protected]3b31c6ac2012-12-06 21:27:2962}
63
64void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) {
[email protected]1960a712013-04-30 17:06:4765 if (root_scroll_layer_)
66 root_scroll_layer_->SetScrollOffsetDelegate(NULL);
[email protected]3b31c6ac2012-12-06 21:27:2967 root_layer_ = layer.Pass();
[email protected]5c4824e12013-01-12 16:34:5368 currently_scrolling_layer_ = NULL;
[email protected]1960a712013-04-30 17:06:4769 root_scroll_layer_ = NULL;
[email protected]5c4824e12013-01-12 16:34:5370
[email protected]c1bb5af2013-03-13 19:06:2771 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
[email protected]5c4824e12013-01-12 16:34:5372}
73
74void LayerTreeImpl::FindRootScrollLayer() {
[email protected]3c0a3252013-03-18 04:24:3675 root_scroll_layer_ = FindRootScrollLayerRecursive(root_layer_.get());
[email protected]3b31c6ac2012-12-06 21:27:2976
[email protected]1960a712013-04-30 17:06:4777 if (root_scroll_layer_) {
78 root_scroll_layer_->SetScrollOffsetDelegate(
79 root_layer_scroll_offset_delegate_);
80 }
81
[email protected]3b31c6ac2012-12-06 21:27:2982 if (root_layer_ && scrolling_layer_id_from_previous_tree_) {
[email protected]6ba914122013-03-22 16:26:3983 currently_scrolling_layer_ = LayerTreeHostCommon::FindLayerInSubtree(
[email protected]3b31c6ac2012-12-06 21:27:2984 root_layer_.get(),
85 scrolling_layer_id_from_previous_tree_);
86 }
87
88 scrolling_layer_id_from_previous_tree_ = 0;
[email protected]3b31c6ac2012-12-06 21:27:2989}
90
91scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() {
92 // Clear all data structures that have direct references to the layer tree.
93 scrolling_layer_id_from_previous_tree_ =
94 currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0;
[email protected]1960a712013-04-30 17:06:4795 if (root_scroll_layer_)
96 root_scroll_layer_->SetScrollOffsetDelegate(NULL);
[email protected]69b50ec2013-01-19 04:58:0197 root_scroll_layer_ = NULL;
[email protected]3b31c6ac2012-12-06 21:27:2998 currently_scrolling_layer_ = NULL;
99
[email protected]76ffd9e2012-12-20 19:12:47100 render_surface_layer_list_.clear();
[email protected]615c78a2013-01-24 23:44:16101 set_needs_update_draw_properties();
[email protected]3b31c6ac2012-12-06 21:27:29102 return root_layer_.Pass();
103}
104
[email protected]7aba6662013-03-12 10:17:34105void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) {
[email protected]e4c3c87a2013-04-22 02:28:40106 target_tree->SetLatencyInfo(latency_info_);
107 latency_info_.Clear();
[email protected]c60279472013-01-30 12:10:51108 target_tree->SetPageScaleFactorAndLimits(
109 page_scale_factor(), min_page_scale_factor(), max_page_scale_factor());
110 target_tree->SetPageScaleDelta(
111 target_tree->page_scale_delta() / target_tree->sent_page_scale_delta());
112 target_tree->set_sent_page_scale_delta(1);
113
114 // This should match the property synchronization in
115 // LayerTreeHost::finishCommitOnImplThread().
116 target_tree->set_source_frame_number(source_frame_number());
117 target_tree->set_background_color(background_color());
118 target_tree->set_has_transparent_background(has_transparent_background());
119
120 if (ContentsTexturesPurged())
121 target_tree->SetContentsTexturesPurged();
122 else
123 target_tree->ResetContentsTexturesPurged();
124
[email protected]318822852013-02-14 00:54:27125 if (ViewportSizeInvalid())
126 target_tree->SetViewportSizeInvalid();
127 else
128 target_tree->ResetViewportSizeInvalid();
129
[email protected]c60279472013-01-30 12:10:51130 if (hud_layer())
131 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(
[email protected]6ba914122013-03-22 16:26:39132 LayerTreeHostCommon::FindLayerInSubtree(
[email protected]c1bb5af2013-03-13 19:06:27133 target_tree->root_layer(), hud_layer()->id())));
[email protected]c60279472013-01-30 12:10:51134 else
135 target_tree->set_hud_layer(NULL);
136}
137
[email protected]ffb2720f2013-03-15 19:18:37138LayerImpl* LayerTreeImpl::RootScrollLayer() const {
[email protected]69b50ec2013-01-19 04:58:01139 DCHECK(IsActiveTree());
140 return root_scroll_layer_;
141}
142
[email protected]ffb2720f2013-03-15 19:18:37143LayerImpl* LayerTreeImpl::RootClipLayer() const {
144 return root_scroll_layer_ ? root_scroll_layer_->parent() : NULL;
145}
146
147LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() const {
[email protected]69b50ec2013-01-19 04:58:01148 DCHECK(IsActiveTree());
149 return currently_scrolling_layer_;
150}
151
[email protected]0fc818e2013-03-18 06:45:20152void LayerTreeImpl::SetCurrentlyScrollingLayer(LayerImpl* layer) {
153 if (currently_scrolling_layer_ == layer)
154 return;
155
156 if (currently_scrolling_layer_ &&
157 currently_scrolling_layer_->scrollbar_animation_controller())
[email protected]6bc09e82013-03-19 03:48:35158 currently_scrolling_layer_->scrollbar_animation_controller()->
[email protected]fb7425a2013-04-22 16:28:55159 DidScrollGestureEnd(CurrentFrameTimeTicks());
[email protected]0fc818e2013-03-18 06:45:20160 currently_scrolling_layer_ = layer;
161 if (layer && layer->scrollbar_animation_controller())
[email protected]6bc09e82013-03-19 03:48:35162 layer->scrollbar_animation_controller()->DidScrollGestureBegin();
[email protected]0fc818e2013-03-18 06:45:20163}
164
[email protected]3b31c6ac2012-12-06 21:27:29165void LayerTreeImpl::ClearCurrentlyScrollingLayer() {
[email protected]0fc818e2013-03-18 06:45:20166 SetCurrentlyScrollingLayer(NULL);
[email protected]3b31c6ac2012-12-06 21:27:29167 scrolling_layer_id_from_previous_tree_ = 0;
168}
169
[email protected]c60279472013-01-30 12:10:51170void LayerTreeImpl::SetPageScaleFactorAndLimits(float page_scale_factor,
[email protected]3c0a3252013-03-18 04:24:36171 float min_page_scale_factor, float max_page_scale_factor) {
[email protected]c60279472013-01-30 12:10:51172 if (!page_scale_factor)
173 return;
174
175 min_page_scale_factor_ = min_page_scale_factor;
176 max_page_scale_factor_ = max_page_scale_factor;
177 page_scale_factor_ = page_scale_factor;
178}
179
[email protected]3c0a3252013-03-18 04:24:36180void LayerTreeImpl::SetPageScaleDelta(float delta) {
[email protected]c60279472013-01-30 12:10:51181 // Clamp to the current min/max limits.
182 float total = page_scale_factor_ * delta;
183 if (min_page_scale_factor_ && total < min_page_scale_factor_)
184 delta = min_page_scale_factor_ / page_scale_factor_;
185 else if (max_page_scale_factor_ && total > max_page_scale_factor_)
186 delta = max_page_scale_factor_ / page_scale_factor_;
187
188 if (delta == page_scale_delta_)
189 return;
190
191 page_scale_delta_ = delta;
192
193 if (IsActiveTree()) {
[email protected]c1bb5af2013-03-13 19:06:27194 LayerTreeImpl* pending_tree = layer_tree_host_impl_->pending_tree();
[email protected]c60279472013-01-30 12:10:51195 if (pending_tree) {
196 DCHECK_EQ(1, pending_tree->sent_page_scale_delta());
[email protected]ca2902e92013-03-28 01:45:35197 pending_tree->SetPageScaleDelta(
198 page_scale_delta_ / sent_page_scale_delta_);
[email protected]c60279472013-01-30 12:10:51199 }
200 }
201
202 UpdateMaxScrollOffset();
203 set_needs_update_draw_properties();
204}
205
[email protected]257abfa82013-01-29 23:47:24206gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const {
[email protected]ffb2720f2013-03-15 19:18:37207 return gfx::ScaleSize(layer_tree_host_impl_->VisibleViewportSize(),
208 1.0f / total_page_scale_factor());
[email protected]257abfa82013-01-29 23:47:24209}
210
[email protected]caa567d2012-12-20 07:56:16211void LayerTreeImpl::UpdateMaxScrollOffset() {
[email protected]69b50ec2013-01-19 04:58:01212 if (!root_scroll_layer_ || !root_scroll_layer_->children().size())
[email protected]caa567d2012-12-20 07:56:16213 return;
214
[email protected]42ccdbef2013-01-21 07:54:54215 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() -
[email protected]257abfa82013-01-29 23:47:24216 gfx::RectF(ScrollableViewportSize()).bottom_right();
[email protected]caa567d2012-12-20 07:56:16217
218 // The viewport may be larger than the contents in some cases, such as
219 // having a vertical scrollbar but no horizontal overflow.
220 max_scroll.ClampToMin(gfx::Vector2dF());
221
[email protected]7aba6662013-03-12 10:17:34222 root_scroll_layer_->SetMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll));
[email protected]caa567d2012-12-20 07:56:16223}
224
[email protected]ffb2720f2013-03-15 19:18:37225void LayerTreeImpl::UpdateSolidColorScrollbars() {
[email protected]8e0176d2013-03-21 03:14:52226 DCHECK(settings().solid_color_scrollbars);
[email protected]ffb2720f2013-03-15 19:18:37227
228 LayerImpl* root_scroll = RootScrollLayer();
[email protected]ab5f4a92013-03-19 20:08:24229 DCHECK(root_scroll);
230 DCHECK(IsActiveTree());
[email protected]ffb2720f2013-03-15 19:18:37231
232 gfx::RectF scrollable_viewport(
233 gfx::PointAtOffsetFromOrigin(root_scroll->TotalScrollOffset()),
234 ScrollableViewportSize());
235 float vertical_adjust = 0.0f;
236 if (RootClipLayer())
237 vertical_adjust = layer_tree_host_impl_->VisibleViewportSize().height() -
238 RootClipLayer()->bounds().height();
239 if (ScrollbarLayerImpl* horiz = root_scroll->horizontal_scrollbar_layer()) {
240 horiz->set_vertical_adjust(vertical_adjust);
241 horiz->SetViewportWithinScrollableArea(scrollable_viewport,
242 ScrollableSize());
243 }
244 if (ScrollbarLayerImpl* vertical = root_scroll->vertical_scrollbar_layer()) {
245 vertical->set_vertical_adjust(vertical_adjust);
246 vertical->SetViewportWithinScrollableArea(scrollable_viewport,
247 ScrollableSize());
248 }
249}
250
[email protected]7d19dc342013-05-02 22:02:04251void LayerTreeImpl::UpdateDrawProperties() {
[email protected]fe956c9c42013-04-09 04:26:33252 if (IsActiveTree() && RootScrollLayer() && RootClipLayer())
253 UpdateRootScrollLayerSizeDelta();
254
[email protected]ca2902e92013-03-28 01:45:35255 if (settings().solid_color_scrollbars &&
256 IsActiveTree() &&
257 RootScrollLayer()) {
[email protected]ffb2720f2013-03-15 19:18:37258 UpdateSolidColorScrollbars();
259
260 // The top controls manager is incompatible with the WebKit-created cliprect
261 // because it can bring into view a larger amount of content when it
262 // hides. It's safe to deactivate the clip rect if no non-overlay scrollbars
263 // are present.
[email protected]ab5f4a92013-03-19 20:08:24264 if (RootClipLayer() && layer_tree_host_impl_->top_controls_manager())
265 RootClipLayer()->SetMasksToBounds(false);
[email protected]ffb2720f2013-03-15 19:18:37266 }
267
[email protected]615c78a2013-01-24 23:44:16268 needs_update_draw_properties_ = false;
[email protected]76ffd9e2012-12-20 19:12:47269 render_surface_layer_list_.clear();
[email protected]615c78a2013-01-24 23:44:16270
[email protected]ed511b8d2013-03-25 03:29:29271 // For max_texture_size.
[email protected]615c78a2013-01-24 23:44:16272 if (!layer_tree_host_impl_->renderer())
273 return;
274
[email protected]c1bb5af2013-03-13 19:06:27275 if (!root_layer())
[email protected]76ffd9e2012-12-20 19:12:47276 return;
277
[email protected]76ffd9e2012-12-20 19:12:47278 {
[email protected]c1bb5af2013-03-13 19:06:27279 TRACE_EVENT1("cc",
280 "LayerTreeImpl::UpdateDrawProperties",
281 "IsActive",
282 IsActiveTree());
[email protected]6ba914122013-03-22 16:26:39283 LayerTreeHostCommon::CalculateDrawProperties(
[email protected]c1bb5af2013-03-13 19:06:27284 root_layer(),
[email protected]76ffd9e2012-12-20 19:12:47285 device_viewport_size(),
286 device_scale_factor(),
[email protected]c60279472013-01-30 12:10:51287 total_page_scale_factor(),
[email protected]f2136262013-04-26 21:10:19288 root_scroll_layer_,
[email protected]f6776532012-12-21 20:24:33289 MaxTextureSize(),
[email protected]8e0176d2013-03-21 03:14:52290 settings().can_use_lcd_text,
[email protected]35a99a12013-05-09 23:52:29291 settings().layer_transforms_should_scale_layer_contents,
[email protected]7d19dc342013-05-02 22:02:04292 &render_surface_layer_list_);
[email protected]76ffd9e2012-12-20 19:12:47293 }
[email protected]615c78a2013-01-24 23:44:16294
295 DCHECK(!needs_update_draw_properties_) <<
[email protected]7d19dc342013-05-02 22:02:04296 "CalcDrawProperties should not set_needs_update_draw_properties()";
[email protected]76ffd9e2012-12-20 19:12:47297}
298
[email protected]3c0a3252013-03-18 04:24:36299static void ClearRenderSurfacesOnLayerImplRecursive(LayerImpl* current) {
300 DCHECK(current);
301 for (size_t i = 0; i < current->children().size(); ++i)
302 ClearRenderSurfacesOnLayerImplRecursive(current->children()[i]);
303 current->ClearRenderSurface();
[email protected]76ffd9e2012-12-20 19:12:47304}
305
306void LayerTreeImpl::ClearRenderSurfaces() {
[email protected]2a61ad52013-05-13 14:01:29307 if (root_layer() == NULL) {
308 DCHECK(render_surface_layer_list_.empty());
309 return;
310 }
[email protected]c1bb5af2013-03-13 19:06:27311 ClearRenderSurfacesOnLayerImplRecursive(root_layer());
[email protected]76ffd9e2012-12-20 19:12:47312 render_surface_layer_list_.clear();
[email protected]615c78a2013-01-24 23:44:16313 set_needs_update_draw_properties();
[email protected]76ffd9e2012-12-20 19:12:47314}
315
[email protected]50761e92013-03-29 20:51:28316const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const {
[email protected]76ffd9e2012-12-20 19:12:47317 // If this assert triggers, then the list is dirty.
[email protected]615c78a2013-01-24 23:44:16318 DCHECK(!needs_update_draw_properties_);
[email protected]76ffd9e2012-12-20 19:12:47319 return render_surface_layer_list_;
320}
321
[email protected]42ccdbef2013-01-21 07:54:54322gfx::Size LayerTreeImpl::ScrollableSize() const {
[email protected]c4d467a2013-01-21 03:21:01323 if (!root_scroll_layer_ || root_scroll_layer_->children().empty())
[email protected]caa567d2012-12-20 07:56:16324 return gfx::Size();
[email protected]c4d467a2013-01-21 03:21:01325 return root_scroll_layer_->children()[0]->bounds();
[email protected]caa567d2012-12-20 07:56:16326}
327
[email protected]361bc00d2012-12-14 07:03:24328LayerImpl* LayerTreeImpl::LayerById(int id) {
329 LayerIdMap::iterator iter = layer_id_map_.find(id);
330 return iter != layer_id_map_.end() ? iter->second : NULL;
331}
332
333void LayerTreeImpl::RegisterLayer(LayerImpl* layer) {
334 DCHECK(!LayerById(layer->id()));
335 layer_id_map_[layer->id()] = layer;
336}
337
338void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) {
339 DCHECK(LayerById(layer->id()));
340 layer_id_map_.erase(layer->id());
341}
342
[email protected]ed511b8d2013-03-25 03:29:29343void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pending_tree) {
[email protected]1e0f8d62013-01-09 07:41:35344 int id = currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0;
[email protected]2a61ad52013-05-13 14:01:29345 LayerImpl* pending_scrolling_layer_twin = NULL;
346 if (pending_tree->root_layer()) {
347 pending_scrolling_layer_twin =
348 LayerTreeHostCommon::FindLayerInSubtree(pending_tree->root_layer(), id);
349 }
350 pending_tree->SetCurrentlyScrollingLayer(pending_scrolling_layer_twin);
[email protected]1e0f8d62013-01-09 07:41:35351}
352
[email protected]37386f052013-01-13 00:42:22353static void DidBecomeActiveRecursive(LayerImpl* layer) {
[email protected]7aba6662013-03-12 10:17:34354 layer->DidBecomeActive();
[email protected]37386f052013-01-13 00:42:22355 for (size_t i = 0; i < layer->children().size(); ++i)
356 DidBecomeActiveRecursive(layer->children()[i]);
357}
358
359void LayerTreeImpl::DidBecomeActive() {
[email protected]c1bb5af2013-03-13 19:06:27360 if (root_layer())
361 DidBecomeActiveRecursive(root_layer());
[email protected]69b50ec2013-01-19 04:58:01362 FindRootScrollLayer();
363 UpdateMaxScrollOffset();
[email protected]37386f052013-01-13 00:42:22364}
365
[email protected]6f90b9e2013-01-17 23:42:00366bool LayerTreeImpl::ContentsTexturesPurged() const {
367 return contents_textures_purged_;
368}
369
370void LayerTreeImpl::SetContentsTexturesPurged() {
371 contents_textures_purged_ = true;
[email protected]c1bb5af2013-03-13 19:06:27372 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
[email protected]6f90b9e2013-01-17 23:42:00373}
374
375void LayerTreeImpl::ResetContentsTexturesPurged() {
376 contents_textures_purged_ = false;
[email protected]c1bb5af2013-03-13 19:06:27377 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
[email protected]6f90b9e2013-01-17 23:42:00378}
379
[email protected]318822852013-02-14 00:54:27380bool LayerTreeImpl::ViewportSizeInvalid() const {
381 return viewport_size_invalid_;
382}
383
384void LayerTreeImpl::SetViewportSizeInvalid() {
385 viewport_size_invalid_ = true;
[email protected]c1bb5af2013-03-13 19:06:27386 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
[email protected]318822852013-02-14 00:54:27387}
388
389void LayerTreeImpl::ResetViewportSizeInvalid() {
390 viewport_size_invalid_ = false;
[email protected]c1bb5af2013-03-13 19:06:27391 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
[email protected]318822852013-02-14 00:54:27392}
393
[email protected]48871fc2013-01-23 07:36:51394Proxy* LayerTreeImpl::proxy() const {
395 return layer_tree_host_impl_->proxy();
396}
397
[email protected]ff762fb2012-12-12 19:18:37398const LayerTreeSettings& LayerTreeImpl::settings() const {
[email protected]c1bb5af2013-03-13 19:06:27399 return layer_tree_host_impl_->settings();
[email protected]ff762fb2012-12-12 19:18:37400}
401
[email protected]ed511b8d2013-03-25 03:29:29402const RendererCapabilities& LayerTreeImpl::GetRendererCapabilities() const {
[email protected]c1bb5af2013-03-13 19:06:27403 return layer_tree_host_impl_->GetRendererCapabilities();
[email protected]bf5b3a02013-02-13 02:02:52404}
405
[email protected]ff762fb2012-12-12 19:18:37406OutputSurface* LayerTreeImpl::output_surface() const {
[email protected]c1bb5af2013-03-13 19:06:27407 return layer_tree_host_impl_->output_surface();
[email protected]ff762fb2012-12-12 19:18:37408}
409
410ResourceProvider* LayerTreeImpl::resource_provider() const {
[email protected]c1bb5af2013-03-13 19:06:27411 return layer_tree_host_impl_->resource_provider();
[email protected]ff762fb2012-12-12 19:18:37412}
413
414TileManager* LayerTreeImpl::tile_manager() const {
[email protected]c1bb5af2013-03-13 19:06:27415 return layer_tree_host_impl_->tile_manager();
[email protected]ff762fb2012-12-12 19:18:37416}
417
418FrameRateCounter* LayerTreeImpl::frame_rate_counter() const {
[email protected]c1bb5af2013-03-13 19:06:27419 return layer_tree_host_impl_->fps_counter();
[email protected]ff762fb2012-12-12 19:18:37420}
421
[email protected]71691c22013-01-18 03:14:22422PaintTimeCounter* LayerTreeImpl::paint_time_counter() const {
[email protected]c1bb5af2013-03-13 19:06:27423 return layer_tree_host_impl_->paint_time_counter();
[email protected]71691c22013-01-18 03:14:22424}
425
[email protected]1191d9d2013-02-02 06:00:33426MemoryHistory* LayerTreeImpl::memory_history() const {
[email protected]c1bb5af2013-03-13 19:06:27427 return layer_tree_host_impl_->memory_history();
[email protected]1191d9d2013-02-02 06:00:33428}
429
[email protected]f117a4c2012-12-16 04:53:10430bool LayerTreeImpl::IsActiveTree() const {
[email protected]c1bb5af2013-03-13 19:06:27431 return layer_tree_host_impl_->active_tree() == this;
[email protected]f117a4c2012-12-16 04:53:10432}
433
434bool LayerTreeImpl::IsPendingTree() const {
[email protected]c1bb5af2013-03-13 19:06:27435 return layer_tree_host_impl_->pending_tree() == this;
[email protected]f117a4c2012-12-16 04:53:10436}
437
[email protected]48871fc2013-01-23 07:36:51438bool LayerTreeImpl::IsRecycleTree() const {
[email protected]c1bb5af2013-03-13 19:06:27439 return layer_tree_host_impl_->recycle_tree() == this;
[email protected]48871fc2013-01-23 07:36:51440}
441
[email protected]f117a4c2012-12-16 04:53:10442LayerImpl* LayerTreeImpl::FindActiveTreeLayerById(int id) {
[email protected]c1bb5af2013-03-13 19:06:27443 LayerTreeImpl* tree = layer_tree_host_impl_->active_tree();
[email protected]f117a4c2012-12-16 04:53:10444 if (!tree)
445 return NULL;
446 return tree->LayerById(id);
447}
448
449LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) {
[email protected]c1bb5af2013-03-13 19:06:27450 LayerTreeImpl* tree = layer_tree_host_impl_->pending_tree();
[email protected]f117a4c2012-12-16 04:53:10451 if (!tree)
452 return NULL;
453 return tree->LayerById(id);
454}
455
[email protected]f6776532012-12-21 20:24:33456int LayerTreeImpl::MaxTextureSize() const {
[email protected]c1bb5af2013-03-13 19:06:27457 return layer_tree_host_impl_->GetRendererCapabilities().max_texture_size;
[email protected]f6776532012-12-21 20:24:33458}
459
[email protected]166db5c82013-01-09 23:54:31460bool LayerTreeImpl::PinchGestureActive() const {
[email protected]c1bb5af2013-03-13 19:06:27461 return layer_tree_host_impl_->pinch_gesture_active();
[email protected]166db5c82013-01-09 23:54:31462}
463
[email protected]fb7425a2013-04-22 16:28:55464base::TimeTicks LayerTreeImpl::CurrentFrameTimeTicks() const {
465 return layer_tree_host_impl_->CurrentFrameTimeTicks();
466}
467
468base::Time LayerTreeImpl::CurrentFrameTime() const {
[email protected]c1bb5af2013-03-13 19:06:27469 return layer_tree_host_impl_->CurrentFrameTime();
[email protected]829ad972013-01-28 23:36:10470}
471
[email protected]d7eb8c72013-03-23 22:57:13472void LayerTreeImpl::SetNeedsCommit() {
473 layer_tree_host_impl_->SetNeedsCommit();
474}
475
[email protected]ff762fb2012-12-12 19:18:37476void LayerTreeImpl::SetNeedsRedraw() {
[email protected]59adb112013-04-09 04:48:44477 layer_tree_host_impl_->SetNeedsRedraw();
[email protected]ff762fb2012-12-12 19:18:37478}
479
[email protected]ff762fb2012-12-12 19:18:37480const LayerTreeDebugState& LayerTreeImpl::debug_state() const {
[email protected]c1bb5af2013-03-13 19:06:27481 return layer_tree_host_impl_->debug_state();
[email protected]ff762fb2012-12-12 19:18:37482}
483
484float LayerTreeImpl::device_scale_factor() const {
[email protected]c1bb5af2013-03-13 19:06:27485 return layer_tree_host_impl_->device_scale_factor();
[email protected]ff762fb2012-12-12 19:18:37486}
487
[email protected]90ec9872013-03-08 02:28:18488gfx::Size LayerTreeImpl::device_viewport_size() const {
[email protected]c1bb5af2013-03-13 19:06:27489 return layer_tree_host_impl_->device_viewport_size();
[email protected]ff762fb2012-12-12 19:18:37490}
491
[email protected]ff762fb2012-12-12 19:18:37492std::string LayerTreeImpl::layer_tree_as_text() const {
[email protected]c1bb5af2013-03-13 19:06:27493 return layer_tree_host_impl_->LayerTreeAsText();
[email protected]ff762fb2012-12-12 19:18:37494}
495
496DebugRectHistory* LayerTreeImpl::debug_rect_history() const {
[email protected]c1bb5af2013-03-13 19:06:27497 return layer_tree_host_impl_->debug_rect_history();
[email protected]ff762fb2012-12-12 19:18:37498}
499
[email protected]de4afb5e2012-12-20 00:11:34500AnimationRegistrar* LayerTreeImpl::animationRegistrar() const {
[email protected]c1bb5af2013-03-13 19:06:27501 return layer_tree_host_impl_->animation_registrar();
[email protected]de4afb5e2012-12-20 00:11:34502}
[email protected]ff762fb2012-12-12 19:18:37503
[email protected]8c5690222013-02-15 17:36:43504scoped_ptr<base::Value> LayerTreeImpl::AsValue() const {
[email protected]f6742f52013-05-08 23:52:22505 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
506 TracedValue::MakeDictIntoImplicitSnapshot(
507 state.get(), "cc::LayerTreeImpl", this);
508
509 state->Set("root_layer", root_layer_->AsValue().release());
510
511 scoped_ptr<base::ListValue> render_surface_layer_list(new base::ListValue());
[email protected]8c5690222013-02-15 17:36:43512 typedef LayerIterator<LayerImpl,
[email protected]50761e92013-03-29 20:51:28513 LayerImplList,
[email protected]8c5690222013-02-15 17:36:43514 RenderSurfaceImpl,
515 LayerIteratorActions::BackToFront> LayerIteratorType;
[email protected]71dfcc72013-03-20 21:30:09516 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_);
517 for (LayerIteratorType it = LayerIteratorType::Begin(
[email protected]8c5690222013-02-15 17:36:43518 &render_surface_layer_list_); it != end; ++it) {
[email protected]71dfcc72013-03-20 21:30:09519 if (!it.represents_itself())
[email protected]8c5690222013-02-15 17:36:43520 continue;
[email protected]f6742f52013-05-08 23:52:22521 render_surface_layer_list->Append(TracedValue::CreateIDRef(*it).release());
[email protected]8c5690222013-02-15 17:36:43522 }
[email protected]f6742f52013-05-08 23:52:22523
524 state->Set("render_surface_layer_list",
525 render_surface_layer_list.release());
[email protected]8c5690222013-02-15 17:36:43526 return state.PassAs<base::Value>();
527}
528
[email protected]1960a712013-04-30 17:06:47529void LayerTreeImpl::SetRootLayerScrollOffsetDelegate(
530 LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate) {
531 root_layer_scroll_offset_delegate_ = root_layer_scroll_offset_delegate;
532 if (root_scroll_layer_) {
533 root_scroll_layer_->SetScrollOffsetDelegate(
534 root_layer_scroll_offset_delegate_);
535 }
536}
537
[email protected]fe956c9c42013-04-09 04:26:33538void LayerTreeImpl::UpdateRootScrollLayerSizeDelta() {
539 LayerImpl* root_scroll = RootScrollLayer();
540 LayerImpl* root_clip = RootClipLayer();
541 DCHECK(root_scroll);
542 DCHECK(root_clip);
543 DCHECK(IsActiveTree());
544
545 gfx::Vector2dF scrollable_viewport_size =
546 gfx::RectF(ScrollableViewportSize()).bottom_right() - gfx::PointF();
547
548 gfx::Vector2dF original_viewport_size =
549 gfx::RectF(root_clip->bounds()).bottom_right() -
550 gfx::PointF();
551 original_viewport_size.Scale(1 / page_scale_factor());
552
553 root_scroll->SetFixedContainerSizeDelta(
554 scrollable_viewport_size - original_viewport_size);
555}
556
[email protected]e4c3c87a2013-04-22 02:28:40557void LayerTreeImpl::SetLatencyInfo(const LatencyInfo& latency_info) {
558 latency_info_.MergeWith(latency_info);
559}
560
561const LatencyInfo& LayerTreeImpl::GetLatencyInfo() {
562 return latency_info_;
563}
564
565void LayerTreeImpl::ClearLatencyInfo() {
566 latency_info_.Clear();
567}
568
[email protected]fcb846d2013-05-22 01:42:36569void LayerTreeImpl::WillModifyTilePriorities() {
570 layer_tree_host_impl_->tile_manager()->WillModifyTilePriorities();
571}
572
[email protected]ca2902e92013-03-28 01:45:35573} // namespace cc