| 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/paint/FilterPainter.h" | 10 #include "core/paint/FilterPainter.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 if (m_renderLayer.parent()) { | 96 if (m_renderLayer.parent()) { |
| 97 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlag
s & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, Ignore
OverlayScrollbarSize); | 97 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlag
s & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, Ignore
OverlayScrollbarSize); |
| 98 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer())
== IgnoreOverflowClip) | 98 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer())
== IgnoreOverflowClip) |
| 99 clipRectsContext.setIgnoreOverflowClip(); | 99 clipRectsContext.setIgnoreOverflowClip(); |
| 100 clipRect = m_renderLayer.clipper().backgroundClipRect(clipRectsConte
xt); | 100 clipRect = m_renderLayer.clipper().backgroundClipRect(clipRectsConte
xt); |
| 101 clipRect.intersect(paintingInfo.paintDirtyRect); | 101 clipRect.intersect(paintingInfo.paintDirtyRect); |
| 102 | 102 |
| 103 if (needsToClip(paintingInfo, clipRect)) { | 103 if (needsToClip(paintingInfo, clipRect)) { |
| 104 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent(),
context, DisplayItem::ClipLayerParent, clipRect)); | 104 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent(),
context, DisplayItem::ClipLayerParent, clipRect)); |
| 105 if (clipRect.hasRadius()) | 105 if (clipRect.hasRadius()) |
| 106 applyRoundedRectClips(*m_renderLayer.parent(), paintingInfo,
context, paintFlags, *clipRecorder); | 106 applyRoundedRectClips(*m_renderLayer.parent(), paintingInfo,
context, LayoutPoint(), paintFlags, *clipRecorder); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 paintLayerByApplyingTransform(context, paintingInfo, paintFlags); | 110 paintLayerByApplyingTransform(context, paintingInfo, paintFlags); |
| 111 | 111 |
| 112 return; | 112 return; |
| 113 } | 113 } |
| 114 | 114 |
| 115 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); | 115 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); |
| 116 } | 116 } |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } | 368 } |
| 369 | 369 |
| 370 return false; | 370 return false; |
| 371 } | 371 } |
| 372 | 372 |
| 373 bool LayerPainter::needsToClip(const LayerPaintingInfo& localPaintingInfo, const
ClipRect& clipRect) | 373 bool LayerPainter::needsToClip(const LayerPaintingInfo& localPaintingInfo, const
ClipRect& clipRect) |
| 374 { | 374 { |
| 375 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa
dius(); | 375 return clipRect.rect() != localPaintingInfo.paintDirtyRect || clipRect.hasRa
dius(); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void LayerPainter::applyRoundedRectClips(RenderLayer& renderLayer, const LayerPa
intingInfo& localPaintingInfo, GraphicsContext* context, | 378 void LayerPainter::applyRoundedRectClips(RenderLayer& renderLayer, const LayerPa
intingInfo& localPaintingInfo, GraphicsContext* context, const LayoutPoint& pagi
nationOffset, PaintLayerFlags paintFlags, ClipRecorder& clipRecorder, BorderRadi
usClippingRule rule) |
| 379 PaintLayerFlags paintFlags, ClipRecorder& clipRecorder, BorderRadiusClipping
Rule rule) | |
| 380 { | 379 { |
| 381 // 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 | 380 // 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 |
| 382 // any layers with overflow. The condition for being able to apply these cli
ps is that the overflow object be in our | 381 // any layers with overflow. The condition for being able to apply these cli
ps is that the overflow object be in our |
| 383 // containing block chain so we check that also. | 382 // containing block chain so we check that also. |
| 384 for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? &renderLayer
: renderLayer.parent(); layer; layer = layer->parent()) { | 383 for (RenderLayer* layer = rule == IncludeSelfForBorderRadius ? &renderLayer
: renderLayer.parent(); layer; layer = layer->parent()) { |
| 385 // Composited scrolling layers handle border-radius clip in the composit
or via a mask layer. We do not | 384 // Composited scrolling layers handle border-radius clip in the composit
or via a mask layer. We do not |
| 386 // want to apply a border-radius clip to the layer contents itself, beca
use that would require re-rastering | 385 // want to apply a border-radius clip to the layer contents itself, beca
use that would require re-rastering |
| 387 // every frame to update the clip. We only want to make sure that the ma
sk layer is properly clipped so | 386 // every frame to update the clip. We only want to make sure that the ma
sk layer is properly clipped so |
| 388 // that it can in turn clip the scrolled contents in the compositor. | 387 // that it can in turn clip the scrolled contents in the compositor. |
| 389 if (layer->needsCompositedScrolling() && !(paintFlags & PaintLayerPainti
ngChildClippingMaskPhase)) | 388 if (layer->needsCompositedScrolling() && !(paintFlags & PaintLayerPainti
ngChildClippingMaskPhase)) |
| 390 break; | 389 break; |
| 391 | 390 |
| 392 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()->
hasBorderRadius() && inContainingBlockChain(&renderLayer, layer)) { | 391 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()->
hasBorderRadius() && inContainingBlockChain(&renderLayer, layer)) { |
| 393 LayoutPoint delta; | 392 LayoutPoint delta(paginationOffset); |
| 394 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); | 393 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); |
| 395 clipRecorder.addRoundedRectClip(layer->renderer()->style()->getRound
edInnerBorderFor(LayoutRect(delta, layer->size()))); | 394 clipRecorder.addRoundedRectClip(layer->renderer()->style()->getRound
edInnerBorderFor(LayoutRect(delta, layer->size()))); |
| 396 } | 395 } |
| 397 | 396 |
| 398 if (layer == localPaintingInfo.rootLayer) | 397 if (layer == localPaintingInfo.rootLayer) |
| 399 break; | 398 break; |
| 400 } | 399 } |
| 401 } | 400 } |
| 402 | 401 |
| 403 bool LayerPainter::atLeastOneFragmentIntersectsDamageRect(LayerFragments& fragme
nts, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags localPaintFlags
, const LayoutPoint& offsetFromRoot) | 402 bool LayerPainter::atLeastOneFragmentIntersectsDamageRect(LayerFragments& fragme
nts, const LayerPaintingInfo& localPaintingInfo, PaintLayerFlags localPaintFlags
, const LayoutPoint& offsetFromRoot) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer
Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
PaintLayerFlags paintFlags) | 497 void LayerPainter::paintOverflowControlsForFragments(const LayerFragments& layer
Fragments, GraphicsContext* context, const LayerPaintingInfo& localPaintingInfo,
PaintLayerFlags paintFlags) |
| 499 { | 498 { |
| 500 for (size_t i = 0; i < layerFragments.size(); ++i) { | 499 for (size_t i = 0; i < layerFragments.size(); ++i) { |
| 501 const LayerFragment& fragment = layerFragments.at(i); | 500 const LayerFragment& fragment = layerFragments.at(i); |
| 502 | 501 |
| 503 OwnPtr<ClipRecorder> clipRecorder; | 502 OwnPtr<ClipRecorder> clipRecorder; |
| 504 | 503 |
| 505 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { | 504 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) { |
| 506 clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, Di
splayItem::ClipLayerOverflowControls, fragment.backgroundRect)); | 505 clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, Di
splayItem::ClipLayerOverflowControls, fragment.backgroundRect)); |
| 507 if (fragment.backgroundRect.hasRadius()) | 506 if (fragment.backgroundRect.hasRadius()) |
| 508 applyRoundedRectClips(m_renderLayer, localPaintingInfo, context,
paintFlags, *clipRecorder); | 507 applyRoundedRectClips(m_renderLayer, localPaintingInfo, context,
fragment.paginationOffset, paintFlags, *clipRecorder); |
| 509 } | 508 } |
| 510 if (RenderLayerScrollableArea* scrollableArea = m_renderLayer.scrollable
Area()) | 509 if (RenderLayerScrollableArea* scrollableArea = m_renderLayer.scrollable
Area()) |
| 511 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); | 510 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); |
| 512 } | 511 } |
| 513 } | 512 } |
| 514 | 513 |
| 515 static bool checkContainingBlockChainForPagination(RenderLayerModelObject* rende
rer, RenderBox* ancestorColumnsRenderer) | 514 static bool checkContainingBlockChainForPagination(RenderLayerModelObject* rende
rer, RenderBox* ancestorColumnsRenderer) |
| 516 { | 515 { |
| 517 RenderView* view = renderer->view(); | 516 RenderView* view = renderer->view(); |
| 518 RenderLayerModelObject* prevBlock = renderer; | 517 RenderLayerModelObject* prevBlock = renderer; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 break; | 686 break; |
| 688 case PaintPhaseClippingMask: | 687 case PaintPhaseClippingMask: |
| 689 clipType = DisplayItem::ClipLayerFragmentClippingMask; | 688 clipType = DisplayItem::ClipLayerFragmentClippingMask; |
| 690 break; | 689 break; |
| 691 default: | 690 default: |
| 692 ASSERT_NOT_REACHED(); | 691 ASSERT_NOT_REACHED(); |
| 693 } | 692 } |
| 694 | 693 |
| 695 clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, clipTy
pe, clipRect)); | 694 clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, clipTy
pe, clipRect)); |
| 696 if (clipRect.hasRadius()) | 695 if (clipRect.hasRadius()) |
| 697 applyRoundedRectClips(m_renderLayer, paintingInfo, context, paintFla
gs, *clipRecorder, clippingRule); | 696 applyRoundedRectClips(m_renderLayer, paintingInfo, context, fragment
.paginationOffset, paintFlags, *clipRecorder, clippingRule); |
| 698 } | 697 } |
| 699 | 698 |
| 700 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa
intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer()); | 699 PaintInfo paintInfo(context, pixelSnappedIntRect(clipRect.rect()), phase, pa
intBehavior, paintingRootForRenderer, 0, paintingInfo.rootLayer->renderer()); |
| 701 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds.loca
tion() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(painti
ngInfo.subPixelAccumulation, m_renderLayer.compositingState()))); | 700 m_renderLayer.renderer()->paint(paintInfo, toPoint(fragment.layerBounds.loca
tion() - m_renderLayer.renderBoxLocation() + subPixelAccumulationIfNeeded(painti
ngInfo.subPixelAccumulation, m_renderLayer.compositingState()))); |
| 702 } | 701 } |
| 703 | 702 |
| 704 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme
nts, GraphicsContext* context, | 703 void LayerPainter::paintBackgroundForFragments(const LayerFragments& layerFragme
nts, GraphicsContext* context, |
| 705 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L
ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, | 704 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const L
ayerPaintingInfo& localPaintingInfo, PaintBehavior paintBehavior, |
| 706 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) | 705 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) |
| 707 { | 706 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 729 } | 728 } |
| 730 } | 729 } |
| 731 | 730 |
| 732 // Optimize clipping for the single fragment case. | 731 // Optimize clipping for the single fragment case. |
| 733 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size()
== 1 && !layerFragments[0].foregroundRect.isEmpty(); | 732 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size()
== 1 && !layerFragments[0].foregroundRect.isEmpty(); |
| 734 ClipState clipState = HasNotClipped; | 733 ClipState clipState = HasNotClipped; |
| 735 OwnPtr<ClipRecorder> clipRecorder; | 734 OwnPtr<ClipRecorder> clipRecorder; |
| 736 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun
dRect)) { | 735 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun
dRect)) { |
| 737 clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, Displa
yItem::ClipLayerForeground, layerFragments[0].foregroundRect)); | 736 clipRecorder = adoptPtr(new ClipRecorder(&m_renderLayer, context, Displa
yItem::ClipLayerForeground, layerFragments[0].foregroundRect)); |
| 738 if (layerFragments[0].foregroundRect.hasRadius()) | 737 if (layerFragments[0].foregroundRect.hasRadius()) |
| 739 applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, pai
ntFlags, *clipRecorder); | 738 applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, lay
erFragments[0].paginationOffset, paintFlags, *clipRecorder); |
| 740 clipState = HasClipped; | 739 clipState = HasClipped; |
| 741 } | 740 } |
| 742 | 741 |
| 743 // We have to loop through every fragment multiple times, since we have to i
ssue paint invalidations in each specific phase in order for | 742 // We have to loop through every fragment multiple times, since we have to i
ssue paint invalidations in each specific phase in order for |
| 744 // interleaving of the fragments to work properly. | 743 // interleaving of the fragments to work properly. |
| 745 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P
aintPhaseChildBlockBackgrounds, layerFragments, | 744 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P
aintPhaseChildBlockBackgrounds, layerFragments, |
| 746 context, localPaintingInfo, paintBehavior, paintingRootForRenderer, pain
tFlags, clipState); | 745 context, localPaintingInfo, paintBehavior, paintingRootForRenderer, pain
tFlags, clipState); |
| 747 | 746 |
| 748 if (!selectionOnly) { | 747 if (!selectionOnly) { |
| 749 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co
ntext, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, cl
ipState); | 748 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co
ntext, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, cl
ipState); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 | 824 |
| 826 OwnPtr<ClipRecorder> clipRecorder; | 825 OwnPtr<ClipRecorder> clipRecorder; |
| 827 if (needsToClip(paintingInfo, clipRect)) | 826 if (needsToClip(paintingInfo, clipRect)) |
| 828 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent(), con
text, DisplayItem::ClipLayerFragmentParent, clipRect)); | 827 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent(), con
text, DisplayItem::ClipLayerFragmentParent, clipRect)); |
| 829 | 828 |
| 830 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen
t.paginationOffset); | 829 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen
t.paginationOffset); |
| 831 } | 830 } |
| 832 } | 831 } |
| 833 | 832 |
| 834 } // namespace blink | 833 } // namespace blink |
| OLD | NEW |