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

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: Clean up unnecessary test changes 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
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 "cc/debug_border_draw_quad.h" 9 #include "cc/debug_border_draw_quad.h"
10 #include "cc/debug_colors.h" 10 #include "cc/debug_colors.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 LayerImpl::~LayerImpl() 59 LayerImpl::~LayerImpl()
60 { 60 {
61 #ifndef NDEBUG 61 #ifndef NDEBUG
62 DCHECK(!m_betweenWillDrawAndDidDraw); 62 DCHECK(!m_betweenWillDrawAndDidDraw);
63 #endif 63 #endif
64 } 64 }
65 65
66 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) 66 void LayerImpl::addChild(scoped_ptr<LayerImpl> child)
67 { 67 {
68 child->setParent(this); 68 child->setParent(this);
69 child->setLayerTreeHostImpl(layerTreeHostImpl());
69 m_children.append(child.Pass()); 70 m_children.append(child.Pass());
71
72 if (m_layerTreeHostImpl)
73 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
70 } 74 }
71 75
72 void LayerImpl::removeFromParent() 76 void LayerImpl::removeFromParent()
73 { 77 {
74 if (!m_parent) 78 if (!m_parent)
75 return; 79 return;
76 80
77 LayerImpl* parent = m_parent; 81 LayerImpl* parent = m_parent;
78 m_parent = 0; 82 m_parent = 0;
79 83
80 for (size_t i = 0; i < parent->m_children.size(); ++i) { 84 for (size_t i = 0; i < parent->m_children.size(); ++i) {
81 if (parent->m_children[i] == this) { 85 if (parent->m_children[i] == this) {
82 parent->m_children.remove(i); 86 parent->m_children.remove(i);
87 if (m_layerTreeHostImpl)
88 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
83 return; 89 return;
84 } 90 }
85 } 91 }
86 } 92 }
87 93
88 void LayerImpl::removeAllChildren() 94 void LayerImpl::removeAllChildren()
89 { 95 {
90 while (m_children.size()) 96 while (m_children.size())
91 m_children[0]->removeFromParent(); 97 m_children[0]->removeFromParent();
92 } 98 }
93 99
94 void LayerImpl::clearChildList() 100 void LayerImpl::clearChildList()
95 { 101 {
96 m_children.clear(); 102 m_children.clear();
103 if (m_layerTreeHostImpl)
104 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
97 } 105 }
98 106
99 void LayerImpl::createRenderSurface() 107 void LayerImpl::createRenderSurface()
100 { 108 {
101 DCHECK(!m_drawProperties.render_surface); 109 DCHECK(!m_drawProperties.render_surface);
102 m_drawProperties.render_surface = make_scoped_ptr(new RenderSurfaceImpl(this )); 110 m_drawProperties.render_surface = make_scoped_ptr(new RenderSurfaceImpl(this ));
103 m_drawProperties.render_target = this; 111 m_drawProperties.render_target = this;
104 } 112 }
105 113
106 int LayerImpl::descendantsDrawContent() 114 int LayerImpl::descendantsDrawContent()
107 { 115 {
108 int result = 0; 116 int result = 0;
109 for (size_t i = 0; i < m_children.size(); ++i) { 117 for (size_t i = 0; i < m_children.size(); ++i) {
110 if (m_children[i]->drawsContent()) 118 if (m_children[i]->drawsContent())
111 ++result; 119 ++result;
112 result += m_children[i]->descendantsDrawContent(); 120 result += m_children[i]->descendantsDrawContent();
113 if (result > 1) 121 if (result > 1)
114 return result; 122 return result;
115 } 123 }
116 return result; 124 return result;
117 } 125 }
118 126
127 void LayerImpl::setLayerTreeHostImpl(LayerTreeHostImpl* hostImpl)
128 {
129 if (m_layerTreeHostImpl == hostImpl)
130 return;
131
132 m_layerTreeHostImpl = hostImpl;
133
134 for (size_t i = 0; i < m_children.size(); ++i)
135 m_children[i]->setLayerTreeHostImpl(hostImpl);
136
137 if (m_maskLayer)
138 m_maskLayer->setLayerTreeHostImpl(hostImpl);
139 if (m_replicaLayer)
140 m_replicaLayer->setLayerTreeHostImpl(hostImpl);
141
142 if (m_layerTreeHostImpl)
143 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
144 }
145
119 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const 146 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const
120 { 147 {
121 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); 148 scoped_ptr<SharedQuadState> state = SharedQuadState::Create();
122 state->SetAll(m_drawProperties.target_space_transform, 149 state->SetAll(m_drawProperties.target_space_transform,
123 m_drawProperties.visible_content_rect, 150 m_drawProperties.visible_content_rect,
124 m_drawProperties.drawable_content_rect, 151 m_drawProperties.drawable_content_rect,
125 m_drawProperties.clip_rect, 152 m_drawProperties.clip_rect,
126 m_drawProperties.is_clipped, 153 m_drawProperties.is_clipped,
127 m_drawProperties.opacity); 154 m_drawProperties.opacity);
128 return state.Pass(); 155 return state.Pass();
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 LayerImpl* current = this->m_parent; 395 LayerImpl* current = this->m_parent;
369 while (current && !current->m_drawProperties.render_surface) { 396 while (current && !current->m_drawProperties.render_surface) {
370 if (current->m_layerSurfacePropertyChanged) 397 if (current->m_layerSurfacePropertyChanged)
371 return true; 398 return true;
372 current = current->m_parent; 399 current = current->m_parent;
373 } 400 }
374 401
375 return false; 402 return false;
376 } 403 }
377 404
405 void LayerImpl::noteLayerSurfacePropertyChanged()
406 {
407 m_layerSurfacePropertyChanged = true;
408 if (m_layerTreeHostImpl)
409 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
410 }
411
412 void LayerImpl::noteLayerPropertyChanged()
413 {
414 m_layerPropertyChanged = true;
415 if (m_layerTreeHostImpl)
416 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
417 }
418
378 void LayerImpl::noteLayerPropertyChangedForSubtree() 419 void LayerImpl::noteLayerPropertyChangedForSubtree()
379 { 420 {
380 m_layerPropertyChanged = true; 421 noteLayerPropertyChanged();
381 noteLayerPropertyChangedForDescendants(); 422 noteLayerPropertyChangedForDescendants();
382 } 423 }
383 424
384 void LayerImpl::noteLayerPropertyChangedForDescendants() 425 void LayerImpl::noteLayerPropertyChangedForDescendants()
385 { 426 {
386 for (size_t i = 0; i < m_children.size(); ++i) 427 for (size_t i = 0; i < m_children.size(); ++i) {
danakj 2012/12/06 19:12:10 extra {}s
enne (OOO) 2012/12/06 19:25:42 Done.
387 m_children[i]->noteLayerPropertyChangedForSubtree(); 428 m_children[i]->noteLayerPropertyChangedForSubtree();
429 }
388 } 430 }
389 431
390 const char* LayerImpl::layerTypeAsString() const 432 const char* LayerImpl::layerTypeAsString() const
391 { 433 {
392 return "Layer"; 434 return "Layer";
393 } 435 }
394 436
395 void LayerImpl::resetAllChangeTrackingForSubtree() 437 void LayerImpl::resetAllChangeTrackingForSubtree()
396 { 438 {
397 m_layerPropertyChanged = false; 439 m_layerPropertyChanged = false;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 void LayerImpl::setBounds(const gfx::Size& bounds) 487 void LayerImpl::setBounds(const gfx::Size& bounds)
446 { 488 {
447 if (m_bounds == bounds) 489 if (m_bounds == bounds)
448 return; 490 return;
449 491
450 m_bounds = bounds; 492 m_bounds = bounds;
451 493
452 if (masksToBounds()) 494 if (masksToBounds())
453 noteLayerPropertyChangedForSubtree(); 495 noteLayerPropertyChangedForSubtree();
454 else 496 else
455 m_layerPropertyChanged = true; 497 noteLayerPropertyChanged();
456 } 498 }
457 499
458 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) 500 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer)
459 { 501 {
460 m_maskLayer = maskLayer.Pass(); 502 m_maskLayer = maskLayer.Pass();
461 503
462 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1; 504 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1;
463 if (newLayerId == m_maskLayerId) 505 if (newLayerId == m_maskLayerId)
464 return; 506 return;
465 507
(...skipping 12 matching lines...) Expand all
478 m_replicaLayerId = newLayerId; 520 m_replicaLayerId = newLayerId;
479 noteLayerPropertyChangedForSubtree(); 521 noteLayerPropertyChangedForSubtree();
480 } 522 }
481 523
482 void LayerImpl::setDrawsContent(bool drawsContent) 524 void LayerImpl::setDrawsContent(bool drawsContent)
483 { 525 {
484 if (m_drawsContent == drawsContent) 526 if (m_drawsContent == drawsContent)
485 return; 527 return;
486 528
487 m_drawsContent = drawsContent; 529 m_drawsContent = drawsContent;
488 m_layerPropertyChanged = true; 530 noteLayerPropertyChanged();
489 } 531 }
490 532
491 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint) 533 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint)
492 { 534 {
493 if (m_anchorPoint == anchorPoint) 535 if (m_anchorPoint == anchorPoint)
494 return; 536 return;
495 537
496 m_anchorPoint = anchorPoint; 538 m_anchorPoint = anchorPoint;
497 noteLayerPropertyChangedForSubtree(); 539 noteLayerPropertyChangedForSubtree();
498 } 540 }
499 541
500 void LayerImpl::setAnchorPointZ(float anchorPointZ) 542 void LayerImpl::setAnchorPointZ(float anchorPointZ)
501 { 543 {
502 if (m_anchorPointZ == anchorPointZ) 544 if (m_anchorPointZ == anchorPointZ)
503 return; 545 return;
504 546
505 m_anchorPointZ = anchorPointZ; 547 m_anchorPointZ = anchorPointZ;
506 noteLayerPropertyChangedForSubtree(); 548 noteLayerPropertyChangedForSubtree();
507 } 549 }
508 550
509 void LayerImpl::setBackgroundColor(SkColor backgroundColor) 551 void LayerImpl::setBackgroundColor(SkColor backgroundColor)
510 { 552 {
511 if (m_backgroundColor == backgroundColor) 553 if (m_backgroundColor == backgroundColor)
512 return; 554 return;
513 555
514 m_backgroundColor = backgroundColor; 556 m_backgroundColor = backgroundColor;
515 m_layerPropertyChanged = true; 557 noteLayerPropertyChanged();
516 } 558 }
517 559
518 void LayerImpl::setFilters(const WebKit::WebFilterOperations& filters) 560 void LayerImpl::setFilters(const WebKit::WebFilterOperations& filters)
519 { 561 {
520 if (m_filters == filters) 562 if (m_filters == filters)
521 return; 563 return;
522 564
523 DCHECK(!m_filter); 565 DCHECK(!m_filter);
524 m_filters = filters; 566 m_filters = filters;
525 noteLayerPropertyChangedForSubtree(); 567 noteLayerPropertyChangedForSubtree();
526 } 568 }
527 569
528 void LayerImpl::setBackgroundFilters(const WebKit::WebFilterOperations& backgrou ndFilters) 570 void LayerImpl::setBackgroundFilters(const WebKit::WebFilterOperations& backgrou ndFilters)
529 { 571 {
530 if (m_backgroundFilters == backgroundFilters) 572 if (m_backgroundFilters == backgroundFilters)
531 return; 573 return;
532 574
533 m_backgroundFilters = backgroundFilters; 575 m_backgroundFilters = backgroundFilters;
534 m_layerPropertyChanged = true; 576 noteLayerPropertyChanged();
535 } 577 }
536 578
537 void LayerImpl::setFilter(const skia::RefPtr<SkImageFilter>& filter) 579 void LayerImpl::setFilter(const skia::RefPtr<SkImageFilter>& filter)
538 { 580 {
539 if (m_filter.get() == filter.get()) 581 if (m_filter.get() == filter.get())
540 return; 582 return;
541 583
542 DCHECK(m_filters.isEmpty()); 584 DCHECK(m_filters.isEmpty());
543 m_filter = filter; 585 m_filter = filter;
544 noteLayerPropertyChangedForSubtree(); 586 noteLayerPropertyChangedForSubtree();
(...skipping 16 matching lines...) Expand all
561 m_contentsOpaque = opaque; 603 m_contentsOpaque = opaque;
562 noteLayerPropertyChangedForSubtree(); 604 noteLayerPropertyChangedForSubtree();
563 } 605 }
564 606
565 void LayerImpl::setOpacity(float opacity) 607 void LayerImpl::setOpacity(float opacity)
566 { 608 {
567 if (m_opacity == opacity) 609 if (m_opacity == opacity)
568 return; 610 return;
569 611
570 m_opacity = opacity; 612 m_opacity = opacity;
571 m_layerSurfacePropertyChanged = true; 613 noteLayerSurfacePropertyChanged();
572 } 614 }
573 615
574 bool LayerImpl::opacityIsAnimating() const 616 bool LayerImpl::opacityIsAnimating() const
575 { 617 {
576 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac ity); 618 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac ity);
577 } 619 }
578 620
579 void LayerImpl::setPosition(const gfx::PointF& position) 621 void LayerImpl::setPosition(const gfx::PointF& position)
580 { 622 {
581 if (m_position == position) 623 if (m_position == position)
(...skipping 21 matching lines...) Expand all
603 // sublayer transform does not affect the current layer; it affects only its children. 645 // sublayer transform does not affect the current layer; it affects only its children.
604 noteLayerPropertyChangedForDescendants(); 646 noteLayerPropertyChangedForDescendants();
605 } 647 }
606 648
607 void LayerImpl::setTransform(const gfx::Transform& transform) 649 void LayerImpl::setTransform(const gfx::Transform& transform)
608 { 650 {
609 if (m_transform == transform) 651 if (m_transform == transform)
610 return; 652 return;
611 653
612 m_transform = transform; 654 m_transform = transform;
613 m_layerSurfacePropertyChanged = true; 655 noteLayerSurfacePropertyChanged();
614 } 656 }
615 657
616 bool LayerImpl::transformIsAnimating() const 658 bool LayerImpl::transformIsAnimating() const
617 { 659 {
618 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform); 660 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform);
619 } 661 }
620 662
621 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) 663 void LayerImpl::setContentBounds(const gfx::Size& contentBounds)
622 { 664 {
623 if (m_contentBounds == contentBounds) 665 if (m_contentBounds == contentBounds)
624 return; 666 return;
625 667
626 m_contentBounds = contentBounds; 668 m_contentBounds = contentBounds;
627 m_layerPropertyChanged = true; 669 noteLayerPropertyChanged();
628 } 670 }
629 671
630 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) 672 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY)
631 { 673 {
632 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY ) 674 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY )
633 return; 675 return;
634 676
635 m_contentsScaleX = contentsScaleX; 677 m_contentsScaleX = contentsScaleX;
636 m_contentsScaleY = contentsScaleY; 678 m_contentsScaleY = contentsScaleY;
637 m_layerPropertyChanged = true; 679 noteLayerPropertyChanged();
638 } 680 }
639 681
640 void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset) 682 void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset)
641 { 683 {
642 if (m_scrollOffset == scrollOffset) 684 if (m_scrollOffset == scrollOffset)
643 return; 685 return;
644 686
645 m_scrollOffset = scrollOffset; 687 m_scrollOffset = scrollOffset;
646 noteLayerPropertyChangedForSubtree(); 688 noteLayerPropertyChangedForSubtree();
647 } 689 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 765
724 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) 766 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
725 { 767 {
726 if (!m_scrollbarAnimationController) 768 if (!m_scrollbarAnimationController)
727 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is); 769 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
728 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 770 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
729 m_scrollbarAnimationController->updateScrollOffset(this); 771 m_scrollbarAnimationController->updateScrollOffset(this);
730 } 772 }
731 773
732 } // namespace cc 774 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698