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

Side by Side Diff: cc/layer_impl.cc

Issue 11447028: cc: Split out calcDrawEtc from drawLayers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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_impl.h ('k') | cc/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 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_impl.h" 5 #include "cc/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "cc/debug_border_draw_quad.h" 10 #include "cc/debug_border_draw_quad.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #ifndef NDEBUG 62 #ifndef NDEBUG
63 DCHECK(!m_betweenWillDrawAndDidDraw); 63 DCHECK(!m_betweenWillDrawAndDidDraw);
64 #endif 64 #endif
65 } 65 }
66 66
67 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) 67 void LayerImpl::addChild(scoped_ptr<LayerImpl> child)
68 { 68 {
69 child->setParent(this); 69 child->setParent(this);
70 DCHECK_EQ(layerTreeHostImpl(), child->layerTreeHostImpl()); 70 DCHECK_EQ(layerTreeHostImpl(), child->layerTreeHostImpl());
71 m_children.append(child.Pass()); 71 m_children.append(child.Pass());
72 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
72 } 73 }
73 74
74 void LayerImpl::removeFromParent() 75 void LayerImpl::removeFromParent()
75 { 76 {
76 if (!m_parent) 77 if (!m_parent)
77 return; 78 return;
78 79
79 LayerImpl* parent = m_parent; 80 LayerImpl* parent = m_parent;
80 m_parent = 0; 81 m_parent = 0;
81 82
82 for (size_t i = 0; i < parent->m_children.size(); ++i) { 83 for (size_t i = 0; i < parent->m_children.size(); ++i) {
83 if (parent->m_children[i] == this) { 84 if (parent->m_children[i] == this) {
85 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
86 // This remove call deletes |this|, so don't touch it anymore.
84 parent->m_children.remove(i); 87 parent->m_children.remove(i);
85 return; 88 return;
86 } 89 }
87 } 90 }
88 } 91 }
89 92
90 void LayerImpl::removeAllChildren() 93 void LayerImpl::removeAllChildren()
91 { 94 {
92 while (m_children.size()) 95 while (m_children.size())
93 m_children[0]->removeFromParent(); 96 m_children[0]->removeFromParent();
94 } 97 }
95 98
96 void LayerImpl::clearChildList() 99 void LayerImpl::clearChildList()
97 { 100 {
101 if (m_children.isEmpty())
102 return;
103
98 m_children.clear(); 104 m_children.clear();
105 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
99 } 106 }
100 107
101 void LayerImpl::createRenderSurface() 108 void LayerImpl::createRenderSurface()
102 { 109 {
103 DCHECK(!m_drawProperties.render_surface); 110 DCHECK(!m_drawProperties.render_surface);
104 m_drawProperties.render_surface = make_scoped_ptr(new RenderSurfaceImpl(this )); 111 m_drawProperties.render_surface = make_scoped_ptr(new RenderSurfaceImpl(this ));
105 m_drawProperties.render_target = this; 112 m_drawProperties.render_target = this;
106 } 113 }
107 114
108 int LayerImpl::descendantsDrawContent() 115 int LayerImpl::descendantsDrawContent()
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 LayerImpl* current = this->m_parent; 404 LayerImpl* current = this->m_parent;
398 while (current && !current->m_drawProperties.render_surface) { 405 while (current && !current->m_drawProperties.render_surface) {
399 if (current->m_layerSurfacePropertyChanged) 406 if (current->m_layerSurfacePropertyChanged)
400 return true; 407 return true;
401 current = current->m_parent; 408 current = current->m_parent;
402 } 409 }
403 410
404 return false; 411 return false;
405 } 412 }
406 413
414 void LayerImpl::noteLayerSurfacePropertyChanged()
415 {
416 m_layerSurfacePropertyChanged = true;
417 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
418 }
419
420 void LayerImpl::noteLayerPropertyChanged()
421 {
422 m_layerPropertyChanged = true;
423 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
424 }
425
407 void LayerImpl::noteLayerPropertyChangedForSubtree() 426 void LayerImpl::noteLayerPropertyChangedForSubtree()
408 { 427 {
409 m_layerPropertyChanged = true; 428 noteLayerPropertyChanged();
410 noteLayerPropertyChangedForDescendants(); 429 noteLayerPropertyChangedForDescendants();
411 } 430 }
412 431
413 void LayerImpl::noteLayerPropertyChangedForDescendants() 432 void LayerImpl::noteLayerPropertyChangedForDescendants()
414 { 433 {
434 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
415 for (size_t i = 0; i < m_children.size(); ++i) 435 for (size_t i = 0; i < m_children.size(); ++i)
416 m_children[i]->noteLayerPropertyChangedForSubtree(); 436 m_children[i]->noteLayerPropertyChangedForSubtree();
417 } 437 }
418 438
419 const char* LayerImpl::layerTypeAsString() const 439 const char* LayerImpl::layerTypeAsString() const
420 { 440 {
421 return "Layer"; 441 return "Layer";
422 } 442 }
423 443
424 void LayerImpl::resetAllChangeTrackingForSubtree() 444 void LayerImpl::resetAllChangeTrackingForSubtree()
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 void LayerImpl::setBounds(const gfx::Size& bounds) 494 void LayerImpl::setBounds(const gfx::Size& bounds)
475 { 495 {
476 if (m_bounds == bounds) 496 if (m_bounds == bounds)
477 return; 497 return;
478 498
479 m_bounds = bounds; 499 m_bounds = bounds;
480 500
481 if (masksToBounds()) 501 if (masksToBounds())
482 noteLayerPropertyChangedForSubtree(); 502 noteLayerPropertyChangedForSubtree();
483 else 503 else
484 m_layerPropertyChanged = true; 504 noteLayerPropertyChanged();
485 } 505 }
486 506
487 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) 507 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer)
488 { 508 {
489 if (maskLayer) 509 if (maskLayer)
490 DCHECK_EQ(layerTreeHostImpl(), maskLayer->layerTreeHostImpl()); 510 DCHECK_EQ(layerTreeHostImpl(), maskLayer->layerTreeHostImpl());
491 m_maskLayer = maskLayer.Pass(); 511 m_maskLayer = maskLayer.Pass();
492 512
493 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1; 513 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1;
494 if (newLayerId == m_maskLayerId) 514 if (newLayerId == m_maskLayerId)
(...skipping 16 matching lines...) Expand all
511 m_replicaLayerId = newLayerId; 531 m_replicaLayerId = newLayerId;
512 noteLayerPropertyChangedForSubtree(); 532 noteLayerPropertyChangedForSubtree();
513 } 533 }
514 534
515 void LayerImpl::setDrawsContent(bool drawsContent) 535 void LayerImpl::setDrawsContent(bool drawsContent)
516 { 536 {
517 if (m_drawsContent == drawsContent) 537 if (m_drawsContent == drawsContent)
518 return; 538 return;
519 539
520 m_drawsContent = drawsContent; 540 m_drawsContent = drawsContent;
521 m_layerPropertyChanged = true; 541 noteLayerPropertyChanged();
522 } 542 }
523 543
524 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint) 544 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint)
525 { 545 {
526 if (m_anchorPoint == anchorPoint) 546 if (m_anchorPoint == anchorPoint)
527 return; 547 return;
528 548
529 m_anchorPoint = anchorPoint; 549 m_anchorPoint = anchorPoint;
530 noteLayerPropertyChangedForSubtree(); 550 noteLayerPropertyChangedForSubtree();
531 } 551 }
532 552
533 void LayerImpl::setAnchorPointZ(float anchorPointZ) 553 void LayerImpl::setAnchorPointZ(float anchorPointZ)
534 { 554 {
535 if (m_anchorPointZ == anchorPointZ) 555 if (m_anchorPointZ == anchorPointZ)
536 return; 556 return;
537 557
538 m_anchorPointZ = anchorPointZ; 558 m_anchorPointZ = anchorPointZ;
539 noteLayerPropertyChangedForSubtree(); 559 noteLayerPropertyChangedForSubtree();
540 } 560 }
541 561
542 void LayerImpl::setBackgroundColor(SkColor backgroundColor) 562 void LayerImpl::setBackgroundColor(SkColor backgroundColor)
543 { 563 {
544 if (m_backgroundColor == backgroundColor) 564 if (m_backgroundColor == backgroundColor)
545 return; 565 return;
546 566
547 m_backgroundColor = backgroundColor; 567 m_backgroundColor = backgroundColor;
548 m_layerPropertyChanged = true; 568 noteLayerPropertyChanged();
549 } 569 }
550 570
551 void LayerImpl::setFilters(const WebKit::WebFilterOperations& filters) 571 void LayerImpl::setFilters(const WebKit::WebFilterOperations& filters)
552 { 572 {
553 if (m_filters == filters) 573 if (m_filters == filters)
554 return; 574 return;
555 575
556 DCHECK(!m_filter); 576 DCHECK(!m_filter);
557 m_filters = filters; 577 m_filters = filters;
558 noteLayerPropertyChangedForSubtree(); 578 noteLayerPropertyChangedForSubtree();
559 } 579 }
560 580
561 void LayerImpl::setBackgroundFilters(const WebKit::WebFilterOperations& backgrou ndFilters) 581 void LayerImpl::setBackgroundFilters(const WebKit::WebFilterOperations& backgrou ndFilters)
562 { 582 {
563 if (m_backgroundFilters == backgroundFilters) 583 if (m_backgroundFilters == backgroundFilters)
564 return; 584 return;
565 585
566 m_backgroundFilters = backgroundFilters; 586 m_backgroundFilters = backgroundFilters;
567 m_layerPropertyChanged = true; 587 noteLayerPropertyChanged();
568 } 588 }
569 589
570 void LayerImpl::setFilter(const skia::RefPtr<SkImageFilter>& filter) 590 void LayerImpl::setFilter(const skia::RefPtr<SkImageFilter>& filter)
571 { 591 {
572 if (m_filter.get() == filter.get()) 592 if (m_filter.get() == filter.get())
573 return; 593 return;
574 594
575 DCHECK(m_filters.isEmpty()); 595 DCHECK(m_filters.isEmpty());
576 m_filter = filter; 596 m_filter = filter;
577 noteLayerPropertyChangedForSubtree(); 597 noteLayerPropertyChangedForSubtree();
(...skipping 16 matching lines...) Expand all
594 m_contentsOpaque = opaque; 614 m_contentsOpaque = opaque;
595 noteLayerPropertyChangedForSubtree(); 615 noteLayerPropertyChangedForSubtree();
596 } 616 }
597 617
598 void LayerImpl::setOpacity(float opacity) 618 void LayerImpl::setOpacity(float opacity)
599 { 619 {
600 if (m_opacity == opacity) 620 if (m_opacity == opacity)
601 return; 621 return;
602 622
603 m_opacity = opacity; 623 m_opacity = opacity;
604 m_layerSurfacePropertyChanged = true; 624 noteLayerSurfacePropertyChanged();
605 } 625 }
606 626
607 bool LayerImpl::opacityIsAnimating() const 627 bool LayerImpl::opacityIsAnimating() const
608 { 628 {
609 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac ity); 629 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac ity);
610 } 630 }
611 631
612 void LayerImpl::setPosition(const gfx::PointF& position) 632 void LayerImpl::setPosition(const gfx::PointF& position)
613 { 633 {
614 if (m_position == position) 634 if (m_position == position)
(...skipping 21 matching lines...) Expand all
636 // sublayer transform does not affect the current layer; it affects only its children. 656 // sublayer transform does not affect the current layer; it affects only its children.
637 noteLayerPropertyChangedForDescendants(); 657 noteLayerPropertyChangedForDescendants();
638 } 658 }
639 659
640 void LayerImpl::setTransform(const gfx::Transform& transform) 660 void LayerImpl::setTransform(const gfx::Transform& transform)
641 { 661 {
642 if (m_transform == transform) 662 if (m_transform == transform)
643 return; 663 return;
644 664
645 m_transform = transform; 665 m_transform = transform;
646 m_layerSurfacePropertyChanged = true; 666 noteLayerSurfacePropertyChanged();
647 } 667 }
648 668
649 bool LayerImpl::transformIsAnimating() const 669 bool LayerImpl::transformIsAnimating() const
650 { 670 {
651 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform); 671 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform);
652 } 672 }
653 673
654 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) 674 void LayerImpl::setContentBounds(const gfx::Size& contentBounds)
655 { 675 {
656 if (m_contentBounds == contentBounds) 676 if (m_contentBounds == contentBounds)
657 return; 677 return;
658 678
659 m_contentBounds = contentBounds; 679 m_contentBounds = contentBounds;
660 m_layerPropertyChanged = true; 680 noteLayerPropertyChanged();
661 } 681 }
662 682
663 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) 683 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY)
664 { 684 {
665 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY ) 685 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY )
666 return; 686 return;
667 687
668 m_contentsScaleX = contentsScaleX; 688 m_contentsScaleX = contentsScaleX;
669 m_contentsScaleY = contentsScaleY; 689 m_contentsScaleY = contentsScaleY;
670 m_layerPropertyChanged = true; 690 noteLayerPropertyChanged();
671 } 691 }
672 692
673 void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset) 693 void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset)
674 { 694 {
675 if (m_scrollOffset == scrollOffset) 695 if (m_scrollOffset == scrollOffset)
676 return; 696 return;
677 697
678 m_scrollOffset = scrollOffset; 698 m_scrollOffset = scrollOffset;
679 noteLayerPropertyChangedForSubtree(); 699 noteLayerPropertyChangedForSubtree();
680 } 700 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 return visibleContentRect(); 732 return visibleContentRect();
713 return Region(); 733 return Region();
714 } 734 }
715 735
716 void LayerImpl::didLoseOutputSurface() 736 void LayerImpl::didLoseOutputSurface()
717 { 737 {
718 } 738 }
719 739
720 void LayerImpl::setMaxScrollOffset(gfx::Vector2d maxScrollOffset) 740 void LayerImpl::setMaxScrollOffset(gfx::Vector2d maxScrollOffset)
721 { 741 {
742 if (m_maxScrollOffset == maxScrollOffset)
743 return;
722 m_maxScrollOffset = maxScrollOffset; 744 m_maxScrollOffset = maxScrollOffset;
723 745
746 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
747
724 if (!m_scrollbarAnimationController) 748 if (!m_scrollbarAnimationController)
725 return; 749 return;
726 m_scrollbarAnimationController->updateScrollOffset(this); 750 m_scrollbarAnimationController->updateScrollOffset(this);
727 } 751 }
728 752
729 ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer() 753 ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer()
730 { 754 {
731 return m_scrollbarAnimationController ? m_scrollbarAnimationController->hori zontalScrollbarLayer() : 0; 755 return m_scrollbarAnimationController ? m_scrollbarAnimationController->hori zontalScrollbarLayer() : 0;
732 } 756 }
733 757
(...skipping 22 matching lines...) Expand all
756 780
757 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) 781 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
758 { 782 {
759 if (!m_scrollbarAnimationController) 783 if (!m_scrollbarAnimationController)
760 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is); 784 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
761 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 785 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
762 m_scrollbarAnimationController->updateScrollOffset(this); 786 m_scrollbarAnimationController->updateScrollOffset(this);
763 } 787 }
764 788
765 } // namespace cc 789 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_impl.h ('k') | cc/layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698