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

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: Testing 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 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) {
84 parent->m_children.remove(i); 85 parent->m_children.remove(i);
86 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
85 return; 87 return;
86 } 88 }
87 } 89 }
88 } 90 }
89 91
90 void LayerImpl::removeAllChildren() 92 void LayerImpl::removeAllChildren()
91 { 93 {
92 while (m_children.size()) 94 while (m_children.size())
93 m_children[0]->removeFromParent(); 95 m_children[0]->removeFromParent();
94 } 96 }
95 97
96 void LayerImpl::clearChildList() 98 void LayerImpl::clearChildList()
97 { 99 {
danakj 2012/12/07 23:12:49 should this early-out if m_children.empty() now?
enne (OOO) 2012/12/07 23:25:05 Done.
98 m_children.clear(); 100 m_children.clear();
101 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
99 } 102 }
100 103
101 void LayerImpl::createRenderSurface() 104 void LayerImpl::createRenderSurface()
102 { 105 {
103 DCHECK(!m_drawProperties.render_surface); 106 DCHECK(!m_drawProperties.render_surface);
104 m_drawProperties.render_surface = make_scoped_ptr(new RenderSurfaceImpl(this )); 107 m_drawProperties.render_surface = make_scoped_ptr(new RenderSurfaceImpl(this ));
105 m_drawProperties.render_target = this; 108 m_drawProperties.render_target = this;
106 } 109 }
107 110
108 int LayerImpl::descendantsDrawContent() 111 int LayerImpl::descendantsDrawContent()
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 LayerImpl* current = this->m_parent; 365 LayerImpl* current = this->m_parent;
363 while (current && !current->m_drawProperties.render_surface) { 366 while (current && !current->m_drawProperties.render_surface) {
364 if (current->m_layerSurfacePropertyChanged) 367 if (current->m_layerSurfacePropertyChanged)
365 return true; 368 return true;
366 current = current->m_parent; 369 current = current->m_parent;
367 } 370 }
368 371
369 return false; 372 return false;
370 } 373 }
371 374
375 void LayerImpl::noteLayerSurfacePropertyChanged()
376 {
377 m_layerSurfacePropertyChanged = true;
378 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
379 }
380
381 void LayerImpl::noteLayerPropertyChanged()
382 {
383 m_layerPropertyChanged = true;
384 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
385 }
386
372 void LayerImpl::noteLayerPropertyChangedForSubtree() 387 void LayerImpl::noteLayerPropertyChangedForSubtree()
373 { 388 {
374 m_layerPropertyChanged = true; 389 noteLayerPropertyChanged();
375 noteLayerPropertyChangedForDescendants(); 390 noteLayerPropertyChangedForDescendants();
376 } 391 }
377 392
378 void LayerImpl::noteLayerPropertyChangedForDescendants() 393 void LayerImpl::noteLayerPropertyChangedForDescendants()
379 { 394 {
395 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
380 for (size_t i = 0; i < m_children.size(); ++i) 396 for (size_t i = 0; i < m_children.size(); ++i)
381 m_children[i]->noteLayerPropertyChangedForSubtree(); 397 m_children[i]->noteLayerPropertyChangedForSubtree();
382 } 398 }
383 399
384 const char* LayerImpl::layerTypeAsString() const 400 const char* LayerImpl::layerTypeAsString() const
385 { 401 {
386 return "Layer"; 402 return "Layer";
387 } 403 }
388 404
389 void LayerImpl::resetAllChangeTrackingForSubtree() 405 void LayerImpl::resetAllChangeTrackingForSubtree()
(...skipping 29 matching lines...) Expand all
419 void LayerImpl::setBounds(const gfx::Size& bounds) 435 void LayerImpl::setBounds(const gfx::Size& bounds)
420 { 436 {
421 if (m_bounds == bounds) 437 if (m_bounds == bounds)
422 return; 438 return;
423 439
424 m_bounds = bounds; 440 m_bounds = bounds;
425 441
426 if (masksToBounds()) 442 if (masksToBounds())
427 noteLayerPropertyChangedForSubtree(); 443 noteLayerPropertyChangedForSubtree();
428 else 444 else
429 m_layerPropertyChanged = true; 445 noteLayerPropertyChanged();
430 } 446 }
431 447
432 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer) 448 void LayerImpl::setMaskLayer(scoped_ptr<LayerImpl> maskLayer)
433 { 449 {
434 if (maskLayer) 450 if (maskLayer)
435 DCHECK_EQ(layerTreeHostImpl(), maskLayer->layerTreeHostImpl()); 451 DCHECK_EQ(layerTreeHostImpl(), maskLayer->layerTreeHostImpl());
436 m_maskLayer = maskLayer.Pass(); 452 m_maskLayer = maskLayer.Pass();
437 453
438 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1; 454 int newLayerId = m_maskLayer ? m_maskLayer->id() : -1;
439 if (newLayerId == m_maskLayerId) 455 if (newLayerId == m_maskLayerId)
(...skipping 16 matching lines...) Expand all
456 m_replicaLayerId = newLayerId; 472 m_replicaLayerId = newLayerId;
457 noteLayerPropertyChangedForSubtree(); 473 noteLayerPropertyChangedForSubtree();
458 } 474 }
459 475
460 void LayerImpl::setDrawsContent(bool drawsContent) 476 void LayerImpl::setDrawsContent(bool drawsContent)
461 { 477 {
462 if (m_drawsContent == drawsContent) 478 if (m_drawsContent == drawsContent)
463 return; 479 return;
464 480
465 m_drawsContent = drawsContent; 481 m_drawsContent = drawsContent;
466 m_layerPropertyChanged = true; 482 noteLayerPropertyChanged();
467 } 483 }
468 484
469 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint) 485 void LayerImpl::setAnchorPoint(const gfx::PointF& anchorPoint)
470 { 486 {
471 if (m_anchorPoint == anchorPoint) 487 if (m_anchorPoint == anchorPoint)
472 return; 488 return;
473 489
474 m_anchorPoint = anchorPoint; 490 m_anchorPoint = anchorPoint;
475 noteLayerPropertyChangedForSubtree(); 491 noteLayerPropertyChangedForSubtree();
476 } 492 }
477 493
478 void LayerImpl::setAnchorPointZ(float anchorPointZ) 494 void LayerImpl::setAnchorPointZ(float anchorPointZ)
479 { 495 {
480 if (m_anchorPointZ == anchorPointZ) 496 if (m_anchorPointZ == anchorPointZ)
481 return; 497 return;
482 498
483 m_anchorPointZ = anchorPointZ; 499 m_anchorPointZ = anchorPointZ;
484 noteLayerPropertyChangedForSubtree(); 500 noteLayerPropertyChangedForSubtree();
485 } 501 }
486 502
487 void LayerImpl::setBackgroundColor(SkColor backgroundColor) 503 void LayerImpl::setBackgroundColor(SkColor backgroundColor)
488 { 504 {
489 if (m_backgroundColor == backgroundColor) 505 if (m_backgroundColor == backgroundColor)
490 return; 506 return;
491 507
492 m_backgroundColor = backgroundColor; 508 m_backgroundColor = backgroundColor;
493 m_layerPropertyChanged = true; 509 noteLayerPropertyChanged();
494 } 510 }
495 511
496 void LayerImpl::setFilters(const WebKit::WebFilterOperations& filters) 512 void LayerImpl::setFilters(const WebKit::WebFilterOperations& filters)
497 { 513 {
498 if (m_filters == filters) 514 if (m_filters == filters)
499 return; 515 return;
500 516
501 DCHECK(!m_filter); 517 DCHECK(!m_filter);
502 m_filters = filters; 518 m_filters = filters;
503 noteLayerPropertyChangedForSubtree(); 519 noteLayerPropertyChangedForSubtree();
504 } 520 }
505 521
506 void LayerImpl::setBackgroundFilters(const WebKit::WebFilterOperations& backgrou ndFilters) 522 void LayerImpl::setBackgroundFilters(const WebKit::WebFilterOperations& backgrou ndFilters)
507 { 523 {
508 if (m_backgroundFilters == backgroundFilters) 524 if (m_backgroundFilters == backgroundFilters)
509 return; 525 return;
510 526
511 m_backgroundFilters = backgroundFilters; 527 m_backgroundFilters = backgroundFilters;
512 m_layerPropertyChanged = true; 528 noteLayerPropertyChanged();
513 } 529 }
514 530
515 void LayerImpl::setFilter(const skia::RefPtr<SkImageFilter>& filter) 531 void LayerImpl::setFilter(const skia::RefPtr<SkImageFilter>& filter)
516 { 532 {
517 if (m_filter.get() == filter.get()) 533 if (m_filter.get() == filter.get())
518 return; 534 return;
519 535
520 DCHECK(m_filters.isEmpty()); 536 DCHECK(m_filters.isEmpty());
521 m_filter = filter; 537 m_filter = filter;
522 noteLayerPropertyChangedForSubtree(); 538 noteLayerPropertyChangedForSubtree();
(...skipping 14 matching lines...) Expand all
537 return; 553 return;
538 554
539 m_contentsOpaque = opaque; 555 m_contentsOpaque = opaque;
540 noteLayerPropertyChangedForSubtree(); 556 noteLayerPropertyChangedForSubtree();
541 } 557 }
542 558
543 void LayerImpl::setOpacity(float opacity) 559 void LayerImpl::setOpacity(float opacity)
544 { 560 {
545 if (!m_layerAnimationController->setOpacity(opacity)) 561 if (!m_layerAnimationController->setOpacity(opacity))
546 return; 562 return;
547 m_layerSurfacePropertyChanged = true; 563
564 noteLayerSurfacePropertyChanged();
548 } 565 }
549 566
550 float LayerImpl::opacity() const 567 float LayerImpl::opacity() const
551 { 568 {
552 return m_layerAnimationController->opacity(); 569 return m_layerAnimationController->opacity();
553 } 570 }
554 571
555 bool LayerImpl::opacityIsAnimating() const 572 bool LayerImpl::opacityIsAnimating() const
556 { 573 {
557 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac ity); 574 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac ity);
(...skipping 24 matching lines...) Expand all
582 599
583 m_sublayerTransform = sublayerTransform; 600 m_sublayerTransform = sublayerTransform;
584 // sublayer transform does not affect the current layer; it affects only its children. 601 // sublayer transform does not affect the current layer; it affects only its children.
585 noteLayerPropertyChangedForDescendants(); 602 noteLayerPropertyChangedForDescendants();
586 } 603 }
587 604
588 void LayerImpl::setTransform(const gfx::Transform& transform) 605 void LayerImpl::setTransform(const gfx::Transform& transform)
589 { 606 {
590 if (!m_layerAnimationController->setTransform(transform)) 607 if (!m_layerAnimationController->setTransform(transform))
591 return; 608 return;
592 m_layerSurfacePropertyChanged = true; 609
610 noteLayerSurfacePropertyChanged();
593 } 611 }
594 612
595 const gfx::Transform& LayerImpl::transform() const 613 const gfx::Transform& LayerImpl::transform() const
596 { 614 {
597 return m_layerAnimationController->transform(); 615 return m_layerAnimationController->transform();
598 } 616 }
599 617
600 bool LayerImpl::transformIsAnimating() const 618 bool LayerImpl::transformIsAnimating() const
601 { 619 {
602 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform); 620 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran sform);
603 } 621 }
604 622
605 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) 623 void LayerImpl::setContentBounds(const gfx::Size& contentBounds)
606 { 624 {
607 if (m_contentBounds == contentBounds) 625 if (m_contentBounds == contentBounds)
608 return; 626 return;
609 627
610 m_contentBounds = contentBounds; 628 m_contentBounds = contentBounds;
611 m_layerPropertyChanged = true; 629 noteLayerPropertyChanged();
612 } 630 }
613 631
614 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) 632 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY)
615 { 633 {
616 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY ) 634 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY )
617 return; 635 return;
618 636
619 m_contentsScaleX = contentsScaleX; 637 m_contentsScaleX = contentsScaleX;
620 m_contentsScaleY = contentsScaleY; 638 m_contentsScaleY = contentsScaleY;
621 m_layerPropertyChanged = true; 639 noteLayerPropertyChanged();
622 } 640 }
623 641
624 void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset) 642 void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset)
625 { 643 {
626 if (m_scrollOffset == scrollOffset) 644 if (m_scrollOffset == scrollOffset)
627 return; 645 return;
628 646
629 m_scrollOffset = scrollOffset; 647 m_scrollOffset = scrollOffset;
630 noteLayerPropertyChangedForSubtree(); 648 noteLayerPropertyChangedForSubtree();
631 } 649 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 return visibleContentRect(); 681 return visibleContentRect();
664 return Region(); 682 return Region();
665 } 683 }
666 684
667 void LayerImpl::didLoseOutputSurface() 685 void LayerImpl::didLoseOutputSurface()
668 { 686 {
669 } 687 }
670 688
671 void LayerImpl::setMaxScrollOffset(gfx::Vector2d maxScrollOffset) 689 void LayerImpl::setMaxScrollOffset(gfx::Vector2d maxScrollOffset)
672 { 690 {
691 if (m_maxScrollOffset == maxScrollOffset)
692 return;
673 m_maxScrollOffset = maxScrollOffset; 693 m_maxScrollOffset = maxScrollOffset;
674 694
695 m_layerTreeHostImpl->setNeedsUpdateDrawProperties();
696
675 if (!m_scrollbarAnimationController) 697 if (!m_scrollbarAnimationController)
676 return; 698 return;
677 m_scrollbarAnimationController->updateScrollOffset(this); 699 m_scrollbarAnimationController->updateScrollOffset(this);
678 } 700 }
679 701
680 ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer() 702 ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer()
681 { 703 {
682 return m_scrollbarAnimationController ? m_scrollbarAnimationController->hori zontalScrollbarLayer() : 0; 704 return m_scrollbarAnimationController ? m_scrollbarAnimationController->hori zontalScrollbarLayer() : 0;
683 } 705 }
684 706
(...skipping 22 matching lines...) Expand all
707 729
708 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) 730 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer)
709 { 731 {
710 if (!m_scrollbarAnimationController) 732 if (!m_scrollbarAnimationController)
711 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is); 733 m_scrollbarAnimationController = ScrollbarAnimationController::create(th is);
712 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); 734 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer);
713 m_scrollbarAnimationController->updateScrollOffset(this); 735 m_scrollbarAnimationController->updateScrollOffset(this);
714 } 736 }
715 737
716 } // namespace cc 738 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_impl.h ('k') | cc/layer_impl_unittest.cc » ('j') | cc/layer_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698