| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 private: | 170 private: |
| 171 Vector<OverlapMapContainer> m_overlapStack; | 171 Vector<OverlapMapContainer> m_overlapStack; |
| 172 HashSet<const RenderLayer*> m_layers; | 172 HashSet<const RenderLayer*> m_layers; |
| 173 RenderGeometryMap m_geometryMap; | 173 RenderGeometryMap m_geometryMap; |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 struct CompositingRecursionData { | 176 struct CompositingRecursionData { |
| 177 CompositingRecursionData(RenderLayer* compAncestor, bool testOverlap) | 177 CompositingRecursionData(RenderLayer* compAncestor, bool testOverlap) |
| 178 : m_compositingAncestor(compAncestor) | 178 : m_compositingAncestor(compAncestor) |
| 179 , m_subtreeIsCompositing(false) | 179 , m_subtreeIsCompositing(false) |
| 180 , m_hasUnisolatedCompositedBlendingDescendant(false) |
| 180 , m_testingOverlap(testOverlap) | 181 , m_testingOverlap(testOverlap) |
| 181 #ifndef NDEBUG | 182 #ifndef NDEBUG |
| 182 , m_depth(0) | 183 , m_depth(0) |
| 183 #endif | 184 #endif |
| 184 { | 185 { |
| 185 } | 186 } |
| 186 | 187 |
| 187 CompositingRecursionData(const CompositingRecursionData& other) | 188 CompositingRecursionData(const CompositingRecursionData& other) |
| 188 : m_compositingAncestor(other.m_compositingAncestor) | 189 : m_compositingAncestor(other.m_compositingAncestor) |
| 189 , m_subtreeIsCompositing(other.m_subtreeIsCompositing) | 190 , m_subtreeIsCompositing(other.m_subtreeIsCompositing) |
| 191 , m_hasUnisolatedCompositedBlendingDescendant(other.m_hasUnisolatedCompo
sitedBlendingDescendant) |
| 190 , m_testingOverlap(other.m_testingOverlap) | 192 , m_testingOverlap(other.m_testingOverlap) |
| 191 #ifndef NDEBUG | 193 #ifndef NDEBUG |
| 192 , m_depth(other.m_depth + 1) | 194 , m_depth(other.m_depth + 1) |
| 193 #endif | 195 #endif |
| 194 { | 196 { |
| 195 } | 197 } |
| 196 | 198 |
| 197 RenderLayer* m_compositingAncestor; | 199 RenderLayer* m_compositingAncestor; |
| 198 bool m_subtreeIsCompositing; | 200 bool m_subtreeIsCompositing; |
| 201 bool m_hasUnisolatedCompositedBlendingDescendant; |
| 199 bool m_testingOverlap; | 202 bool m_testingOverlap; |
| 200 #ifndef NDEBUG | 203 #ifndef NDEBUG |
| 201 int m_depth; | 204 int m_depth; |
| 202 #endif | 205 #endif |
| 203 }; | 206 }; |
| 204 | 207 |
| 205 | 208 |
| 206 RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView) | 209 RenderLayerCompositor::RenderLayerCompositor(RenderView* renderView) |
| 207 : m_renderView(renderView) | 210 : m_renderView(renderView) |
| 208 , m_hasAcceleratedCompositing(true) | 211 , m_hasAcceleratedCompositing(true) |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 if (inCompositingMode() && m_hasAcceleratedCompositing) | 910 if (inCompositingMode() && m_hasAcceleratedCompositing) |
| 908 willBeComposited = true; | 911 willBeComposited = true; |
| 909 } | 912 } |
| 910 | 913 |
| 911 // All layers (even ones that aren't being composited) need to get added to | 914 // All layers (even ones that aren't being composited) need to get added to |
| 912 // the overlap map. Layers that are not separately composited will paint int
o their | 915 // the overlap map. Layers that are not separately composited will paint int
o their |
| 913 // compositing ancestor's backing, and so are still considered for overlap. | 916 // compositing ancestor's backing, and so are still considered for overlap. |
| 914 if (overlapMap && childRecursionData.m_compositingAncestor && !childRecursio
nData.m_compositingAncestor->isRootLayer()) | 917 if (overlapMap && childRecursionData.m_compositingAncestor && !childRecursio
nData.m_compositingAncestor->isRootLayer()) |
| 915 addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds); | 918 addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds); |
| 916 | 919 |
| 920 if (layer->stackingNode()->isStackingContext()) { |
| 921 layer->setShouldIsolateCompositedDescendants(childRecursionData.m_hasUni
solatedCompositedBlendingDescendant); |
| 922 } else { |
| 923 layer->setShouldIsolateCompositedDescendants(false); |
| 924 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = child
RecursionData.m_hasUnisolatedCompositedBlendingDescendant; |
| 925 } |
| 926 |
| 917 // Now check for reasons to become composited that depend on the state of de
scendant layers. | 927 // Now check for reasons to become composited that depend on the state of de
scendant layers. |
| 918 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing(
layer->renderer(), childRecursionData.m_subtreeIsCompositing, anyDescendantHas3D
Transform); | 928 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing(
layer->renderer(), childRecursionData.m_subtreeIsCompositing, anyDescendantHas3D
Transform); |
| 919 reasonsToComposite |= subtreeCompositingReasons; | 929 reasonsToComposite |= subtreeCompositingReasons; |
| 920 if (!willBeComposited && canBeComposited(layer) && requiresCompositing(subtr
eeCompositingReasons)) { | 930 if (!willBeComposited && canBeComposited(layer) && requiresCompositing(subtr
eeCompositingReasons)) { |
| 921 childRecursionData.m_compositingAncestor = layer; | 931 childRecursionData.m_compositingAncestor = layer; |
| 922 if (overlapMap) { | 932 if (overlapMap) { |
| 923 // FIXME: this context push is effectively a no-op but needs to exis
t for | 933 // FIXME: this context push is effectively a no-op but needs to exis
t for |
| 924 // now, because the code is designed to push overlap information to
the | 934 // now, because the code is designed to push overlap information to
the |
| 925 // second-from-top context of the stack. | 935 // second-from-top context of the stack. |
| 926 overlapMap->beginNewOverlapTestingContext(); | 936 overlapMap->beginNewOverlapTestingContext(); |
| 927 addToOverlapMapRecursive(*overlapMap, layer); | 937 addToOverlapMapRecursive(*overlapMap, layer); |
| 928 } | 938 } |
| 929 willBeComposited = true; | 939 willBeComposited = true; |
| 930 } | 940 } |
| 931 | 941 |
| 932 // If the original layer is composited, the reflection needs to be, too. | 942 // If the original layer is composited, the reflection needs to be, too. |
| 933 if (layer->reflectionInfo()) { | 943 if (layer->reflectionInfo()) { |
| 934 // FIXME: Shouldn't we call computeCompositingRequirements to handle a r
eflection overlapping with another renderer? | 944 // FIXME: Shouldn't we call computeCompositingRequirements to handle a r
eflection overlapping with another renderer? |
| 935 CompositingReasons reflectionCompositingReason = willBeComposited ? Comp
ositingReasonReflectionOfCompositedParent : CompositingReasonNone; | 945 CompositingReasons reflectionCompositingReason = willBeComposited ? Comp
ositingReasonReflectionOfCompositedParent : CompositingReasonNone; |
| 936 layer->reflectionInfo()->reflectionLayer()->setCompositingReasons(layer-
>reflectionInfo()->reflectionLayer()->compositingReasons() | reflectionCompositi
ngReason); | 946 layer->reflectionInfo()->reflectionLayer()->setCompositingReasons(layer-
>reflectionInfo()->reflectionLayer()->compositingReasons() | reflectionCompositi
ngReason); |
| 937 } | 947 } |
| 938 | 948 |
| 939 // Subsequent layers in the parent's stacking context may also need to compo
site. | 949 // Subsequent layers in the parent's stacking context may also need to compo
site. |
| 940 if (childRecursionData.m_subtreeIsCompositing) | 950 if (childRecursionData.m_subtreeIsCompositing) |
| 941 currentRecursionData.m_subtreeIsCompositing = true; | 951 currentRecursionData.m_subtreeIsCompositing = true; |
| 942 | 952 |
| 953 if (willBeComposited && layer->hasBlendMode()) |
| 954 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = true; |
| 955 |
| 943 // Set the flag to say that this SC has compositing children. | 956 // Set the flag to say that this SC has compositing children. |
| 944 layer->setHasCompositingDescendant(childRecursionData.m_subtreeIsCompositing
); | 957 layer->setHasCompositingDescendant(childRecursionData.m_subtreeIsCompositing
); |
| 945 | 958 |
| 946 // Turn overlap testing off for later layers if it's already off, or if we h
ave an animating transform. | 959 // Turn overlap testing off for later layers if it's already off, or if we h
ave an animating transform. |
| 947 // 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 | 960 // 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 |
| 948 // we know for sure the animation is contained inside the clipping rectangle
, which is already added to the overlap map. | 961 // we know for sure the animation is contained inside the clipping rectangle
, which is already added to the overlap map. |
| 949 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi
te & CompositingReasonClipsCompositingDescendants); | 962 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi
te & CompositingReasonClipsCompositingDescendants); |
| 950 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) ||
isRunningAcceleratedTransformAnimation(layer->renderer())) | 963 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) ||
isRunningAcceleratedTransformAnimation(layer->renderer())) |
| 951 currentRecursionData.m_testingOverlap = false; | 964 currentRecursionData.m_testingOverlap = false; |
| 952 | 965 |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1739 | 1752 |
| 1740 // 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. | 1753 // 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. |
| 1741 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); | 1754 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); |
| 1742 | 1755 |
| 1743 // When a layer has composited descendants, some effects, like 2d transforms
, filters, masks etc must be implemented | 1756 // When a layer has composited descendants, some effects, like 2d transforms
, filters, masks etc must be implemented |
| 1744 // via compositing so that they also apply to those composited descdendants. | 1757 // via compositing so that they also apply to those composited descdendants. |
| 1745 if (hasCompositedDescendants) { | 1758 if (hasCompositedDescendants) { |
| 1746 if (layer->transform()) | 1759 if (layer->transform()) |
| 1747 subtreeReasons |= CompositingReasonTransformWithCompositedDescendant
s; | 1760 subtreeReasons |= CompositingReasonTransformWithCompositedDescendant
s; |
| 1748 | 1761 |
| 1762 if (layer->shouldIsolateCompositedDescendants()) { |
| 1763 ASSERT(layer->stackingNode()->isStackingContext()); |
| 1764 subtreeReasons |= CompositingReasonIsolateCompositedDescendants; |
| 1765 } |
| 1766 |
| 1749 // If the implementation of createsGroup changes, we need to be aware of
that in this part of code. | 1767 // If the implementation of createsGroup changes, we need to be aware of
that in this part of code. |
| 1750 ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->ha
sFilter() || renderer->hasBlendMode()) == renderer->createsGroup()); | 1768 ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->ha
sFilter() || renderer->hasBlendMode()) == renderer->createsGroup()); |
| 1751 if (renderer->isTransparent()) | 1769 if (renderer->isTransparent()) |
| 1752 subtreeReasons |= CompositingReasonOpacityWithCompositedDescendants; | 1770 subtreeReasons |= CompositingReasonOpacityWithCompositedDescendants; |
| 1753 if (renderer->hasMask()) | 1771 if (renderer->hasMask()) |
| 1754 subtreeReasons |= CompositingReasonMaskWithCompositedDescendants; | 1772 subtreeReasons |= CompositingReasonMaskWithCompositedDescendants; |
| 1755 if (renderer->hasFilter()) | 1773 if (renderer->hasFilter()) |
| 1756 subtreeReasons |= CompositingReasonFilterWithCompositedDescendants; | 1774 subtreeReasons |= CompositingReasonFilterWithCompositedDescendants; |
| 1757 if (renderer->hasBlendMode()) | 1775 if (renderer->hasBlendMode()) |
| 1758 subtreeReasons |= CompositingReasonBlendingWithCompositedDescendants
; | 1776 subtreeReasons |= CompositingReasonBlendingWithCompositedDescendants
; |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2484 } else if (graphicsLayer == m_scrollLayer.get()) { | 2502 } else if (graphicsLayer == m_scrollLayer.get()) { |
| 2485 name = "Frame Scrolling Layer"; | 2503 name = "Frame Scrolling Layer"; |
| 2486 } else { | 2504 } else { |
| 2487 ASSERT_NOT_REACHED(); | 2505 ASSERT_NOT_REACHED(); |
| 2488 } | 2506 } |
| 2489 | 2507 |
| 2490 return name; | 2508 return name; |
| 2491 } | 2509 } |
| 2492 | 2510 |
| 2493 } // namespace WebCore | 2511 } // namespace WebCore |
| OLD | NEW |