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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp

Issue 2641173008: [SPv2] Add CSS mask support (Closed)
Patch Set: update layout test expectation && add unit tests Created 3 years, 10 months 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
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 "core/paint/PaintLayerPainter.h" 5 #include "core/paint/PaintLayerPainter.h"
6 6
7 #include "core/frame/LocalFrame.h" 7 #include "core/frame/LocalFrame.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/paint/ClipPathClipper.h" 9 #include "core/paint/ClipPathClipper.h"
10 #include "core/paint/FilterPainter.h" 10 #include "core/paint/FilterPainter.h"
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 if (shouldPaintContent) { 479 if (shouldPaintContent) {
480 // TODO(wangxianzhu): This is for old slow scrolling. Implement similar 480 // TODO(wangxianzhu): This is for old slow scrolling. Implement similar
481 // optimization for slimming paint v2. 481 // optimization for slimming paint v2.
482 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect( 482 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(
483 layerFragments, localPaintingInfo, paintFlags, offsetFromRoot); 483 layerFragments, localPaintingInfo, paintFlags, offsetFromRoot);
484 if (!shouldPaintContent) 484 if (!shouldPaintContent)
485 result = MayBeClippedByPaintDirtyRect; 485 result = MayBeClippedByPaintDirtyRect;
486 } 486 }
487 } 487 }
488 488
489 Optional<ScopedPaintChunkProperties> contentScopedPaintChunkProperties;
490 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
491 !scopedPaintChunkProperties.has_value()) {
492 // If layoutObject() is a LayoutView and root layer scrolling is enabled,
493 // the LayoutView's paint properties will already have been applied at
494 // the top of this method, in scopedPaintChunkProperties.
495 DCHECK(!(RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
496 m_paintLayer.layoutObject() &&
497 m_paintLayer.layoutObject()->isLayoutView()));
498 const auto* objectPaintProperties =
499 m_paintLayer.layoutObject()->paintProperties();
500 DCHECK(objectPaintProperties &&
501 objectPaintProperties->localBorderBoxProperties());
502 PaintChunkProperties properties(
503 context.getPaintController().currentPaintChunkProperties());
504 properties.propertyTreeState =
505 *objectPaintProperties->localBorderBoxProperties();
506 properties.backfaceHidden =
507 m_paintLayer.layoutObject()->hasHiddenBackface();
508 contentScopedPaintChunkProperties.emplace(context.getPaintController(),
509 m_paintLayer, properties);
510 }
511
489 bool selectionOnly = 512 bool selectionOnly =
490 localPaintingInfo.getGlobalPaintFlags() & GlobalPaintSelectionOnly; 513 localPaintingInfo.getGlobalPaintFlags() & GlobalPaintSelectionOnly;
491
492 { // Begin block for the lifetime of any filter. 514 { // Begin block for the lifetime of any filter.
493 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, 515 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot,
494 layerFragments.isEmpty() 516 layerFragments.isEmpty()
495 ? ClipRect() 517 ? ClipRect()
496 : layerFragments[0].backgroundRect, 518 : layerFragments[0].backgroundRect,
497 localPaintingInfo, paintFlags); 519 localPaintingInfo, paintFlags);
498 520
499 Optional<ScopedPaintChunkProperties> contentScopedPaintChunkProperties;
500 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
501 !scopedPaintChunkProperties.has_value()) {
502 // If layoutObject() is a LayoutView and root layer scrolling is enabled,
503 // the LayoutView's paint properties will already have been applied at
504 // the top of this method, in scopedPaintChunkProperties.
505 DCHECK(!(RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
506 m_paintLayer.layoutObject() &&
507 m_paintLayer.layoutObject()->isLayoutView()));
508 const auto* objectPaintProperties =
509 m_paintLayer.layoutObject()->paintProperties();
510 DCHECK(objectPaintProperties &&
511 objectPaintProperties->localBorderBoxProperties());
512 PaintChunkProperties properties(
513 context.getPaintController().currentPaintChunkProperties());
514 properties.propertyTreeState =
515 *objectPaintProperties->localBorderBoxProperties();
516 properties.backfaceHidden =
517 m_paintLayer.layoutObject()->hasHiddenBackface();
518 contentScopedPaintChunkProperties.emplace(context.getPaintController(),
519 m_paintLayer, properties);
520 }
521
522 bool isPaintingRootLayer = (&m_paintLayer) == paintingInfo.rootLayer; 521 bool isPaintingRootLayer = (&m_paintLayer) == paintingInfo.rootLayer;
523 bool shouldPaintBackground = 522 bool shouldPaintBackground =
524 shouldPaintContent && !selectionOnly && 523 shouldPaintContent && !selectionOnly &&
525 (isPaintingCompositedBackground || 524 (isPaintingCompositedBackground ||
526 (isPaintingRootLayer && 525 (isPaintingRootLayer &&
527 !(paintFlags & PaintLayerPaintingSkipRootBackground))); 526 !(paintFlags & PaintLayerPaintingSkipRootBackground)));
528 bool shouldPaintNegZOrderList = 527 bool shouldPaintNegZOrderList =
529 (isPaintingScrollingContent && isPaintingOverflowContents) || 528 (isPaintingScrollingContent && isPaintingOverflowContents) ||
530 (!isPaintingScrollingContent && isPaintingCompositedBackground); 529 (!isPaintingScrollingContent && isPaintingCompositedBackground);
531 bool shouldPaintOwnContents = 530 bool shouldPaintOwnContents =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 569
571 bool shouldPaintMask = 570 bool shouldPaintMask =
572 (paintFlags & PaintLayerPaintingCompositingMaskPhase) && 571 (paintFlags & PaintLayerPaintingCompositingMaskPhase) &&
573 shouldPaintContent && m_paintLayer.layoutObject()->hasMask() && 572 shouldPaintContent && m_paintLayer.layoutObject()->hasMask() &&
574 !selectionOnly; 573 !selectionOnly;
575 bool shouldPaintClippingMask = 574 bool shouldPaintClippingMask =
576 (paintFlags & (PaintLayerPaintingChildClippingMaskPhase | 575 (paintFlags & (PaintLayerPaintingChildClippingMaskPhase |
577 PaintLayerPaintingAncestorClippingMaskPhase)) && 576 PaintLayerPaintingAncestorClippingMaskPhase)) &&
578 shouldPaintContent && !selectionOnly; 577 shouldPaintContent && !selectionOnly;
579 578
580 if (shouldPaintMask) 579 if (shouldPaintMask) {
581 paintMaskForFragments(layerFragments, context, localPaintingInfo, 580 paintMaskForFragments(layerFragments, context, localPaintingInfo,
582 paintFlags); 581 paintFlags);
582 }
583
583 if (shouldPaintClippingMask) { 584 if (shouldPaintClippingMask) {
584 // Paint the border radius mask for the fragments. 585 // Paint the border radius mask for the fragments.
585 paintChildClippingMaskForFragments(layerFragments, context, 586 paintChildClippingMaskForFragments(layerFragments, context,
586 localPaintingInfo, paintFlags); 587 localPaintingInfo, paintFlags);
587 } 588 }
588 589
589 if (subsequenceRecorder) 590 if (subsequenceRecorder)
590 m_paintLayer.setPreviousPaintResult(result); 591 m_paintLayer.setPreviousPaintResult(result);
591 return result; 592 return result;
592 } 593 }
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 1137
1137 void PaintLayerPainter::paintMaskForFragments( 1138 void PaintLayerPainter::paintMaskForFragments(
1138 const PaintLayerFragments& layerFragments, 1139 const PaintLayerFragments& layerFragments,
1139 GraphicsContext& context, 1140 GraphicsContext& context,
1140 const PaintLayerPaintingInfo& localPaintingInfo, 1141 const PaintLayerPaintingInfo& localPaintingInfo,
1141 PaintLayerFlags paintFlags) { 1142 PaintLayerFlags paintFlags) {
1142 Optional<DisplayItemCacheSkipper> cacheSkipper; 1143 Optional<DisplayItemCacheSkipper> cacheSkipper;
1143 if (layerFragments.size() > 1) 1144 if (layerFragments.size() > 1)
1144 cacheSkipper.emplace(context); 1145 cacheSkipper.emplace(context);
1145 1146
1147 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties;
1148 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1149 const auto* objectPaintProperties =
1150 m_paintLayer.layoutObject()->paintProperties();
1151 DCHECK(objectPaintProperties && objectPaintProperties->mask());
1152 PaintChunkProperties properties(
1153 context.getPaintController().currentPaintChunkProperties());
1154 properties.propertyTreeState.setEffect(objectPaintProperties->mask());
1155 scopedPaintChunkProperties.emplace(context.getPaintController(),
1156 m_paintLayer, properties);
1157 }
1158
1146 for (auto& fragment : layerFragments) 1159 for (auto& fragment : layerFragments)
1147 paintFragmentWithPhase(PaintPhaseMask, fragment, context, 1160 paintFragmentWithPhase(PaintPhaseMask, fragment, context,
1148 fragment.backgroundRect, localPaintingInfo, 1161 fragment.backgroundRect, localPaintingInfo,
1149 paintFlags, HasNotClipped); 1162 paintFlags, HasNotClipped);
1150 } 1163 }
1151 1164
1152 void PaintLayerPainter::paintChildClippingMaskForFragments( 1165 void PaintLayerPainter::paintChildClippingMaskForFragments(
1153 const PaintLayerFragments& layerFragments, 1166 const PaintLayerFragments& layerFragments,
1154 GraphicsContext& context, 1167 GraphicsContext& context,
1155 const PaintLayerPaintingInfo& localPaintingInfo, 1168 const PaintLayerPaintingInfo& localPaintingInfo,
(...skipping 30 matching lines...) Expand all
1186 context, layoutObject, PaintPhaseClippingMask)) 1199 context, layoutObject, PaintPhaseClippingMask))
1187 return; 1200 return;
1188 1201
1189 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); 1202 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
1190 LayoutObjectDrawingRecorder drawingRecorder( 1203 LayoutObjectDrawingRecorder drawingRecorder(
1191 context, layoutObject, PaintPhaseClippingMask, snappedClipRect); 1204 context, layoutObject, PaintPhaseClippingMask, snappedClipRect);
1192 context.fillRect(snappedClipRect, Color::black); 1205 context.fillRect(snappedClipRect, Color::black);
1193 } 1206 }
1194 1207
1195 } // namespace blink 1208 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698