| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 } | 738 } |
| 739 | 739 |
| 740 void RenderLayer::updateStackingNode() | 740 void RenderLayer::updateStackingNode() |
| 741 { | 741 { |
| 742 if (requiresStackingNode()) | 742 if (requiresStackingNode()) |
| 743 m_stackingNode = adoptPtr(new RenderLayerStackingNode(this)); | 743 m_stackingNode = adoptPtr(new RenderLayerStackingNode(this)); |
| 744 else | 744 else |
| 745 m_stackingNode = nullptr; | 745 m_stackingNode = nullptr; |
| 746 } | 746 } |
| 747 | 747 |
| 748 void RenderLayer::paint(GraphicsContext* context, const LayoutRect& damageRect,
RenderObject* paintingRoot) | 748 void RenderLayer::paint(GraphicsContext* context, const LayoutRect& damageRect) |
| 749 { | 749 { |
| 750 TRACE_EVENT0("blink", "RenderLayer::paint"); | 750 TRACE_EVENT0("blink", "RenderLayer::paint"); |
| 751 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), LayoutSiz
e(), paintingRoot); | 751 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), LayoutSiz
e()); |
| 752 paintLayer(context, paintingInfo, PaintContent); | 752 paintLayer(context, paintingInfo, PaintContent); |
| 753 } | 753 } |
| 754 | 754 |
| 755 static bool inContainingBlockChain(RenderLayer* startLayer, RenderLayer* endLaye
r) | 755 static bool inContainingBlockChain(RenderLayer* startLayer, RenderLayer* endLaye
r) |
| 756 { | 756 { |
| 757 if (startLayer == endLayer) | 757 if (startLayer == endLayer) |
| 758 return true; | 758 return true; |
| 759 | 759 |
| 760 RenderView* view = startLayer->renderer()->view(); | 760 RenderView* view = startLayer->renderer()->view(); |
| 761 for (RenderBlock* currentBlock = startLayer->renderer()->containingBlock();
currentBlock && currentBlock != view; currentBlock = currentBlock->containingBlo
ck()) { | 761 for (RenderBlock* currentBlock = startLayer->renderer()->containingBlock();
currentBlock && currentBlock != view; currentBlock = currentBlock->containingBlo
ck()) { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 // FIXME: It is incorrect to just clip to the damageRect here once m
ultiple fragments are involved. | 926 // FIXME: It is incorrect to just clip to the damageRect here once m
ultiple fragments are involved. |
| 927 clipToRect(localPaintingInfo, context, backgroundRect); | 927 clipToRect(localPaintingInfo, context, backgroundRect); |
| 928 // Subsequent code should not clip to the dirty rect, since we've al
ready | 928 // Subsequent code should not clip to the dirty rect, since we've al
ready |
| 929 // done it above, and doing it later will defeat the outsets. | 929 // done it above, and doing it later will defeat the outsets. |
| 930 localPaintingInfo.clipToDirtyRect = false; | 930 localPaintingInfo.clipToDirtyRect = false; |
| 931 | 931 |
| 932 context = filterPainter.beginFilterEffect(context); | 932 context = filterPainter.beginFilterEffect(context); |
| 933 } | 933 } |
| 934 } | 934 } |
| 935 | 935 |
| 936 // If this layer's renderer is a child of the paintingRoot, we render uncond
itionally, which | |
| 937 // is done by passing a nil paintingRoot down to our renderer (as if no pain
tingRoot was ever set). | |
| 938 // Else, our renderer tree may or may not contain the painting root, so we p
ass that root along | |
| 939 // so it will be tested against as we descend through the renderers. | |
| 940 RenderObject* paintingRootForRenderer = 0; | |
| 941 if (localPaintingInfo.paintingRoot && !renderer()->isDescendantOf(localPaint
ingInfo.paintingRoot)) | |
| 942 paintingRootForRenderer = localPaintingInfo.paintingRoot; | |
| 943 | |
| 944 LayoutPoint layerLocation = toPoint(layerBounds.location() - renderBoxLocati
on() + localPaintingInfo.subPixelAccumulation); | 936 LayoutPoint layerLocation = toPoint(layerBounds.location() - renderBoxLocati
on() + localPaintingInfo.subPixelAccumulation); |
| 945 | 937 |
| 946 if (shouldPaintContent) { | 938 if (shouldPaintContent) { |
| 947 paintForeground(context, transparencyLayerContext, paintingInfo.paintDir
tyRect, haveTransparency, | 939 paintForeground(context, transparencyLayerContext, paintingInfo.paintDir
tyRect, haveTransparency, |
| 948 localPaintingInfo, paintingRootForRenderer, layerLocation, backgroun
dRect); | 940 localPaintingInfo, layerLocation, backgroundRect); |
| 949 } | 941 } |
| 950 | 942 |
| 951 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, painting
Info, paintFlags); | 943 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, painting
Info, paintFlags); |
| 952 | 944 |
| 953 if (filterPainter.hasStartedFilterEffect()) { | 945 if (filterPainter.hasStartedFilterEffect()) { |
| 954 context = filterPainter.applyFilterEffect(); | 946 context = filterPainter.applyFilterEffect(); |
| 955 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect,
backgroundRect); | 947 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect,
backgroundRect); |
| 956 } | 948 } |
| 957 | 949 |
| 958 // Make sure that we now use the original transparency context. | 950 // Make sure that we now use the original transparency context. |
| 959 ASSERT(transparencyLayerContext == context); | 951 ASSERT(transparencyLayerContext == context); |
| 960 | 952 |
| 961 if (shouldPaintContent && renderer()->hasMask()) | 953 if (shouldPaintContent && renderer()->hasMask()) |
| 962 paintMask(context, localPaintingInfo, paintingRootForRenderer, layerLoca
tion, backgroundRect); | 954 paintMask(context, localPaintingInfo, layerLocation, backgroundRect); |
| 963 | 955 |
| 964 // End our transparency layer | 956 // End our transparency layer |
| 965 if (haveTransparency && m_usedTransparency) { | 957 if (haveTransparency && m_usedTransparency) { |
| 966 context->endLayer(); | 958 context->endLayer(); |
| 967 context->restore(); | 959 context->restore(); |
| 968 m_usedTransparency = false; | 960 m_usedTransparency = false; |
| 969 } | 961 } |
| 970 } | 962 } |
| 971 | 963 |
| 972 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const
LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint&
translationOffset) | 964 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const
LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint&
translationOffset) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 983 | 975 |
| 984 // Apply the transform. | 976 // Apply the transform. |
| 985 GraphicsContextStateSaver stateSaver(*context, false); | 977 GraphicsContextStateSaver stateSaver(*context, false); |
| 986 if (!transform.isIdentity()) { | 978 if (!transform.isIdentity()) { |
| 987 stateSaver.save(); | 979 stateSaver.save(); |
| 988 context->concatCTM(transform.toAffineTransform()); | 980 context->concatCTM(transform.toAffineTransform()); |
| 989 } | 981 } |
| 990 | 982 |
| 991 // Now do a paint with the root layer shifted to be us. | 983 // Now do a paint with the root layer shifted to be us. |
| 992 LayerPaintingInfo transformedPaintingInfo(this, enclosingIntRect(transform.i
nverse().mapRect(paintingInfo.paintDirtyRect)), | 984 LayerPaintingInfo transformedPaintingInfo(this, enclosingIntRect(transform.i
nverse().mapRect(paintingInfo.paintDirtyRect)), |
| 993 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); | 985 adjustedSubPixelAccumulation); |
| 994 paintLayerContents(context, transformedPaintingInfo, paintFlags); | 986 paintLayerContents(context, transformedPaintingInfo, paintFlags); |
| 995 } | 987 } |
| 996 | 988 |
| 997 void RenderLayer::paintChildren(unsigned childrenToVisit, GraphicsContext* conte
xt, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) | 989 void RenderLayer::paintChildren(unsigned childrenToVisit, GraphicsContext* conte
xt, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) |
| 998 { | 990 { |
| 999 if (!hasSelfPaintingLayerDescendant()) | 991 if (!hasSelfPaintingLayerDescendant()) |
| 1000 return; | 992 return; |
| 1001 | 993 |
| 1002 #if ENABLE(ASSERT) | 994 #if ENABLE(ASSERT) |
| 1003 LayerListMutationDetector mutationChecker(m_stackingNode.get()); | 995 LayerListMutationDetector mutationChecker(m_stackingNode.get()); |
| 1004 #endif | 996 #endif |
| 1005 | 997 |
| 1006 RenderLayerStackingNodeIterator iterator(*m_stackingNode, childrenToVisit); | 998 RenderLayerStackingNodeIterator iterator(*m_stackingNode, childrenToVisit); |
| 1007 while (RenderLayerStackingNode* child = iterator.next()) { | 999 while (RenderLayerStackingNode* child = iterator.next()) { |
| 1008 child->layer()->paintLayer(context, paintingInfo, paintFlags); | 1000 child->layer()->paintLayer(context, paintingInfo, paintFlags); |
| 1009 } | 1001 } |
| 1010 } | 1002 } |
| 1011 | 1003 |
| 1012 void RenderLayer::paintForeground(GraphicsContext* context, GraphicsContext* tra
nsparencyLayerContext, | 1004 void RenderLayer::paintForeground(GraphicsContext* context, GraphicsContext* tra
nsparencyLayerContext, |
| 1013 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L
ayerPaintingInfo& localPaintingInfo, | 1005 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L
ayerPaintingInfo& localPaintingInfo, |
| 1014 RenderObject* paintingRootForRenderer, LayoutPoint& layerLocation, ClipRect&
layerForegroundRect) | 1006 LayoutPoint& layerLocation, ClipRect& layerForegroundRect) |
| 1015 { | 1007 { |
| 1016 bool foregroundRectIsEmpty = layerForegroundRect.isEmpty(); | 1008 bool foregroundRectIsEmpty = layerForegroundRect.isEmpty(); |
| 1017 | 1009 |
| 1018 // Begin transparency if we have something to paint. | 1010 // Begin transparency if we have something to paint. |
| 1019 if (haveTransparency && !foregroundRectIsEmpty) | 1011 if (haveTransparency && !foregroundRectIsEmpty) |
| 1020 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo.root
Layer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation); | 1012 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo.root
Layer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation); |
| 1021 | 1013 |
| 1022 // Optimize clipping for the single fragment case. | 1014 // Optimize clipping for the single fragment case. |
| 1023 bool shouldClip = localPaintingInfo.clipToDirtyRect && !foregroundRectIsEmpt
y; | 1015 bool shouldClip = localPaintingInfo.clipToDirtyRect && !foregroundRectIsEmpt
y; |
| 1024 if (shouldClip) | 1016 if (shouldClip) |
| 1025 clipToRect(localPaintingInfo, context, layerForegroundRect); | 1017 clipToRect(localPaintingInfo, context, layerForegroundRect); |
| 1026 | 1018 |
| 1027 if (!foregroundRectIsEmpty) { | 1019 if (!foregroundRectIsEmpty) { |
| 1028 // We have to loop through every fragment multiple times, since we have
to issue paint invalidations in each specific phase in order for | 1020 // We have to loop through every fragment multiple times, since we have
to issue paint invalidations in each specific phase in order for |
| 1029 // interleaving of the fragments to work properly. | 1021 // interleaving of the fragments to work properly. |
| 1030 // FIXME(sky): Do we still need this for anything now that we don't have
fragments? | 1022 // FIXME(sky): Do we still need this for anything now that we don't have
fragments? |
| 1031 paintForegroundWithPhase(PaintPhaseForeground, | 1023 paintForegroundWithPhase(PaintPhaseForeground, |
| 1032 context, localPaintingInfo, paintingRootForRenderer, | 1024 context, localPaintingInfo, |
| 1033 layerLocation, layerForegroundRect); | 1025 layerLocation, layerForegroundRect); |
| 1034 } | 1026 } |
| 1035 | 1027 |
| 1036 if (shouldClip) | 1028 if (shouldClip) |
| 1037 restoreClip(context, localPaintingInfo.paintDirtyRect, layerForegroundRe
ct); | 1029 restoreClip(context, localPaintingInfo.paintDirtyRect, layerForegroundRe
ct); |
| 1038 } | 1030 } |
| 1039 | 1031 |
| 1040 void RenderLayer::paintForegroundWithPhase(PaintPhase phase, GraphicsContext* co
ntext, | 1032 void RenderLayer::paintForegroundWithPhase(PaintPhase phase, GraphicsContext* co
ntext, |
| 1041 const LayerPaintingInfo& localPaintingInfo, RenderObject* paintingRootForRen
derer, LayoutPoint& layerLocation, ClipRect& layerForegroundRect) | 1033 const LayerPaintingInfo& localPaintingInfo, LayoutPoint& layerLocation, Clip
Rect& layerForegroundRect) |
| 1042 { | 1034 { |
| 1043 PaintInfo paintInfo(context, pixelSnappedIntRect(layerForegroundRect.rect())
, phase, paintingRootForRenderer, localPaintingInfo.rootLayer->renderer()); | 1035 PaintInfo paintInfo(context, pixelSnappedIntRect(layerForegroundRect.rect())
, phase, localPaintingInfo.rootLayer->renderer()); |
| 1044 renderer()->paint(paintInfo, layerLocation); | 1036 renderer()->paint(paintInfo, layerLocation); |
| 1045 } | 1037 } |
| 1046 | 1038 |
| 1047 void RenderLayer::paintMask(GraphicsContext* context, const LayerPaintingInfo& l
ocalPaintingInfo, | 1039 void RenderLayer::paintMask(GraphicsContext* context, const LayerPaintingInfo& l
ocalPaintingInfo, |
| 1048 RenderObject* paintingRootForRenderer, LayoutPoint& layerLocation, ClipRect&
layerBackgroundRect) | 1040 LayoutPoint& layerLocation, ClipRect& layerBackgroundRect) |
| 1049 { | 1041 { |
| 1050 if (localPaintingInfo.clipToDirtyRect) | 1042 if (localPaintingInfo.clipToDirtyRect) |
| 1051 clipToRect(localPaintingInfo, context, layerBackgroundRect, DoNotInclude
SelfForBorderRadius); // Mask painting will handle clipping to self. | 1043 clipToRect(localPaintingInfo, context, layerBackgroundRect, DoNotInclude
SelfForBorderRadius); // Mask painting will handle clipping to self. |
| 1052 | 1044 |
| 1053 // Paint the mask. | 1045 // Paint the mask. |
| 1054 // FIXME: Eventually we will collect the region from the fragment itself ins
tead of just from the paint info. | 1046 // FIXME: Eventually we will collect the region from the fragment itself ins
tead of just from the paint info. |
| 1055 PaintInfo paintInfo(context, pixelSnappedIntRect(layerBackgroundRect.rect())
, PaintPhaseMask, paintingRootForRenderer, localPaintingInfo.rootLayer->renderer
()); | 1047 PaintInfo paintInfo(context, pixelSnappedIntRect(layerBackgroundRect.rect())
, PaintPhaseMask, localPaintingInfo.rootLayer->renderer()); |
| 1056 renderer()->paint(paintInfo, layerLocation); | 1048 renderer()->paint(paintInfo, layerLocation); |
| 1057 | 1049 |
| 1058 if (localPaintingInfo.clipToDirtyRect) | 1050 if (localPaintingInfo.clipToDirtyRect) |
| 1059 restoreClip(context, localPaintingInfo.paintDirtyRect, layerBackgroundRe
ct); | 1051 restoreClip(context, localPaintingInfo.paintDirtyRect, layerBackgroundRe
ct); |
| 1060 } | 1052 } |
| 1061 | 1053 |
| 1062 static inline LayoutRect frameVisibleRect(RenderObject* renderer) | 1054 static inline LayoutRect frameVisibleRect(RenderObject* renderer) |
| 1063 { | 1055 { |
| 1064 FrameView* frameView = renderer->document().view(); | 1056 FrameView* frameView = renderer->document().view(); |
| 1065 if (!frameView) | 1057 if (!frameView) |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 } | 1699 } |
| 1708 } | 1700 } |
| 1709 | 1701 |
| 1710 void showLayerTree(const blink::RenderObject* renderer) | 1702 void showLayerTree(const blink::RenderObject* renderer) |
| 1711 { | 1703 { |
| 1712 if (!renderer) | 1704 if (!renderer) |
| 1713 return; | 1705 return; |
| 1714 showLayerTree(renderer->enclosingLayer()); | 1706 showLayerTree(renderer->enclosingLayer()); |
| 1715 } | 1707 } |
| 1716 #endif | 1708 #endif |
| OLD | NEW |