| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "CCLayerTreeHostCommon.h" | 7 #include "CCLayerTreeHostCommon.h" |
| 8 | 8 |
| 9 #include "CCLayerImpl.h" | 9 #include "CCLayerImpl.h" |
| 10 #include "CCLayerIterator.h" | 10 #include "CCLayerIterator.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 template<typename LayerType> | 105 template<typename LayerType> |
| 106 static inline bool layerClipsSubtree(LayerType* layer) | 106 static inline bool layerClipsSubtree(LayerType* layer) |
| 107 { | 107 { |
| 108 return layer->masksToBounds() || layer->maskLayer(); | 108 return layer->masksToBounds() || layer->maskLayer(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 template<typename LayerType> | 111 template<typename LayerType> |
| 112 static IntRect calculateVisibleContentRect(LayerType* layer) | 112 static IntRect calculateVisibleContentRect(LayerType* layer) |
| 113 { | 113 { |
| 114 ASSERT(layer->renderTarget()); | 114 DCHECK(layer->renderTarget()); |
| 115 | 115 |
| 116 // Nothing is visible if the layer bounds are empty. | 116 // Nothing is visible if the layer bounds are empty. |
| 117 if (!layer->drawsContent() || layer->contentBounds().isEmpty() || layer->dra
wableContentRect().isEmpty()) | 117 if (!layer->drawsContent() || layer->contentBounds().isEmpty() || layer->dra
wableContentRect().isEmpty()) |
| 118 return IntRect(); | 118 return IntRect(); |
| 119 | 119 |
| 120 IntRect targetSurfaceClipRect; | 120 IntRect targetSurfaceClipRect; |
| 121 | 121 |
| 122 // First, compute visible bounds in target surface space. | 122 // First, compute visible bounds in target surface space. |
| 123 if (layer->renderTarget()->renderSurface()->clipRect().isEmpty()) | 123 if (layer->renderTarget()->renderSurface()->clipRect().isEmpty()) |
| 124 targetSurfaceClipRect = layer->drawableContentRect(); | 124 targetSurfaceClipRect = layer->drawableContentRect(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 // | 179 // |
| 180 // Note, if the layer should not have been drawn due to being fully transpar
ent, | 180 // Note, if the layer should not have been drawn due to being fully transpar
ent, |
| 181 // we would have skipped the entire subtree and never made it into this func
tion, | 181 // we would have skipped the entire subtree and never made it into this func
tion, |
| 182 // so it is safe to omit this check here. | 182 // so it is safe to omit this check here. |
| 183 | 183 |
| 184 if (!layer->drawsContent() || layer->bounds().isEmpty()) | 184 if (!layer->drawsContent() || layer->bounds().isEmpty()) |
| 185 return true; | 185 return true; |
| 186 | 186 |
| 187 LayerType* backfaceTestLayer = layer; | 187 LayerType* backfaceTestLayer = layer; |
| 188 if (layer->useParentBackfaceVisibility()) { | 188 if (layer->useParentBackfaceVisibility()) { |
| 189 ASSERT(layer->parent()); | 189 DCHECK(layer->parent()); |
| 190 ASSERT(!layer->parent()->useParentBackfaceVisibility()); | 190 DCHECK(!layer->parent()->useParentBackfaceVisibility()); |
| 191 backfaceTestLayer = layer->parent(); | 191 backfaceTestLayer = layer->parent(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 // The layer should not be drawn if (1) it is not double-sided and (2) the b
ack of the layer is known to be facing the screen. | 194 // The layer should not be drawn if (1) it is not double-sided and (2) the b
ack of the layer is known to be facing the screen. |
| 195 if (!backfaceTestLayer->doubleSided() && transformToScreenIsKnown(backfaceTe
stLayer) && isLayerBackFaceVisible(backfaceTestLayer)) | 195 if (!backfaceTestLayer->doubleSided() && transformToScreenIsKnown(backfaceTe
stLayer) && isLayerBackFaceVisible(backfaceTestLayer)) |
| 196 return true; | 196 return true; |
| 197 | 197 |
| 198 return false; | 198 return false; |
| 199 } | 199 } |
| 200 | 200 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 // Should be called just before the recursive calculateDrawTransformsInternal(). | 346 // Should be called just before the recursive calculateDrawTransformsInternal(). |
| 347 template<typename LayerType, typename LayerList> | 347 template<typename LayerType, typename LayerList> |
| 348 void setupRootLayerAndSurfaceForRecursion(LayerType* rootLayer, LayerList& rende
rSurfaceLayerList, const IntSize& deviceViewportSize) | 348 void setupRootLayerAndSurfaceForRecursion(LayerType* rootLayer, LayerList& rende
rSurfaceLayerList, const IntSize& deviceViewportSize) |
| 349 { | 349 { |
| 350 if (!rootLayer->renderSurface()) | 350 if (!rootLayer->renderSurface()) |
| 351 rootLayer->createRenderSurface(); | 351 rootLayer->createRenderSurface(); |
| 352 | 352 |
| 353 rootLayer->renderSurface()->setContentRect(IntRect(IntPoint::zero(), deviceV
iewportSize)); | 353 rootLayer->renderSurface()->setContentRect(IntRect(IntPoint::zero(), deviceV
iewportSize)); |
| 354 rootLayer->renderSurface()->clearLayerLists(); | 354 rootLayer->renderSurface()->clearLayerLists(); |
| 355 | 355 |
| 356 ASSERT(renderSurfaceLayerList.empty()); | 356 DCHECK(renderSurfaceLayerList.empty()); |
| 357 renderSurfaceLayerList.push_back(rootLayer); | 357 renderSurfaceLayerList.push_back(rootLayer); |
| 358 } | 358 } |
| 359 | 359 |
| 360 // Recursively walks the layer tree starting at the given node and computes all
the | 360 // Recursively walks the layer tree starting at the given node and computes all
the |
| 361 // necessary transformations, clipRects, render surfaces, etc. | 361 // necessary transformations, clipRects, render surfaces, etc. |
| 362 template<typename LayerType, typename LayerList, typename RenderSurfaceType, typ
ename LayerSorter> | 362 template<typename LayerType, typename LayerList, typename RenderSurfaceType, typ
ename LayerSorter> |
| 363 static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
er, const WebTransformationMatrix& parentMatrix, | 363 static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
er, const WebTransformationMatrix& parentMatrix, |
| 364 const WebTransformationMatrix& fullHierarchyMatrix, const WebTransformationM
atrix& currentScrollCompensationMatrix, | 364 const WebTransformationMatrix& fullHierarchyMatrix, const WebTransformationM
atrix& currentScrollCompensationMatrix, |
| 365 const IntRect& clipRectFromAncestor, bool ancestorClipsSubtree, | 365 const IntRect& clipRectFromAncestor, bool ancestorClipsSubtree, |
| 366 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL
ayerList, LayerList& layerList, | 366 RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceL
ayerList, LayerList& layerList, |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 } else { | 591 } else { |
| 592 layer->setDrawTransform(drawTransform); | 592 layer->setDrawTransform(drawTransform); |
| 593 layer->setDrawTransformIsAnimating(animatingTransformToTarget); | 593 layer->setDrawTransformIsAnimating(animatingTransformToTarget); |
| 594 layer->setScreenSpaceTransformIsAnimating(animatingTransformToScreen); | 594 layer->setScreenSpaceTransformIsAnimating(animatingTransformToScreen); |
| 595 sublayerMatrix = combinedTransform; | 595 sublayerMatrix = combinedTransform; |
| 596 | 596 |
| 597 layer->setDrawOpacity(drawOpacity); | 597 layer->setDrawOpacity(drawOpacity); |
| 598 layer->setDrawOpacityIsAnimating(drawOpacityIsAnimating); | 598 layer->setDrawOpacityIsAnimating(drawOpacityIsAnimating); |
| 599 | 599 |
| 600 if (layer != rootLayer) { | 600 if (layer != rootLayer) { |
| 601 ASSERT(layer->parent()); | 601 DCHECK(layer->parent()); |
| 602 layer->clearRenderSurface(); | 602 layer->clearRenderSurface(); |
| 603 | 603 |
| 604 // Layers without renderSurfaces directly inherit the ancestor's cli
p status. | 604 // Layers without renderSurfaces directly inherit the ancestor's cli
p status. |
| 605 subtreeShouldBeClipped = ancestorClipsSubtree; | 605 subtreeShouldBeClipped = ancestorClipsSubtree; |
| 606 if (ancestorClipsSubtree) | 606 if (ancestorClipsSubtree) |
| 607 clipRectForSubtree = clipRectFromAncestor; | 607 clipRectForSubtree = clipRectFromAncestor; |
| 608 | 608 |
| 609 // Layers that are not their own renderTarget will render into the t
arget of their nearest ancestor. | 609 // Layers that are not their own renderTarget will render into the t
arget of their nearest ancestor. |
| 610 layer->setRenderTarget(layer->parent()->renderTarget()); | 610 layer->setRenderTarget(layer->parent()->renderTarget()); |
| 611 } else { | 611 } else { |
| 612 // FIXME: This root layer special case code should eventually go awa
y. https://bugs.webkit.org/show_bug.cgi?id=92290 | 612 // FIXME: This root layer special case code should eventually go awa
y. https://bugs.webkit.org/show_bug.cgi?id=92290 |
| 613 ASSERT(!layer->parent()); | 613 DCHECK(!layer->parent()); |
| 614 ASSERT(layer->renderSurface()); | 614 DCHECK(layer->renderSurface()); |
| 615 ASSERT(ancestorClipsSubtree); | 615 DCHECK(ancestorClipsSubtree); |
| 616 layer->renderSurface()->setClipRect(clipRectFromAncestor); | 616 layer->renderSurface()->setClipRect(clipRectFromAncestor); |
| 617 subtreeShouldBeClipped = false; | 617 subtreeShouldBeClipped = false; |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 IntRect rectInTargetSpace = enclosingIntRect(CCMathUtil::mapClippedRect(laye
r->drawTransform(), contentRect)); | 621 IntRect rectInTargetSpace = enclosingIntRect(CCMathUtil::mapClippedRect(laye
r->drawTransform(), contentRect)); |
| 622 | 622 |
| 623 if (layerClipsSubtree(layer)) { | 623 if (layerClipsSubtree(layer)) { |
| 624 subtreeShouldBeClipped = true; | 624 subtreeShouldBeClipped = true; |
| 625 if (ancestorClipsSubtree && !layer->renderSurface()) { | 625 if (ancestorClipsSubtree && !layer->renderSurface()) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 if (!layer->renderSurface()->layerList().size()) { | 729 if (!layer->renderSurface()->layerList().size()) { |
| 730 // FIXME: Originally we asserted that this layer was already at the
end of the | 730 // FIXME: Originally we asserted that this layer was already at the
end of the |
| 731 // list, and only needed to remove that layer. For now, we re
move the | 731 // list, and only needed to remove that layer. For now, we re
move the |
| 732 // entire subtree of surfaces to fix a crash bug. The root ca
use is | 732 // entire subtree of surfaces to fix a crash bug. The root ca
use is |
| 733 // https://bugs.webkit.org/show_bug.cgi?id=74147 and we shoul
d be able | 733 // https://bugs.webkit.org/show_bug.cgi?id=74147 and we shoul
d be able |
| 734 // to put the original assert after fixing that. | 734 // to put the original assert after fixing that. |
| 735 while (renderSurfaceLayerList.back() != layer) { | 735 while (renderSurfaceLayerList.back() != layer) { |
| 736 renderSurfaceLayerList.back()->clearRenderSurface(); | 736 renderSurfaceLayerList.back()->clearRenderSurface(); |
| 737 renderSurfaceLayerList.pop_back(); | 737 renderSurfaceLayerList.pop_back(); |
| 738 } | 738 } |
| 739 ASSERT(renderSurfaceLayerList.back() == layer); | 739 DCHECK(renderSurfaceLayerList.back() == layer); |
| 740 renderSurfaceLayerList.pop_back(); | 740 renderSurfaceLayerList.pop_back(); |
| 741 layer->clearRenderSurface(); | 741 layer->clearRenderSurface(); |
| 742 return; | 742 return; |
| 743 } | 743 } |
| 744 } | 744 } |
| 745 | 745 |
| 746 // If neither this layer nor any of its children were added, early out. | 746 // If neither this layer nor any of its children were added, early out. |
| 747 if (sortingStartIndex == descendants.size()) | 747 if (sortingStartIndex == descendants.size()) |
| 748 return; | 748 return; |
| 749 | 749 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 | 855 |
| 856 foundLayer = currentLayer; | 856 foundLayer = currentLayer; |
| 857 break; | 857 break; |
| 858 } | 858 } |
| 859 | 859 |
| 860 // This can potentially return 0, which means the viewportPoint did not succ
essfully hit test any layers, not even the root layer. | 860 // This can potentially return 0, which means the viewportPoint did not succ
essfully hit test any layers, not even the root layer. |
| 861 return foundLayer; | 861 return foundLayer; |
| 862 } | 862 } |
| 863 | 863 |
| 864 } // namespace cc | 864 } // namespace cc |
| OLD | NEW |