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/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 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) | |
42 , m_preserves3D(false) | 41 , m_preserves3D(false) |
43 , m_useParentBackfaceVisibility(false) | 42 , m_useParentBackfaceVisibility(false) |
44 , m_drawCheckerboardForMissingTiles(false) | 43 , m_drawCheckerboardForMissingTiles(false) |
45 , m_useLCDText(false) | 44 , m_useLCDText(false) |
46 , m_drawsContent(false) | 45 , m_drawsContent(false) |
47 , m_forceRenderSurface(false) | 46 , m_forceRenderSurface(false) |
48 , m_isContainerForFixedPositionLayers(false) | 47 , m_isContainerForFixedPositionLayers(false) |
49 , m_fixedToContainerLayer(false) | 48 , m_fixedToContainerLayer(false) |
50 , m_drawDepth(0) | 49 , m_drawDepth(0) |
51 #ifndef NDEBUG | 50 #ifndef NDEBUG |
52 , m_betweenWillDrawAndDidDraw(false) | 51 , m_betweenWillDrawAndDidDraw(false) |
53 #endif | 52 #endif |
54 , m_layerAnimationController(LayerAnimationController::create(this)) | 53 , m_layerAnimationController(LayerAnimationController::create()) |
55 { | 54 { |
56 DCHECK(m_layerId > 0); | 55 DCHECK(m_layerId > 0); |
| 56 m_layerAnimationController->setId(m_layerId); |
57 } | 57 } |
58 | 58 |
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) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 for (size_t i = 0; i < m_children.size(); ++i) { | 109 for (size_t i = 0; i < m_children.size(); ++i) { |
110 if (m_children[i]->drawsContent()) | 110 if (m_children[i]->drawsContent()) |
111 ++result; | 111 ++result; |
112 result += m_children[i]->descendantsDrawContent(); | 112 result += m_children[i]->descendantsDrawContent(); |
113 if (result > 1) | 113 if (result > 1) |
114 return result; | 114 return result; |
115 } | 115 } |
116 return result; | 116 return result; |
117 } | 117 } |
118 | 118 |
| 119 void LayerImpl::setLayerTreeHostImpl(LayerTreeHostImpl* hostImpl) |
| 120 { |
| 121 m_layerTreeHostImpl = hostImpl; |
| 122 m_layerAnimationController->setAnimationRegistrar(hostImpl); |
| 123 } |
| 124 |
119 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const | 125 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const |
120 { | 126 { |
121 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); | 127 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); |
122 state->SetAll(m_drawProperties.target_space_transform, | 128 state->SetAll(m_drawProperties.target_space_transform, |
123 m_drawProperties.visible_content_rect, | 129 m_drawProperties.visible_content_rect, |
124 m_drawProperties.drawable_content_rect, | 130 m_drawProperties.drawable_content_rect, |
125 m_drawProperties.clip_rect, | 131 m_drawProperties.clip_rect, |
126 m_drawProperties.is_clipped, | 132 m_drawProperties.is_clipped, |
127 m_drawProperties.opacity); | 133 m_drawProperties.opacity); |
128 return state.Pass(); | 134 return state.Pass(); |
(...skipping 286 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 |