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

Side by Side Diff: cc/layer_tree_impl.cc

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings Created 7 years, 9 months 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') | cc/layer_unittest.cc » ('j') | 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 "base/debug/trace_event.h"
8 #include "cc/heads_up_display_layer_impl.h" 8 #include "cc/heads_up_display_layer_impl.h"
9 #include "cc/layer_tree_host_common.h" 9 #include "cc/layer_tree_host_common.h"
10 #include "cc/layer_tree_host_impl.h" 10 #include "cc/layer_tree_host_impl.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 scrolling_layer_id_from_previous_tree_ = 80 scrolling_layer_id_from_previous_tree_ =
81 currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0; 81 currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0;
82 root_scroll_layer_ = NULL; 82 root_scroll_layer_ = NULL;
83 currently_scrolling_layer_ = NULL; 83 currently_scrolling_layer_ = NULL;
84 84
85 render_surface_layer_list_.clear(); 85 render_surface_layer_list_.clear();
86 set_needs_update_draw_properties(); 86 set_needs_update_draw_properties();
87 return root_layer_.Pass(); 87 return root_layer_.Pass();
88 } 88 }
89 89
90 void LayerTreeImpl::pushPropertiesTo(LayerTreeImpl* target_tree) { 90 void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) {
91 target_tree->SetPageScaleFactorAndLimits( 91 target_tree->SetPageScaleFactorAndLimits(
92 page_scale_factor(), min_page_scale_factor(), max_page_scale_factor()); 92 page_scale_factor(), min_page_scale_factor(), max_page_scale_factor());
93 target_tree->SetPageScaleDelta( 93 target_tree->SetPageScaleDelta(
94 target_tree->page_scale_delta() / target_tree->sent_page_scale_delta()); 94 target_tree->page_scale_delta() / target_tree->sent_page_scale_delta());
95 target_tree->set_sent_page_scale_delta(1); 95 target_tree->set_sent_page_scale_delta(1);
96 96
97 // This should match the property synchronization in 97 // This should match the property synchronization in
98 // LayerTreeHost::finishCommitOnImplThread(). 98 // LayerTreeHost::finishCommitOnImplThread().
99 target_tree->set_source_frame_number(source_frame_number()); 99 target_tree->set_source_frame_number(source_frame_number());
100 target_tree->set_background_color(background_color()); 100 target_tree->set_background_color(background_color());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const { 173 gfx::SizeF LayerTreeImpl::ScrollableViewportSize() const {
174 gfx::SizeF view_bounds; 174 gfx::SizeF view_bounds;
175 // The clip layer should be used for scrolling bounds if available since it 175 // The clip layer should be used for scrolling bounds if available since it
176 // adjusts for non-overlay scrollbars. Otherwise, fall back to our knowledge 176 // adjusts for non-overlay scrollbars. Otherwise, fall back to our knowledge
177 // of the physical viewport size. 177 // of the physical viewport size.
178 LayerImpl* clip_layer = NULL; 178 LayerImpl* clip_layer = NULL;
179 if (root_scroll_layer_) 179 if (root_scroll_layer_)
180 clip_layer = root_scroll_layer_->parent(); 180 clip_layer = root_scroll_layer_->parent();
181 if (clip_layer && clip_layer->masksToBounds()) { 181 if (clip_layer && clip_layer->masks_to_bounds()) {
182 view_bounds = clip_layer->bounds(); 182 view_bounds = clip_layer->bounds();
183 } else { 183 } else {
184 view_bounds = gfx::ScaleSize(device_viewport_size(), 184 view_bounds = gfx::ScaleSize(device_viewport_size(),
185 1 / device_scale_factor()); 185 1 / device_scale_factor());
186 } 186 }
187 view_bounds.Scale(1 / total_page_scale_factor()); 187 view_bounds.Scale(1 / total_page_scale_factor());
188 188
189 return view_bounds; 189 return view_bounds;
190 } 190 }
191 191
192 void LayerTreeImpl::UpdateMaxScrollOffset() { 192 void LayerTreeImpl::UpdateMaxScrollOffset() {
193 if (!root_scroll_layer_ || !root_scroll_layer_->children().size()) 193 if (!root_scroll_layer_ || !root_scroll_layer_->children().size())
194 return; 194 return;
195 195
196 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() - 196 gfx::Vector2dF max_scroll = gfx::Rect(ScrollableSize()).bottom_right() -
197 gfx::RectF(ScrollableViewportSize()).bottom_right(); 197 gfx::RectF(ScrollableViewportSize()).bottom_right();
198 198
199 // The viewport may be larger than the contents in some cases, such as 199 // The viewport may be larger than the contents in some cases, such as
200 // having a vertical scrollbar but no horizontal overflow. 200 // having a vertical scrollbar but no horizontal overflow.
201 max_scroll.ClampToMin(gfx::Vector2dF()); 201 max_scroll.ClampToMin(gfx::Vector2dF());
202 202
203 root_scroll_layer_->setMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll)); 203 root_scroll_layer_->SetMaxScrollOffset(gfx::ToFlooredVector2d(max_scroll));
204 } 204 }
205 205
206 gfx::Transform LayerTreeImpl::ImplTransform() const { 206 gfx::Transform LayerTreeImpl::ImplTransform() const {
207 gfx::Transform transform; 207 gfx::Transform transform;
208 transform.Scale(total_page_scale_factor(), total_page_scale_factor()); 208 transform.Scale(total_page_scale_factor(), total_page_scale_factor());
209 return transform; 209 return transform;
210 } 210 }
211 211
212 struct UpdateTilePrioritiesForLayer { 212 struct UpdateTilePrioritiesForLayer {
213 void operator()(LayerImpl *layer) { 213 void operator()(LayerImpl *layer) {
214 layer->updateTilePriorities(); 214 layer->UpdateTilePriorities();
215 } 215 }
216 }; 216 };
217 217
218 void LayerTreeImpl::UpdateDrawProperties(UpdateDrawPropertiesReason reason) { 218 void LayerTreeImpl::UpdateDrawProperties(UpdateDrawPropertiesReason reason) {
219 if (!needs_update_draw_properties_) { 219 if (!needs_update_draw_properties_) {
220 if (reason == UPDATE_ACTIVE_TREE_FOR_DRAW && RootLayer()) 220 if (reason == UPDATE_ACTIVE_TREE_FOR_DRAW && RootLayer())
221 LayerTreeHostCommon::callFunctionForSubtree<UpdateTilePrioritiesForLayer>( 221 LayerTreeHostCommon::callFunctionForSubtree<UpdateTilePrioritiesForLayer>(
222 RootLayer()); 222 RootLayer());
223 return; 223 return;
224 } 224 }
225 225
226 needs_update_draw_properties_ = false; 226 needs_update_draw_properties_ = false;
227 render_surface_layer_list_.clear(); 227 render_surface_layer_list_.clear();
228 228
229 // For maxTextureSize. 229 // For maxTextureSize.
230 if (!layer_tree_host_impl_->renderer()) 230 if (!layer_tree_host_impl_->renderer())
231 return; 231 return;
232 232
233 if (!RootLayer()) 233 if (!RootLayer())
234 return; 234 return;
235 235
236 if (root_scroll_layer_) { 236 if (root_scroll_layer_) {
237 root_scroll_layer_->setImplTransform(ImplTransform()); 237 root_scroll_layer_->SetImplTransform(ImplTransform());
238 // Setting the impl transform re-sets this. 238 // Setting the impl transform re-sets this.
239 needs_update_draw_properties_ = false; 239 needs_update_draw_properties_ = false;
240 } 240 }
241 241
242 { 242 {
243 TRACE_EVENT1("cc", "LayerTreeImpl::UpdateDrawProperties", "IsActive", IsActi veTree()); 243 TRACE_EVENT1("cc", "LayerTreeImpl::UpdateDrawProperties", "IsActive", IsActi veTree());
244 bool update_tile_priorities = 244 bool update_tile_priorities =
245 reason == UPDATE_PENDING_TREE || 245 reason == UPDATE_PENDING_TREE ||
246 reason == UPDATE_ACTIVE_TREE_FOR_DRAW; 246 reason == UPDATE_ACTIVE_TREE_FOR_DRAW;
247 LayerTreeHostCommon::calculateDrawProperties( 247 LayerTreeHostCommon::calculateDrawProperties(
248 RootLayer(), 248 RootLayer(),
249 device_viewport_size(), 249 device_viewport_size(),
250 device_scale_factor(), 250 device_scale_factor(),
251 total_page_scale_factor(), 251 total_page_scale_factor(),
252 MaxTextureSize(), 252 MaxTextureSize(),
253 settings().canUseLCDText, 253 settings().canUseLCDText,
254 render_surface_layer_list_, 254 render_surface_layer_list_,
255 update_tile_priorities); 255 update_tile_priorities);
256 } 256 }
257 257
258 DCHECK(!needs_update_draw_properties_) << 258 DCHECK(!needs_update_draw_properties_) <<
259 "calcDrawProperties should not set_needs_update_draw_properties()"; 259 "calcDrawProperties should not set_needs_update_draw_properties()";
260 } 260 }
261 261
262 static void ClearRenderSurfacesOnLayerImplRecursive(LayerImpl* current) 262 static void ClearRenderSurfacesOnLayerImplRecursive(LayerImpl* current)
263 { 263 {
264 DCHECK(current); 264 DCHECK(current);
265 for (size_t i = 0; i < current->children().size(); ++i) 265 for (size_t i = 0; i < current->children().size(); ++i)
266 ClearRenderSurfacesOnLayerImplRecursive(current->children()[i]); 266 ClearRenderSurfacesOnLayerImplRecursive(current->children()[i]);
267 current->clearRenderSurface(); 267 current->ClearRenderSurface();
268 } 268 }
269 269
270 void LayerTreeImpl::ClearRenderSurfaces() { 270 void LayerTreeImpl::ClearRenderSurfaces() {
271 ClearRenderSurfacesOnLayerImplRecursive(RootLayer()); 271 ClearRenderSurfacesOnLayerImplRecursive(RootLayer());
272 render_surface_layer_list_.clear(); 272 render_surface_layer_list_.clear();
273 set_needs_update_draw_properties(); 273 set_needs_update_draw_properties();
274 } 274 }
275 275
276 bool LayerTreeImpl::AreVisibleResourcesReady() const { 276 bool LayerTreeImpl::AreVisibleResourcesReady() const {
277 TRACE_EVENT0("cc", "LayerTreeImpl::AreVisibleResourcesReady"); 277 TRACE_EVENT0("cc", "LayerTreeImpl::AreVisibleResourcesReady");
278 278
279 typedef LayerIterator<LayerImpl, 279 typedef LayerIterator<LayerImpl,
280 std::vector<LayerImpl*>, 280 std::vector<LayerImpl*>,
281 RenderSurfaceImpl, 281 RenderSurfaceImpl,
282 LayerIteratorActions::BackToFront> LayerIteratorType; 282 LayerIteratorActions::BackToFront> LayerIteratorType;
283 LayerIteratorType end = LayerIteratorType::end(&render_surface_layer_list_); 283 LayerIteratorType end = LayerIteratorType::end(&render_surface_layer_list_);
284 for (LayerIteratorType it = LayerIteratorType::begin( 284 for (LayerIteratorType it = LayerIteratorType::begin(
285 &render_surface_layer_list_); it != end; ++it) { 285 &render_surface_layer_list_); it != end; ++it) {
286 if (it.representsItself() && !(*it)->areVisibleResourcesReady()) 286 if (it.representsItself() && !(*it)->AreVisibleResourcesReady())
287 return false; 287 return false;
288 } 288 }
289 289
290 return true; 290 return true;
291 } 291 }
292 292
293 const LayerTreeImpl::LayerList& LayerTreeImpl::RenderSurfaceLayerList() const { 293 const LayerTreeImpl::LayerList& LayerTreeImpl::RenderSurfaceLayerList() const {
294 // If this assert triggers, then the list is dirty. 294 // If this assert triggers, then the list is dirty.
295 DCHECK(!needs_update_draw_properties_); 295 DCHECK(!needs_update_draw_properties_);
296 return render_surface_layer_list_; 296 return render_surface_layer_list_;
(...skipping 20 matching lines...) Expand all
317 layer_id_map_.erase(layer->id()); 317 layer_id_map_.erase(layer->id());
318 } 318 }
319 319
320 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pendingTree) { 320 void LayerTreeImpl::PushPersistedState(LayerTreeImpl* pendingTree) {
321 int id = currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0; 321 int id = currently_scrolling_layer_ ? currently_scrolling_layer_->id() : 0;
322 pendingTree->set_currently_scrolling_layer( 322 pendingTree->set_currently_scrolling_layer(
323 LayerTreeHostCommon::findLayerInSubtree(pendingTree->RootLayer(), id)); 323 LayerTreeHostCommon::findLayerInSubtree(pendingTree->RootLayer(), id));
324 } 324 }
325 325
326 static void DidBecomeActiveRecursive(LayerImpl* layer) { 326 static void DidBecomeActiveRecursive(LayerImpl* layer) {
327 layer->didBecomeActive(); 327 layer->DidBecomeActive();
328 for (size_t i = 0; i < layer->children().size(); ++i) 328 for (size_t i = 0; i < layer->children().size(); ++i)
329 DidBecomeActiveRecursive(layer->children()[i]); 329 DidBecomeActiveRecursive(layer->children()[i]);
330 } 330 }
331 331
332 void LayerTreeImpl::DidBecomeActive() { 332 void LayerTreeImpl::DidBecomeActive() {
333 if (RootLayer()) 333 if (RootLayer())
334 DidBecomeActiveRecursive(RootLayer()); 334 DidBecomeActiveRecursive(RootLayer());
335 FindRootScrollLayer(); 335 FindRootScrollLayer();
336 UpdateMaxScrollOffset(); 336 UpdateMaxScrollOffset();
337 } 337 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 for (LayerIteratorType it = LayerIteratorType::begin( 480 for (LayerIteratorType it = LayerIteratorType::begin(
481 &render_surface_layer_list_); it != end; ++it) { 481 &render_surface_layer_list_); it != end; ++it) {
482 if (!it.representsItself()) 482 if (!it.representsItself())
483 continue; 483 continue;
484 state->Append((*it)->AsValue().release()); 484 state->Append((*it)->AsValue().release());
485 } 485 }
486 return state.PassAs<base::Value>(); 486 return state.PassAs<base::Value>();
487 } 487 }
488 488
489 } // namespace cc 489 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_impl.h ('k') | cc/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698