| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 private: | 172 private: |
| 173 Vector<OverlapMapContainer> m_overlapStack; | 173 Vector<OverlapMapContainer> m_overlapStack; |
| 174 HashSet<const RenderLayer*> m_layers; | 174 HashSet<const RenderLayer*> m_layers; |
| 175 RenderGeometryMap m_geometryMap; | 175 RenderGeometryMap m_geometryMap; |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 struct CompositingRecursionData { | 178 struct CompositingRecursionData { |
| 179 CompositingRecursionData(RenderLayer* compAncestor, bool testOverlap) | 179 CompositingRecursionData(RenderLayer* compAncestor, bool testOverlap) |
| 180 : m_compositingAncestor(compAncestor) | 180 : m_compositingAncestor(compAncestor) |
| 181 , m_subtreeIsCompositing(false) | 181 , m_subtreeIsCompositing(false) |
| 182 , m_hasUnisolatedCompositedBlendingDescendant(false) |
| 182 , m_testingOverlap(testOverlap) | 183 , m_testingOverlap(testOverlap) |
| 183 #ifndef NDEBUG | 184 #ifndef NDEBUG |
| 184 , m_depth(0) | 185 , m_depth(0) |
| 185 #endif | 186 #endif |
| 186 { | 187 { |
| 187 } | 188 } |
| 188 | 189 |
| 189 CompositingRecursionData(const CompositingRecursionData& other) | 190 CompositingRecursionData(const CompositingRecursionData& other) |
| 190 : m_compositingAncestor(other.m_compositingAncestor) | 191 : m_compositingAncestor(other.m_compositingAncestor) |
| 191 , m_subtreeIsCompositing(other.m_subtreeIsCompositing) | 192 , m_subtreeIsCompositing(other.m_subtreeIsCompositing) |
| 193 , m_hasUnisolatedCompositedBlendingDescendant(other.m_hasUnisolatedCompo
sitedBlendingDescendant) |
| 192 , m_testingOverlap(other.m_testingOverlap) | 194 , m_testingOverlap(other.m_testingOverlap) |
| 193 #ifndef NDEBUG | 195 #ifndef NDEBUG |
| 194 , m_depth(other.m_depth + 1) | 196 , m_depth(other.m_depth + 1) |
| 195 #endif | 197 #endif |
| 196 { | 198 { |
| 197 } | 199 } |
| 198 | 200 |
| 199 RenderLayer* m_compositingAncestor; | 201 RenderLayer* m_compositingAncestor; |
| 200 bool m_subtreeIsCompositing; | 202 bool m_subtreeIsCompositing; |
| 203 bool m_hasUnisolatedCompositedBlendingDescendant; |
| 201 bool m_testingOverlap; | 204 bool m_testingOverlap; |
| 202 #ifndef NDEBUG | 205 #ifndef NDEBUG |
| 203 int m_depth; | 206 int m_depth; |
| 204 #endif | 207 #endif |
| 205 }; | 208 }; |
| 206 | 209 |
| 207 | 210 |
| 208 RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView) | 211 RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView) |
| 209 : m_renderView(renderView) | 212 : m_renderView(renderView) |
| 210 , m_hasAcceleratedCompositing(true) | 213 , m_hasAcceleratedCompositing(true) |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 if (inCompositingMode() && m_hasAcceleratedCompositing) | 905 if (inCompositingMode() && m_hasAcceleratedCompositing) |
| 903 willBeComposited = true; | 906 willBeComposited = true; |
| 904 } | 907 } |
| 905 | 908 |
| 906 // All layers (even ones that aren't being composited) need to get added to | 909 // All layers (even ones that aren't being composited) need to get added to |
| 907 // the overlap map. Layers that are not separately composited will paint int
o their | 910 // the overlap map. Layers that are not separately composited will paint int
o their |
| 908 // compositing ancestor's backing, and so are still considered for overlap. | 911 // compositing ancestor's backing, and so are still considered for overlap. |
| 909 if (overlapMap && childRecursionData.m_compositingAncestor && !childRecursio
nData.m_compositingAncestor->isRootLayer()) | 912 if (overlapMap && childRecursionData.m_compositingAncestor && !childRecursio
nData.m_compositingAncestor->isRootLayer()) |
| 910 addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds); | 913 addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds); |
| 911 | 914 |
| 915 if (layer->stackingNode()->isStackingContext()) { |
| 916 layer->setShouldIsolateCompositedDescendants(childRecursionData.m_hasUni
solatedCompositedBlendingDescendant); |
| 917 } else { |
| 918 layer->setShouldIsolateCompositedDescendants(false); |
| 919 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = child
RecursionData.m_hasUnisolatedCompositedBlendingDescendant; |
| 920 } |
| 921 |
| 912 // Now check for reasons to become composited that depend on the state of de
scendant layers. | 922 // Now check for reasons to become composited that depend on the state of de
scendant layers. |
| 913 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing(
layer->renderer(), childRecursionData.m_subtreeIsCompositing, anyDescendantHas3D
Transform); | 923 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing(
layer->renderer(), childRecursionData.m_subtreeIsCompositing, anyDescendantHas3D
Transform); |
| 914 reasonsToComposite |= subtreeCompositingReasons; | 924 reasonsToComposite |= subtreeCompositingReasons; |
| 915 if (!willBeComposited && canBeComposited(layer) && requiresCompositing(subtr
eeCompositingReasons)) { | 925 if (!willBeComposited && canBeComposited(layer) && requiresCompositing(subtr
eeCompositingReasons)) { |
| 916 childRecursionData.m_compositingAncestor = layer; | 926 childRecursionData.m_compositingAncestor = layer; |
| 917 if (overlapMap) { | 927 if (overlapMap) { |
| 918 // FIXME: this context push is effectively a no-op but needs to exis
t for | 928 // FIXME: this context push is effectively a no-op but needs to exis
t for |
| 919 // now, because the code is designed to push overlap information to
the | 929 // now, because the code is designed to push overlap information to
the |
| 920 // second-from-top context of the stack. | 930 // second-from-top context of the stack. |
| 921 overlapMap->beginNewOverlapTestingContext(); | 931 overlapMap->beginNewOverlapTestingContext(); |
| 922 addToOverlapMapRecursive(*overlapMap, layer); | 932 addToOverlapMapRecursive(*overlapMap, layer); |
| 923 } | 933 } |
| 924 willBeComposited = true; | 934 willBeComposited = true; |
| 925 } | 935 } |
| 926 | 936 |
| 927 // If the original layer is composited, the reflection needs to be, too. | 937 // If the original layer is composited, the reflection needs to be, too. |
| 928 if (layer->reflectionInfo()) { | 938 if (layer->reflectionInfo()) { |
| 929 // FIXME: Shouldn't we call computeCompositingRequirements to handle a r
eflection overlapping with another renderer? | 939 // FIXME: Shouldn't we call computeCompositingRequirements to handle a r
eflection overlapping with another renderer? |
| 930 CompositingReasons reflectionCompositingReason = willBeComposited ? Comp
ositingReasonReflectionOfCompositedParent : CompositingReasonNone; | 940 CompositingReasons reflectionCompositingReason = willBeComposited ? Comp
ositingReasonReflectionOfCompositedParent : CompositingReasonNone; |
| 931 layer->reflectionInfo()->reflectionLayer()->setCompositingReasons(layer-
>reflectionInfo()->reflectionLayer()->compositingReasons() | reflectionCompositi
ngReason); | 941 layer->reflectionInfo()->reflectionLayer()->setCompositingReasons(layer-
>reflectionInfo()->reflectionLayer()->compositingReasons() | reflectionCompositi
ngReason); |
| 932 } | 942 } |
| 933 | 943 |
| 934 // Subsequent layers in the parent's stacking context may also need to compo
site. | 944 // Subsequent layers in the parent's stacking context may also need to compo
site. |
| 935 if (childRecursionData.m_subtreeIsCompositing) | 945 if (childRecursionData.m_subtreeIsCompositing) |
| 936 currentRecursionData.m_subtreeIsCompositing = true; | 946 currentRecursionData.m_subtreeIsCompositing = true; |
| 937 | 947 |
| 948 if (willBeComposited && layer->hasBlendMode()) |
| 949 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = true; |
| 950 |
| 938 // Set the flag to say that this SC has compositing children. | 951 // Set the flag to say that this SC has compositing children. |
| 939 layer->setHasCompositingDescendant(childRecursionData.m_subtreeIsCompositing
); | 952 layer->setHasCompositingDescendant(childRecursionData.m_subtreeIsCompositing
); |
| 940 | 953 |
| 941 // Turn overlap testing off for later layers if it's already off, or if we h
ave an animating transform. | 954 // Turn overlap testing off for later layers if it's already off, or if we h
ave an animating transform. |
| 942 // Note that if the layer clips its descendants, there's no reason to propag
ate the child animation to the parent layers. That's because | 955 // Note that if the layer clips its descendants, there's no reason to propag
ate the child animation to the parent layers. That's because |
| 943 // we know for sure the animation is contained inside the clipping rectangle
, which is already added to the overlap map. | 956 // we know for sure the animation is contained inside the clipping rectangle
, which is already added to the overlap map. |
| 944 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi
te & CompositingReasonClipsCompositingDescendants); | 957 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi
te & CompositingReasonClipsCompositingDescendants); |
| 945 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) ||
isRunningAcceleratedTransformAnimation(layer->renderer())) | 958 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) ||
isRunningAcceleratedTransformAnimation(layer->renderer())) |
| 946 currentRecursionData.m_testingOverlap = false; | 959 currentRecursionData.m_testingOverlap = false; |
| 947 | 960 |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1731 | 1744 |
| 1732 // FIXME: this seems to be a potentially different layer than the layer for
which this was called. May not be an error, but is very confusing. | 1745 // FIXME: this seems to be a potentially different layer than the layer for
which this was called. May not be an error, but is very confusing. |
| 1733 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); | 1746 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); |
| 1734 | 1747 |
| 1735 // When a layer has composited descendants, some effects, like 2d transforms
, filters, masks etc must be implemented | 1748 // When a layer has composited descendants, some effects, like 2d transforms
, filters, masks etc must be implemented |
| 1736 // via compositing so that they also apply to those composited descdendants. | 1749 // via compositing so that they also apply to those composited descdendants. |
| 1737 if (hasCompositedDescendants) { | 1750 if (hasCompositedDescendants) { |
| 1738 if (layer->transform()) | 1751 if (layer->transform()) |
| 1739 subtreeReasons |= CompositingReasonTransformWithCompositedDescendant
s; | 1752 subtreeReasons |= CompositingReasonTransformWithCompositedDescendant
s; |
| 1740 | 1753 |
| 1754 if (layer->shouldIsolateCompositedDescendants()) { |
| 1755 ASSERT(layer->stackingNode()->isStackingContext()); |
| 1756 subtreeReasons |= CompositingReasonIsolateCompositedDescendants; |
| 1757 } |
| 1758 |
| 1741 // If the implementation of createsGroup changes, we need to be aware of
that in this part of code. | 1759 // If the implementation of createsGroup changes, we need to be aware of
that in this part of code. |
| 1742 ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->ha
sFilter() || renderer->hasBlendMode()) == renderer->createsGroup()); | 1760 ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->ha
sFilter() || renderer->hasBlendMode()) == renderer->createsGroup()); |
| 1743 if (renderer->isTransparent()) | 1761 if (renderer->isTransparent()) |
| 1744 subtreeReasons |= CompositingReasonOpacityWithCompositedDescendants; | 1762 subtreeReasons |= CompositingReasonOpacityWithCompositedDescendants; |
| 1745 if (renderer->hasMask()) | 1763 if (renderer->hasMask()) |
| 1746 subtreeReasons |= CompositingReasonMaskWithCompositedDescendants; | 1764 subtreeReasons |= CompositingReasonMaskWithCompositedDescendants; |
| 1747 if (renderer->hasFilter()) | 1765 if (renderer->hasFilter()) |
| 1748 subtreeReasons |= CompositingReasonFilterWithCompositedDescendants; | 1766 subtreeReasons |= CompositingReasonFilterWithCompositedDescendants; |
| 1749 if (renderer->hasBlendMode()) | 1767 if (renderer->hasBlendMode()) |
| 1750 subtreeReasons |= CompositingReasonBlendingWithCompositedDescendants
; | 1768 subtreeReasons |= CompositingReasonBlendingWithCompositedDescendants
; |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 } else if (graphicsLayer == m_scrollLayer.get()) { | 2494 } else if (graphicsLayer == m_scrollLayer.get()) { |
| 2477 name = "Frame Scrolling Layer"; | 2495 name = "Frame Scrolling Layer"; |
| 2478 } else { | 2496 } else { |
| 2479 ASSERT_NOT_REACHED(); | 2497 ASSERT_NOT_REACHED(); |
| 2480 } | 2498 } |
| 2481 | 2499 |
| 2482 return name; | 2500 return name; |
| 2483 } | 2501 } |
| 2484 | 2502 |
| 2485 } // namespace WebCore | 2503 } // namespace WebCore |
| OLD | NEW |