blob: b0cbfde2d56d67f912d6a6723cb27e4ffcaba056 [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
5#include "cc/layer_tree_impl.h"
6
[email protected]76ffd9e2012-12-20 19:12:477#include "base/debug/trace_event.h"
[email protected]c60279472013-01-30 12:10:518#include "cc/heads_up_display_layer_impl.h"
[email protected]3b31c6ac2012-12-06 21:27:299#include "cc/layer_tree_host_common.h"
10#include "cc/layer_tree_host_impl.h"
[email protected]ffb2720f2013-03-15 19:18:3711#include "cc/scrollbar_layer_impl.h"
12#include "ui/gfx/size_conversions.h"
[email protected]caa567d2012-12-20 07:56:1613#include "ui/gfx/vector2d_conversions.h"
[email protected]3b31c6ac2012-12-06 21:27:2914
15namespace cc {
16
[email protected]8bef40572012-12-11 21:38:0817LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl)
[email protected]db8259f2013-02-01 05:25:0418 : layer_tree_host_impl_(layer_tree_host_impl),
19 source_frame_number_(-1),
20 hud_layer_(0),
21 root_scroll_layer_(0),
22 currently_scrolling_layer_(0),
23 background_color_(0),
24 has_transparent_background_(false),
25 page_scale_factor_(1),
26 page_scale_delta_(1),
27 sent_page_scale_delta_(1),
28 min_page_scale_factor_(0),
29 max_page_scale_factor_(0),
30 scrolling_layer_id_from_previous_tree_(0),
31 contents_textures_purged_(false),
[email protected]318822852013-02-14 00:54:2732 viewport_size_invalid_(false),
[email protected]db8259f2013-02-01 05:25:0433 needs_update_draw_properties_(true),
34 needs_full_tree_sync_(true) {
[email protected]3b31c6ac2012-12-06 21:27:2935}
36
37LayerTreeImpl::~LayerTreeImpl() {
[email protected]361bc00d2012-12-14 07:03:2438 // Need to explicitly clear the tree prior to destroying this so that
39 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor.
40 root_layer_.reset();
[email protected]3b31c6ac2012-12-06 21:27:2941}
42
43static LayerImpl* findRootScrollLayer(LayerImpl* layer)
44{
45 if (!layer)
46 return 0;
47
48 if (layer->scrollable())
49 return layer;
50
51 for (size_t i = 0; i < layer->children().size(); ++i) {
52 LayerImpl* found = findRootScrollLayer(layer->children()[i]);
53 if (found)
54 return found;
55 }
56
57 return 0;
58}
59
60void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) {
61 root_layer_ = layer.Pass();
[email protected]5c4824e12013-01-12 16:34:5362 root_scroll_layer_ = NULL;
63 currently_scrolling_layer_ = NULL;
64
[email protected]c1bb5af2013-03-13 19:06:2765 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
[email protected]5c4824e12013-01-12 16:34:5366}
67
68void LayerTreeImpl::FindRootScrollLayer() {
[email protected]3b31c6ac2012-12-06 21:27:2969 root_scroll_layer_ = findRootScrollLayer(root_layer_.get());
[email protected]3b31c6ac2012-12-06 21:27:2970
71 if (root_layer_ && scrolling_layer_id_from_previous_tree_) {
72 currently_scrolling_layer_ = LayerTreeHostCommon::findLayerInSubtree(
73 root_layer_.get(),
74 scrolling_layer_id_from_previous_tree_);
75 }
76
77 scrolling_layer_id_from_previous_tree_ = 0;
[email protected]3b31c6ac2012-12-06 21:27:2978}
79
80scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() {
81 // Clear all data structures that have direct references to the layer tree.
82 scrolling_layer_id_from_previous_tree_ =
83 currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0;
[email protected]69b50ec2013-01-19 04:58:0184 root_scroll_layer_ = NULL;
[email protected]3b31c6ac2012-12-06 21:27:2985 currently_scrolling_layer_ = NULL;
86
[email protected]76ffd9e2012-12-20 19:12:4787 render_surface_layer_list_.clear();
[email protected]615c78a2013-01-24 23:44:1688 set_needs_update_draw_properties();
[email protected]3b31c6ac2012-12-06 21:27:2989 return root_layer_.Pass();
90}
91
[email protected]7aba6662013-03-12 10:17:3492void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) {
[email protected]c60279472013-01-30 12:10:5193 target_tree->SetPageScaleFactorAndLimits(
94 page_scale_factor(), min_page_scale_factor(), max_page_scale_factor());
95 target_tree->SetPageScaleDelta(
96 target_tree->page_scale_delta() / target_tree->sent_page_scale_delta());
97 target_tree->set_sent_page_scale_delta(1);
98
99 // This should match the property synchronization in
100 // LayerTreeHost::finishCommitOnImplThread().
101 target_tree->set_source_frame_number(source_frame_number());
102 target_tree->set_background_color(background_color());
103 target_tree->set_has_transparent_background(has_transparent_background());
104
105 if (ContentsTexturesPurged())
106 target_tree->SetContentsTexturesPurged();
107 else
108 target_tree->ResetContentsTexturesPurged();
109
[email protected]318822852013-02-14 00:54:27110 if (ViewportSizeInvalid())
111 target_tree->SetViewportSizeInvalid();
112 else
113 target_tree->ResetViewportSizeInvalid();
114
[email protected]c60279472013-01-30 12:10:51115 if (hud_layer())
116 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(
117 LayerTreeHostCommon::findLayerInSubtree(
[email protected]c1bb5af2013-03-13 19:06:27118 target_tree->root_layer(), hud_layer()->id())));
[email protected]c60279472013-01-30 12:10:51119 else
120 target_tree->set_hud_layer(NULL);
121}
122
[email protected]ffb2720f2013-03-15 19:18:37123LayerImpl* LayerTreeImpl::RootScrollLayer() const {
[email protected]69b50ec2013-01-19 04:58:01124 DCHECK(IsActiveTree());
125 return root_scroll_layer_;
126}
127
[email protected]ffb2720f2013-03-15 19:18:37128LayerImpl* LayerTreeImpl::RootClipLayer() const {
129 return root_scroll_layer_ ? root_scroll_layer_->parent() : NULL;
130}
131
132LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() const {
[email protected]69b50ec2013-01-19 04:58:01133 DCHECK(IsActiveTree());
134 return currently_scrolling_layer_;
135}
136
[email protected]3b31c6ac2012-12-06 21:27:29137void LayerTreeImpl::ClearCurrentlyScrollingLayer() {
138 currently_scrolling_layer_ = NULL;
139 scrolling_layer_id_from_previous_tree_ = 0;
140}
141
[email protected]c60279472013-01-30 12:10:51142void LayerTreeImpl::SetPageScaleFactorAndLimits(float page_scale_factor,
143 float min_page_scale_factor, float max_page_scale_factor)
144{
145 if (!page_scale_factor)
146 return;
147
148 min_page_scale_factor_ = min_page_scale_factor;
149 max_page_scale_factor_ = max_page_scale_factor;
150 page_scale_factor_ = page_scale_factor;
151}
152
153void LayerTreeImpl::SetPageScaleDelta(float delta)
154{
155 // Clamp to the current min/max limits.
156 float total = page_scale_factor_ * delta;
157 if (min_page_scale_factor_ && total < min_page_scale_factor_)
158 delta = min_page_scale_factor_ / page_scale_factor_;
159 else if (max_page_scale_factor_ && total > max_page_scale_factor_)
160 delta = max_page_scale_factor_ / page_scale_factor_;
161
162 if (delta == page_scale_delta_)
163 return;
164
165 page_scale_delta_ = delta;
166
167 if (IsActiveTree()) {
[email protected]c1bb5af2013-03-13 19:06:27168 LayerTreeImpl* pending_tree = layer_tree_host_impl_->pending_tree();
[email protected]c60279472013-01-30 12:10:51169 if (pending_tree) {
170 DCHECK_EQ(1, pending_tree->sent_page_scale_delta());
171 pending_tree->SetPageScaleDelta(page_scale_delta_ / sent_page_scale_delta_);
172 }
173 }
174
175 UpdateMaxScrollOffset();
176 set_needs_update_draw_properties();
177}
178
[email protected]257abfa82013-01-29 23:47:24179gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const {
[email protected]ffb2720f2013-03-15 19:18:37180 return gfx::ScaleSize(layer_tree_host_impl_->VisibleViewportSize(),
181 1.0f / total_page_scale_factor());
[email protected]257abfa82013-01-29 23:47:24182}
183
[email protected]caa567d2012-12-20 07:56:16184void LayerTreeImpl::UpdateMaxScrollOffset() {
[email protected]69b50ec2013-01-19 04:58:01185 if (!root_scroll_layer_ || !root_scroll_layer_->children().size())
[email protected]caa567d2012-12-20 07:56:16186 return;
187
[email protected]42ccdbef2013-01-21 07:54:54188 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() -
[email protected]257abfa82013-01-29 23:47:24189 gfx::RectF(ScrollableViewportSize()).bottom_right();
[email protected]caa567d2012-12-20 07:56:16190
191 // The viewport may be larger than the contents in some cases, such as
192 // having a vertical scrollbar but no horizontal overflow.
193 max_scroll.ClampToMin(gfx::Vector2dF());
194
[email protected]7aba6662013-03-12 10:17:34195 root_scroll_layer_->SetMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll));
[email protected]caa567d2012-12-20 07:56:16196}
197
[email protected]c60279472013-01-30 12:10:51198gfx::Transform LayerTreeImpl::ImplTransform() const {
199 gfx::Transform transform;
[email protected]c2d0c5a2013-02-26 04:43:36200 transform.Scale(total_page_scale_factor(), total_page_scale_factor());
[email protected]c60279472013-01-30 12:10:51201 return transform;
202}
203
[email protected]ffb2720f2013-03-15 19:18:37204void LayerTreeImpl::UpdateSolidColorScrollbars() {
205 DCHECK(settings().solidColorScrollbars);
206
207 LayerImpl* root_scroll = RootScrollLayer();
208 if (!root_scroll)
209 return;
210
211 if (!IsActiveTree())
212 return;
213
214 gfx::RectF scrollable_viewport(
215 gfx::PointAtOffsetFromOrigin(root_scroll->TotalScrollOffset()),
216 ScrollableViewportSize());
217 float vertical_adjust = 0.0f;
218 if (RootClipLayer())
219 vertical_adjust = layer_tree_host_impl_->VisibleViewportSize().height() -
220 RootClipLayer()->bounds().height();
221 if (ScrollbarLayerImpl* horiz = root_scroll->horizontal_scrollbar_layer()) {
222 horiz->set_vertical_adjust(vertical_adjust);
223 horiz->SetViewportWithinScrollableArea(scrollable_viewport,
224 ScrollableSize());
225 }
226 if (ScrollbarLayerImpl* vertical = root_scroll->vertical_scrollbar_layer()) {
227 vertical->set_vertical_adjust(vertical_adjust);
228 vertical->SetViewportWithinScrollableArea(scrollable_viewport,
229 ScrollableSize());
230 }
231}
232
[email protected]4c9bb952013-01-27 05:41:18233struct UpdateTilePrioritiesForLayer {
234 void operator()(LayerImpl *layer) {
[email protected]7aba6662013-03-12 10:17:34235 layer->UpdateTilePriorities();
[email protected]4c9bb952013-01-27 05:41:18236 }
237};
238
239void LayerTreeImpl::UpdateDrawProperties(UpdateDrawPropertiesReason reason) {
[email protected]ffb2720f2013-03-15 19:18:37240 if (settings().solidColorScrollbars && IsActiveTree()) {
241 UpdateSolidColorScrollbars();
242
243 // The top controls manager is incompatible with the WebKit-created cliprect
244 // because it can bring into view a larger amount of content when it
245 // hides. It's safe to deactivate the clip rect if no non-overlay scrollbars
246 // are present.
247 if (layer_tree_host_impl_->top_controls_manager())
248 RootScrollLayer()->parent()->SetMasksToBounds(false);
249 }
250
[email protected]4c9bb952013-01-27 05:41:18251 if (!needs_update_draw_properties_) {
[email protected]c1bb5af2013-03-13 19:06:27252 if (reason == UPDATE_ACTIVE_TREE_FOR_DRAW && root_layer())
[email protected]4c9bb952013-01-27 05:41:18253 LayerTreeHostCommon::callFunctionForSubtree<UpdateTilePrioritiesForLayer>(
[email protected]c1bb5af2013-03-13 19:06:27254 root_layer());
[email protected]615c78a2013-01-24 23:44:16255 return;
[email protected]4c9bb952013-01-27 05:41:18256 }
[email protected]615c78a2013-01-24 23:44:16257
258 needs_update_draw_properties_ = false;
[email protected]76ffd9e2012-12-20 19:12:47259 render_surface_layer_list_.clear();
[email protected]615c78a2013-01-24 23:44:16260
261 // For maxTextureSize.
262 if (!layer_tree_host_impl_->renderer())
263 return;
264
[email protected]c1bb5af2013-03-13 19:06:27265 if (!root_layer())
[email protected]76ffd9e2012-12-20 19:12:47266 return;
267
[email protected]69b50ec2013-01-19 04:58:01268 if (root_scroll_layer_) {
[email protected]7aba6662013-03-12 10:17:34269 root_scroll_layer_->SetImplTransform(ImplTransform());
[email protected]615c78a2013-01-24 23:44:16270 // Setting the impl transform re-sets this.
271 needs_update_draw_properties_ = false;
[email protected]76ffd9e2012-12-20 19:12:47272 }
273
274 {
[email protected]c1bb5af2013-03-13 19:06:27275 TRACE_EVENT1("cc",
276 "LayerTreeImpl::UpdateDrawProperties",
277 "IsActive",
278 IsActiveTree());
[email protected]4c9bb952013-01-27 05:41:18279 bool update_tile_priorities =
280 reason == UPDATE_PENDING_TREE ||
281 reason == UPDATE_ACTIVE_TREE_FOR_DRAW;
[email protected]76ffd9e2012-12-20 19:12:47282 LayerTreeHostCommon::calculateDrawProperties(
[email protected]c1bb5af2013-03-13 19:06:27283 root_layer(),
[email protected]76ffd9e2012-12-20 19:12:47284 device_viewport_size(),
285 device_scale_factor(),
[email protected]c60279472013-01-30 12:10:51286 total_page_scale_factor(),
[email protected]f6776532012-12-21 20:24:33287 MaxTextureSize(),
[email protected]76ffd9e2012-12-20 19:12:47288 settings().canUseLCDText,
[email protected]4c9bb952013-01-27 05:41:18289 render_surface_layer_list_,
290 update_tile_priorities);
[email protected]76ffd9e2012-12-20 19:12:47291 }
[email protected]615c78a2013-01-24 23:44:16292
293 DCHECK(!needs_update_draw_properties_) <<
294 "calcDrawProperties should not set_needs_update_draw_properties()";
[email protected]76ffd9e2012-12-20 19:12:47295}
296
297static void ClearRenderSurfacesOnLayerImplRecursive(LayerImpl* current)
298{
299 DCHECK(current);
300 for (size_t i = 0; i < current->children().size(); ++i)
301 ClearRenderSurfacesOnLayerImplRecursive(current->children()[i]);
[email protected]7aba6662013-03-12 10:17:34302 current->ClearRenderSurface();
[email protected]76ffd9e2012-12-20 19:12:47303}
304
305void LayerTreeImpl::ClearRenderSurfaces() {
[email protected]c1bb5af2013-03-13 19:06:27306 ClearRenderSurfacesOnLayerImplRecursive(root_layer());
[email protected]76ffd9e2012-12-20 19:12:47307 render_surface_layer_list_.clear();
[email protected]615c78a2013-01-24 23:44:16308 set_needs_update_draw_properties();
[email protected]76ffd9e2012-12-20 19:12:47309}
310
[email protected]b0a917c8d2013-01-12 17:42:25311bool LayerTreeImpl::AreVisibleResourcesReady() const {
312 TRACE_EVENT0("cc", "LayerTreeImpl::AreVisibleResourcesReady");
313
314 typedef LayerIterator<LayerImpl,
315 std::vector<LayerImpl*>,
316 RenderSurfaceImpl,
317 LayerIteratorActions::BackToFront> LayerIteratorType;
318 LayerIteratorType end = LayerIteratorType::end(&render_surface_layer_list_);
319 for (LayerIteratorType it = LayerIteratorType::begin(
320 &render_surface_layer_list_); it != end; ++it) {
[email protected]7aba6662013-03-12 10:17:34321 if (it.representsItself() && !(*it)->AreVisibleResourcesReady())
[email protected]b0a917c8d2013-01-12 17:42:25322 return false;
323 }
324
325 return true;
326}
327
[email protected]76ffd9e2012-12-20 19:12:47328const LayerTreeImpl::LayerList& LayerTreeImpl::RenderSurfaceLayerList() const {
329 // If this assert triggers, then the list is dirty.
[email protected]615c78a2013-01-24 23:44:16330 DCHECK(!needs_update_draw_properties_);
[email protected]76ffd9e2012-12-20 19:12:47331 return render_surface_layer_list_;
332}
333
[email protected]42ccdbef2013-01-21 07:54:54334gfx::Size LayerTreeImpl::ScrollableSize() const {
[email protected]c4d467a2013-01-21 03:21:01335 if (!root_scroll_layer_ || root_scroll_layer_->children().empty())
[email protected]caa567d2012-12-20 07:56:16336 return gfx::Size();
[email protected]c4d467a2013-01-21 03:21:01337 return root_scroll_layer_->children()[0]->bounds();
[email protected]caa567d2012-12-20 07:56:16338}
339
[email protected]361bc00d2012-12-14 07:03:24340LayerImpl* LayerTreeImpl::LayerById(int id) {
341 LayerIdMap::iterator iter = layer_id_map_.find(id);
342 return iter != layer_id_map_.end() ? iter->second : NULL;
343}
344
345void LayerTreeImpl::RegisterLayer(LayerImpl* layer) {
346 DCHECK(!LayerById(layer->id()));
347 layer_id_map_[layer->id()] = layer;
348}
349
350void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) {
351 DCHECK(LayerById(layer->id()));
352 layer_id_map_.erase(layer->id());
353}
354
[email protected]1e0f8d62013-01-09 07:41:35355void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pendingTree) {
356 int id = currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0;
357 pendingTree->set_currently_scrolling_layer(
[email protected]c1bb5af2013-03-13 19:06:27358 LayerTreeHostCommon::findLayerInSubtree(pendingTree->root_layer(), id));
[email protected]1e0f8d62013-01-09 07:41:35359}
360
[email protected]37386f052013-01-13 00:42:22361static void DidBecomeActiveRecursive(LayerImpl* layer) {
[email protected]7aba6662013-03-12 10:17:34362 layer->DidBecomeActive();
[email protected]37386f052013-01-13 00:42:22363 for (size_t i = 0; i < layer->children().size(); ++i)
364 DidBecomeActiveRecursive(layer->children()[i]);
365}
366
367void LayerTreeImpl::DidBecomeActive() {
[email protected]c1bb5af2013-03-13 19:06:27368 if (root_layer())
369 DidBecomeActiveRecursive(root_layer());
[email protected]69b50ec2013-01-19 04:58:01370 FindRootScrollLayer();
371 UpdateMaxScrollOffset();
[email protected]37386f052013-01-13 00:42:22372}
373
[email protected]6f90b9e2013-01-17 23:42:00374bool LayerTreeImpl::ContentsTexturesPurged() const {
375 return contents_textures_purged_;
376}
377
378void LayerTreeImpl::SetContentsTexturesPurged() {
379 contents_textures_purged_ = true;
[email protected]c1bb5af2013-03-13 19:06:27380 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
[email protected]6f90b9e2013-01-17 23:42:00381}
382
383void LayerTreeImpl::ResetContentsTexturesPurged() {
384 contents_textures_purged_ = false;
[email protected]c1bb5af2013-03-13 19:06:27385 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
[email protected]6f90b9e2013-01-17 23:42:00386}
387
[email protected]318822852013-02-14 00:54:27388bool LayerTreeImpl::ViewportSizeInvalid() const {
389 return viewport_size_invalid_;
390}
391
392void LayerTreeImpl::SetViewportSizeInvalid() {
393 viewport_size_invalid_ = true;
[email protected]c1bb5af2013-03-13 19:06:27394 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
[email protected]318822852013-02-14 00:54:27395}
396
397void LayerTreeImpl::ResetViewportSizeInvalid() {
398 viewport_size_invalid_ = false;
[email protected]c1bb5af2013-03-13 19:06:27399 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
[email protected]318822852013-02-14 00:54:27400}
401
[email protected]48871fc2013-01-23 07:36:51402Proxy* LayerTreeImpl::proxy() const {
403 return layer_tree_host_impl_->proxy();
404}
405
[email protected]ff762fb2012-12-12 19:18:37406const LayerTreeSettings& LayerTreeImpl::settings() const {
[email protected]c1bb5af2013-03-13 19:06:27407 return layer_tree_host_impl_->settings();
[email protected]ff762fb2012-12-12 19:18:37408}
409
[email protected]bf5b3a02013-02-13 02:02:52410const RendererCapabilities& LayerTreeImpl::rendererCapabilities() const {
[email protected]c1bb5af2013-03-13 19:06:27411 return layer_tree_host_impl_->GetRendererCapabilities();
[email protected]bf5b3a02013-02-13 02:02:52412}
413
[email protected]ff762fb2012-12-12 19:18:37414OutputSurface* LayerTreeImpl::output_surface() const {
[email protected]c1bb5af2013-03-13 19:06:27415 return layer_tree_host_impl_->output_surface();
[email protected]ff762fb2012-12-12 19:18:37416}
417
418ResourceProvider* LayerTreeImpl::resource_provider() const {
[email protected]c1bb5af2013-03-13 19:06:27419 return layer_tree_host_impl_->resource_provider();
[email protected]ff762fb2012-12-12 19:18:37420}
421
422TileManager* LayerTreeImpl::tile_manager() const {
[email protected]c1bb5af2013-03-13 19:06:27423 return layer_tree_host_impl_->tile_manager();
[email protected]ff762fb2012-12-12 19:18:37424}
425
426FrameRateCounter* LayerTreeImpl::frame_rate_counter() const {
[email protected]c1bb5af2013-03-13 19:06:27427 return layer_tree_host_impl_->fps_counter();
[email protected]ff762fb2012-12-12 19:18:37428}
429
[email protected]71691c22013-01-18 03:14:22430PaintTimeCounter* LayerTreeImpl::paint_time_counter() const {
[email protected]c1bb5af2013-03-13 19:06:27431 return layer_tree_host_impl_->paint_time_counter();
[email protected]71691c22013-01-18 03:14:22432}
433
[email protected]1191d9d2013-02-02 06:00:33434MemoryHistory* LayerTreeImpl::memory_history() const {
[email protected]c1bb5af2013-03-13 19:06:27435 return layer_tree_host_impl_->memory_history();
[email protected]1191d9d2013-02-02 06:00:33436}
437
[email protected]f117a4c2012-12-16 04:53:10438bool LayerTreeImpl::IsActiveTree() const {
[email protected]c1bb5af2013-03-13 19:06:27439 return layer_tree_host_impl_->active_tree() == this;
[email protected]f117a4c2012-12-16 04:53:10440}
441
442bool LayerTreeImpl::IsPendingTree() const {
[email protected]c1bb5af2013-03-13 19:06:27443 return layer_tree_host_impl_->pending_tree() == this;
[email protected]f117a4c2012-12-16 04:53:10444}
445
[email protected]48871fc2013-01-23 07:36:51446bool LayerTreeImpl::IsRecycleTree() const {
[email protected]c1bb5af2013-03-13 19:06:27447 return layer_tree_host_impl_->recycle_tree() == this;
[email protected]48871fc2013-01-23 07:36:51448}
449
[email protected]f117a4c2012-12-16 04:53:10450LayerImpl* LayerTreeImpl::FindActiveTreeLayerById(int id) {
[email protected]c1bb5af2013-03-13 19:06:27451 LayerTreeImpl* tree = layer_tree_host_impl_->active_tree();
[email protected]f117a4c2012-12-16 04:53:10452 if (!tree)
453 return NULL;
454 return tree->LayerById(id);
455}
456
457LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) {
[email protected]c1bb5af2013-03-13 19:06:27458 LayerTreeImpl* tree = layer_tree_host_impl_->pending_tree();
[email protected]f117a4c2012-12-16 04:53:10459 if (!tree)
460 return NULL;
461 return tree->LayerById(id);
462}
463
[email protected]f6776532012-12-21 20:24:33464int LayerTreeImpl::MaxTextureSize() const {
[email protected]c1bb5af2013-03-13 19:06:27465 return layer_tree_host_impl_->GetRendererCapabilities().max_texture_size;
[email protected]f6776532012-12-21 20:24:33466}
467
[email protected]166db5c82013-01-09 23:54:31468bool LayerTreeImpl::PinchGestureActive() const {
[email protected]c1bb5af2013-03-13 19:06:27469 return layer_tree_host_impl_->pinch_gesture_active();
[email protected]166db5c82013-01-09 23:54:31470}
471
[email protected]829ad972013-01-28 23:36:10472base::TimeTicks LayerTreeImpl::CurrentFrameTime() const {
[email protected]c1bb5af2013-03-13 19:06:27473 return layer_tree_host_impl_->CurrentFrameTime();
[email protected]829ad972013-01-28 23:36:10474}
475
[email protected]ff762fb2012-12-12 19:18:37476void LayerTreeImpl::SetNeedsRedraw() {
477 layer_tree_host_impl_->setNeedsRedraw();
478}
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]c1bb5af2013-03-13 19:06:27492gfx::Size LayerTreeImpl::layout_viewport_size() const {
493 return layer_tree_host_impl_->layout_viewport_size();
[email protected]ff762fb2012-12-12 19:18:37494}
495
496std::string LayerTreeImpl::layer_tree_as_text() const {
[email protected]c1bb5af2013-03-13 19:06:27497 return layer_tree_host_impl_->LayerTreeAsText();
[email protected]ff762fb2012-12-12 19:18:37498}
499
500DebugRectHistory* LayerTreeImpl::debug_rect_history() const {
[email protected]c1bb5af2013-03-13 19:06:27501 return layer_tree_host_impl_->debug_rect_history();
[email protected]ff762fb2012-12-12 19:18:37502}
503
[email protected]de4afb5e2012-12-20 00:11:34504AnimationRegistrar* LayerTreeImpl::animationRegistrar() const {
[email protected]c1bb5af2013-03-13 19:06:27505 return layer_tree_host_impl_->animation_registrar();
[email protected]de4afb5e2012-12-20 00:11:34506}
[email protected]ff762fb2012-12-12 19:18:37507
[email protected]8c5690222013-02-15 17:36:43508scoped_ptr<base::Value> LayerTreeImpl::AsValue() const {
509 scoped_ptr<base::ListValue> state(new base::ListValue());
510 typedef LayerIterator<LayerImpl,
511 std::vector<LayerImpl*>,
512 RenderSurfaceImpl,
513 LayerIteratorActions::BackToFront> LayerIteratorType;
514 LayerIteratorType end = LayerIteratorType::end(&render_surface_layer_list_);
515 for (LayerIteratorType it = LayerIteratorType::begin(
516 &render_surface_layer_list_); it != end; ++it) {
517 if (!it.representsItself())
518 continue;
519 state->Append((*it)->AsValue().release());
520 }
521 return state.PassAs<base::Value>();
522}
523
[email protected]3b31c6ac2012-12-06 21:27:29524} // namespace cc