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