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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 , m_drawDepth(0) | 52 , m_drawDepth(0) |
53 , m_drawOpacity(0) | 53 , m_drawOpacity(0) |
54 , m_drawOpacityIsAnimating(false) | 54 , m_drawOpacityIsAnimating(false) |
55 , m_filter(0) | 55 , m_filter(0) |
56 , m_drawTransformIsAnimating(false) | 56 , m_drawTransformIsAnimating(false) |
57 , m_screenSpaceTransformIsAnimating(false) | 57 , m_screenSpaceTransformIsAnimating(false) |
58 , m_isClipped(false) | 58 , m_isClipped(false) |
59 #ifndef NDEBUG | 59 #ifndef NDEBUG |
60 , m_betweenWillDrawAndDidDraw(false) | 60 , m_betweenWillDrawAndDidDraw(false) |
61 #endif | 61 #endif |
62 , m_layerAnimationController(LayerAnimationController::create(this)) | 62 , m_layerAnimationController(LayerAnimationController::create()) |
63 { | 63 { |
64 DCHECK(m_layerId > 0); | 64 DCHECK(m_layerId > 0); |
| 65 m_layerAnimationController->setId(m_layerId); |
65 } | 66 } |
66 | 67 |
67 LayerImpl::~LayerImpl() | 68 LayerImpl::~LayerImpl() |
68 { | 69 { |
69 #ifndef NDEBUG | 70 #ifndef NDEBUG |
70 DCHECK(!m_betweenWillDrawAndDidDraw); | 71 DCHECK(!m_betweenWillDrawAndDidDraw); |
71 #endif | 72 #endif |
72 SkSafeUnref(m_filter); | 73 SkSafeUnref(m_filter); |
73 } | 74 } |
74 | 75 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 115 |
115 bool LayerImpl::descendantDrawsContent() | 116 bool LayerImpl::descendantDrawsContent() |
116 { | 117 { |
117 for (size_t i = 0; i < m_children.size(); ++i) { | 118 for (size_t i = 0; i < m_children.size(); ++i) { |
118 if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsConte
nt()) | 119 if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsConte
nt()) |
119 return true; | 120 return true; |
120 } | 121 } |
121 return false; | 122 return false; |
122 } | 123 } |
123 | 124 |
| 125 void LayerImpl::setLayerTreeHostImpl(LayerTreeHostImpl* hostImpl) |
| 126 { |
| 127 m_layerTreeHostImpl = hostImpl; |
| 128 m_layerAnimationController->setAnimationRegistrar(hostImpl); |
| 129 } |
| 130 |
124 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const | 131 scoped_ptr<SharedQuadState> LayerImpl::createSharedQuadState() const |
125 { | 132 { |
126 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); | 133 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); |
127 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); |
128 return state.Pass(); | 135 return state.Pass(); |
129 } | 136 } |
130 | 137 |
131 void LayerImpl::willDraw(ResourceProvider*) | 138 void LayerImpl::willDraw(ResourceProvider*) |
132 { | 139 { |
133 #ifndef NDEBUG | 140 #ifndef NDEBUG |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 bool LayerImpl::layerIsAlwaysDamaged() const | 421 bool LayerImpl::layerIsAlwaysDamaged() const |
415 { | 422 { |
416 return false; | 423 return false; |
417 } | 424 } |
418 | 425 |
419 int LayerImpl::id() const | 426 int LayerImpl::id() const |
420 { | 427 { |
421 return m_layerId; | 428 return m_layerId; |
422 } | 429 } |
423 | 430 |
424 float LayerImpl::opacity() const | |
425 { | |
426 return m_opacity; | |
427 } | |
428 | |
429 void LayerImpl::setOpacityFromAnimation(float opacity) | |
430 { | |
431 setOpacity(opacity); | |
432 } | |
433 | |
434 const gfx::Transform& LayerImpl::transform() const | |
435 { | |
436 return m_transform; | |
437 } | |
438 | |
439 void LayerImpl::setTransformFromAnimation(const gfx::Transform& transform) | |
440 { | |
441 setTransform(transform); | |
442 } | |
443 | |
444 void LayerImpl::setBounds(const gfx::Size& bounds) | 431 void LayerImpl::setBounds(const gfx::Size& bounds) |
445 { | 432 { |
446 if (m_bounds == bounds) | 433 if (m_bounds == bounds) |
447 return; | 434 return; |
448 | 435 |
449 m_bounds = bounds; | 436 m_bounds = bounds; |
450 | 437 |
451 if (masksToBounds()) | 438 if (masksToBounds()) |
452 noteLayerPropertyChangedForSubtree(); | 439 noteLayerPropertyChangedForSubtree(); |
453 else | 440 else |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 m_contentsOpaque = opaque; | 547 m_contentsOpaque = opaque; |
561 noteLayerPropertyChangedForSubtree(); | 548 noteLayerPropertyChangedForSubtree(); |
562 } | 549 } |
563 | 550 |
564 void LayerImpl::setOpacity(float opacity) | 551 void LayerImpl::setOpacity(float opacity) |
565 { | 552 { |
566 if (m_opacity == opacity) | 553 if (m_opacity == opacity) |
567 return; | 554 return; |
568 | 555 |
569 m_opacity = opacity; | 556 m_opacity = opacity; |
| 557 m_opacityLastUpdateTime = base::TimeTicks::Now(); |
570 m_layerSurfacePropertyChanged = true; | 558 m_layerSurfacePropertyChanged = true; |
571 } | 559 } |
572 | 560 |
| 561 float LayerImpl::opacity() const |
| 562 { |
| 563 if (m_layerAnimationController->opacityLastUpdateTime() > m_opacityLastUpdat
eTime) |
| 564 return m_layerAnimationController->opacity(); |
| 565 return m_opacity; |
| 566 } |
| 567 |
573 bool LayerImpl::opacityIsAnimating() const | 568 bool LayerImpl::opacityIsAnimating() const |
574 { | 569 { |
575 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); | 570 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Opac
ity); |
576 } | 571 } |
577 | 572 |
578 void LayerImpl::setPosition(const gfx::PointF& position) | 573 void LayerImpl::setPosition(const gfx::PointF& position) |
579 { | 574 { |
580 if (m_position == position) | 575 if (m_position == position) |
581 return; | 576 return; |
582 | 577 |
(...skipping 19 matching lines...) Expand all Loading... |
602 // sublayer transform does not affect the current layer; it affects only its
children. | 597 // sublayer transform does not affect the current layer; it affects only its
children. |
603 noteLayerPropertyChangedForDescendants(); | 598 noteLayerPropertyChangedForDescendants(); |
604 } | 599 } |
605 | 600 |
606 void LayerImpl::setTransform(const gfx::Transform& transform) | 601 void LayerImpl::setTransform(const gfx::Transform& transform) |
607 { | 602 { |
608 if (m_transform == transform) | 603 if (m_transform == transform) |
609 return; | 604 return; |
610 | 605 |
611 m_transform = transform; | 606 m_transform = transform; |
| 607 m_transformLastUpdateTime = base::TimeTicks::Now(); |
612 m_layerSurfacePropertyChanged = true; | 608 m_layerSurfacePropertyChanged = true; |
613 } | 609 } |
614 | 610 |
| 611 const gfx::Transform& LayerImpl::transform() const |
| 612 { |
| 613 if (m_layerAnimationController->transformLastUpdateTime() > m_transformLastU
pdateTime) |
| 614 return m_layerAnimationController->transform(); |
| 615 return m_transform; |
| 616 } |
| 617 |
615 bool LayerImpl::transformIsAnimating() const | 618 bool LayerImpl::transformIsAnimating() const |
616 { | 619 { |
617 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran
sform); | 620 return m_layerAnimationController->isAnimatingProperty(ActiveAnimation::Tran
sform); |
618 } | 621 } |
619 | 622 |
620 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) | 623 void LayerImpl::setContentBounds(const gfx::Size& contentBounds) |
621 { | 624 { |
622 if (m_contentBounds == contentBounds) | 625 if (m_contentBounds == contentBounds) |
623 return; | 626 return; |
624 | 627 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 | 725 |
723 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 726 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
724 { | 727 { |
725 if (!m_scrollbarAnimationController) | 728 if (!m_scrollbarAnimationController) |
726 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); | 729 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); |
727 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); | 730 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
728 m_scrollbarAnimationController->updateScrollOffset(this); | 731 m_scrollbarAnimationController->updateScrollOffset(this); |
729 } | 732 } |
730 | 733 |
731 } // namespace cc | 734 } // namespace cc |
OLD | NEW |