Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(866)

Side by Side Diff: Source/core/paint/LayerPainter.cpp

Issue 721363002: [New Multicolumn] Make rounded corners clipping multicol-aware. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase master Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/paint/LayerPainter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (m_renderLayer.parent()) { 97 if (m_renderLayer.parent()) {
98 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlag s & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, Ignore OverlayScrollbarSize); 98 ClipRectsContext clipRectsContext(paintingInfo.rootLayer, (paintFlag s & PaintLayerUncachedClipRects) ? UncachedClipRects : PaintingClipRects, Ignore OverlayScrollbarSize);
99 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == IgnoreOverflowClip) 99 if (shouldRespectOverflowClip(paintFlags, m_renderLayer.renderer()) == IgnoreOverflowClip)
100 clipRectsContext.setIgnoreOverflowClip(); 100 clipRectsContext.setIgnoreOverflowClip();
101 clipRect = m_renderLayer.clipper().backgroundClipRect(clipRectsConte xt); 101 clipRect = m_renderLayer.clipper().backgroundClipRect(clipRectsConte xt);
102 clipRect.intersect(paintingInfo.paintDirtyRect); 102 clipRect.intersect(paintingInfo.paintDirtyRect);
103 103
104 if (needsToClip(paintingInfo, clipRect)) { 104 if (needsToClip(paintingInfo, clipRect)) {
105 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent()- >renderer(), context, DisplayItem::ClipLayerParent, clipRect)); 105 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.parent()- >renderer(), context, DisplayItem::ClipLayerParent, clipRect));
106 if (clipRect.hasRadius()) 106 if (clipRect.hasRadius())
107 applyRoundedRectClips(*m_renderLayer.parent(), paintingInfo, context, paintFlags, *clipRecorder); 107 applyRoundedRectClips(*m_renderLayer.parent(), paintingInfo, context, LayoutPoint(), paintFlags, *clipRecorder);
108 } 108 }
109 } 109 }
110 110
111 paintLayerByApplyingTransform(context, paintingInfo, paintFlags); 111 paintLayerByApplyingTransform(context, paintingInfo, paintFlags);
112 112
113 return; 113 return;
114 } 114 }
115 115
116 paintLayerContentsAndReflection(context, paintingInfo, paintFlags); 116 paintLayerContentsAndReflection(context, paintingInfo, paintFlags);
117 } 117 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
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& frag mentOffset, PaintLayerFlags paintFlags, ClipRecorder& clipRecorder, BorderRadius ClippingRule 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(fragmentOffset);
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
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.renderer(), c ontext, DisplayItem::ClipLayerOverflowControls, fragment.backgroundRect)); 505 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), c ontext, DisplayItem::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
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.renderer(), conte xt, clipType, clipRect)); 694 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), conte xt, clipType, 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, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior, 704 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior,
706 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags) 705 RenderObject* paintingRootForRenderer, PaintLayerFlags paintFlags)
707 { 706 {
708 for (const auto& fragment: layerFragments) { 707 for (const auto& fragment: layerFragments) {
709 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, HasNotClipped); 708 paintFragmentWithPhase(PaintPhaseBlockBackground, fragment, context, fra gment.backgroundRect, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, HasNotClipped);
710 } 709 }
711 } 710 }
712 711
713 void LayerPainter::paintForegroundForFragments(const LayerFragments& layerFragme nts, GraphicsContext* context, 712 void LayerPainter::paintForegroundForFragments(const LayerFragments& layerFragme nts, GraphicsContext* context,
714 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior, 713 const LayoutRect& transparencyPaintDirtyRect, const LayerPaintingInfo& local PaintingInfo, PaintBehavior paintBehavior,
715 RenderObject* paintingRootForRenderer, bool selectionOnly, PaintLayerFlags p aintFlags) 714 RenderObject* paintingRootForRenderer, bool selectionOnly, PaintLayerFlags p aintFlags)
716 { 715 {
717 // Optimize clipping for the single fragment case. 716 // Optimize clipping for the single fragment case.
718 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty(); 717 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size() == 1 && !layerFragments[0].foregroundRect.isEmpty();
719 ClipState clipState = HasNotClipped; 718 ClipState clipState = HasNotClipped;
720 OwnPtr<ClipRecorder> clipRecorder; 719 OwnPtr<ClipRecorder> clipRecorder;
721 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) { 720 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun dRect)) {
722 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), conte xt, DisplayItem::ClipLayerForeground, layerFragments[0].foregroundRect)); 721 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), conte xt, DisplayItem::ClipLayerForeground, layerFragments[0].foregroundRect));
723 if (layerFragments[0].foregroundRect.hasRadius()) 722 if (layerFragments[0].foregroundRect.hasRadius())
724 applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, pai ntFlags, *clipRecorder); 723 applyRoundedRectClips(m_renderLayer, localPaintingInfo, context, lay erFragments[0].paginationOffset, paintFlags, *clipRecorder);
725 clipState = HasClipped; 724 clipState = HasClipped;
726 } 725 }
727 726
728 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for 727 // We have to loop through every fragment multiple times, since we have to i ssue paint invalidations in each specific phase in order for
729 // interleaving of the fragments to work properly. 728 // interleaving of the fragments to work properly.
730 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseChildBlockBackgrounds, layerFragments, 729 paintForegroundForFragmentsWithPhase(selectionOnly ? PaintPhaseSelection : P aintPhaseChildBlockBackgrounds, layerFragments,
731 context, localPaintingInfo, paintBehavior, paintingRootForRenderer, pain tFlags, clipState); 730 context, localPaintingInfo, paintBehavior, paintingRootForRenderer, pain tFlags, clipState);
732 731
733 if (!selectionOnly) { 732 if (!selectionOnly) {
734 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, cl ipState); 733 paintForegroundForFragmentsWithPhase(PaintPhaseFloat, layerFragments, co ntext, localPaintingInfo, paintBehavior, paintingRootForRenderer, paintFlags, cl ipState);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 809
811 OwnPtr<ClipRecorder> clipRecorder; 810 OwnPtr<ClipRecorder> clipRecorder;
812 if (needsToClip(paintingInfo, clipRect)) 811 if (needsToClip(paintingInfo, clipRect))
813 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), c ontext, DisplayItem::ClipLayerFragmentParent, clipRect)); 812 clipRecorder = adoptPtr(new ClipRecorder(m_renderLayer.renderer(), c ontext, DisplayItem::ClipLayerFragmentParent, clipRect));
814 813
815 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen t.paginationOffset); 814 paintLayerByApplyingTransform(context, paintingInfo, paintFlags, fragmen t.paginationOffset);
816 } 815 }
817 } 816 }
818 817
819 } // namespace blink 818 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/LayerPainter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698