| 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 "cc/animation_registrar.h" |
| 9 #include "cc/debug_border_draw_quad.h" | 10 #include "cc/debug_border_draw_quad.h" |
| 10 #include "cc/debug_colors.h" | 11 #include "cc/debug_colors.h" |
| 11 #include "cc/layer_sorter.h" | 12 #include "cc/layer_sorter.h" |
| 12 #include "cc/layer_tree_host_impl.h" | 13 #include "cc/layer_tree_host_impl.h" |
| 13 #include "cc/math_util.h" | 14 #include "cc/math_util.h" |
| 14 #include "cc/proxy.h" | 15 #include "cc/proxy.h" |
| 15 #include "cc/quad_sink.h" | 16 #include "cc/quad_sink.h" |
| 16 #include "cc/scrollbar_animation_controller.h" | 17 #include "cc/scrollbar_animation_controller.h" |
| 17 #include "ui/gfx/point_conversions.h" | 18 #include "ui/gfx/point_conversions.h" |
| 18 #include "ui/gfx/rect_conversions.h" | 19 #include "ui/gfx/rect_conversions.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 31 , m_contentsScaleY(1.0) | 32 , m_contentsScaleY(1.0) |
| 32 , m_scrollable(false) | 33 , m_scrollable(false) |
| 33 , m_shouldScrollOnMainThread(false) | 34 , m_shouldScrollOnMainThread(false) |
| 34 , m_haveWheelEventHandlers(false) | 35 , m_haveWheelEventHandlers(false) |
| 35 , m_backgroundColor(0) | 36 , m_backgroundColor(0) |
| 36 , m_doubleSided(true) | 37 , m_doubleSided(true) |
| 37 , m_layerPropertyChanged(false) | 38 , m_layerPropertyChanged(false) |
| 38 , m_layerSurfacePropertyChanged(false) | 39 , m_layerSurfacePropertyChanged(false) |
| 39 , m_masksToBounds(false) | 40 , m_masksToBounds(false) |
| 40 , m_contentsOpaque(false) | 41 , m_contentsOpaque(false) |
| 41 , m_opacity(1.0) | |
| 42 , m_preserves3D(false) | 42 , m_preserves3D(false) |
| 43 , m_useParentBackfaceVisibility(false) | 43 , m_useParentBackfaceVisibility(false) |
| 44 , m_drawCheckerboardForMissingTiles(false) | 44 , m_drawCheckerboardForMissingTiles(false) |
| 45 , m_useLCDText(false) | 45 , m_useLCDText(false) |
| 46 , m_drawsContent(false) | 46 , m_drawsContent(false) |
| 47 , m_forceRenderSurface(false) | 47 , m_forceRenderSurface(false) |
| 48 , m_isContainerForFixedPositionLayers(false) | 48 , m_isContainerForFixedPositionLayers(false) |
| 49 , m_fixedToContainerLayer(false) | 49 , m_fixedToContainerLayer(false) |
| 50 , m_renderTarget(0) | 50 , m_renderTarget(0) |
| 51 , m_drawDepth(0) | 51 , m_drawDepth(0) |
| 52 , m_drawOpacity(0) | 52 , m_drawOpacity(0) |
| 53 , m_drawOpacityIsAnimating(false) | 53 , m_drawOpacityIsAnimating(false) |
| 54 , m_drawTransformIsAnimating(false) | 54 , m_drawTransformIsAnimating(false) |
| 55 , m_screenSpaceTransformIsAnimating(false) | 55 , m_screenSpaceTransformIsAnimating(false) |
| 56 , m_isClipped(false) | 56 , m_isClipped(false) |
| 57 #ifndef NDEBUG | 57 #ifndef NDEBUG |
| 58 , m_betweenWillDrawAndDidDraw(false) | 58 , m_betweenWillDrawAndDidDraw(false) |
| 59 #endif | 59 #endif |
| 60 , m_layerAnimationController(LayerAnimationController::create(this)) | 60 , m_layerAnimationController(LayerAnimationController::create(AnimationRegis
trar::CompositorThread)) |
| 61 { | 61 { |
| 62 DCHECK(m_layerId > 0); | 62 DCHECK(m_layerId > 0); |
| 63 m_layerAnimationController->setId(m_layerId); |
| 63 } | 64 } |
| 64 | 65 |
| 65 LayerImpl::~LayerImpl() | 66 LayerImpl::~LayerImpl() |
| 66 { | 67 { |
| 67 #ifndef NDEBUG | 68 #ifndef NDEBUG |
| 68 DCHECK(!m_betweenWillDrawAndDidDraw); | 69 DCHECK(!m_betweenWillDrawAndDidDraw); |
| 69 #endif | 70 #endif |
| 70 } | 71 } |
| 71 | 72 |
| 72 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) | 73 void LayerImpl::addChild(scoped_ptr<LayerImpl> child) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 for (size_t i = 0; i < m_children.size(); ++i) { | 116 for (size_t i = 0; i < m_children.size(); ++i) { |
| 116 if (m_children[i]->drawsContent()) | 117 if (m_children[i]->drawsContent()) |
| 117 ++result; | 118 ++result; |
| 118 result += m_children[i]->descendantsDrawContent(); | 119 result += m_children[i]->descendantsDrawContent(); |
| 119 if (result > 1) | 120 if (result > 1) |
| 120 return result; | 121 return result; |
| 121 } | 122 } |
| 122 return result; | 123 return result; |
| 123 } | 124 } |
| 124 | 125 |
| 126 void LayerImpl::setLayerTreeHostImpl(LayerTreeHostImpl* hostImpl) |
| 127 { |
| 128 m_layerTreeHostImpl = hostImpl; |
| 129 } |
| 130 |
| 125 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const | 131 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const |
| 126 { | 132 { |
| 127 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); | 133 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); |
| 128 state->SetAll(m_drawTransform, m_visibleContentRect, m_drawableContentRect, m_
clipRect, m_isClipped, m_drawOpacity); | 134 state->SetAll(m_drawTransform, m_visibleContentRect, m_drawableContentRect, m_
clipRect, m_isClipped, m_drawOpacity); |
| 129 return state.Pass(); | 135 return state.Pass(); |
| 130 } | 136 } |
| 131 | 137 |
| 132 void LayerImpl::willDraw(ResourceProvider*) | 138 void LayerImpl::willDraw(ResourceProvider*) |
| 133 { | 139 { |
| 134 #ifndef NDEBUG | 140 #ifndef NDEBUG |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 bool LayerImpl::layerIsAlwaysDamaged() const | 421 bool LayerImpl::layerIsAlwaysDamaged() const |
| 416 { | 422 { |
| 417 return false; | 423 return false; |
| 418 } | 424 } |
| 419 | 425 |
| 420 int LayerImpl::id() const | 426 int LayerImpl::id() const |
| 421 { | 427 { |
| 422 return m_layerId; | 428 return m_layerId; |
| 423 } | 429 } |
| 424 | 430 |
| 425 float LayerImpl::opacity() const | |
| 426 { | |
| 427 return m_opacity; | |
| 428 } | |
| 429 | |
| 430 void LayerImpl::setOpacityFromAnimation(float opacity) | |
| 431 { | |
| 432 setOpacity(opacity); | |
| 433 } | |
| 434 | |
| 435 const gfx::Transform& LayerImpl::transform() const | |
| 436 { | |
| 437 return m_transform; | |
| 438 } | |
| 439 | |
| 440 void LayerImpl::setTransformFromAnimation(const gfx::Transform& transform) | |
| 441 { | |
| 442 setTransform(transform); | |
| 443 } | |
| 444 | |
| 445 void LayerImpl::setBounds(const gfx::Size& bounds) | 431 void LayerImpl::setBounds(const gfx::Size& bounds) |
| 446 { | 432 { |
| 447 if (m_bounds == bounds) | 433 if (m_bounds == bounds) |
| 448 return; | 434 return; |
| 449 | 435 |
| 450 m_bounds = bounds; | 436 m_bounds = bounds; |
| 451 | 437 |
| 452 if (masksToBounds()) | 438 if (masksToBounds()) |
| 453 noteLayerPropertyChangedForSubtree(); | 439 noteLayerPropertyChangedForSubtree(); |
| 454 else | 440 else |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 { | 543 { |
| 558 if (m_contentsOpaque == opaque) | 544 if (m_contentsOpaque == opaque) |
| 559 return; | 545 return; |
| 560 | 546 |
| 561 m_contentsOpaque = opaque; | 547 m_contentsOpaque = opaque; |
| 562 noteLayerPropertyChangedForSubtree(); | 548 noteLayerPropertyChangedForSubtree(); |
| 563 } | 549 } |
| 564 | 550 |
| 565 void LayerImpl::setOpacity(float opacity) | 551 void LayerImpl::setOpacity(float opacity) |
| 566 { | 552 { |
| 567 if (m_opacity == opacity) | 553 if (!m_layerAnimationController->setOpacity(opacity)) |
| 568 return; | 554 return; |
| 555 m_layerSurfacePropertyChanged = true; |
| 556 } |
| 569 | 557 |
| 570 m_opacity = opacity; | 558 float LayerImpl::opacity() const |
| 571 m_layerSurfacePropertyChanged = true; | 559 { |
| 560 return m_layerAnimationController->opacity(); |
| 572 } | 561 } |
| 573 | 562 |
| 574 bool LayerImpl::opacityIsAnimating() const | 563 bool LayerImpl::opacityIsAnimating() const |
| 575 { | 564 { |
| 576 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); | 565 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); |
| 577 } | 566 } |
| 578 | 567 |
| 579 void LayerImpl::setPosition(const gfx::PointF& position) | 568 void LayerImpl::setPosition(const gfx::PointF& position) |
| 580 { | 569 { |
| 581 if (m_position == position) | 570 if (m_position == position) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 599 if (m_sublayerTransform == sublayerTransform) | 588 if (m_sublayerTransform == sublayerTransform) |
| 600 return; | 589 return; |
| 601 | 590 |
| 602 m_sublayerTransform = sublayerTransform; | 591 m_sublayerTransform = sublayerTransform; |
| 603 // sublayer transform does not affect the current layer; it affects only its
children. | 592 // sublayer transform does not affect the current layer; it affects only its
children. |
| 604 noteLayerPropertyChangedForDescendants(); | 593 noteLayerPropertyChangedForDescendants(); |
| 605 } | 594 } |
| 606 | 595 |
| 607 void LayerImpl::setTransform(const gfx::Transform& transform) | 596 void LayerImpl::setTransform(const gfx::Transform& transform) |
| 608 { | 597 { |
| 609 if (m_transform == transform) | 598 if (!m_layerAnimationController->setTransform(transform)) |
| 610 return; | 599 return; |
| 600 m_layerSurfacePropertyChanged = true; |
| 601 } |
| 611 | 602 |
| 612 m_transform = transform; | 603 const gfx::Transform& LayerImpl::transform() const |
| 613 m_layerSurfacePropertyChanged = true; | 604 { |
| 605 return m_layerAnimationController->transform(); |
| 614 } | 606 } |
| 615 | 607 |
| 616 bool LayerImpl::transformIsAnimating() const | 608 bool LayerImpl::transformIsAnimating() const |
| 617 { | 609 { |
| 618 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran
sform); | 610 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran
sform); |
| 619 } | 611 } |
| 620 | 612 |
| 621 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) | 613 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) |
| 622 { | 614 { |
| 623 if (m_contentBounds == contentBounds) | 615 if (m_contentBounds == contentBounds) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 | 715 |
| 724 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 716 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
| 725 { | 717 { |
| 726 if (!m_scrollbarAnimationController) | 718 if (!m_scrollbarAnimationController) |
| 727 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); | 719 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); |
| 728 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); | 720 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
| 729 m_scrollbarAnimationController->updateScrollOffset(this); | 721 m_scrollbarAnimationController->updateScrollOffset(this); |
| 730 } | 722 } |
| 731 | 723 |
| 732 } // namespace cc | 724 } // namespace cc |
| OLD | NEW |