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

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

Issue 2840433002: Move LayerImpl's bounds_delta to property trees (Closed)
Patch Set: Document ViewportBoundsDelta better Created 3 years, 8 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/layers/layer_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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 return transform_tree.Node(transform_tree_index()) 375 return transform_tree.Node(transform_tree_index())
376 ->in_subtree_of_page_scale_layer; 376 ->in_subtree_of_page_scale_layer;
377 } 377 }
378 378
379 gfx::Vector2dF LayerImpl::FixedContainerSizeDelta() const { 379 gfx::Vector2dF LayerImpl::FixedContainerSizeDelta() const {
380 LayerImpl* scroll_clip_layer = 380 LayerImpl* scroll_clip_layer =
381 layer_tree_impl()->LayerById(scroll_clip_layer_id_); 381 layer_tree_impl()->LayerById(scroll_clip_layer_id_);
382 if (!scroll_clip_layer) 382 if (!scroll_clip_layer)
383 return gfx::Vector2dF(); 383 return gfx::Vector2dF();
384 384
385 return scroll_clip_layer->bounds_delta(); 385 return scroll_clip_layer->ViewportBoundsDelta();
386 } 386 }
387 387
388 std::unique_ptr<base::DictionaryValue> LayerImpl::LayerTreeAsJson() { 388 std::unique_ptr<base::DictionaryValue> LayerImpl::LayerTreeAsJson() {
389 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue); 389 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
390 result->SetInteger("LayerId", id()); 390 result->SetInteger("LayerId", id());
391 result->SetString("LayerType", LayerTypeAsString()); 391 result->SetString("LayerType", LayerTypeAsString());
392 392
393 auto list = base::MakeUnique<base::ListValue>(); 393 auto list = base::MakeUnique<base::ListValue>();
394 list->AppendInteger(bounds().width()); 394 list->AppendInteger(bounds().width());
395 list->AppendInteger(bounds().height()); 395 list->AppendInteger(bounds().height());
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 497
498 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { 498 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const {
499 return CurrentScrollOffset(); 499 return CurrentScrollOffset();
500 } 500 }
501 501
502 bool LayerImpl::IsActive() const { 502 bool LayerImpl::IsActive() const {
503 return layer_tree_impl_->IsActiveTree(); 503 return layer_tree_impl_->IsActiveTree();
504 } 504 }
505 505
506 gfx::Size LayerImpl::bounds() const { 506 gfx::Size LayerImpl::bounds() const {
507 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_); 507 auto viewport_bounds_delta = gfx::ToCeiledVector2d(ViewportBoundsDelta());
508 return gfx::Size(bounds_.width() + delta.x(), 508 return gfx::Size(bounds_.width() + viewport_bounds_delta.x(),
509 bounds_.height() + delta.y()); 509 bounds_.height() + viewport_bounds_delta.y());
510 } 510 }
511 511
512 gfx::SizeF LayerImpl::BoundsForScrolling() const { 512 gfx::SizeF LayerImpl::BoundsForScrolling() const {
513 return gfx::SizeF(bounds_.width() + bounds_delta_.x(), 513 auto viewport_bounds_delta = ViewportBoundsDelta();
514 bounds_.height() + bounds_delta_.y()); 514 return gfx::SizeF(bounds_.width() + viewport_bounds_delta.x(),
515 bounds_.height() + viewport_bounds_delta.y());
515 } 516 }
516 517
517 void LayerImpl::SetBounds(const gfx::Size& bounds) { 518 void LayerImpl::SetBounds(const gfx::Size& bounds) {
518 if (bounds_ == bounds) 519 if (bounds_ == bounds)
519 return; 520 return;
520 521
521 bounds_ = bounds; 522 bounds_ = bounds;
522 523
523 layer_tree_impl()->DidUpdateScrollState(id()); 524 layer_tree_impl()->DidUpdateScrollState(id());
524 525
525 NoteLayerPropertyChanged(); 526 NoteLayerPropertyChanged();
526 } 527 }
527 528
528 void LayerImpl::SetBoundsDelta(const gfx::Vector2dF& bounds_delta) { 529 void LayerImpl::SetViewportBoundsDelta(const gfx::Vector2dF& bounds_delta) {
529 DCHECK(IsActive()); 530 DCHECK(IsActive());
530 if (bounds_delta_ == bounds_delta) 531
532 if (bounds_delta == ViewportBoundsDelta())
531 return; 533 return;
532 534
533 bounds_delta_ = bounds_delta;
534
535 PropertyTrees* property_trees = GetPropertyTrees(); 535 PropertyTrees* property_trees = GetPropertyTrees();
536 if (this == layer_tree_impl()->InnerViewportContainerLayer()) 536 if (this == layer_tree_impl()->InnerViewportContainerLayer())
537 property_trees->SetInnerViewportContainerBoundsDelta(bounds_delta); 537 property_trees->SetInnerViewportContainerBoundsDelta(bounds_delta);
538 else if (this == layer_tree_impl()->OuterViewportContainerLayer()) 538 else if (this == layer_tree_impl()->OuterViewportContainerLayer())
539 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta); 539 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta);
540 else if (this == layer_tree_impl()->InnerViewportScrollLayer()) 540 else if (this == layer_tree_impl()->InnerViewportScrollLayer())
541 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta); 541 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta);
542 else
543 NOTREACHED();
542 544
543 layer_tree_impl()->DidUpdateScrollState(id()); 545 layer_tree_impl()->DidUpdateScrollState(id());
544 546
545 if (masks_to_bounds()) { 547 if (masks_to_bounds()) {
546 // If layer is clipping, then update the clip node using the new bounds. 548 // If layer is clipping, then update the clip node using the new bounds.
547 if (ClipNode* clip_node = 549 if (ClipNode* clip_node =
548 property_trees->clip_tree.UpdateNodeFromOwningLayerId(id())) { 550 property_trees->clip_tree.UpdateNodeFromOwningLayerId(id())) {
549 DCHECK_EQ(clip_node->id, clip_tree_index()); 551 DCHECK_EQ(clip_node->id, clip_tree_index());
550 clip_node->clip = gfx::RectF(gfx::PointF() + offset_to_transform_parent(), 552 clip_node->clip = gfx::RectF(gfx::PointF() + offset_to_transform_parent(),
551 gfx::SizeF(bounds())); 553 gfx::SizeF(bounds()));
552 property_trees->clip_tree.set_needs_update(true); 554 property_trees->clip_tree.set_needs_update(true);
553 } 555 }
554 property_trees->full_tree_damaged = true; 556 property_trees->full_tree_damaged = true;
555 layer_tree_impl()->set_needs_update_draw_properties(); 557 layer_tree_impl()->set_needs_update_draw_properties();
556 } else { 558 } else {
557 NoteLayerPropertyChanged(); 559 NoteLayerPropertyChanged();
558 } 560 }
559 } 561 }
560 562
563 gfx::Vector2dF LayerImpl::ViewportBoundsDelta() const {
564 if (this == layer_tree_impl()->InnerViewportContainerLayer())
565 return GetPropertyTrees()->inner_viewport_container_bounds_delta();
566 else if (this == layer_tree_impl()->OuterViewportContainerLayer())
567 return GetPropertyTrees()->outer_viewport_container_bounds_delta();
568 else if (this == layer_tree_impl()->InnerViewportScrollLayer())
569 return GetPropertyTrees()->inner_viewport_scroll_bounds_delta();
570 return gfx::Vector2dF();
571 }
572
561 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() { 573 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() {
562 return nullptr; 574 return nullptr;
563 } 575 }
564 576
565 void LayerImpl::SetDrawsContent(bool draws_content) { 577 void LayerImpl::SetDrawsContent(bool draws_content) {
566 if (draws_content_ == draws_content) 578 if (draws_content_ == draws_content)
567 return; 579 return;
568 580
569 draws_content_ = draws_content; 581 draws_content_ = draws_content;
570 NoteLayerPropertyChanged(); 582 NoteLayerPropertyChanged();
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 988
977 ScrollTree& LayerImpl::GetScrollTree() const { 989 ScrollTree& LayerImpl::GetScrollTree() const {
978 return GetPropertyTrees()->scroll_tree; 990 return GetPropertyTrees()->scroll_tree;
979 } 991 }
980 992
981 TransformTree& LayerImpl::GetTransformTree() const { 993 TransformTree& LayerImpl::GetTransformTree() const {
982 return GetPropertyTrees()->transform_tree; 994 return GetPropertyTrees()->transform_tree;
983 } 995 }
984 996
985 } // namespace cc 997 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698