| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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.h" | 5 #include "cc/layer.h" |
| 6 | 6 |
| 7 #include "cc/active_animation.h" | 7 #include "cc/active_animation.h" |
| 8 #include "cc/animation_events.h" | 8 #include "cc/animation_events.h" |
| 9 #include "cc/layer_animation_controller.h" | 9 #include "cc/layer_animation_controller.h" |
| 10 #include "cc/layer_impl.h" | 10 #include "cc/layer_impl.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 , m_anchorPoint(0.5, 0.5) | 41 , m_anchorPoint(0.5, 0.5) |
| 42 , m_backgroundColor(0) | 42 , m_backgroundColor(0) |
| 43 , m_opacity(1.0) | 43 , m_opacity(1.0) |
| 44 , m_anchorPointZ(0) | 44 , m_anchorPointZ(0) |
| 45 , m_isContainerForFixedPositionLayers(false) | 45 , m_isContainerForFixedPositionLayers(false) |
| 46 , m_fixedToContainerLayer(false) | 46 , m_fixedToContainerLayer(false) |
| 47 , m_isDrawable(false) | 47 , m_isDrawable(false) |
| 48 , m_masksToBounds(false) | 48 , m_masksToBounds(false) |
| 49 , m_contentsOpaque(false) | 49 , m_contentsOpaque(false) |
| 50 , m_doubleSided(true) | 50 , m_doubleSided(true) |
| 51 , m_useLCDText(false) | 51 , m_canUseLCDText(false) |
| 52 , m_preserves3D(false) | 52 , m_preserves3D(false) |
| 53 , m_useParentBackfaceVisibility(false) | 53 , m_useParentBackfaceVisibility(false) |
| 54 , m_drawCheckerboardForMissingTiles(false) | 54 , m_drawCheckerboardForMissingTiles(false) |
| 55 , m_forceRenderSurface(false) | 55 , m_forceRenderSurface(false) |
| 56 , m_replicaLayer(0) | 56 , m_replicaLayer(0) |
| 57 , m_rasterScale(1.0) | 57 , m_rasterScale(1.0) |
| 58 , m_automaticallyComputeRasterScale(false) | 58 , m_automaticallyComputeRasterScale(false) |
| 59 , m_boundsContainPageScale(false) | 59 , m_boundsContainPageScale(false) |
| 60 , m_layerAnimationDelegate(0) | 60 , m_layerAnimationDelegate(0) |
| 61 , m_layerScrollClient(0) | 61 , m_layerScrollClient(0) |
| 62 { | 62 { |
| 63 if (m_layerId < 0) { | 63 if (m_layerId < 0) { |
| 64 s_nextLayerId = 1; | 64 s_nextLayerId = 1; |
| 65 m_layerId = s_nextLayerId++; | 65 m_layerId = s_nextLayerId++; |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 Layer::~Layer() | 69 Layer::~Layer() |
| 70 { | 70 { |
| 71 // Our parent should be holding a reference to us so there should be no | 71 // Our parent should be holding a reference to us so there should be no |
| 72 // way for us to be destroyed while we still have a parent. | 72 // way for us to be destroyed while we still have a parent. |
| 73 DCHECK(!parent()); | 73 DCHECK(!parent()); |
| 74 | 74 |
| 75 // Remove the parent reference from all children. | 75 // Remove the parent reference from all children. |
| 76 removeAllChildren(); | 76 removeAllChildren(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void Layer::setUseLCDText(bool useLCDText) | 79 void Layer::setCanUseLCDText(bool useLCDText) |
| 80 { | 80 { |
| 81 m_useLCDText = useLCDText; | 81 if (m_canUseLCDText == useLCDText) |
| 82 return; |
| 83 |
| 84 if (!canUseLCDTextWillChange()) |
| 85 return; |
| 86 |
| 87 m_canUseLCDText = useLCDText; |
| 88 canUseLCDTextDidChange(); |
| 82 } | 89 } |
| 83 | 90 |
| 84 void Layer::setLayerTreeHost(LayerTreeHost* host) | 91 void Layer::setLayerTreeHost(LayerTreeHost* host) |
| 85 { | 92 { |
| 86 if (m_layerTreeHost == host) | 93 if (m_layerTreeHost == host) |
| 87 return; | 94 return; |
| 88 | 95 |
| 89 m_layerTreeHost = host; | 96 m_layerTreeHost = host; |
| 90 | 97 |
| 91 for (size_t i = 0; i < m_children.size(); ++i) | 98 for (size_t i = 0; i < m_children.size(); ++i) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 106 if (m_layerTreeHost) | 113 if (m_layerTreeHost) |
| 107 m_layerTreeHost->setNeedsCommit(); | 114 m_layerTreeHost->setNeedsCommit(); |
| 108 } | 115 } |
| 109 | 116 |
| 110 void Layer::setNeedsFullTreeSync() | 117 void Layer::setNeedsFullTreeSync() |
| 111 { | 118 { |
| 112 if (m_layerTreeHost) | 119 if (m_layerTreeHost) |
| 113 m_layerTreeHost->setNeedsFullTreeSync(); | 120 m_layerTreeHost->setNeedsFullTreeSync(); |
| 114 } | 121 } |
| 115 | 122 |
| 123 bool Layer::canUseLCDTextWillChange() |
| 124 { |
| 125 return true; |
| 126 } |
| 127 |
| 116 gfx::Rect Layer::layerRectToContentRect(const gfx::RectF& layerRect) const | 128 gfx::Rect Layer::layerRectToContentRect(const gfx::RectF& layerRect) const |
| 117 { | 129 { |
| 118 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content
sScaleY()); | 130 gfx::RectF contentRect = gfx::ScaleRect(layerRect, contentsScaleX(), content
sScaleY()); |
| 119 // Intersect with content rect to avoid the extra pixel because for some | 131 // Intersect with content rect to avoid the extra pixel because for some |
| 120 // values x and y, ceil((x / y) * y) may be x + 1. | 132 // values x and y, ceil((x / y) * y) may be x + 1. |
| 121 contentRect.Intersect(gfx::Rect(gfx::Point(), contentBounds())); | 133 contentRect.Intersect(gfx::Rect(gfx::Point(), contentBounds())); |
| 122 return gfx::ToEnclosingRect(contentRect); | 134 return gfx::ToEnclosingRect(contentRect); |
| 123 } | 135 } |
| 124 | 136 |
| 125 bool Layer::blocksPendingCommit() const | 137 bool Layer::blocksPendingCommit() const |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 layer->setContentBounds(contentBounds()); | 572 layer->setContentBounds(contentBounds()); |
| 561 layer->setContentsScale(contentsScaleX(), contentsScaleY()); | 573 layer->setContentsScale(contentsScaleX(), contentsScaleY()); |
| 562 layer->setDebugName(m_debugName); | 574 layer->setDebugName(m_debugName); |
| 563 layer->setDoubleSided(m_doubleSided); | 575 layer->setDoubleSided(m_doubleSided); |
| 564 layer->setDrawCheckerboardForMissingTiles(m_drawCheckerboardForMissingTiles)
; | 576 layer->setDrawCheckerboardForMissingTiles(m_drawCheckerboardForMissingTiles)
; |
| 565 layer->setForceRenderSurface(m_forceRenderSurface); | 577 layer->setForceRenderSurface(m_forceRenderSurface); |
| 566 layer->setDrawsContent(drawsContent()); | 578 layer->setDrawsContent(drawsContent()); |
| 567 layer->setFilters(filters()); | 579 layer->setFilters(filters()); |
| 568 layer->setFilter(filter()); | 580 layer->setFilter(filter()); |
| 569 layer->setBackgroundFilters(backgroundFilters()); | 581 layer->setBackgroundFilters(backgroundFilters()); |
| 570 layer->setUseLCDText(m_useLCDText); | 582 layer->setCanUseLCDText(m_canUseLCDText); |
| 571 layer->setMasksToBounds(m_masksToBounds); | 583 layer->setMasksToBounds(m_masksToBounds); |
| 572 layer->setScrollable(m_scrollable); | 584 layer->setScrollable(m_scrollable); |
| 573 layer->setShouldScrollOnMainThread(m_shouldScrollOnMainThread); | 585 layer->setShouldScrollOnMainThread(m_shouldScrollOnMainThread); |
| 574 layer->setHaveWheelEventHandlers(m_haveWheelEventHandlers); | 586 layer->setHaveWheelEventHandlers(m_haveWheelEventHandlers); |
| 575 // Copying a Region is more expensive than most layer properties, since it i
nvolves copying two Vectors that may be | 587 // Copying a Region is more expensive than most layer properties, since it i
nvolves copying two Vectors that may be |
| 576 // arbitrarily large depending on page content, so we only push the property
if it's changed. | 588 // arbitrarily large depending on page content, so we only push the property
if it's changed. |
| 577 if (m_nonFastScrollableRegionChanged) { | 589 if (m_nonFastScrollableRegionChanged) { |
| 578 layer->setNonFastScrollableRegion(m_nonFastScrollableRegion); | 590 layer->setNonFastScrollableRegion(m_nonFastScrollableRegion); |
| 579 m_nonFastScrollableRegionChanged = false; | 591 m_nonFastScrollableRegionChanged = false; |
| 580 } | 592 } |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 { | 852 { |
| 841 return 0; | 853 return 0; |
| 842 } | 854 } |
| 843 | 855 |
| 844 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*) | 856 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*) |
| 845 { | 857 { |
| 846 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort Layers. | 858 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort Layers. |
| 847 } | 859 } |
| 848 | 860 |
| 849 } // namespace cc | 861 } // namespace cc |
| OLD | NEW |