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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 private: | 173 private: |
174 Vector<OverlapMapContainer> m_overlapStack; | 174 Vector<OverlapMapContainer> m_overlapStack; |
175 HashSet<const RenderLayer*> m_layers; | 175 HashSet<const RenderLayer*> m_layers; |
176 RenderGeometryMap m_geometryMap; | 176 RenderGeometryMap m_geometryMap; |
177 }; | 177 }; |
178 | 178 |
179 struct CompositingState { | 179 struct CompositingState { |
180 CompositingState(RenderLayer* compAncestor, bool testOverlap) | 180 CompositingState(RenderLayer* compAncestor, bool testOverlap) |
181 : m_compositingAncestor(compAncestor) | 181 : m_compositingAncestor(compAncestor) |
182 , m_subtreeIsCompositing(false) | 182 , m_subtreeIsCompositing(false) |
| 183 , m_hasCompositedBlendingDescendents(false) |
183 , m_testingOverlap(testOverlap) | 184 , m_testingOverlap(testOverlap) |
184 #ifndef NDEBUG | 185 #ifndef NDEBUG |
185 , m_depth(0) | 186 , m_depth(0) |
186 #endif | 187 #endif |
187 { | 188 { |
188 } | 189 } |
189 | 190 |
190 CompositingState(const CompositingState& other) | 191 CompositingState(const CompositingState& other) |
191 : m_compositingAncestor(other.m_compositingAncestor) | 192 : m_compositingAncestor(other.m_compositingAncestor) |
192 , m_subtreeIsCompositing(other.m_subtreeIsCompositing) | 193 , m_subtreeIsCompositing(other.m_subtreeIsCompositing) |
| 194 , m_hasCompositedBlendingDescendents(other.m_hasCompositedBlendingDescen
dents) |
193 , m_testingOverlap(other.m_testingOverlap) | 195 , m_testingOverlap(other.m_testingOverlap) |
194 #ifndef NDEBUG | 196 #ifndef NDEBUG |
195 , m_depth(other.m_depth + 1) | 197 , m_depth(other.m_depth + 1) |
196 #endif | 198 #endif |
197 { | 199 { |
198 } | 200 } |
199 | 201 |
200 RenderLayer* m_compositingAncestor; | 202 RenderLayer* m_compositingAncestor; |
201 bool m_subtreeIsCompositing; | 203 bool m_subtreeIsCompositing; |
| 204 bool m_hasCompositedBlendingDescendents; |
202 bool m_testingOverlap; | 205 bool m_testingOverlap; |
203 #ifndef NDEBUG | 206 #ifndef NDEBUG |
204 int m_depth; | 207 int m_depth; |
205 #endif | 208 #endif |
206 }; | 209 }; |
207 | 210 |
208 | 211 |
209 static inline bool compositingLogEnabled() | 212 static inline bool compositingLogEnabled() |
210 { | 213 { |
211 #if !LOG_DISABLED | 214 #if !LOG_DISABLED |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 // | 774 // |
772 void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor
Layer, RenderLayer* layer, OverlapMap* overlapMap, CompositingState& compositing
State, bool& layersChanged, bool& descendantHas3DTransform) | 775 void RenderLayerCompositor::computeCompositingRequirements(RenderLayer* ancestor
Layer, RenderLayer* layer, OverlapMap* overlapMap, CompositingState& compositing
State, bool& layersChanged, bool& descendantHas3DTransform) |
773 { | 776 { |
774 layer->updateLayerListsIfNeeded(); | 777 layer->updateLayerListsIfNeeded(); |
775 | 778 |
776 if (overlapMap) | 779 if (overlapMap) |
777 overlapMap->geometryMap().pushMappingsToAncestor(layer, ancestorLayer); | 780 overlapMap->geometryMap().pushMappingsToAncestor(layer, ancestorLayer); |
778 | 781 |
779 // Clear the flag | 782 // Clear the flag |
780 layer->setHasCompositingDescendant(false); | 783 layer->setHasCompositingDescendant(false); |
| 784 layer->setShouldIsolateCompositedBlendingDescendants(false); |
781 | 785 |
782 // Start by assuming this layer will not need to composite. | 786 // Start by assuming this layer will not need to composite. |
783 CompositingReasons reasonsToComposite = CompositingReasonNone; | 787 CompositingReasons reasonsToComposite = CompositingReasonNone; |
784 | 788 |
785 // First accumulate the straightforward compositing reasons. | 789 // First accumulate the straightforward compositing reasons. |
786 CompositingReasons directReasons = directReasonsForCompositing(layer); | 790 CompositingReasons directReasons = directReasonsForCompositing(layer); |
787 | 791 |
788 // Video is special. It's the only RenderLayer type that can both have | 792 // Video is special. It's the only RenderLayer type that can both have |
789 // RenderLayer children and whose children can't use its backing to render | 793 // RenderLayer children and whose children can't use its backing to render |
790 // into. These children (the controls) always need to be promoted into their | 794 // into. These children (the controls) always need to be promoted into their |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 if (inCompositingMode() && m_hasAcceleratedCompositing) | 909 if (inCompositingMode() && m_hasAcceleratedCompositing) |
906 willBeComposited = true; | 910 willBeComposited = true; |
907 } | 911 } |
908 | 912 |
909 // All layers (even ones that aren't being composited) need to get added to | 913 // All layers (even ones that aren't being composited) need to get added to |
910 // the overlap map. Layers that do not composite will draw into their | 914 // the overlap map. Layers that do not composite will draw into their |
911 // compositing ancestor's backing, and so are still considered for overlap. | 915 // compositing ancestor's backing, and so are still considered for overlap. |
912 if (overlapMap && childState.m_compositingAncestor && !childState.m_composit
ingAncestor->isRootLayer()) | 916 if (overlapMap && childState.m_compositingAncestor && !childState.m_composit
ingAncestor->isRootLayer()) |
913 addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds); | 917 addToOverlapMap(*overlapMap, layer, absBounds, haveComputedBounds); |
914 | 918 |
| 919 // According to http://dev.w3.org/fxtf/compositing-1/#csscompositingrules_CS
S, |
| 920 // an element that has blending applied, must blend with all the underlying |
| 921 // content of the stacking context [CSS21] that element belongs to. |
| 922 // We should isolate and accelerate the stacking contexts containing |
| 923 // accelerated blending descendants |
| 924 if (layer->isStackingContext()) |
| 925 layer->setShouldIsolateCompositedBlendingDescendants(childState.m_hasCom
positedBlendingDescendents); |
| 926 else |
| 927 compositingState.m_hasCompositedBlendingDescendents = childState.m_hasCo
mpositedBlendingDescendents; |
| 928 |
915 // Now check for reasons to become composited that depend on the state of de
scendant layers. | 929 // Now check for reasons to become composited that depend on the state of de
scendant layers. |
916 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing(
layer->renderer(), childState.m_subtreeIsCompositing, anyDescendantHas3DTransfor
m); | 930 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing(
layer->renderer(), childState.m_subtreeIsCompositing, anyDescendantHas3DTransfor
m); |
917 reasonsToComposite |= subtreeCompositingReasons; | 931 reasonsToComposite |= subtreeCompositingReasons; |
918 if (!willBeComposited && canBeComposited(layer) && requiresCompositing(subtr
eeCompositingReasons)) { | 932 if (!willBeComposited && canBeComposited(layer) && requiresCompositing(subtr
eeCompositingReasons)) { |
919 childState.m_compositingAncestor = layer; | 933 childState.m_compositingAncestor = layer; |
920 if (overlapMap) { | 934 if (overlapMap) { |
921 // FIXME: this context push is effectively a no-op but needs to exis
t for | 935 // FIXME: this context push is effectively a no-op but needs to exis
t for |
922 // now, because the code is designed to push overlap information to
the | 936 // now, because the code is designed to push overlap information to
the |
923 // second-from-top context of the stack. | 937 // second-from-top context of the stack. |
924 overlapMap->beginNewOverlapTestingContext(); | 938 overlapMap->beginNewOverlapTestingContext(); |
925 addToOverlapMapRecursive(*overlapMap, layer); | 939 addToOverlapMapRecursive(*overlapMap, layer); |
926 } | 940 } |
927 willBeComposited = true; | 941 willBeComposited = true; |
928 } | 942 } |
929 | 943 |
930 // If the original layer is composited, the reflection needs to be, too. | 944 // If the original layer is composited, the reflection needs to be, too. |
931 if (layer->reflectionLayer()) { | 945 if (layer->reflectionLayer()) { |
932 // FIXME: Shouldn't we call computeCompositingRequirements to handle a r
eflection overlapping with another renderer? | 946 // FIXME: Shouldn't we call computeCompositingRequirements to handle a r
eflection overlapping with another renderer? |
933 CompositingReasons reflectionCompositingReason = willBeComposited ? Comp
ositingReasonReflectionOfCompositedParent : CompositingReasonNone; | 947 CompositingReasons reflectionCompositingReason = willBeComposited ? Comp
ositingReasonReflectionOfCompositedParent : CompositingReasonNone; |
934 layer->reflectionLayer()->setCompositingReasons(layer->reflectionLayer()
->compositingReasons() | reflectionCompositingReason); | 948 layer->reflectionLayer()->setCompositingReasons(layer->reflectionLayer()
->compositingReasons() | reflectionCompositingReason); |
935 } | 949 } |
936 | 950 |
937 // Subsequent layers in the parent's stacking context may also need to compo
site. | 951 // Subsequent layers in the parent's stacking context may also need to compo
site. |
938 if (childState.m_subtreeIsCompositing) | 952 if (childState.m_subtreeIsCompositing) |
939 compositingState.m_subtreeIsCompositing = true; | 953 compositingState.m_subtreeIsCompositing = true; |
| 954 if (willBeComposited && layer->hasBlendMode()) |
| 955 compositingState.m_hasCompositedBlendingDescendents = true; |
940 | 956 |
941 // Set the flag to say that this SC has compositing children. | 957 // Set the flag to say that this SC has compositing children. |
942 layer->setHasCompositingDescendant(childState.m_subtreeIsCompositing); | 958 layer->setHasCompositingDescendant(childState.m_subtreeIsCompositing); |
943 | 959 |
944 | 960 |
945 // Turn overlap testing off for later layers if it's already off, or if we h
ave an animating transform. | 961 // Turn overlap testing off for later layers if it's already off, or if we h
ave an animating transform. |
946 // 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 | 962 // 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 |
947 // we know for sure the animation is contained inside the clipping rectangle
, which is already added to the overlap map. | 963 // we know for sure the animation is contained inside the clipping rectangle
, which is already added to the overlap map. |
948 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi
te & CompositingReasonClipsCompositingDescendants); | 964 bool isCompositedClippingLayer = canBeComposited(layer) && (reasonsToComposi
te & CompositingReasonClipsCompositingDescendants); |
949 if ((!childState.m_testingOverlap && !isCompositedClippingLayer) || isRunnin
gAcceleratedTransformAnimation(layer->renderer())) | 965 if ((!childState.m_testingOverlap && !isCompositedClippingLayer) || isRunnin
gAcceleratedTransformAnimation(layer->renderer())) |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 return true; | 1583 return true; |
1568 | 1584 |
1569 CompositingReasons indirectReasonsThatNeedBacking = CompositingReasonOverlap | 1585 CompositingReasons indirectReasonsThatNeedBacking = CompositingReasonOverlap |
1570 | CompositingReasonAssumedOverlap | 1586 | CompositingReasonAssumedOverlap |
1571 | CompositingReasonNegativeZIndexChildren | 1587 | CompositingReasonNegativeZIndexChildren |
1572 | CompositingReasonTransformWithCompositedDescendants | 1588 | CompositingReasonTransformWithCompositedDescendants |
1573 | CompositingReasonOpacityWithCompositedDescendants | 1589 | CompositingReasonOpacityWithCompositedDescendants |
1574 | CompositingReasonMaskWithCompositedDescendants | 1590 | CompositingReasonMaskWithCompositedDescendants |
1575 | CompositingReasonFilterWithCompositedDescendants | 1591 | CompositingReasonFilterWithCompositedDescendants |
1576 | CompositingReasonBlendingWithCompositedDescendants | 1592 | CompositingReasonBlendingWithCompositedDescendants |
| 1593 | CompositingReasonIsolateCompositedDescendants |
1577 | CompositingReasonPreserve3D; // preserve-3d has to create backing stor
e to ensure that 3d-transformed elements intersect. | 1594 | CompositingReasonPreserve3D; // preserve-3d has to create backing stor
e to ensure that 3d-transformed elements intersect. |
1578 return layer->compositingReasons() & indirectReasonsThatNeedBacking; | 1595 return layer->compositingReasons() & indirectReasonsThatNeedBacking; |
1579 } | 1596 } |
1580 | 1597 |
1581 CompositingReasons RenderLayerCompositor::directReasonsForCompositing(const Rend
erLayer* layer) const | 1598 CompositingReasons RenderLayerCompositor::directReasonsForCompositing(const Rend
erLayer* layer) const |
1582 { | 1599 { |
1583 RenderObject* renderer = layer->renderer(); | 1600 RenderObject* renderer = layer->renderer(); |
1584 CompositingReasons directReasons = CompositingReasonNone; | 1601 CompositingReasons directReasons = CompositingReasonNone; |
1585 | 1602 |
1586 if (requiresCompositingForTransform(renderer)) | 1603 if (requiresCompositingForTransform(renderer)) |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 CompositingReasons subtreeReasons = CompositingReasonNone; | 1908 CompositingReasons subtreeReasons = CompositingReasonNone; |
1892 | 1909 |
1893 // 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. | 1910 // 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. |
1894 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); | 1911 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); |
1895 | 1912 |
1896 // When a layer has composited descendants, some effects, like 2d transforms
, filters, masks etc must be implemented | 1913 // When a layer has composited descendants, some effects, like 2d transforms
, filters, masks etc must be implemented |
1897 // via compositing so that they also apply to those composited descdendants. | 1914 // via compositing so that they also apply to those composited descdendants. |
1898 if (hasCompositedDescendants) { | 1915 if (hasCompositedDescendants) { |
1899 if (layer->transform()) | 1916 if (layer->transform()) |
1900 subtreeReasons |= CompositingReasonTransformWithCompositedDescendant
s; | 1917 subtreeReasons |= CompositingReasonTransformWithCompositedDescendant
s; |
| 1918 if (layer->shouldIsolateCompositedBlendingDescendants()) |
| 1919 subtreeReasons |= CompositingReasonIsolateCompositedDescendants; |
1901 | 1920 |
1902 // If the implementation of createsGroup changes, we need to be aware of
that in this part of code. | 1921 // If the implementation of createsGroup changes, we need to be aware of
that in this part of code. |
1903 ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->ha
sFilter() || renderer->hasBlendMode()) == renderer->createsGroup()); | 1922 ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->ha
sFilter() || renderer->hasBlendMode()) == renderer->createsGroup()); |
1904 if (renderer->isTransparent()) | 1923 if (renderer->isTransparent()) |
1905 subtreeReasons |= CompositingReasonOpacityWithCompositedDescendants; | 1924 subtreeReasons |= CompositingReasonOpacityWithCompositedDescendants; |
1906 if (renderer->hasMask()) | 1925 if (renderer->hasMask()) |
1907 subtreeReasons |= CompositingReasonMaskWithCompositedDescendants; | 1926 subtreeReasons |= CompositingReasonMaskWithCompositedDescendants; |
1908 if (renderer->hasFilter()) | 1927 if (renderer->hasFilter()) |
1909 subtreeReasons |= CompositingReasonFilterWithCompositedDescendants; | 1928 subtreeReasons |= CompositingReasonFilterWithCompositedDescendants; |
1910 if (renderer->hasBlendMode()) | 1929 if (renderer->hasBlendMode()) |
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2704 } else if (graphicsLayer == m_scrollLayer.get()) { | 2723 } else if (graphicsLayer == m_scrollLayer.get()) { |
2705 name = "Frame Scrolling Layer"; | 2724 name = "Frame Scrolling Layer"; |
2706 } else { | 2725 } else { |
2707 ASSERT_NOT_REACHED(); | 2726 ASSERT_NOT_REACHED(); |
2708 } | 2727 } |
2709 | 2728 |
2710 return name; | 2729 return name; |
2711 } | 2730 } |
2712 | 2731 |
2713 } // namespace WebCore | 2732 } // namespace WebCore |
OLD | NEW |