| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/LayerPainter.h" | 6 #include "core/paint/LayerPainter.h" |
| 7 | 7 |
| 8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
| 9 #include "core/page/Page.h" | 9 #include "core/page/Page.h" |
| 10 #include "core/rendering/ClipPathOperation.h" | 10 #include "core/rendering/ClipPathOperation.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 246 } |
| 247 | 247 |
| 248 // Blending operations must be performed only with the nearest ancestor stac
king context. | 248 // Blending operations must be performed only with the nearest ancestor stac
king context. |
| 249 // Note that there is no need to create a transparency layer if we're painti
ng the root. | 249 // Note that there is no need to create a transparency layer if we're painti
ng the root. |
| 250 bool createTransparencyLayerForBlendMode = !m_renderLayer.renderer()->isDocu
mentElement() && m_renderLayer.stackingNode()->isStackingContext() && m_renderLa
yer.hasDescendantWithBlendMode(); | 250 bool createTransparencyLayerForBlendMode = !m_renderLayer.renderer()->isDocu
mentElement() && m_renderLayer.stackingNode()->isStackingContext() && m_renderLa
yer.hasDescendantWithBlendMode(); |
| 251 | 251 |
| 252 if (createTransparencyLayerForBlendMode) | 252 if (createTransparencyLayerForBlendMode) |
| 253 beginTransparencyLayers(context, paintingInfo.rootLayer, paintingInfo.pa
intDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior); | 253 beginTransparencyLayers(context, paintingInfo.rootLayer, paintingInfo.pa
intDirtyRect, paintingInfo.subPixelAccumulation, paintingInfo.paintBehavior); |
| 254 | 254 |
| 255 LayerPaintingInfo localPaintingInfo(paintingInfo); | 255 LayerPaintingInfo localPaintingInfo(paintingInfo); |
| 256 FilterEffectRendererHelper filterPainter(m_renderLayer.filterRenderer() && m
_renderLayer.paintsWithFilters()); | 256 bool haveFilterEffect = m_renderLayer.filterRenderer() && m_renderLayer.pain
tsWithFilters(); |
| 257 | 257 |
| 258 LayerFragments layerFragments; | 258 LayerFragments layerFragments; |
| 259 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars)
{ | 259 if (shouldPaintContent || shouldPaintOutline || isPaintingOverlayScrollbars)
{ |
| 260 // Collect the fragments. This will compute the clip rectangles and pain
t offsets for each layer fragment, as well as whether or not the content of each | 260 // Collect the fragments. This will compute the clip rectangles and pain
t offsets for each layer fragment, as well as whether or not the content of each |
| 261 // fragment should paint. | 261 // fragment should paint. |
| 262 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.rootLay
er, localPaintingInfo.paintDirtyRect, | 262 m_renderLayer.collectFragments(layerFragments, localPaintingInfo.rootLay
er, localPaintingInfo.paintDirtyRect, |
| 263 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Pai
ntingClipRects, IgnoreOverlayScrollbarSize, | 263 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Pai
ntingClipRects, IgnoreOverlayScrollbarSize, |
| 264 shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()), &of
fsetFromRoot, localPaintingInfo.subPixelAccumulation); | 264 shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()), &of
fsetFromRoot, localPaintingInfo.subPixelAccumulation); |
| 265 updatePaintingInfoForFragments(layerFragments, localPaintingInfo, paintF
lags, shouldPaintContent, &offsetFromRoot); | 265 updatePaintingInfoForFragments(layerFragments, localPaintingInfo, paintF
lags, shouldPaintContent, &offsetFromRoot); |
| 266 } | 266 } |
| 267 | 267 |
| 268 if (filterPainter.haveFilterEffect()) { | 268 if (haveFilterEffect) { |
| 269 ASSERT(m_renderLayer.filterInfo()); | 269 ASSERT(m_renderLayer.filterInfo()); |
| 270 | 270 |
| 271 if (!rootRelativeBoundsComputed) | 271 if (!rootRelativeBoundsComputed) |
| 272 rootRelativeBounds = m_renderLayer.physicalBoundingBoxIncludingRefle
ctionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); | 272 rootRelativeBounds = m_renderLayer.physicalBoundingBoxIncludingRefle
ctionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); |
| 273 | 273 |
| 274 if (filterPainter.prepareFilterEffect(&m_renderLayer, rootRelativeBounds
, paintingInfo.paintDirtyRect)) { | 274 // Do transparency and clipping before starting filter processing. |
| 275 | 275 if (haveTransparency) { |
| 276 // Do transparency and clipping before starting filter processing. | 276 // If we have a filter and transparency, we have to eagerly start a
transparency layer here, rather than risk a child layer lazily starts one after
filter processing. |
| 277 if (haveTransparency) { | 277 beginTransparencyLayers(context, localPaintingInfo.rootLayer, painti
ngInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, localPaintingInfo.pain
tBehavior); |
| 278 // If we have a filter and transparency, we have to eagerly star
t a transparency layer here, rather than risk a child layer lazily starts one af
ter filter processing. | 278 } |
| 279 beginTransparencyLayers(context, localPaintingInfo.rootLayer, pa
intingInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, localPaintingInfo.
paintBehavior); | 279 // We'll handle clipping to the dirty rect before filter rasterization. |
| 280 } | 280 // Filter processing will automatically expand the clip rect and the off
screen to accommodate any filter outsets. |
| 281 // We'll handle clipping to the dirty rect before filter rasterizati
on. | 281 // FIXME: It is incorrect to just clip to the damageRect here once multi
ple fragments are involved. |
| 282 // Filter processing will automatically expand the clip rect and the
offscreen to accommodate any filter outsets. | 282 ClipRect backgroundRect = layerFragments.isEmpty() ? ClipRect() : layerF
ragments[0].backgroundRect; |
| 283 // FIXME: It is incorrect to just clip to the damageRect here once m
ultiple fragments are involved. | 283 clipToRect(localPaintingInfo, context, backgroundRect, paintFlags); |
| 284 ClipRect backgroundRect = layerFragments.isEmpty() ? ClipRect() : la
yerFragments[0].backgroundRect; | 284 // Subsequent code should not clip to the dirty rect, since we've alread
y |
| 285 clipToRect(localPaintingInfo, context, backgroundRect, paintFlags); | 285 // done it above, and doing it later will defeat the outsets. |
| 286 // Subsequent code should not clip to the dirty rect, since we've al
ready | 286 localPaintingInfo.clipToDirtyRect = false; |
| 287 // done it above, and doing it later will defeat the outsets. | 287 haveFilterEffect = m_renderLayer.filterRenderer()->beginFilterEffect(con
text, rootRelativeBounds); |
| 288 localPaintingInfo.clipToDirtyRect = false; | 288 if (!haveFilterEffect) { |
| 289 filterPainter.beginFilterEffect(context); | 289 // If the the filter failed to start, undo the clip immediately |
| 290 | 290 restoreClip(context, localPaintingInfo.paintDirtyRect, backgroundRec
t); |
| 291 if (!filterPainter.haveFilterEffect()) { | |
| 292 // If the the filter failed to start, undo the clip immediately | |
| 293 restoreClip(context, localPaintingInfo.paintDirtyRect, backgroun
dRect); | |
| 294 } | |
| 295 | |
| 296 } | 291 } |
| 297 } | 292 } |
| 298 | 293 |
| 299 // If this layer's renderer is a child of the paintingRoot, we render uncond
itionally, which | 294 // If this layer's renderer is a child of the paintingRoot, we render uncond
itionally, which |
| 300 // is done by passing a nil paintingRoot down to our renderer (as if no pain
tingRoot was ever set). | 295 // is done by passing a nil paintingRoot down to our renderer (as if no pain
tingRoot was ever set). |
| 301 // Else, our renderer tree may or may not contain the painting root, so we p
ass that root along | 296 // Else, our renderer tree may or may not contain the painting root, so we p
ass that root along |
| 302 // so it will be tested against as we descend through the renderers. | 297 // so it will be tested against as we descend through the renderers. |
| 303 RenderObject* paintingRootForRenderer = 0; | 298 RenderObject* paintingRootForRenderer = 0; |
| 304 if (localPaintingInfo.paintingRoot && !m_renderLayer.renderer()->isDescendan
tOf(localPaintingInfo.paintingRoot)) | 299 if (localPaintingInfo.paintingRoot && !m_renderLayer.renderer()->isDescendan
tOf(localPaintingInfo.paintingRoot)) |
| 305 paintingRootForRenderer = localPaintingInfo.paintingRoot; | 300 paintingRootForRenderer = localPaintingInfo.paintingRoot; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 336 | 331 |
| 337 if (shouldPaintOutline) | 332 if (shouldPaintOutline) |
| 338 paintOutlineForFragments(layerFragments, context, localPaintingInfo, pai
ntBehavior, paintingRootForRenderer, paintFlags); | 333 paintOutlineForFragments(layerFragments, context, localPaintingInfo, pai
ntBehavior, paintingRootForRenderer, paintFlags); |
| 339 | 334 |
| 340 if (shouldPaintNormalFlowAndPosZOrderLists) | 335 if (shouldPaintNormalFlowAndPosZOrderLists) |
| 341 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, pain
tingInfo, paintFlags); | 336 paintChildren(NormalFlowChildren | PositiveZOrderChildren, context, pain
tingInfo, paintFlags); |
| 342 | 337 |
| 343 if (shouldPaintOverlayScrollbars) | 338 if (shouldPaintOverlayScrollbars) |
| 344 paintOverflowControlsForFragments(layerFragments, context, localPainting
Info, paintFlags); | 339 paintOverflowControlsForFragments(layerFragments, context, localPainting
Info, paintFlags); |
| 345 | 340 |
| 346 if (filterPainter.haveFilterEffect()) { | 341 if (haveFilterEffect) { |
| 347 // Apply the correct clipping (ie. overflow: hidden). | 342 // Apply the correct clipping (ie. overflow: hidden). |
| 348 // FIXME: It is incorrect to just clip to the damageRect here once multi
ple fragments are involved. | 343 // FIXME: It is incorrect to just clip to the damageRect here once multi
ple fragments are involved. |
| 349 ClipRect backgroundRect = layerFragments.isEmpty() ? ClipRect() : layerF
ragments[0].backgroundRect; | 344 ClipRect backgroundRect = layerFragments.isEmpty() ? ClipRect() : layerF
ragments[0].backgroundRect; |
| 350 filterPainter.endFilterEffect(context); | 345 m_renderLayer.filterRenderer()->endFilterEffect(context); |
| 351 restoreClip(context, localPaintingInfo.paintDirtyRect, backgroundRect); | 346 restoreClip(context, localPaintingInfo.paintDirtyRect, backgroundRect); |
| 352 } | 347 } |
| 353 | 348 |
| 354 if (shouldPaintMask) | 349 if (shouldPaintMask) |
| 355 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti
ngRootForRenderer, paintFlags); | 350 paintMaskForFragments(layerFragments, context, localPaintingInfo, painti
ngRootForRenderer, paintFlags); |
| 356 | 351 |
| 357 if (shouldPaintClippingMask) { | 352 if (shouldPaintClippingMask) { |
| 358 // Paint the border radius mask for the fragments. | 353 // Paint the border radius mask for the fragments. |
| 359 paintChildClippingMaskForFragments(layerFragments, context, localPaintin
gInfo, paintingRootForRenderer, paintFlags); | 354 paintChildClippingMaskForFragments(layerFragments, context, localPaintin
gInfo, paintingRootForRenderer, paintFlags); |
| 360 } | 355 } |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 clipRect.intersect(parentClipRect); | 841 clipRect.intersect(parentClipRect); |
| 847 } | 842 } |
| 848 | 843 |
| 849 LayerPainter(*m_renderLayer.parent()).clipToRect(paintingInfo, context,
clipRect, paintFlags); | 844 LayerPainter(*m_renderLayer.parent()).clipToRect(paintingInfo, context,
clipRect, paintFlags); |
| 850 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen
t.paginationOffset); | 845 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen
t.paginationOffset); |
| 851 LayerPainter(*m_renderLayer.parent()).restoreClip(context, paintingInfo.
paintDirtyRect, clipRect); | 846 LayerPainter(*m_renderLayer.parent()).restoreClip(context, paintingInfo.
paintDirtyRect, clipRect); |
| 852 } | 847 } |
| 853 } | 848 } |
| 854 | 849 |
| 855 } // namespace blink | 850 } // namespace blink |
| OLD | NEW |