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

Side by Side Diff: cc/layers/layer_impl.cc

Issue 2867793002: Add a cache of LayerImpl's viewport layer type (Closed)
Patch Set: Rebase from space Created 3 years, 7 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
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/trees/layer_tree_host_impl_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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 layer_property_changed_(false), 61 layer_property_changed_(false),
62 may_contain_video_(false), 62 may_contain_video_(false),
63 masks_to_bounds_(false), 63 masks_to_bounds_(false),
64 contents_opaque_(false), 64 contents_opaque_(false),
65 use_parent_backface_visibility_(false), 65 use_parent_backface_visibility_(false),
66 use_local_transform_for_backface_visibility_(false), 66 use_local_transform_for_backface_visibility_(false),
67 should_check_backface_visibility_(false), 67 should_check_backface_visibility_(false),
68 draws_content_(false), 68 draws_content_(false),
69 contributes_to_drawn_render_surface_(false), 69 contributes_to_drawn_render_surface_(false),
70 was_ever_ready_since_last_transform_animation_(true), 70 was_ever_ready_since_last_transform_animation_(true),
71 viewport_layer_type_(NOT_VIEWPORT_LAYER),
71 background_color_(0), 72 background_color_(0),
72 safe_opaque_background_color_(0), 73 safe_opaque_background_color_(0),
73 transform_tree_index_(TransformTree::kInvalidNodeId), 74 transform_tree_index_(TransformTree::kInvalidNodeId),
74 effect_tree_index_(EffectTree::kInvalidNodeId), 75 effect_tree_index_(EffectTree::kInvalidNodeId),
75 clip_tree_index_(ClipTree::kInvalidNodeId), 76 clip_tree_index_(ClipTree::kInvalidNodeId),
76 scroll_tree_index_(ScrollTree::kInvalidNodeId), 77 scroll_tree_index_(ScrollTree::kInvalidNodeId),
77 current_draw_mode_(DRAW_MODE_NONE), 78 current_draw_mode_(DRAW_MODE_NONE),
78 mutable_properties_(MutableProperty::kNone), 79 mutable_properties_(MutableProperty::kNone),
79 debug_info_(nullptr), 80 debug_info_(nullptr),
80 has_will_change_transform_hint_(false), 81 has_will_change_transform_hint_(false),
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 return scroll_tree.ScrollBy(scroll_node, scroll, layer_tree_impl()); 273 return scroll_tree.ScrollBy(scroll_node, scroll, layer_tree_impl());
273 } 274 }
274 275
275 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) { 276 void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) {
276 if (scroll_clip_layer_id_ == scroll_clip_layer_id) 277 if (scroll_clip_layer_id_ == scroll_clip_layer_id)
277 return; 278 return;
278 279
279 layer_tree_impl()->UnregisterScrollLayer(this); 280 layer_tree_impl()->UnregisterScrollLayer(this);
280 scroll_clip_layer_id_ = scroll_clip_layer_id; 281 scroll_clip_layer_id_ = scroll_clip_layer_id;
281 layer_tree_impl()->RegisterScrollLayer(this); 282 layer_tree_impl()->RegisterScrollLayer(this);
283
284 // Ensure our viewport layer type is updated.
285 layer_tree_impl()->UpdateViewportLayerTypes();
282 } 286 }
283 287
284 LayerImpl* LayerImpl::scroll_clip_layer() const { 288 LayerImpl* LayerImpl::scroll_clip_layer() const {
285 return layer_tree_impl()->LayerById(scroll_clip_layer_id_); 289 return layer_tree_impl()->LayerById(scroll_clip_layer_id_);
286 } 290 }
287 291
288 bool LayerImpl::scrollable() const { 292 bool LayerImpl::scrollable() const {
289 return scroll_clip_layer_id_ != Layer::INVALID_ID; 293 return scroll_clip_layer_id_ != Layer::INVALID_ID;
290 } 294 }
291 295
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 NoteLayerPropertyChanged(); 523 NoteLayerPropertyChanged();
520 } 524 }
521 525
522 void LayerImpl::SetViewportBoundsDelta(const gfx::Vector2dF& bounds_delta) { 526 void LayerImpl::SetViewportBoundsDelta(const gfx::Vector2dF& bounds_delta) {
523 DCHECK(IsActive()); 527 DCHECK(IsActive());
524 528
525 if (bounds_delta == ViewportBoundsDelta()) 529 if (bounds_delta == ViewportBoundsDelta())
526 return; 530 return;
527 531
528 PropertyTrees* property_trees = GetPropertyTrees(); 532 PropertyTrees* property_trees = GetPropertyTrees();
529 if (this == layer_tree_impl()->InnerViewportContainerLayer()) 533 switch (viewport_layer_type_) {
530 property_trees->SetInnerViewportContainerBoundsDelta(bounds_delta); 534 case (INNER_VIEWPORT_CONTAINER):
531 else if (this == layer_tree_impl()->OuterViewportContainerLayer()) 535 property_trees->SetInnerViewportContainerBoundsDelta(bounds_delta);
532 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta); 536 break;
533 else if (this == layer_tree_impl()->InnerViewportScrollLayer()) 537 case (OUTER_VIEWPORT_CONTAINER):
534 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta); 538 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta);
535 else 539 break;
536 NOTREACHED(); 540 case (INNER_VIEWPORT_SCROLL):
541 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta);
542 break;
543 case (OUTER_VIEWPORT_SCROLL):
544 // OUTER_VIEWPORT_SCROLL should not have viewport bounds deltas.
545 NOTREACHED();
546 }
537 547
538 layer_tree_impl()->DidUpdateScrollState(id()); 548 layer_tree_impl()->DidUpdateScrollState(id());
539 549
540 if (masks_to_bounds()) { 550 if (masks_to_bounds()) {
541 // If layer is clipping, then update the clip node using the new bounds. 551 // If layer is clipping, then update the clip node using the new bounds.
542 if (ClipNode* clip_node = 552 if (ClipNode* clip_node =
543 property_trees->clip_tree.UpdateNodeFromOwningLayerId(id())) { 553 property_trees->clip_tree.UpdateNodeFromOwningLayerId(id())) {
544 DCHECK_EQ(clip_node->id, clip_tree_index()); 554 DCHECK_EQ(clip_node->id, clip_tree_index());
545 clip_node->clip = gfx::RectF(gfx::PointF() + offset_to_transform_parent(), 555 clip_node->clip = gfx::RectF(gfx::PointF() + offset_to_transform_parent(),
546 gfx::SizeF(bounds())); 556 gfx::SizeF(bounds()));
547 property_trees->clip_tree.set_needs_update(true); 557 property_trees->clip_tree.set_needs_update(true);
548 } 558 }
549 property_trees->full_tree_damaged = true; 559 property_trees->full_tree_damaged = true;
550 layer_tree_impl()->set_needs_update_draw_properties(); 560 layer_tree_impl()->set_needs_update_draw_properties();
551 } else { 561 } else {
552 NoteLayerPropertyChanged(); 562 NoteLayerPropertyChanged();
553 } 563 }
554 } 564 }
555 565
556 gfx::Vector2dF LayerImpl::ViewportBoundsDelta() const { 566 gfx::Vector2dF LayerImpl::ViewportBoundsDelta() const {
557 if (this == layer_tree_impl()->InnerViewportContainerLayer()) 567 switch (viewport_layer_type_) {
558 return GetPropertyTrees()->inner_viewport_container_bounds_delta(); 568 case (INNER_VIEWPORT_CONTAINER):
559 else if (this == layer_tree_impl()->OuterViewportContainerLayer()) 569 return GetPropertyTrees()->inner_viewport_container_bounds_delta();
560 return GetPropertyTrees()->outer_viewport_container_bounds_delta(); 570 case (OUTER_VIEWPORT_CONTAINER):
561 else if (this == layer_tree_impl()->InnerViewportScrollLayer()) 571 return GetPropertyTrees()->outer_viewport_container_bounds_delta();
562 return GetPropertyTrees()->inner_viewport_scroll_bounds_delta(); 572 case (INNER_VIEWPORT_SCROLL):
563 return gfx::Vector2dF(); 573 return GetPropertyTrees()->inner_viewport_scroll_bounds_delta();
574 default:
575 return gfx::Vector2dF();
576 }
564 } 577 }
565 578
566 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() { 579 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() {
567 return nullptr; 580 return nullptr;
568 } 581 }
569 582
570 void LayerImpl::SetDrawsContent(bool draws_content) { 583 void LayerImpl::SetDrawsContent(bool draws_content) {
571 if (draws_content_ == draws_content) 584 if (draws_content_ == draws_content)
572 return; 585 return;
573 586
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 986
974 ScrollTree& LayerImpl::GetScrollTree() const { 987 ScrollTree& LayerImpl::GetScrollTree() const {
975 return GetPropertyTrees()->scroll_tree; 988 return GetPropertyTrees()->scroll_tree;
976 } 989 }
977 990
978 TransformTree& LayerImpl::GetTransformTree() const { 991 TransformTree& LayerImpl::GetTransformTree() const {
979 return GetPropertyTrees()->transform_tree; 992 return GetPropertyTrees()->transform_tree;
980 } 993 }
981 994
982 } // namespace cc 995 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698