Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: cc/layer_tree_impl.cc

Issue 11640035: cc: Move updateDrawProperties to LayerTreeImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove a TODO Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer_tree_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer_tree_impl.h" 5 #include "cc/layer_tree_impl.h"
6 6
7 #include "base/debug/trace_event.h"
7 #include "cc/layer_tree_host_common.h" 8 #include "cc/layer_tree_host_common.h"
8 #include "cc/layer_tree_host_impl.h" 9 #include "cc/layer_tree_host_impl.h"
9 #include "ui/gfx/vector2d_conversions.h" 10 #include "ui/gfx/vector2d_conversions.h"
10 11
11 namespace cc { 12 namespace cc {
12 13
13 LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl) 14 LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl)
14 : layer_tree_host_impl_(layer_tree_host_impl) 15 : layer_tree_host_impl_(layer_tree_host_impl)
15 , source_frame_number_(-1) 16 , source_frame_number_(-1)
16 , hud_layer_(0) 17 , hud_layer_(0)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 58
58 layer_tree_host_impl_->OnCanDrawStateChangedForTree(this); 59 layer_tree_host_impl_->OnCanDrawStateChangedForTree(this);
59 } 60 }
60 61
61 scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() { 62 scoped_ptr<LayerImpl> LayerTreeImpl::DetachLayerTree() {
62 // Clear all data structures that have direct references to the layer tree. 63 // Clear all data structures that have direct references to the layer tree.
63 scrolling_layer_id_from_previous_tree_ = 64 scrolling_layer_id_from_previous_tree_ =
64 currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0; 65 currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0;
65 currently_scrolling_layer_ = NULL; 66 currently_scrolling_layer_ = NULL;
66 67
68 render_surface_layer_list_.clear();
69 SetNeedsUpdateDrawProperties();
67 return root_layer_.Pass(); 70 return root_layer_.Pass();
68 } 71 }
69 72
70 void LayerTreeImpl::ClearCurrentlyScrollingLayer() { 73 void LayerTreeImpl::ClearCurrentlyScrollingLayer() {
71 currently_scrolling_layer_ = NULL; 74 currently_scrolling_layer_ = NULL;
72 scrolling_layer_id_from_previous_tree_ = 0; 75 scrolling_layer_id_from_previous_tree_ = 0;
73 } 76 }
74 77
75 void LayerTreeImpl::UpdateMaxScrollOffset() { 78 void LayerTreeImpl::UpdateMaxScrollOffset() {
76 if (!root_scroll_layer() || !root_scroll_layer()->children().size()) 79 if (!root_scroll_layer() || !root_scroll_layer()->children().size())
(...skipping 22 matching lines...) Expand all
99 gfx::RectF(view_bounds).bottom_right(); 102 gfx::RectF(view_bounds).bottom_right();
100 max_scroll.Scale(1 / device_scale_factor()); 103 max_scroll.Scale(1 / device_scale_factor());
101 104
102 // The viewport may be larger than the contents in some cases, such as 105 // The viewport may be larger than the contents in some cases, such as
103 // having a vertical scrollbar but no horizontal overflow. 106 // having a vertical scrollbar but no horizontal overflow.
104 max_scroll.ClampToMin(gfx::Vector2dF()); 107 max_scroll.ClampToMin(gfx::Vector2dF());
105 108
106 root_scroll_layer()->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); 109 root_scroll_layer()->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll));
107 } 110 }
108 111
112 void LayerTreeImpl::UpdateDrawProperties() {
113 render_surface_layer_list_.clear();
114 if (!RootLayer())
115 return;
116
117 if (root_scroll_layer()) {
118 root_scroll_layer()->setImplTransform(
119 layer_tree_host_impl_->implTransform());
120 }
121
122 {
123 TRACE_EVENT0("cc", "LayerTreeImpl::UpdateDrawProperties");
124 LayerTreeHostCommon::calculateDrawProperties(
125 RootLayer(),
126 device_viewport_size(),
127 device_scale_factor(),
128 pinch_zoom_viewport().pageScaleFactor(),
129 layer_tree_host_impl_->rendererCapabilities().maxTextureSize,
130 settings().canUseLCDText,
131 render_surface_layer_list_);
132 }
133 }
134
135 static void ClearRenderSurfacesOnLayerImplRecursive(LayerImpl* current)
136 {
137 DCHECK(current);
138 for (size_t i = 0; i < current->children().size(); ++i)
139 ClearRenderSurfacesOnLayerImplRecursive(current->children()[i]);
140 current->clearRenderSurface();
141 }
142
143 void LayerTreeImpl::ClearRenderSurfaces() {
144 ClearRenderSurfacesOnLayerImplRecursive(RootLayer());
145 render_surface_layer_list_.clear();
146 SetNeedsUpdateDrawProperties();
147 }
148
149 const LayerTreeImpl::LayerList& LayerTreeImpl::RenderSurfaceLayerList() const {
150 // If this assert triggers, then the list is dirty.
151 DCHECK(!layer_tree_host_impl_->needsUpdateDrawProperties());
152 return render_surface_layer_list_;
153 }
154
109 gfx::Size LayerTreeImpl::ContentSize() const { 155 gfx::Size LayerTreeImpl::ContentSize() const {
110 // TODO(aelias): Hardcoding the first child here is weird. Think of 156 // TODO(aelias): Hardcoding the first child here is weird. Think of
111 // a cleaner way to get the contentBounds on the Impl side. 157 // a cleaner way to get the contentBounds on the Impl side.
112 if (!root_scroll_layer() || root_scroll_layer()->children().isEmpty()) 158 if (!root_scroll_layer() || root_scroll_layer()->children().isEmpty())
113 return gfx::Size(); 159 return gfx::Size();
114 return root_scroll_layer()->children()[0]->contentBounds(); 160 return root_scroll_layer()->children()[0]->contentBounds();
115 } 161 }
116 162
117 LayerImpl* LayerTreeImpl::LayerById(int id) { 163 LayerImpl* LayerTreeImpl::LayerById(int id) {
118 LayerIdMap::iterator iter = layer_id_map_.find(id); 164 LayerIdMap::iterator iter = layer_id_map_.find(id);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 251
206 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const { 252 AnimationRegistrar* LayerTreeImpl::animationRegistrar() const {
207 return layer_tree_host_impl_->animationRegistrar(); 253 return layer_tree_host_impl_->animationRegistrar();
208 } 254 }
209 255
210 const PinchZoomViewport& LayerTreeImpl::pinch_zoom_viewport() const { 256 const PinchZoomViewport& LayerTreeImpl::pinch_zoom_viewport() const {
211 return layer_tree_host_impl_->pinchZoomViewport(); 257 return layer_tree_host_impl_->pinchZoomViewport();
212 } 258 }
213 259
214 } // namespace cc 260 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698