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 "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" |
11 #include "core/paint/LayerClipRecorder.h" | 11 #include "core/paint/LayerClipRecorder.h" |
| 12 #include "core/paint/LayoutObjectDrawingRecorder.h" |
12 #include "core/paint/ObjectPaintProperties.h" | 13 #include "core/paint/ObjectPaintProperties.h" |
13 #include "core/paint/PaintInfo.h" | 14 #include "core/paint/PaintInfo.h" |
14 #include "core/paint/PaintLayer.h" | 15 #include "core/paint/PaintLayer.h" |
15 #include "core/paint/ScrollRecorder.h" | 16 #include "core/paint/ScrollRecorder.h" |
16 #include "core/paint/ScrollableAreaPainter.h" | 17 #include "core/paint/ScrollableAreaPainter.h" |
17 #include "core/paint/Transform3DRecorder.h" | 18 #include "core/paint/Transform3DRecorder.h" |
18 #include "platform/RuntimeEnabledFeatures.h" | 19 #include "platform/RuntimeEnabledFeatures.h" |
19 #include "platform/geometry/FloatPoint3D.h" | 20 #include "platform/geometry/FloatPoint3D.h" |
20 #include "platform/graphics/GraphicsLayer.h" | 21 #include "platform/graphics/GraphicsLayer.h" |
21 #include "platform/graphics/paint/CompositingRecorder.h" | 22 #include "platform/graphics/paint/CompositingRecorder.h" |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 default: | 895 default: |
895 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; | 896 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; |
896 break; | 897 break; |
897 } | 898 } |
898 | 899 |
899 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, | 900 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, |
900 clipRect, &paintingInfo, fragment.paginationOffset, | 901 clipRect, &paintingInfo, fragment.paginationOffset, |
901 paintFlags, clippingRule); | 902 paintFlags, clippingRule); |
902 } | 903 } |
903 | 904 |
| 905 // If we are painting a mask for any reason and we have already processed the |
| 906 // clips, there is no need to go through the remaining painting pipeline. |
| 907 // We know that the mask just needs the area bounded by the clip rects to be |
| 908 // filled with black. |
| 909 if (clipRecorder && phase == PaintPhaseClippingMask) { |
| 910 fillMaskingFragment(context, *clipRecorder); |
| 911 return; |
| 912 } |
| 913 |
904 LayoutRect newCullRect(clipRect.rect()); | 914 LayoutRect newCullRect(clipRect.rect()); |
905 Optional<ScrollRecorder> scrollRecorder; | 915 Optional<ScrollRecorder> scrollRecorder; |
906 LayoutPoint paintOffset = -m_paintLayer.layoutBoxLocation(); | 916 LayoutPoint paintOffset = -m_paintLayer.layoutBoxLocation(); |
907 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 917 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
908 const auto* objectPaintProperties = | 918 const auto* objectPaintProperties = |
909 m_paintLayer.layoutObject()->paintProperties(); | 919 m_paintLayer.layoutObject()->paintProperties(); |
910 DCHECK(objectPaintProperties && | 920 DCHECK(objectPaintProperties && |
911 objectPaintProperties->localBorderBoxProperties()); | 921 objectPaintProperties->localBorderBoxProperties()); |
912 paintOffset += | 922 paintOffset += |
913 toSize(objectPaintProperties->localBorderBoxProperties()->paintOffset); | 923 toSize(objectPaintProperties->localBorderBoxProperties()->paintOffset); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 return; | 1119 return; |
1110 | 1120 |
1111 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, | 1121 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, |
1112 LayoutRect(enclosingIntRect(damageRect)), | 1122 LayoutRect(enclosingIntRect(damageRect)), |
1113 paintFlags, LayoutSize()); | 1123 paintFlags, LayoutSize()); |
1114 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 1124 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
1115 | 1125 |
1116 m_paintLayer.setContainsDirtyOverlayScrollbars(false); | 1126 m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
1117 } | 1127 } |
1118 | 1128 |
| 1129 void PaintLayerPainter::fillMaskingFragment( |
| 1130 GraphicsContext& context, |
| 1131 const LayerClipRecorder& clipRecorder) { |
| 1132 DCHECK(m_paintLayer.compositingState() == PaintsIntoOwnBacking); |
| 1133 DCHECK(m_paintLayer.layoutObject()->isBox()); |
| 1134 |
| 1135 const LayoutBox* layoutBox = toLayoutBox(m_paintLayer.layoutObject()); |
| 1136 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( |
| 1137 context, *layoutBox, PaintPhaseClippingMask)) |
| 1138 return; |
| 1139 |
| 1140 IntRect clipBoundingRect = clipRecorder.snappedClipRect(); |
| 1141 for (auto& roundedRect : clipRecorder.roundedRects()) { |
| 1142 IntRect snappedRect = enclosingIntRect(roundedRect.rect()); |
| 1143 clipBoundingRect.unite(snappedRect); |
| 1144 } |
| 1145 LayoutObjectDrawingRecorder drawingRecorder( |
| 1146 context, *layoutBox, PaintPhaseClippingMask, clipBoundingRect); |
| 1147 context.fillRect(clipBoundingRect, Color::black); |
| 1148 } |
| 1149 |
1119 } // namespace blink | 1150 } // namespace blink |
OLD | NEW |