| 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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 | 1028 |
| 1029 context->clipPath(clipPath->path(rootRelativeBounds), clipPath->
windRule()); | 1029 context->clipPath(clipPath->path(rootRelativeBounds), clipPath->
windRule()); |
| 1030 } | 1030 } |
| 1031 } | 1031 } |
| 1032 } | 1032 } |
| 1033 | 1033 |
| 1034 LayerPaintingInfo localPaintingInfo(paintingInfo); | 1034 LayerPaintingInfo localPaintingInfo(paintingInfo); |
| 1035 bool deferredFiltersEnabled = renderer()->document().settings()->deferredFil
tersEnabled(); | 1035 bool deferredFiltersEnabled = renderer()->document().settings()->deferredFil
tersEnabled(); |
| 1036 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte
rs()); | 1036 FilterEffectRendererHelper filterPainter(filterRenderer() && paintsWithFilte
rs()); |
| 1037 | 1037 |
| 1038 // FIXME(sky): There's only one fragment. Get rid of the vector. | 1038 LayoutRect layerBounds; |
| 1039 LayerFragments layerFragments; | 1039 ClipRect backgroundRect, foregroundRect, outlineRect; |
| 1040 LayerFragment fragment; | |
| 1041 ClipRectsContext clipRectsContext(localPaintingInfo.rootLayer, PaintingClipR
ects, localPaintingInfo.subPixelAccumulation); | 1040 ClipRectsContext clipRectsContext(localPaintingInfo.rootLayer, PaintingClipR
ects, localPaintingInfo.subPixelAccumulation); |
| 1042 clipper().calculateRects(clipRectsContext, localPaintingInfo.paintDirtyRect, | 1041 clipper().calculateRects(clipRectsContext, localPaintingInfo.paintDirtyRect, |
| 1043 fragment.layerBounds, fragment.backgroundRect, fragment.foregroundRect,
fragment.outlineRect, | 1042 layerBounds, backgroundRect, foregroundRect, outlineRect, |
| 1044 &offsetFromRoot); | 1043 &offsetFromRoot); |
| 1045 layerFragments.append(fragment); | |
| 1046 | 1044 |
| 1047 bool isPaintingOverlayScrollbars = paintFlags == PaintOverlayScrollbars; | 1045 bool isPaintingOverlayScrollbars = paintFlags == PaintOverlayScrollbars; |
| 1048 bool shouldPaintContent = isSelfPaintingLayer() && !isPaintingOverlayScrollb
ars; | 1046 bool shouldPaintContent = isSelfPaintingLayer() && !isPaintingOverlayScrollb
ars |
| 1049 updatePaintingInfoForFragments(layerFragments, localPaintingInfo, shouldPain
tContent, &offsetFromRoot); | 1047 && intersectsDamageRect(layerBounds, backgroundRect.rect(), localPaintin
gInfo.rootLayer, &offsetFromRoot); |
| 1050 | 1048 |
| 1051 bool haveTransparency = isTransparent(); | 1049 bool haveTransparency = isTransparent(); |
| 1052 | 1050 |
| 1053 if (filterPainter.haveFilterEffect()) { | 1051 if (filterPainter.haveFilterEffect()) { |
| 1054 ASSERT(this->filterInfo()); | 1052 ASSERT(this->filterInfo()); |
| 1055 | 1053 |
| 1056 if (!rootRelativeBoundsComputed) | 1054 if (!rootRelativeBoundsComputed) |
| 1057 rootRelativeBounds = physicalBoundingBoxIncludingReflectionAndStacki
ngChildren(paintingInfo.rootLayer, offsetFromRoot); | 1055 rootRelativeBounds = physicalBoundingBoxIncludingReflectionAndStacki
ngChildren(paintingInfo.rootLayer, offsetFromRoot); |
| 1058 | 1056 |
| 1059 if (filterPainter.prepareFilterEffect(this, rootRelativeBounds, painting
Info.paintDirtyRect)) { | 1057 if (filterPainter.prepareFilterEffect(this, rootRelativeBounds, painting
Info.paintDirtyRect)) { |
| 1060 | 1058 |
| 1061 // Rewire the old context to a memory buffer, so that we can capture
the contents of the layer. | 1059 // Rewire the old context to a memory buffer, so that we can capture
the contents of the layer. |
| 1062 // NOTE: We saved the old context in the "transparencyLayerContext"
local variable, to be able to start a transparency layer | 1060 // NOTE: We saved the old context in the "transparencyLayerContext"
local variable, to be able to start a transparency layer |
| 1063 // on the original context and avoid duplicating "beginFilterEffect"
after each transparency layer call. Also, note that | 1061 // on the original context and avoid duplicating "beginFilterEffect"
after each transparency layer call. Also, note that |
| 1064 // beginTransparencyLayers will only create a single lazy transparen
cy layer, even though it is called twice in this method. | 1062 // beginTransparencyLayers will only create a single lazy transparen
cy layer, even though it is called twice in this method. |
| 1065 // With deferred filters, we don't need a separate context, but we d
o need to do transparency and clipping before starting | 1063 // With deferred filters, we don't need a separate context, but we d
o need to do transparency and clipping before starting |
| 1066 // filter processing. | 1064 // filter processing. |
| 1067 // FIXME: when the legacy path is removed, remove the transparencyLa
yerContext as well. | 1065 // FIXME: when the legacy path is removed, remove the transparencyLa
yerContext as well. |
| 1068 if (deferredFiltersEnabled) { | 1066 if (deferredFiltersEnabled) { |
| 1069 if (haveTransparency) { | 1067 if (haveTransparency) { |
| 1070 // If we have a filter and transparency, we have to eagerly
start a transparency layer here, rather than risk a child layer lazily starts on
e after filter processing. | 1068 // If we have a filter and transparency, we have to eagerly
start a transparency layer here, rather than risk a child layer lazily starts on
e after filter processing. |
| 1071 beginTransparencyLayers(context, localPaintingInfo.rootLayer
, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation); | 1069 beginTransparencyLayers(context, localPaintingInfo.rootLayer
, paintingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation); |
| 1072 } | 1070 } |
| 1073 // We'll handle clipping to the dirty rect before filter rasteri
zation. | 1071 // We'll handle clipping to the dirty rect before filter rasteri
zation. |
| 1074 // Filter processing will automatically expand the clip rect and
the offscreen to accommodate any filter outsets. | 1072 // Filter processing will automatically expand the clip rect and
the offscreen to accommodate any filter outsets. |
| 1075 // FIXME: It is incorrect to just clip to the damageRect here on
ce multiple fragments are involved. | 1073 // FIXME: It is incorrect to just clip to the damageRect here on
ce multiple fragments are involved. |
| 1076 ClipRect backgroundRect = fragment.backgroundRect; | |
| 1077 clipToRect(localPaintingInfo, context, backgroundRect); | 1074 clipToRect(localPaintingInfo, context, backgroundRect); |
| 1078 // Subsequent code should not clip to the dirty rect, since we'v
e already | 1075 // Subsequent code should not clip to the dirty rect, since we'v
e already |
| 1079 // done it above, and doing it later will defeat the outsets. | 1076 // done it above, and doing it later will defeat the outsets. |
| 1080 localPaintingInfo.clipToDirtyRect = false; | 1077 localPaintingInfo.clipToDirtyRect = false; |
| 1081 } | 1078 } |
| 1082 context = filterPainter.beginFilterEffect(context); | 1079 context = filterPainter.beginFilterEffect(context); |
| 1083 | 1080 |
| 1084 // Check that we didn't fail to allocate the graphics context for th
e offscreen buffer. | 1081 // Check that we didn't fail to allocate the graphics context for th
e offscreen buffer. |
| 1085 if (filterPainter.hasStartedFilterEffect() && !deferredFiltersEnable
d) { | 1082 if (filterPainter.hasStartedFilterEffect() && !deferredFiltersEnable
d) { |
| 1086 localPaintingInfo.paintDirtyRect = filterPainter.paintInvalidati
onRect(); | 1083 localPaintingInfo.paintDirtyRect = filterPainter.paintInvalidati
onRect(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1098 } | 1095 } |
| 1099 | 1096 |
| 1100 // If this layer's renderer is a child of the paintingRoot, we render uncond
itionally, which | 1097 // If this layer's renderer is a child of the paintingRoot, we render uncond
itionally, which |
| 1101 // is done by passing a nil paintingRoot down to our renderer (as if no pain
tingRoot was ever set). | 1098 // is done by passing a nil paintingRoot down to our renderer (as if no pain
tingRoot was ever set). |
| 1102 // Else, our renderer tree may or may not contain the painting root, so we p
ass that root along | 1099 // Else, our renderer tree may or may not contain the painting root, so we p
ass that root along |
| 1103 // so it will be tested against as we descend through the renderers. | 1100 // so it will be tested against as we descend through the renderers. |
| 1104 RenderObject* paintingRootForRenderer = 0; | 1101 RenderObject* paintingRootForRenderer = 0; |
| 1105 if (localPaintingInfo.paintingRoot && !renderer()->isDescendantOf(localPaint
ingInfo.paintingRoot)) | 1102 if (localPaintingInfo.paintingRoot && !renderer()->isDescendantOf(localPaint
ingInfo.paintingRoot)) |
| 1106 paintingRootForRenderer = localPaintingInfo.paintingRoot; | 1103 paintingRootForRenderer = localPaintingInfo.paintingRoot; |
| 1107 | 1104 |
| 1105 LayoutPoint layerLocation = toPoint(layerBounds.location() - renderBoxLocati
on() + localPaintingInfo.subPixelAccumulation); |
| 1106 |
| 1108 if (shouldPaintContent) { | 1107 if (shouldPaintContent) { |
| 1109 paintBackgroundForFragments(layerFragments, context, transparencyLayerCo
ntext, paintingInfo.paintDirtyRect, haveTransparency, | 1108 paintBackground(context, transparencyLayerContext, paintingInfo.paintDir
tyRect, haveTransparency, |
| 1110 localPaintingInfo, paintingRootForRenderer); | 1109 localPaintingInfo, paintingRootForRenderer, layerLocation, backgroun
dRect); |
| 1111 } | 1110 } |
| 1112 | 1111 |
| 1113 paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFlags); | 1112 paintChildren(NegativeZOrderChildren, context, paintingInfo, paintFlags); |
| 1114 | 1113 |
| 1115 if (shouldPaintContent) { | 1114 if (shouldPaintContent) { |
| 1116 paintForegroundForFragments(layerFragments, context, transparencyLayerCo
ntext, paintingInfo.paintDirtyRect, haveTransparency, | 1115 paintForeground(context, transparencyLayerContext, paintingInfo.paintDir
tyRect, haveTransparency, |
| 1117 localPaintingInfo, paintingRootForRenderer); | 1116 localPaintingInfo, paintingRootForRenderer, layerLocation, foregroun
dRect); |
| 1118 } | 1117 } |
| 1119 | 1118 |
| 1120 paintOutlineForFragments(layerFragments, context, localPaintingInfo, paintin
gRootForRenderer); | 1119 paintOutline(context, localPaintingInfo, paintingRootForRenderer, layerLocat
ion, outlineRect); |
| 1121 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, painting
Info, paintFlags); | 1120 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, painting
Info, paintFlags); |
| 1122 | 1121 |
| 1123 if (isPaintingOverlayScrollbars) | 1122 if (isPaintingOverlayScrollbars) |
| 1124 paintOverflowControlsForFragments(layerFragments, context, localPainting
Info); | 1123 paintOverflowControls(context, localPaintingInfo, layerLocation, backgro
undRect); |
| 1125 | 1124 |
| 1126 if (filterPainter.hasStartedFilterEffect()) { | 1125 if (filterPainter.hasStartedFilterEffect()) { |
| 1127 // Apply the correct clipping (ie. overflow: hidden). | 1126 // Apply the correct clipping (ie. overflow: hidden). |
| 1128 // FIXME: It is incorrect to just clip to the damageRect here once multi
ple fragments are involved. | 1127 // FIXME: It is incorrect to just clip to the damageRect here once multi
ple fragments are involved. |
| 1129 ClipRect backgroundRect = fragment.backgroundRect; | |
| 1130 if (!deferredFiltersEnabled) | 1128 if (!deferredFiltersEnabled) |
| 1131 clipToRect(localPaintingInfo, transparencyLayerContext, backgroundRe
ct); | 1129 clipToRect(localPaintingInfo, transparencyLayerContext, backgroundRe
ct); |
| 1132 | 1130 |
| 1133 context = filterPainter.applyFilterEffect(); | 1131 context = filterPainter.applyFilterEffect(); |
| 1134 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect,
backgroundRect); | 1132 restoreClip(transparencyLayerContext, localPaintingInfo.paintDirtyRect,
backgroundRect); |
| 1135 } | 1133 } |
| 1136 | 1134 |
| 1137 // Make sure that we now use the original transparency context. | 1135 // Make sure that we now use the original transparency context. |
| 1138 ASSERT(transparencyLayerContext == context); | 1136 ASSERT(transparencyLayerContext == context); |
| 1139 | 1137 |
| 1140 if (shouldPaintContent && renderer()->hasMask()) | 1138 if (shouldPaintContent && renderer()->hasMask()) |
| 1141 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti
ngRootForRenderer); | 1139 paintMask(context, localPaintingInfo, paintingRootForRenderer, layerLoca
tion, backgroundRect); |
| 1142 | 1140 |
| 1143 // End our transparency layer | 1141 // End our transparency layer |
| 1144 if (haveTransparency && m_usedTransparency) { | 1142 if (haveTransparency && m_usedTransparency) { |
| 1145 context->endLayer(); | 1143 context->endLayer(); |
| 1146 context->restore(); | 1144 context->restore(); |
| 1147 m_usedTransparency = false; | 1145 m_usedTransparency = false; |
| 1148 } | 1146 } |
| 1149 } | 1147 } |
| 1150 | 1148 |
| 1151 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const
LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint&
translationOffset) | 1149 void RenderLayer::paintLayerByApplyingTransform(GraphicsContext* context, const
LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags, const LayoutPoint&
translationOffset) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1181 #if ENABLE(ASSERT) | 1179 #if ENABLE(ASSERT) |
| 1182 LayerListMutationDetector mutationChecker(m_stackingNode.get()); | 1180 LayerListMutationDetector mutationChecker(m_stackingNode.get()); |
| 1183 #endif | 1181 #endif |
| 1184 | 1182 |
| 1185 RenderLayerStackingNodeIterator iterator(*m_stackingNode, childrenToVisit); | 1183 RenderLayerStackingNodeIterator iterator(*m_stackingNode, childrenToVisit); |
| 1186 while (RenderLayerStackingNode* child = iterator.next()) { | 1184 while (RenderLayerStackingNode* child = iterator.next()) { |
| 1187 child->layer()->paintLayer(context, paintingInfo, paintFlags); | 1185 child->layer()->paintLayer(context, paintingInfo, paintFlags); |
| 1188 } | 1186 } |
| 1189 } | 1187 } |
| 1190 | 1188 |
| 1191 void RenderLayer::updatePaintingInfoForFragments(LayerFragments& fragments, cons
t LayerPaintingInfo& localPaintingInfo, | 1189 void RenderLayer::paintBackground(GraphicsContext* context, GraphicsContext* tra
nsparencyLayerContext, |
| 1192 bool shouldPaintContent, const LayoutPoint* offsetFromRoot) | 1190 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L
ayerPaintingInfo& localPaintingInfo, |
| 1191 RenderObject* paintingRootForRenderer, LayoutPoint& layerLocation, ClipRect&
layerBackgroundRect) |
| 1193 { | 1192 { |
| 1194 ASSERT(offsetFromRoot); | 1193 // Begin transparency layers lazily now that we know we have to paint someth
ing. |
| 1195 for (size_t i = 0; i < fragments.size(); ++i) { | 1194 if (haveTransparency) |
| 1196 LayerFragment& fragment = fragments.at(i); | 1195 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo.root
Layer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation); |
| 1197 LayoutPoint newOffsetFromRoot = *offsetFromRoot; | 1196 |
| 1198 fragment.shouldPaintContent = shouldPaintContent && intersectsDamageRect
(fragment.layerBounds, fragment.backgroundRect.rect(), localPaintingInfo.rootLay
er, &newOffsetFromRoot); | 1197 if (localPaintingInfo.clipToDirtyRect) { |
| 1198 // Paint our background first, before painting any child layers. |
| 1199 // Establish the clip used to paint our background. |
| 1200 clipToRect(localPaintingInfo, context, layerBackgroundRect, DoNotInclude
SelfForBorderRadius); // Background painting will handle clipping to self. |
| 1199 } | 1201 } |
| 1202 |
| 1203 // Paint the background. |
| 1204 // FIXME: Eventually we will collect the region from the fragment itself ins
tead of just from the paint info. |
| 1205 PaintInfo paintInfo(context, pixelSnappedIntRect(layerBackgroundRect.rect())
, PaintPhaseBlockBackground, paintingRootForRenderer, 0, localPaintingInfo.rootL
ayer->renderer()); |
| 1206 renderer()->paint(paintInfo, layerLocation); |
| 1207 |
| 1208 if (localPaintingInfo.clipToDirtyRect) |
| 1209 restoreClip(context, localPaintingInfo.paintDirtyRect, layerBackgroundRe
ct); |
| 1200 } | 1210 } |
| 1201 | 1211 |
| 1202 void RenderLayer::paintBackgroundForFragments(const LayerFragments& layerFragmen
ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext, | 1212 void RenderLayer::paintForeground(GraphicsContext* context, GraphicsContext* tra
nsparencyLayerContext, |
| 1203 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L
ayerPaintingInfo& localPaintingInfo, | 1213 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L
ayerPaintingInfo& localPaintingInfo, |
| 1204 RenderObject* paintingRootForRenderer) | 1214 RenderObject* paintingRootForRenderer, LayoutPoint& layerLocation, ClipRect&
layerForegroundRect) |
| 1205 { | 1215 { |
| 1206 for (size_t i = 0; i < layerFragments.size(); ++i) { | 1216 bool foregroundRectIsEmpty = layerForegroundRect.isEmpty(); |
| 1207 const LayerFragment& fragment = layerFragments.at(i); | |
| 1208 if (!fragment.shouldPaintContent) | |
| 1209 continue; | |
| 1210 | 1217 |
| 1211 // Begin transparency layers lazily now that we know we have to paint so
mething. | 1218 // Begin transparency if we have something to paint. |
| 1212 if (haveTransparency) | 1219 if (haveTransparency && !foregroundRectIsEmpty) |
| 1213 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo.
rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation); | 1220 beginTransparencyLayers(transparencyLayerContext, localPaintingInfo.root
Layer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation); |
| 1214 | 1221 |
| 1215 if (localPaintingInfo.clipToDirtyRect) { | 1222 // Optimize clipping for the single fragment case. |
| 1216 // Paint our background first, before painting any child layers. | 1223 bool shouldClip = localPaintingInfo.clipToDirtyRect && !foregroundRectIsEmpt
y; |
| 1217 // Establish the clip used to paint our background. | 1224 if (shouldClip) |
| 1218 clipToRect(localPaintingInfo, context, fragment.backgroundRect, DoNo
tIncludeSelfForBorderRadius); // Background painting will handle clipping to sel
f. | 1225 clipToRect(localPaintingInfo, context, layerForegroundRect); |
| 1219 } | |
| 1220 | 1226 |
| 1221 // Paint the background. | 1227 if (!foregroundRectIsEmpty) { |
| 1222 // FIXME: Eventually we will collect the region from the fragment itself
instead of just from the paint info. | 1228 // We have to loop through every fragment multiple times, since we have
to issue paint invalidations in each specific phase in order for |
| 1223 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect
.rect()), PaintPhaseBlockBackground, paintingRootForRenderer, 0, localPaintingIn
fo.rootLayer->renderer()); | 1229 // interleaving of the fragments to work properly. |
| 1224 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r
enderBoxLocation() + localPaintingInfo.subPixelAccumulation)); | 1230 // FIXME(sky): Do we still need this for anything now that we don't have
fragments? |
| 1231 paintForegroundWithPhase(PaintPhaseChildBlockBackgrounds, |
| 1232 context, localPaintingInfo, paintingRootForRenderer, |
| 1233 layerLocation, layerForegroundRect); |
| 1234 paintForegroundWithPhase(PaintPhaseForeground, |
| 1235 context, localPaintingInfo, paintingRootForRenderer, |
| 1236 layerLocation, layerForegroundRect); |
| 1237 paintForegroundWithPhase(PaintPhaseChildOutlines, |
| 1238 context, localPaintingInfo, paintingRootForRenderer, |
| 1239 layerLocation, layerForegroundRect); |
| 1240 } |
| 1225 | 1241 |
| 1226 if (localPaintingInfo.clipToDirtyRect) | 1242 if (shouldClip) |
| 1227 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back
groundRect); | 1243 restoreClip(context, localPaintingInfo.paintDirtyRect, layerForegroundRe
ct); |
| 1228 } | |
| 1229 } | 1244 } |
| 1230 | 1245 |
| 1231 void RenderLayer::paintForegroundForFragments(const LayerFragments& layerFragmen
ts, GraphicsContext* context, GraphicsContext* transparencyLayerContext, | 1246 void RenderLayer::paintForegroundWithPhase(PaintPhase phase, GraphicsContext* co
ntext, |
| 1232 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L
ayerPaintingInfo& localPaintingInfo, | 1247 const LayerPaintingInfo& localPaintingInfo, RenderObject* paintingRootForRen
derer, LayoutPoint& layerLocation, ClipRect& layerForegroundRect) |
| 1233 RenderObject* paintingRootForRenderer) | |
| 1234 { | 1248 { |
| 1235 // Begin transparency if we have something to paint. | 1249 PaintInfo paintInfo(context, pixelSnappedIntRect(layerForegroundRect.rect())
, phase, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer()); |
| 1236 if (haveTransparency) { | 1250 renderer()->paint(paintInfo, layerLocation); |
| 1237 for (size_t i = 0; i < layerFragments.size(); ++i) { | |
| 1238 const LayerFragment& fragment = layerFragments.at(i); | |
| 1239 if (fragment.shouldPaintContent && !fragment.foregroundRect.isEmpty(
)) { | |
| 1240 beginTransparencyLayers(transparencyLayerContext, localPaintingI
nfo.rootLayer, transparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulatio
n); | |
| 1241 break; | |
| 1242 } | |
| 1243 } | |
| 1244 } | |
| 1245 | |
| 1246 // Optimize clipping for the single fragment case. | |
| 1247 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size()
== 1 && layerFragments[0].shouldPaintContent && !layerFragments[0].foregroundRe
ct.isEmpty(); | |
| 1248 if (shouldClip) | |
| 1249 clipToRect(localPaintingInfo, context, layerFragments[0].foregroundRect)
; | |
| 1250 | |
| 1251 // We have to loop through every fragment multiple times, since we have to i
ssue paint invalidations in each specific phase in order for | |
| 1252 // interleaving of the fragments to work properly. | |
| 1253 paintForegroundForFragmentsWithPhase(PaintPhaseChildBlockBackgrounds, layerF
ragments, | |
| 1254 context, localPaintingInfo, paintingRootForRenderer); | |
| 1255 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragments, c
ontext, localPaintingInfo, paintingRootForRenderer); | |
| 1256 paintForegroundForFragmentsWithPhase(PaintPhaseChildOutlines, layerFragments
, context, localPaintingInfo, paintingRootForRenderer); | |
| 1257 | |
| 1258 if (shouldClip) | |
| 1259 restoreClip(context, localPaintingInfo.paintDirtyRect, layerFragments[0]
.foregroundRect); | |
| 1260 } | 1251 } |
| 1261 | 1252 |
| 1262 void RenderLayer::paintForegroundForFragmentsWithPhase(PaintPhase phase, const L
ayerFragments& layerFragments, GraphicsContext* context, | 1253 void RenderLayer::paintOutline(GraphicsContext* context, const LayerPaintingInfo
& localPaintingInfo, |
| 1263 const LayerPaintingInfo& localPaintingInfo, RenderObject* paintingRootForRen
derer) | 1254 RenderObject* paintingRootForRenderer, LayoutPoint& layerLocation, ClipRect&
layerOutlineRect) |
| 1264 { | 1255 { |
| 1265 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size()
> 1; | 1256 if (layerOutlineRect.isEmpty()) |
| 1257 return; |
| 1266 | 1258 |
| 1267 for (size_t i = 0; i < layerFragments.size(); ++i) { | 1259 PaintInfo paintInfo(context, pixelSnappedIntRect(layerOutlineRect.rect()), P
aintPhaseSelfOutline, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->r
enderer()); |
| 1268 const LayerFragment& fragment = layerFragments.at(i); | 1260 clipToRect(localPaintingInfo, context, layerOutlineRect, DoNotIncludeSelfFor
BorderRadius); |
| 1269 if (!fragment.shouldPaintContent || fragment.foregroundRect.isEmpty()) | 1261 renderer()->paint(paintInfo, layerLocation); |
| 1270 continue; | 1262 restoreClip(context, localPaintingInfo.paintDirtyRect, layerOutlineRect); |
| 1271 | |
| 1272 if (shouldClip) | |
| 1273 clipToRect(localPaintingInfo, context, fragment.foregroundRect); | |
| 1274 | |
| 1275 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.foregroundRect
.rect()), phase, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->render
er()); | |
| 1276 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r
enderBoxLocation() + localPaintingInfo.subPixelAccumulation)); | |
| 1277 | |
| 1278 if (shouldClip) | |
| 1279 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore
groundRect); | |
| 1280 } | |
| 1281 } | 1263 } |
| 1282 | 1264 |
| 1283 void RenderLayer::paintOutlineForFragments(const LayerFragments& layerFragments,
GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, | 1265 void RenderLayer::paintMask(GraphicsContext* context, const LayerPaintingInfo& l
ocalPaintingInfo, |
| 1284 RenderObject* paintingRootForRenderer) | 1266 RenderObject* paintingRootForRenderer, LayoutPoint& layerLocation, ClipRect&
layerBackgroundRect) |
| 1285 { | 1267 { |
| 1286 for (size_t i = 0; i < layerFragments.size(); ++i) { | 1268 if (localPaintingInfo.clipToDirtyRect) |
| 1287 const LayerFragment& fragment = layerFragments.at(i); | 1269 clipToRect(localPaintingInfo, context, layerBackgroundRect, DoNotInclude
SelfForBorderRadius); // Mask painting will handle clipping to self. |
| 1288 if (fragment.outlineRect.isEmpty()) | |
| 1289 continue; | |
| 1290 | 1270 |
| 1291 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.outlineRect.re
ct()), PaintPhaseSelfOutline, paintingRootForRenderer, 0, localPaintingInfo.root
Layer->renderer()); | 1271 // Paint the mask. |
| 1292 clipToRect(localPaintingInfo, context, fragment.outlineRect, DoNotInclud
eSelfForBorderRadius); | 1272 // FIXME: Eventually we will collect the region from the fragment itself ins
tead of just from the paint info. |
| 1293 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r
enderBoxLocation() + localPaintingInfo.subPixelAccumulation)); | 1273 PaintInfo paintInfo(context, pixelSnappedIntRect(layerBackgroundRect.rect())
, PaintPhaseMask, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->rende
rer()); |
| 1294 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.outlineR
ect); | 1274 renderer()->paint(paintInfo, layerLocation); |
| 1295 } | 1275 |
| 1276 if (localPaintingInfo.clipToDirtyRect) |
| 1277 restoreClip(context, localPaintingInfo.paintDirtyRect, layerBackgroundRe
ct); |
| 1296 } | 1278 } |
| 1297 | 1279 |
| 1298 void RenderLayer::paintMaskForFragments(const LayerFragments& layerFragments, Gr
aphicsContext* context, const LayerPaintingInfo& localPaintingInfo, | 1280 void RenderLayer::paintOverflowControls(GraphicsContext* context, const LayerPai
ntingInfo& localPaintingInfo, LayoutPoint& layerLocation, ClipRect& layerBackgro
undRect) |
| 1299 RenderObject* paintingRootForRenderer) | |
| 1300 { | 1281 { |
| 1301 for (size_t i = 0; i < layerFragments.size(); ++i) { | 1282 clipToRect(localPaintingInfo, context, layerBackgroundRect); |
| 1302 const LayerFragment& fragment = layerFragments.at(i); | 1283 if (RenderLayerScrollableArea* scrollableArea = this->scrollableArea()) |
| 1303 if (!fragment.shouldPaintContent) | 1284 scrollableArea->paintOverflowControls(context, roundedIntPoint(layerLoca
tion), pixelSnappedIntRect(layerBackgroundRect.rect()), true); |
| 1304 continue; | 1285 restoreClip(context, localPaintingInfo.paintDirtyRect, layerBackgroundRect); |
| 1305 | |
| 1306 if (localPaintingInfo.clipToDirtyRect) | |
| 1307 clipToRect(localPaintingInfo, context, fragment.backgroundRect, DoNo
tIncludeSelfForBorderRadius); // Mask painting will handle clipping to self. | |
| 1308 | |
| 1309 // Paint the mask. | |
| 1310 // FIXME: Eventually we will collect the region from the fragment itself
instead of just from the paint info. | |
| 1311 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect
.rect()), PaintPhaseMask, paintingRootForRenderer, 0, localPaintingInfo.rootLaye
r->renderer()); | |
| 1312 renderer()->paint(paintInfo, toPoint(fragment.layerBounds.location() - r
enderBoxLocation() + localPaintingInfo.subPixelAccumulation)); | |
| 1313 | |
| 1314 if (localPaintingInfo.clipToDirtyRect) | |
| 1315 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back
groundRect); | |
| 1316 } | |
| 1317 } | |
| 1318 | |
| 1319 void RenderLayer::paintOverflowControlsForFragments(const LayerFragments& layerF
ragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo) | |
| 1320 { | |
| 1321 for (size_t i = 0; i < layerFragments.size(); ++i) { | |
| 1322 const LayerFragment& fragment = layerFragments.at(i); | |
| 1323 clipToRect(localPaintingInfo, context, fragment.backgroundRect); | |
| 1324 if (RenderLayerScrollableArea* scrollableArea = this->scrollableArea()) | |
| 1325 scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoi
nt(fragment.layerBounds.location() - renderBoxLocation() + localPaintingInfo.sub
PixelAccumulation)), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); | |
| 1326 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgrou
ndRect); | |
| 1327 } | |
| 1328 } | 1286 } |
| 1329 | 1287 |
| 1330 static inline LayoutRect frameVisibleRect(RenderObject* renderer) | 1288 static inline LayoutRect frameVisibleRect(RenderObject* renderer) |
| 1331 { | 1289 { |
| 1332 FrameView* frameView = renderer->document().view(); | 1290 FrameView* frameView = renderer->document().view(); |
| 1333 if (!frameView) | 1291 if (!frameView) |
| 1334 return LayoutRect(); | 1292 return LayoutRect(); |
| 1335 | 1293 |
| 1336 return frameView->visibleContentRect(); | 1294 return frameView->visibleContentRect(); |
| 1337 } | 1295 } |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2106 } | 2064 } |
| 2107 } | 2065 } |
| 2108 | 2066 |
| 2109 void showLayerTree(const blink::RenderObject* renderer) | 2067 void showLayerTree(const blink::RenderObject* renderer) |
| 2110 { | 2068 { |
| 2111 if (!renderer) | 2069 if (!renderer) |
| 2112 return; | 2070 return; |
| 2113 showLayerTree(renderer->enclosingLayer()); | 2071 showLayerTree(renderer->enclosingLayer()); |
| 2114 } | 2072 } |
| 2115 #endif | 2073 #endif |
| OLD | NEW |