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/LayoutInline.h" | 8 #include "core/layout/LayoutInline.h" |
9 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
10 #include "core/paint/ClipPathClipper.h" | 10 #include "core/paint/ClipPathClipper.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 PaintLayerPaintingInfo paintingInfo = paintingInfoArg; | 226 PaintLayerPaintingInfo paintingInfo = paintingInfoArg; |
227 | 227 |
228 LayoutPoint offsetFromRoot; | 228 LayoutPoint offsetFromRoot; |
229 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); | 229 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); |
230 offsetFromRoot.move(subpixelAccumulation); | 230 offsetFromRoot.move(subpixelAccumulation); |
231 | 231 |
232 LayoutRect bounds = m_paintLayer.physicalBoundingBox(offsetFromRoot); | 232 LayoutRect bounds = m_paintLayer.physicalBoundingBox(offsetFromRoot); |
233 if (!paintingInfo.paintDirtyRect.contains(bounds)) | 233 if (!paintingInfo.paintDirtyRect.contains(bounds)) |
234 result = MayBeClippedByPaintDirtyRect; | 234 result = MayBeClippedByPaintDirtyRect; |
235 | 235 |
236 LayoutRect rootRelativeBounds; | |
237 bool rootRelativeBoundsComputed = false; | |
238 | |
239 if (paintingInfo.ancestorHasClipPathClipping && m_paintLayer.layoutObject()-
>isPositioned()) | 236 if (paintingInfo.ancestorHasClipPathClipping && m_paintLayer.layoutObject()-
>isPositioned()) |
240 UseCounter::count(m_paintLayer.layoutObject()->document(), UseCounter::C
lipPathOfPositionedElement); | 237 UseCounter::count(m_paintLayer.layoutObject()->document(), UseCounter::C
lipPathOfPositionedElement); |
241 | 238 |
242 // These helpers output clip and compositing operations using a RAII pattern
. Stack-allocated-varibles are destructed in the reverse order of construction, | 239 // These helpers output clip and compositing operations using a RAII pattern
. Stack-allocated-varibles are destructed in the reverse order of construction, |
243 // so they are nested properly. | 240 // so they are nested properly. |
244 Optional<ClipPathClipper> clipPathClipper; | 241 Optional<ClipPathClipper> clipPathClipper; |
245 // Clip-path, like border radius, must not be applied to the contents of a c
omposited-scrolling container. | 242 // Clip-path, like border radius, must not be applied to the contents of a c
omposited-scrolling container. |
246 // It must, however, still be applied to the mask layer, so that the composi
tor can properly mask the | 243 // It must, however, still be applied to the mask layer, so that the composi
tor can properly mask the |
247 // scrolling contents and scrollbars. | 244 // scrolling contents and scrollbars. |
248 if (m_paintLayer.layoutObject()->hasClipPath() && (!m_paintLayer.needsCompos
itedScrolling() || (paintFlags & PaintLayerPaintingChildClippingMaskPhase))) { | 245 if (m_paintLayer.layoutObject()->hasClipPath() && (!m_paintLayer.needsCompos
itedScrolling() || (paintFlags & PaintLayerPaintingChildClippingMaskPhase))) { |
249 if (!rootRelativeBoundsComputed) { | |
250 rootRelativeBounds = m_paintLayer.physicalBoundingBoxIncludingReflec
tionAndStackingChildren(offsetFromRoot); | |
251 rootRelativeBoundsComputed = true; | |
252 } | |
253 paintingInfo.ancestorHasClipPathClipping = true; | 246 paintingInfo.ancestorHasClipPathClipping = true; |
254 | 247 |
255 LayoutRect referenceBox(m_paintLayer.boxForClipPath()); | 248 LayoutRect referenceBox(m_paintLayer.boxForClipPath()); |
256 referenceBox.moveBy(offsetFromRoot); | 249 referenceBox.moveBy(offsetFromRoot); |
257 clipPathClipper.emplace( | 250 clipPathClipper.emplace( |
258 context, *m_paintLayer.layoutObject(), FloatRect(referenceBox), Floa
tRect(rootRelativeBounds), FloatPoint(offsetFromRoot)); | 251 context, *m_paintLayer.layoutObject(), FloatRect(referenceBox), Floa
tPoint(offsetFromRoot)); |
259 } | 252 } |
260 | 253 |
261 Optional<CompositingRecorder> compositingRecorder; | 254 Optional<CompositingRecorder> compositingRecorder; |
262 // Blending operations must be performed only with the nearest ancestor stac
king context. | 255 // Blending operations must be performed only with the nearest ancestor stac
king context. |
263 // Note that there is no need to composite if we're painting the root. | 256 // Note that there is no need to composite if we're painting the root. |
264 // FIXME: this should be unified further into PaintLayer::paintsWithTranspar
ency(). | 257 // FIXME: this should be unified further into PaintLayer::paintsWithTranspar
ency(). |
265 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument
Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN
ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode
(); | 258 bool shouldCompositeForBlendMode = (!m_paintLayer.layoutObject()->isDocument
Element() || m_paintLayer.layoutObject()->isSVGRoot()) && m_paintLayer.stackingN
ode()->isStackingContext() && m_paintLayer.hasNonIsolatedDescendantWithBlendMode
(); |
266 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint
ingInfo.getGlobalPaintFlags())) { | 259 if (shouldCompositeForBlendMode || m_paintLayer.paintsWithTransparency(paint
ingInfo.getGlobalPaintFlags())) { |
267 FloatRect compositingBounds = FloatRect(m_paintLayer.paintingExtent(pain
tingInfo.rootLayer, paintingInfo.subPixelAccumulation, paintingInfo.getGlobalPai
ntFlags())); | 260 FloatRect compositingBounds = FloatRect(m_paintLayer.paintingExtent(pain
tingInfo.rootLayer, paintingInfo.subPixelAccumulation, paintingInfo.getGlobalPai
ntFlags())); |
268 compositingRecorder.emplace(context, *m_paintLayer.layoutObject(), | 261 compositingRecorder.emplace(context, *m_paintLayer.layoutObject(), |
(...skipping 28 matching lines...) Expand all Loading... |
297 // TODO(wangxianzhu): This is for old slow scrolling. Implement simi
lar optimization for slimming paint v2. | 290 // TODO(wangxianzhu): This is for old slow scrolling. Implement simi
lar optimization for slimming paint v2. |
298 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra
gments, localPaintingInfo, paintFlags, offsetFromRoot); | 291 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra
gments, localPaintingInfo, paintFlags, offsetFromRoot); |
299 if (!shouldPaintContent) | 292 if (!shouldPaintContent) |
300 result = MayBeClippedByPaintDirtyRect; | 293 result = MayBeClippedByPaintDirtyRect; |
301 } | 294 } |
302 } | 295 } |
303 | 296 |
304 bool selectionOnly = localPaintingInfo.getGlobalPaintFlags() & GlobalPaintSe
lectionOnly; | 297 bool selectionOnly = localPaintingInfo.getGlobalPaintFlags() & GlobalPaintSe
lectionOnly; |
305 | 298 |
306 { // Begin block for the lifetime of any filter. | 299 { // Begin block for the lifetime of any filter. |
307 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer
Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti
ngInfo, paintFlags, | 300 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer
Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti
ngInfo, paintFlags); |
308 rootRelativeBounds, rootRelativeBoundsComputed); | |
309 | 301 |
310 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; | 302 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; |
311 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 303 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
312 const ObjectPaintProperties* objectPaintProperties = m_paintLayer.la
youtObject()->objectPaintProperties(); | 304 const ObjectPaintProperties* objectPaintProperties = m_paintLayer.la
youtObject()->objectPaintProperties(); |
313 ASSERT(objectPaintProperties && objectPaintProperties->localBorderBo
xProperties()); | 305 ASSERT(objectPaintProperties && objectPaintProperties->localBorderBo
xProperties()); |
314 PaintChunkProperties properties(context.getPaintController().current
PaintChunkProperties()); | 306 PaintChunkProperties properties(context.getPaintController().current
PaintChunkProperties()); |
315 auto& localBorderBoxProperties = *objectPaintProperties->localBorder
BoxProperties(); | 307 auto& localBorderBoxProperties = *objectPaintProperties->localBorder
BoxProperties(); |
316 properties.transform = localBorderBoxProperties.propertyTreeState.tr
ansform; | 308 properties.transform = localBorderBoxProperties.propertyTreeState.tr
ansform; |
317 properties.clip = localBorderBoxProperties.propertyTreeState.clip; | 309 properties.clip = localBorderBoxProperties.propertyTreeState.clip; |
318 properties.effect = localBorderBoxProperties.propertyTreeState.effec
t; | 310 properties.effect = localBorderBoxProperties.propertyTreeState.effec
t; |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 if (!m_paintLayer.containsDirtyOverlayScrollbars()) | 742 if (!m_paintLayer.containsDirtyOverlayScrollbars()) |
751 return; | 743 return; |
752 | 744 |
753 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe
ct(damageRect)), paintFlags, LayoutSize()); | 745 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe
ct(damageRect)), paintFlags, LayoutSize()); |
754 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 746 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
755 | 747 |
756 m_paintLayer.setContainsDirtyOverlayScrollbars(false); | 748 m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
757 } | 749 } |
758 | 750 |
759 } // namespace blink | 751 } // namespace blink |
OLD | NEW |