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

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

Issue 2840433002: Move LayerImpl's bounds_delta to property trees (Closed)
Patch Set: 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
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 499
500 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { 500 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const {
501 return CurrentScrollOffset(); 501 return CurrentScrollOffset();
502 } 502 }
503 503
504 bool LayerImpl::IsActive() const { 504 bool LayerImpl::IsActive() const {
505 return layer_tree_impl_->IsActiveTree(); 505 return layer_tree_impl_->IsActiveTree();
506 } 506 }
507 507
508 gfx::Size LayerImpl::bounds() const { 508 gfx::Size LayerImpl::bounds() const {
509 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_); 509 auto viewport_bounds_delta = gfx::ToCeiledVector2d(ViewportBoundsDelta());
510 return gfx::Size(bounds_.width() + delta.x(), 510 return gfx::Size(bounds_.width() + viewport_bounds_delta.x(),
511 bounds_.height() + delta.y()); 511 bounds_.height() + viewport_bounds_delta.y());
512 } 512 }
513 513
514 gfx::SizeF LayerImpl::BoundsForScrolling() const { 514 gfx::SizeF LayerImpl::BoundsForScrolling() const {
515 return gfx::SizeF(bounds_.width() + bounds_delta_.x(), 515 auto viewport_bounds_delta = ViewportBoundsDelta();
516 bounds_.height() + bounds_delta_.y()); 516 return gfx::SizeF(bounds_.width() + viewport_bounds_delta.x(),
517 bounds_.height() + viewport_bounds_delta.y());
517 } 518 }
518 519
519 void LayerImpl::SetBounds(const gfx::Size& bounds) { 520 void LayerImpl::SetBounds(const gfx::Size& bounds) {
520 if (bounds_ == bounds) 521 if (bounds_ == bounds)
521 return; 522 return;
522 523
523 bounds_ = bounds; 524 bounds_ = bounds;
524 525
525 layer_tree_impl()->DidUpdateScrollState(id()); 526 layer_tree_impl()->DidUpdateScrollState(id());
526 527
527 NoteLayerPropertyChanged(); 528 NoteLayerPropertyChanged();
528 } 529 }
529 530
530 void LayerImpl::SetBoundsDelta(const gfx::Vector2dF& bounds_delta) { 531 void LayerImpl::SetViewportBoundsDelta(const gfx::Vector2dF& bounds_delta) {
531 DCHECK(IsActive()); 532 DCHECK(IsActive());
532 if (bounds_delta_ == bounds_delta) 533
534 if (bounds_delta == ViewportBoundsDelta())
enne (OOO) 2017/04/24 18:05:08 This is premature optimization, but I think this c
pdr. 2017/04/24 20:06:49 I wanted to preserve the behavior that DidUpdateSc
533 return; 535 return;
534 536
535 bounds_delta_ = bounds_delta;
536
537 PropertyTrees* property_trees = GetPropertyTrees(); 537 PropertyTrees* property_trees = GetPropertyTrees();
538 if (this == layer_tree_impl()->InnerViewportContainerLayer()) 538 if (this == layer_tree_impl()->InnerViewportContainerLayer())
539 property_trees->SetInnerViewportContainerBoundsDelta(bounds_delta); 539 property_trees->SetInnerViewportContainerBoundsDelta(bounds_delta);
540 else if (this == layer_tree_impl()->OuterViewportContainerLayer()) 540 else if (this == layer_tree_impl()->OuterViewportContainerLayer())
541 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta); 541 property_trees->SetOuterViewportContainerBoundsDelta(bounds_delta);
542 else if (this == layer_tree_impl()->InnerViewportScrollLayer()) 542 else if (this == layer_tree_impl()->InnerViewportScrollLayer())
543 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta); 543 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta);
544 else
545 DCHECK(false);
ajuma 2017/04/24 17:37:09 NOTREACHED()
pdr. 2017/04/24 20:06:49 Done
544 546
545 layer_tree_impl()->DidUpdateScrollState(id()); 547 layer_tree_impl()->DidUpdateScrollState(id());
546 548
547 if (masks_to_bounds()) { 549 if (masks_to_bounds()) {
548 // If layer is clipping, then update the clip node using the new bounds. 550 // If layer is clipping, then update the clip node using the new bounds.
549 if (ClipNode* clip_node = 551 if (ClipNode* clip_node =
550 property_trees->clip_tree.UpdateNodeFromOwningLayerId(id())) { 552 property_trees->clip_tree.UpdateNodeFromOwningLayerId(id())) {
551 DCHECK_EQ(clip_node->id, clip_tree_index()); 553 DCHECK_EQ(clip_node->id, clip_tree_index());
552 clip_node->clip = gfx::RectF(gfx::PointF() + offset_to_transform_parent(), 554 clip_node->clip = gfx::RectF(gfx::PointF() + offset_to_transform_parent(),
553 gfx::SizeF(bounds())); 555 gfx::SizeF(bounds()));
554 property_trees->clip_tree.set_needs_update(true); 556 property_trees->clip_tree.set_needs_update(true);
555 } 557 }
556 property_trees->full_tree_damaged = true; 558 property_trees->full_tree_damaged = true;
557 layer_tree_impl()->set_needs_update_draw_properties(); 559 layer_tree_impl()->set_needs_update_draw_properties();
558 } else { 560 } else {
559 NoteLayerPropertyChanged(); 561 NoteLayerPropertyChanged();
560 } 562 }
561 } 563 }
562 564
565 gfx::Vector2dF LayerImpl::ViewportBoundsDelta() const {
566 if (this == layer_tree_impl()->InnerViewportContainerLayer())
567 return GetPropertyTrees()->inner_viewport_container_bounds_delta();
568 else if (this == layer_tree_impl()->OuterViewportContainerLayer())
569 return GetPropertyTrees()->outer_viewport_container_bounds_delta();
570 else if (this == layer_tree_impl()->InnerViewportScrollLayer())
571 return GetPropertyTrees()->inner_viewport_scroll_bounds_delta();
572 return gfx::Vector2dF();
573 }
574
563 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() { 575 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() {
564 return nullptr; 576 return nullptr;
565 } 577 }
566 578
567 void LayerImpl::SetDrawsContent(bool draws_content) { 579 void LayerImpl::SetDrawsContent(bool draws_content) {
568 if (draws_content_ == draws_content) 580 if (draws_content_ == draws_content)
569 return; 581 return;
570 582
571 draws_content_ = draws_content; 583 draws_content_ = draws_content;
572 NoteLayerPropertyChanged(); 584 NoteLayerPropertyChanged();
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 990
979 ScrollTree& LayerImpl::GetScrollTree() const { 991 ScrollTree& LayerImpl::GetScrollTree() const {
980 return GetPropertyTrees()->scroll_tree; 992 return GetPropertyTrees()->scroll_tree;
981 } 993 }
982 994
983 TransformTree& LayerImpl::GetTransformTree() const { 995 TransformTree& LayerImpl::GetTransformTree() const {
984 return GetPropertyTrees()->transform_tree; 996 return GetPropertyTrees()->transform_tree;
985 } 997 }
986 998
987 } // namespace cc 999 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698