OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 , m_contentsScaleY(1.0) | 31 , m_contentsScaleY(1.0) |
32 , m_scrollable(false) | 32 , m_scrollable(false) |
33 , m_shouldScrollOnMainThread(false) | 33 , m_shouldScrollOnMainThread(false) |
34 , m_haveWheelEventHandlers(false) | 34 , m_haveWheelEventHandlers(false) |
35 , m_backgroundColor(0) | 35 , m_backgroundColor(0) |
36 , m_doubleSided(true) | 36 , m_doubleSided(true) |
37 , m_layerPropertyChanged(false) | 37 , m_layerPropertyChanged(false) |
38 , m_layerSurfacePropertyChanged(false) | 38 , m_layerSurfacePropertyChanged(false) |
39 , m_masksToBounds(false) | 39 , m_masksToBounds(false) |
40 , m_contentsOpaque(false) | 40 , m_contentsOpaque(false) |
| 41 , m_opacity(1.0) |
41 , m_preserves3D(false) | 42 , m_preserves3D(false) |
42 , m_useParentBackfaceVisibility(false) | 43 , m_useParentBackfaceVisibility(false) |
43 , m_drawCheckerboardForMissingTiles(false) | 44 , m_drawCheckerboardForMissingTiles(false) |
44 , m_useLCDText(false) | 45 , m_useLCDText(false) |
45 , m_drawsContent(false) | 46 , m_drawsContent(false) |
46 , m_forceRenderSurface(false) | 47 , m_forceRenderSurface(false) |
47 , m_isContainerForFixedPositionLayers(false) | 48 , m_isContainerForFixedPositionLayers(false) |
48 , m_fixedToContainerLayer(false) | 49 , m_fixedToContainerLayer(false) |
49 , m_drawDepth(0) | 50 , m_drawDepth(0) |
50 #ifndef NDEBUG | 51 #ifndef NDEBUG |
51 , m_betweenWillDrawAndDidDraw(false) | 52 , m_betweenWillDrawAndDidDraw(false) |
52 #endif | 53 #endif |
53 , m_layerAnimationController(LayerAnimationController::create()) | 54 , m_layerAnimationController(LayerAnimationController::create(this)) |
54 { | 55 { |
55 DCHECK(m_layerId > 0); | 56 DCHECK(m_layerId > 0); |
56 DCHECK(m_layerTreeHostImpl); | 57 DCHECK(m_layerTreeHostImpl); |
57 m_layerAnimationController->setId(m_layerId); | |
58 m_layerAnimationController->setAnimationRegistrar(hostImpl); | |
59 } | 58 } |
60 | 59 |
61 LayerImpl::~LayerImpl() | 60 LayerImpl::~LayerImpl() |
62 { | 61 { |
63 #ifndef NDEBUG | 62 #ifndef NDEBUG |
64 DCHECK(!m_betweenWillDrawAndDidDraw); | 63 DCHECK(!m_betweenWillDrawAndDidDraw); |
65 #endif | 64 #endif |
66 } | 65 } |
67 | 66 |
68 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) | 67 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 bool LayerImpl::layerIsAlwaysDamaged() const | 444 bool LayerImpl::layerIsAlwaysDamaged() const |
446 { | 445 { |
447 return false; | 446 return false; |
448 } | 447 } |
449 | 448 |
450 int LayerImpl::id() const | 449 int LayerImpl::id() const |
451 { | 450 { |
452 return m_layerId; | 451 return m_layerId; |
453 } | 452 } |
454 | 453 |
| 454 float LayerImpl::opacity() const |
| 455 { |
| 456 return m_opacity; |
| 457 } |
| 458 |
| 459 void LayerImpl::setOpacityFromAnimation(float opacity) |
| 460 { |
| 461 setOpacity(opacity); |
| 462 } |
| 463 |
| 464 const gfx::Transform& LayerImpl::transform() const |
| 465 { |
| 466 return m_transform; |
| 467 } |
| 468 |
| 469 void LayerImpl::setTransformFromAnimation(const gfx::Transform& transform) |
| 470 { |
| 471 setTransform(transform); |
| 472 } |
| 473 |
455 void LayerImpl::setBounds(const gfx::Size& bounds) | 474 void LayerImpl::setBounds(const gfx::Size& bounds) |
456 { | 475 { |
457 if (m_bounds == bounds) | 476 if (m_bounds == bounds) |
458 return; | 477 return; |
459 | 478 |
460 m_bounds = bounds; | 479 m_bounds = bounds; |
461 | 480 |
462 if (masksToBounds()) | 481 if (masksToBounds()) |
463 noteLayerPropertyChangedForSubtree(); | 482 noteLayerPropertyChangedForSubtree(); |
464 else | 483 else |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 { | 590 { |
572 if (m_contentsOpaque == opaque) | 591 if (m_contentsOpaque == opaque) |
573 return; | 592 return; |
574 | 593 |
575 m_contentsOpaque = opaque; | 594 m_contentsOpaque = opaque; |
576 noteLayerPropertyChangedForSubtree(); | 595 noteLayerPropertyChangedForSubtree(); |
577 } | 596 } |
578 | 597 |
579 void LayerImpl::setOpacity(float opacity) | 598 void LayerImpl::setOpacity(float opacity) |
580 { | 599 { |
581 if (!m_layerAnimationController->setOpacity(opacity)) | 600 if (m_opacity == opacity) |
582 return; | 601 return; |
| 602 |
| 603 m_opacity = opacity; |
583 m_layerSurfacePropertyChanged = true; | 604 m_layerSurfacePropertyChanged = true; |
584 } | 605 } |
585 | 606 |
586 float LayerImpl::opacity() const | |
587 { | |
588 return m_layerAnimationController->opacity(); | |
589 } | |
590 | |
591 bool LayerImpl::opacityIsAnimating() const | 607 bool LayerImpl::opacityIsAnimating() const |
592 { | 608 { |
593 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); | 609 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); |
594 } | 610 } |
595 | 611 |
596 void LayerImpl::setPosition(const gfx::PointF& position) | 612 void LayerImpl::setPosition(const gfx::PointF& position) |
597 { | 613 { |
598 if (m_position == position) | 614 if (m_position == position) |
599 return; | 615 return; |
600 | 616 |
(...skipping 15 matching lines...) Expand all Loading... |
616 if (m_sublayerTransform == sublayerTransform) | 632 if (m_sublayerTransform == sublayerTransform) |
617 return; | 633 return; |
618 | 634 |
619 m_sublayerTransform = sublayerTransform; | 635 m_sublayerTransform = sublayerTransform; |
620 // sublayer transform does not affect the current layer; it affects only its
children. | 636 // sublayer transform does not affect the current layer; it affects only its
children. |
621 noteLayerPropertyChangedForDescendants(); | 637 noteLayerPropertyChangedForDescendants(); |
622 } | 638 } |
623 | 639 |
624 void LayerImpl::setTransform(const gfx::Transform& transform) | 640 void LayerImpl::setTransform(const gfx::Transform& transform) |
625 { | 641 { |
626 if (!m_layerAnimationController->setTransform(transform)) | 642 if (m_transform == transform) |
627 return; | 643 return; |
| 644 |
| 645 m_transform = transform; |
628 m_layerSurfacePropertyChanged = true; | 646 m_layerSurfacePropertyChanged = true; |
629 } | 647 } |
630 | 648 |
631 const gfx::Transform& LayerImpl::transform() const | |
632 { | |
633 return m_layerAnimationController->transform(); | |
634 } | |
635 | |
636 bool LayerImpl::transformIsAnimating() const | 649 bool LayerImpl::transformIsAnimating() const |
637 { | 650 { |
638 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran
sform); | 651 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran
sform); |
639 } | 652 } |
640 | 653 |
641 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) | 654 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) |
642 { | 655 { |
643 if (m_contentBounds == contentBounds) | 656 if (m_contentBounds == contentBounds) |
644 return; | 657 return; |
645 | 658 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 | 756 |
744 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 757 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
745 { | 758 { |
746 if (!m_scrollbarAnimationController) | 759 if (!m_scrollbarAnimationController) |
747 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); | 760 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); |
748 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); | 761 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
749 m_scrollbarAnimationController->updateScrollOffset(this); | 762 m_scrollbarAnimationController->updateScrollOffset(this); |
750 } | 763 } |
751 | 764 |
752 } // namespace cc | 765 } // namespace cc |
OLD | NEW |