Chromium Code Reviews| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 // Make sure the parent's clip rects have been calculated. | 91 // Make sure the parent's clip rects have been calculated. |
| 92 ClipRect clipRect = paintingInfo.paintDirtyRect; | 92 ClipRect clipRect = paintingInfo.paintDirtyRect; |
| 93 if (m_renderLayer.parent()) { | 93 if (m_renderLayer.parent()) { |
| 94 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlag s & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, Ignore OverlayScrollbarSize); | 94 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlag s & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, Ignore OverlayScrollbarSize); |
| 95 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == IgnoreOverflowClip) | 95 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == IgnoreOverflowClip) |
| 96 clipRectsContext.setIgnoreOverflowClip(); | 96 clipRectsContext.setIgnoreOverflowClip(); |
| 97 clipRect = m_renderLayer.clipper().backgroundClipRect(clipRectsConte xt); | 97 clipRect = m_renderLayer.clipper().backgroundClipRect(clipRectsConte xt); |
| 98 clipRect.intersect(paintingInfo.paintDirtyRect); | 98 clipRect.intersect(paintingInfo.paintDirtyRect); |
| 99 | 99 |
| 100 // Push the parent coordinate space's clip. | 100 // Push the parent coordinate space's clip. |
| 101 LayerPainter(*m_renderLayer.parent()).clipToRect(paintingInfo, conte xt, clipRect, paintFlags); | 101 LayerPainter(*m_renderLayer.parent()).clipToRect(paintingInfo, conte xt, clipRect, paintFlags, ClipDisplayItem::LayerParent); |
| 102 } | 102 } |
| 103 | 103 |
| 104 paintLayerByApplyingTransform(context, paintingInfo, paintFlags); | 104 paintLayerByApplyingTransform(context, paintingInfo, paintFlags); |
| 105 | 105 |
| 106 // Restore the clip. | 106 // Restore the clip. |
| 107 if (m_renderLayer.parent()) | 107 if (m_renderLayer.parent()) |
| 108 LayerPainter(*m_renderLayer.parent()).restoreClip(context, paintingI nfo.paintDirtyRect, clipRect); | 108 LayerPainter(*m_renderLayer.parent()).restoreClip(context, paintingI nfo.paintDirtyRect, clipRect); |
| 109 | 109 |
| 110 return; | 110 return; |
| 111 } | 111 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 // Do transparency and clipping before starting filter processing. | 274 // Do transparency and clipping before starting filter processing. |
| 275 if (haveTransparency) { | 275 if (haveTransparency) { |
| 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. | 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 beginTransparencyLayers(context, localPaintingInfo.rootLayer, painti ngInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, localPaintingInfo.pain tBehavior); | 277 beginTransparencyLayers(context, localPaintingInfo.rootLayer, painti ngInfo.paintDirtyRect, paintingInfo.subPixelAccumulation, localPaintingInfo.pain tBehavior); |
| 278 } | 278 } |
| 279 | |
| 279 // We'll handle clipping to the dirty rect before filter rasterization. | 280 // We'll handle clipping to the dirty rect before filter rasterization. |
| 280 // Filter processing will automatically expand the clip rect and the off screen to accommodate any filter outsets. | 281 // Filter processing will automatically expand the clip rect and the off screen to accommodate any filter outsets. |
| 281 // FIXME: It is incorrect to just clip to the damageRect here once multi ple fragments are involved. | 282 // FIXME: It is incorrect to just clip to the damageRect here once multi ple fragments are involved. |
| 282 ClipRect backgroundRect = layerFragments.isEmpty() ? ClipRect() : layerF ragments[0].backgroundRect; | 283 ClipRect backgroundRect = layerFragments.isEmpty() ? ClipRect() : layerF ragments[0].backgroundRect; |
| 283 clipToRect(localPaintingInfo, context, backgroundRect, paintFlags); | 284 clipToRect(localPaintingInfo, context, backgroundRect, paintFlags, ClipD isplayItem::LayerFilter); |
| 284 // Subsequent code should not clip to the dirty rect, since we've alread y | 285 // Subsequent code should not clip to the dirty rect, since we've alread y |
| 285 // done it above, and doing it later will defeat the outsets. | 286 // done it above, and doing it later will defeat the outsets. |
| 286 localPaintingInfo.clipToDirtyRect = false; | 287 localPaintingInfo.clipToDirtyRect = false; |
| 287 haveFilterEffect = m_renderLayer.filterRenderer()->beginFilterEffect(con text, rootRelativeBounds); | 288 haveFilterEffect = m_renderLayer.filterRenderer()->beginFilterEffect(con text, rootRelativeBounds); |
| 288 if (!haveFilterEffect) { | 289 if (!haveFilterEffect) { |
| 289 // If the the filter failed to start, undo the clip immediately | 290 // If the the filter failed to start, undo the clip immediately |
| 290 restoreClip(context, localPaintingInfo.paintDirtyRect, backgroundRec t); | 291 restoreClip(context, localPaintingInfo.paintDirtyRect, backgroundRec t); |
| 291 } | 292 } |
| 292 } | 293 } |
| 293 | 294 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 RenderView* view = startLayer->renderer()->view(); | 375 RenderView* view = startLayer->renderer()->view(); |
| 375 for (RenderBlock* currentBlock = startLayer->renderer()->containingBlock(); currentBlock && currentBlock != view; currentBlock = currentBlock->containingBlo ck()) { | 376 for (RenderBlock* currentBlock = startLayer->renderer()->containingBlock(); currentBlock && currentBlock != view; currentBlock = currentBlock->containingBlo ck()) { |
| 376 if (currentBlock->layer() == endLayer) | 377 if (currentBlock->layer() == endLayer) |
| 377 return true; | 378 return true; |
| 378 } | 379 } |
| 379 | 380 |
| 380 return false; | 381 return false; |
| 381 } | 382 } |
| 382 | 383 |
| 383 void LayerPainter::clipToRect(const LayerPaintingInfo& localPaintingInfo, Graphi csContext* context, const ClipRect& clipRect, | 384 void LayerPainter::clipToRect(const LayerPaintingInfo& localPaintingInfo, Graphi csContext* context, const ClipRect& clipRect, |
| 384 PaintLayerFlags paintFlags, BorderRadiusClippingRule rule) | 385 PaintLayerFlags paintFlags, ClipDisplayItem::ClipType clipType, BorderRadius ClippingRule rule) |
| 385 { | 386 { |
| 386 if (clipRect.rect() == localPaintingInfo.paintDirtyRect && !clipRect.hasRadi us()) | 387 if (clipRect.rect() == localPaintingInfo.paintDirtyRect && !clipRect.hasRadi us()) |
| 387 return; | 388 return; |
| 388 context->save(); | 389 |
| 389 context->clip(pixelSnappedIntRect(clipRect.rect())); | 390 StartClipRecorder startClipRecorder(&m_renderLayer, context, clipType, clipR ect); |
|
pdr.
2014/10/16 17:38:12
This may be cleaner if it is just a static functio
| |
| 390 | 391 |
| 391 if (!clipRect.hasRadius()) | 392 if (!clipRect.hasRadius()) |
| 392 return; | 393 return; |
| 393 | 394 |
| 394 // If the clip rect has been tainted by a border radius, then we have to wal k up our layer chain applying the clips from | 395 // If the clip rect has been tainted by a border radius, then we have to wal k up our layer chain applying the clips from |
| 395 // any layers with overflow. The condition for being able to apply these cli ps is that the overflow object be in our | 396 // any layers with overflow. The condition for being able to apply these cli ps is that the overflow object be in our |
| 396 // containing block chain so we check that also. | 397 // containing block chain so we check that also. |
| 397 for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? &m_renderLaye r : m_renderLayer.parent(); layer; layer = layer->parent()) { | 398 for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? &m_renderLaye r : m_renderLayer.parent(); layer; layer = layer->parent()) { |
| 398 // Composited scrolling layers handle border-radius clip in the composit or via a mask layer. We do not | 399 // Composited scrolling layers handle border-radius clip in the composit or via a mask layer. We do not |
| 399 // want to apply a border-radius clip to the layer contents itself, beca use that would require re-rastering | 400 // want to apply a border-radius clip to the layer contents itself, beca use that would require re-rastering |
| 400 // every frame to update the clip. We only want to make sure that the ma sk layer is properly clipped so | 401 // every frame to update the clip. We only want to make sure that the ma sk layer is properly clipped so |
| 401 // that it can in turn clip the scrolled contents in the compositor. | 402 // that it can in turn clip the scrolled contents in the compositor. |
| 402 if (layer->needsCompositedScrolling() && !(paintFlags & PaintLayerPainti ngChildClippingMaskPhase)) | 403 if (layer->needsCompositedScrolling() && !(paintFlags & PaintLayerPainti ngChildClippingMaskPhase)) |
| 403 break; | 404 break; |
| 404 | 405 |
| 405 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()-> hasBorderRadius() && inContainingBlockChain(&m_renderLayer, layer)) { | 406 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()-> hasBorderRadius() && inContainingBlockChain(&m_renderLayer, layer)) { |
| 406 LayoutPoint delta; | 407 LayoutPoint delta; |
| 407 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); | 408 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); |
| 408 context->clipRoundedRect(layer->renderer()->style()->getRoundedInner BorderFor(LayoutRect(delta, layer->size()))); | 409 startClipRecorder.addRoundedRectClip(layer->renderer()->style()->get RoundedInnerBorderFor(LayoutRect(delta, layer->size()))); |
| 409 } | 410 } |
| 410 | 411 |
| 411 if (layer == localPaintingInfo.rootLayer) | 412 if (layer == localPaintingInfo.rootLayer) |
| 412 break; | 413 break; |
| 413 } | 414 } |
| 414 } | 415 } |
| 415 | 416 |
| 416 void LayerPainter::restoreClip(GraphicsContext* context, const LayoutRect& paint DirtyRect, const ClipRect& clipRect) | 417 void LayerPainter::restoreClip(GraphicsContext* context, const LayoutRect& paint DirtyRect, const ClipRect& clipRect) |
| 417 { | 418 { |
| 418 if (clipRect.rect() == paintDirtyRect && !clipRect.hasRadius()) | 419 if (clipRect.rect() == paintDirtyRect && !clipRect.hasRadius()) |
| 419 return; | 420 return; |
| 420 context->restore(); | 421 EndClipRecorder endClipRecorder(&m_renderLayer, context); |
| 421 } | 422 } |
| 422 | 423 |
| 423 void LayerPainter::updatePaintingInfoForFragments(LayerFragments& fragments, con st LayerPaintingInfo& localPaintingInfo, PaintLayerFlags localPaintFlags, | 424 void LayerPainter::updatePaintingInfoForFragments(LayerFragments& fragments, con st LayerPaintingInfo& localPaintingInfo, PaintLayerFlags localPaintFlags, |
| 424 bool shouldPaintContent, const LayoutPoint* offsetFromRoot) | 425 bool shouldPaintContent, const LayoutPoint* offsetFromRoot) |
| 425 { | 426 { |
| 426 ASSERT(offsetFromRoot); | 427 ASSERT(offsetFromRoot); |
| 427 for (size_t i = 0; i < fragments.size(); ++i) { | 428 for (size_t i = 0; i < fragments.size(); ++i) { |
| 428 LayerFragment& fragment = fragments.at(i); | 429 LayerFragment& fragment = fragments.at(i); |
| 429 fragment.shouldPaintContent = shouldPaintContent; | 430 fragment.shouldPaintContent = shouldPaintContent; |
| 430 if (&m_renderLayer != localPaintingInfo.rootLayer || !(localPaintFlags & PaintLayerPaintingOverflowContents)) { | 431 if (&m_renderLayer != localPaintingInfo.rootLayer || !(localPaintFlags & PaintLayerPaintingOverflowContents)) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 // of the renderer already includes any sub-pixel offset. | 507 // of the renderer already includes any sub-pixel offset. |
| 507 if (compositingState == PaintsIntoOwnBacking) | 508 if (compositingState == PaintsIntoOwnBacking) |
| 508 return LayoutSize(); | 509 return LayoutSize(); |
| 509 return subPixelAccumulation; | 510 return subPixelAccumulation; |
| 510 } | 511 } |
| 511 | 512 |
| 512 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) | 513 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) |
| 513 { | 514 { |
| 514 for (size_t i = 0; i < layerFragments.size(); ++i) { | 515 for (size_t i = 0; i < layerFragments.size(); ++i) { |
| 515 const LayerFragment& fragment = layerFragments.at(i); | 516 const LayerFragment& fragment = layerFragments.at(i); |
| 516 clipToRect(localPaintingInfo, context, fragment.backgroundRect, paintFla gs); | 517 |
| 518 clipToRect(localPaintingInfo, context, fragment.backgroundRect, paintFla gs, ClipDisplayItem::LayerOverflowControls); | |
| 517 if (RenderLayerScrollableArea* scrollableArea = m_renderLayer.scrollable Area()) | 519 if (RenderLayerScrollableArea* scrollableArea = m_renderLayer.scrollable Area()) |
| 518 scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoi nt(fragment.layerBounds.location() - m_renderLayer.renderBoxLocation() + subPixe lAccumulationIfNeeded(localPaintingInfo.subPixelAccumulation, m_renderLayer.comp ositingState()))), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); | 520 scrollableArea->paintOverflowControls(context, roundedIntPoint(toPoi nt(fragment.layerBounds.location() - m_renderLayer.renderBoxLocation() + subPixe lAccumulationIfNeeded(localPaintingInfo.subPixelAccumulation, m_renderLayer.comp ositingState()))), pixelSnappedIntRect(fragment.backgroundRect.rect()), true); |
| 519 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgrou ndRect); | 521 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.backgrou ndRect); |
| 520 } | 522 } |
| 521 } | 523 } |
| 522 | 524 |
| 523 static bool checkContainingBlockChainForPagination(RenderLayerModelObject* rende rer, RenderBox* ancestorColumnsRenderer) | 525 static bool checkContainingBlockChainForPagination(RenderLayerModelObject* rende rer, RenderBox* ancestorColumnsRenderer) |
| 524 { | 526 { |
| 525 RenderView* view = renderer->view(); | 527 RenderView* view = renderer->view(); |
| 526 RenderLayerModelObject* prevBlock = renderer; | 528 RenderLayerModelObject* prevBlock = renderer; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 if (!fragment.shouldPaintContent) | 671 if (!fragment.shouldPaintContent) |
| 670 continue; | 672 continue; |
| 671 | 673 |
| 672 // Begin transparency layers lazily now that we know we have to paint so mething. | 674 // Begin transparency layers lazily now that we know we have to paint so mething. |
| 673 if (haveTransparency || m_renderLayer.paintsWithBlendMode()) | 675 if (haveTransparency || m_renderLayer.paintsWithBlendMode()) |
| 674 beginTransparencyLayers(context, localPaintingInfo.rootLayer, transp arencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation, localPaintingInfo. paintBehavior); | 676 beginTransparencyLayers(context, localPaintingInfo.rootLayer, transp arencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation, localPaintingInfo. paintBehavior); |
| 675 | 677 |
| 676 if (localPaintingInfo.clipToDirtyRect) { | 678 if (localPaintingInfo.clipToDirtyRect) { |
| 677 // Paint our background first, before painting any child layers. | 679 // Paint our background first, before painting any child layers. |
| 678 // Establish the clip used to paint our background. | 680 // Establish the clip used to paint our background. |
| 679 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, DoNotIncludeSelfForBorderRadius); // Background painting will handle cli pping to self. | 681 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, ClipDisplayItem::LayerBackground, DoNotIncludeSelfForBorderRadius); // B ackground painting will handle clipping to self. |
| 680 } | 682 } |
| 681 | 683 |
| 682 // Paint the background. | 684 // Paint the background. |
| 683 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info. | 685 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info. |
| 684 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseBlockBackground, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer()); | 686 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseBlockBackground, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer()); |
| 685 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(lo calPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))); | 687 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(lo calPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))); |
| 686 | 688 |
| 687 if (localPaintingInfo.clipToDirtyRect) | 689 if (localPaintingInfo.clipToDirtyRect) |
| 688 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect); | 690 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect); |
| 689 } | 691 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 700 if (fragment.shouldPaintContent && !fragment.foregroundRect.isEmpty( )) { | 702 if (fragment.shouldPaintContent && !fragment.foregroundRect.isEmpty( )) { |
| 701 beginTransparencyLayers(context, localPaintingInfo.rootLayer, tr ansparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation, localPaintingI nfo.paintBehavior); | 703 beginTransparencyLayers(context, localPaintingInfo.rootLayer, tr ansparencyPaintDirtyRect, localPaintingInfo.subPixelAccumulation, localPaintingI nfo.paintBehavior); |
| 702 break; | 704 break; |
| 703 } | 705 } |
| 704 } | 706 } |
| 705 } | 707 } |
| 706 | 708 |
| 707 // Optimize clipping for the single fragment case. | 709 // Optimize clipping for the single fragment case. |
| 708 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && layerFragments[0].shouldPaintContent && !layerFragments[0].foregroundRe ct.isEmpty(); | 710 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && layerFragments[0].shouldPaintContent && !layerFragments[0].foregroundRe ct.isEmpty(); |
| 709 if (shouldClip) | 711 if (shouldClip) |
| 710 clipToRect(localPaintingInfo, context, layerFragments[0].foregroundRect, paintFlags); | 712 clipToRect(localPaintingInfo, context, layerFragments[0].foregroundRect, paintFlags, ClipDisplayItem::LayerForeground); |
| 711 | 713 |
| 712 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for | 714 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for |
| 713 // interleaving of the fragments to work properly. | 715 // interleaving of the fragments to work properly. |
| 714 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseChildBlockBackgrounds, layerFragments, | 716 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseChildBlockBackgrounds, layerFragments, |
| 715 context, localPaintingInfo, paintBehavior, paintingRootForRenderer, pain tFlags); | 717 context, localPaintingInfo, paintBehavior, paintingRootForRenderer, pain tFlags); |
| 716 | 718 |
| 717 if (!selectionOnly) { | 719 if (!selectionOnly) { |
| 718 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags); | 720 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags); |
| 719 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlag s); | 721 paintForegroundForFragmentsWithPhase(PaintPhaseForeground, layerFragment s, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlag s); |
| 720 paintForegroundForFragmentsWithPhase(PaintPhaseChildOutlines, layerFragm ents, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintF lags); | 722 paintForegroundForFragmentsWithPhase(PaintPhaseChildOutlines, layerFragm ents, context, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintF lags); |
| 721 } | 723 } |
| 722 | 724 |
| 723 if (shouldClip) | 725 if (shouldClip) |
| 724 restoreClip(context, localPaintingInfo.paintDirtyRect, layerFragments[0] .foregroundRect); | 726 restoreClip(context, localPaintingInfo.paintDirtyRect, layerFragments[0] .foregroundRect); |
| 725 } | 727 } |
| 726 | 728 |
| 727 void LayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, const LayerFragments& layerFragments, GraphicsContext* context, | 729 void LayerPainter::paintForegroundForFragmentsWithPhase(PaintPhase phase, const LayerFragments& layerFragments, GraphicsContext* context, |
| 728 const LayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, Ren derObject* paintingRootForRenderer, PaintLayerFlags paintFlags) | 730 const LayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, Ren derObject* paintingRootForRenderer, PaintLayerFlags paintFlags) |
| 729 { | 731 { |
| 730 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() > 1; | 732 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() > 1; |
| 731 | 733 |
| 732 for (size_t i = 0; i < layerFragments.size(); ++i) { | 734 for (size_t i = 0; i < layerFragments.size(); ++i) { |
| 733 const LayerFragment& fragment = layerFragments.at(i); | 735 const LayerFragment& fragment = layerFragments.at(i); |
| 734 if (!fragment.shouldPaintContent || fragment.foregroundRect.isEmpty()) | 736 if (!fragment.shouldPaintContent || fragment.foregroundRect.isEmpty()) |
| 735 continue; | 737 continue; |
| 736 | 738 |
| 737 if (shouldClip) | 739 if (shouldClip) { |
| 738 clipToRect(localPaintingInfo, context, fragment.foregroundRect, pain tFlags); | 740 // Note: this method only clips when there is more than one fragment . |
| 741 ClipDisplayItem::ClipType clipType = (ClipDisplayItem::ClipType)0; | |
| 742 switch (phase) { | |
| 743 case PaintPhaseFloat: | |
| 744 clipType = ClipDisplayItem::LayerFragmentFloat; | |
| 745 break; | |
| 746 case PaintPhaseForeground: | |
| 747 clipType = ClipDisplayItem::LayerFragmentForeground; | |
| 748 break; | |
| 749 case PaintPhaseChildOutlines: | |
| 750 clipType = ClipDisplayItem::LayerFragmentChildOutline; | |
| 751 break; | |
| 752 default: | |
| 753 ASSERT_NOT_REACHED(); | |
| 754 } | |
| 755 clipToRect(localPaintingInfo, context, fragment.foregroundRect, pain tFlags, clipType); | |
| 756 } | |
| 739 | 757 |
| 740 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.foregroundRect .rect()), phase, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.ro otLayer->renderer()); | 758 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.foregroundRect .rect()), phase, paintBehavior, paintingRootForRenderer, 0, localPaintingInfo.ro otLayer->renderer()); |
| 741 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(lo calPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))); | 759 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(lo calPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))); |
| 742 | 760 |
| 743 if (shouldClip) | 761 if (shouldClip) |
| 744 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore groundRect); | 762 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore groundRect); |
| 745 } | 763 } |
| 746 } | 764 } |
| 747 | 765 |
| 748 void LayerPainter::paintOutlineForFragments(const LayerFragments& layerFragments , GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, | 766 void LayerPainter::paintOutlineForFragments(const LayerFragments& layerFragments , GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo, |
| 749 PaintBehavior paintBehavior, RenderObject* paintingRootForRenderer, PaintLay erFlags paintFlags) | 767 PaintBehavior paintBehavior, RenderObject* paintingRootForRenderer, PaintLay erFlags paintFlags) |
| 750 { | 768 { |
| 751 for (size_t i = 0; i < layerFragments.size(); ++i) { | 769 for (size_t i = 0; i < layerFragments.size(); ++i) { |
| 752 const LayerFragment& fragment = layerFragments.at(i); | 770 const LayerFragment& fragment = layerFragments.at(i); |
| 753 if (fragment.outlineRect.isEmpty()) | 771 if (fragment.outlineRect.isEmpty()) |
| 754 continue; | 772 continue; |
| 755 | 773 |
| 756 // Paint our own outline | 774 // Paint our own outline |
| 757 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.outlineRect.re ct()), PaintPhaseSelfOutline, paintBehavior, paintingRootForRenderer, 0, localPa intingInfo.rootLayer->renderer()); | 775 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.outlineRect.re ct()), PaintPhaseSelfOutline, paintBehavior, paintingRootForRenderer, 0, localPa intingInfo.rootLayer->renderer()); |
| 758 clipToRect(localPaintingInfo, context, fragment.outlineRect, paintFlags, DoNotIncludeSelfForBorderRadius); | 776 clipToRect(localPaintingInfo, context, fragment.outlineRect, paintFlags, ClipDisplayItem::LayerFragmentOutline, DoNotIncludeSelfForBorderRadius); |
| 759 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(lo calPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))); | 777 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(lo calPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))); |
| 760 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.outlineR ect); | 778 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.outlineR ect); |
| 761 } | 779 } |
| 762 } | 780 } |
| 763 | 781 |
| 764 void LayerPainter::paintMaskForFragments(const LayerFragments& layerFragments, G raphicsContext* context, const LayerPaintingInfo& localPaintingInfo, | 782 void LayerPainter::paintMaskForFragments(const LayerFragments& layerFragments, G raphicsContext* context, const LayerPaintingInfo& localPaintingInfo, |
| 765 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) | 783 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) |
| 766 { | 784 { |
| 767 for (size_t i = 0; i < layerFragments.size(); ++i) { | 785 for (size_t i = 0; i < layerFragments.size(); ++i) { |
| 768 const LayerFragment& fragment = layerFragments.at(i); | 786 const LayerFragment& fragment = layerFragments.at(i); |
| 769 if (!fragment.shouldPaintContent) | 787 if (!fragment.shouldPaintContent) |
| 770 continue; | 788 continue; |
| 771 | 789 |
| 772 if (localPaintingInfo.clipToDirtyRect) | 790 if (localPaintingInfo.clipToDirtyRect) |
| 773 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, DoNotIncludeSelfForBorderRadius); // Mask painting will handle clipping to self. | 791 clipToRect(localPaintingInfo, context, fragment.backgroundRect, pain tFlags, ClipDisplayItem::LayerFragmentMask, DoNotIncludeSelfForBorderRadius); // Mask painting will handle clipping to self. |
| 774 | 792 |
| 775 // Paint the mask. | 793 // Paint the mask. |
| 776 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info. | 794 // FIXME: Eventually we will collect the region from the fragment itself instead of just from the paint info. |
| 777 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseMask, PaintBehaviorNormal, paintingRootForRenderer, 0, local PaintingInfo.rootLayer->renderer()); | 795 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseMask, PaintBehaviorNormal, paintingRootForRenderer, 0, local PaintingInfo.rootLayer->renderer()); |
| 778 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(lo calPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))); | 796 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(lo calPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))); |
| 779 | 797 |
| 780 if (localPaintingInfo.clipToDirtyRect) | 798 if (localPaintingInfo.clipToDirtyRect) |
| 781 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect); | 799 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.back groundRect); |
| 782 } | 800 } |
| 783 } | 801 } |
| 784 | 802 |
| 785 void LayerPainter::paintChildClippingMaskForFragments(const LayerFragments& laye rFragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo , | 803 void LayerPainter::paintChildClippingMaskForFragments(const LayerFragments& laye rFragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo , |
| 786 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) | 804 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) |
| 787 { | 805 { |
| 788 for (size_t i = 0; i < layerFragments.size(); ++i) { | 806 for (size_t i = 0; i < layerFragments.size(); ++i) { |
| 789 const LayerFragment& fragment = layerFragments.at(i); | 807 const LayerFragment& fragment = layerFragments.at(i); |
| 790 if (!fragment.shouldPaintContent) | 808 if (!fragment.shouldPaintContent) |
| 791 continue; | 809 continue; |
| 792 | 810 |
| 793 if (localPaintingInfo.clipToDirtyRect) | 811 if (localPaintingInfo.clipToDirtyRect) |
| 794 clipToRect(localPaintingInfo, context, fragment.foregroundRect, pain tFlags, IncludeSelfForBorderRadius); // Child clipping mask painting will handle clipping to self. | 812 clipToRect(localPaintingInfo, context, fragment.foregroundRect, pain tFlags, ClipDisplayItem::LayerFragmentClippingMask, IncludeSelfForBorderRadius); // Child clipping mask painting will handle clipping to self. |
| 795 | 813 |
| 796 // Paint the the clipped mask. | 814 // Paint the the clipped mask. |
| 797 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseClippingMask, PaintBehaviorNormal, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer()); | 815 PaintInfo paintInfo(context, pixelSnappedIntRect(fragment.backgroundRect .rect()), PaintPhaseClippingMask, PaintBehaviorNormal, paintingRootForRenderer, 0, localPaintingInfo.rootLayer->renderer()); |
| 798 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(lo calPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))); | 816 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds. location() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(lo calPaintingInfo.subPixelAccumulation, m_renderLayer.compositingState()))); |
| 799 | 817 |
| 800 if (localPaintingInfo.clipToDirtyRect) | 818 if (localPaintingInfo.clipToDirtyRect) |
| 801 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore groundRect); | 819 restoreClip(context, localPaintingInfo.paintDirtyRect, fragment.fore groundRect); |
| 802 } | 820 } |
| 803 } | 821 } |
| 804 | 822 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 834 m_renderLayer.enclosingPaginationLayer()->convertToLayerCoords(paint ingInfo.rootLayer, offsetOfPaginationLayerFromRoot); | 852 m_renderLayer.enclosingPaginationLayer()->convertToLayerCoords(paint ingInfo.rootLayer, offsetOfPaginationLayerFromRoot); |
| 835 | 853 |
| 836 ClipRectsContext clipRectsContext(m_renderLayer.enclosingPaginationL ayer(), (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Paintin gClipRects, IgnoreOverlayScrollbarSize); | 854 ClipRectsContext clipRectsContext(m_renderLayer.enclosingPaginationL ayer(), (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects : Paintin gClipRects, IgnoreOverlayScrollbarSize); |
| 837 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == IgnoreOverflowClip) | 855 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == IgnoreOverflowClip) |
| 838 clipRectsContext.setIgnoreOverflowClip(); | 856 clipRectsContext.setIgnoreOverflowClip(); |
| 839 LayoutRect parentClipRect = m_renderLayer.clipper().backgroundClipRe ct(clipRectsContext).rect(); | 857 LayoutRect parentClipRect = m_renderLayer.clipper().backgroundClipRe ct(clipRectsContext).rect(); |
| 840 parentClipRect.moveBy(fragment.paginationOffset + offsetOfPagination LayerFromRoot); | 858 parentClipRect.moveBy(fragment.paginationOffset + offsetOfPagination LayerFromRoot); |
| 841 clipRect.intersect(parentClipRect); | 859 clipRect.intersect(parentClipRect); |
| 842 } | 860 } |
| 843 | 861 |
| 844 LayerPainter(*m_renderLayer.parent()).clipToRect(paintingInfo, context, clipRect, paintFlags); | 862 LayerPainter(*m_renderLayer.parent()).clipToRect(paintingInfo, context, clipRect, paintFlags, ClipDisplayItem::LayerFragmentParent); |
| 845 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen t.paginationOffset); | 863 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen t.paginationOffset); |
| 846 LayerPainter(*m_renderLayer.parent()).restoreClip(context, paintingInfo. paintDirtyRect, clipRect); | 864 LayerPainter(*m_renderLayer.parent()).restoreClip(context, paintingInfo. paintDirtyRect, clipRect); |
| 847 } | 865 } |
| 848 } | 866 } |
| 849 | 867 |
| 850 } // namespace blink | 868 } // namespace blink |
| OLD | NEW |