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

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

Issue 1657993002: [SPv2] Use pre-computed paint property context for layer painter and disable fragmentation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chunk_property_hookup_1
Patch Set: rebased Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/ObjectPaintProperties.cpp ('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 "core/paint/PaintLayerPainter.h" 5 #include "core/paint/PaintLayerPainter.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/layout/ClipPathOperation.h" 9 #include "core/layout/ClipPathOperation.h"
10 #include "core/layout/LayoutBlock.h" 10 #include "core/layout/LayoutBlock.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 // If this layer is totally invisible then there is nothing to paint. 87 // If this layer is totally invisible then there is nothing to paint.
88 if (!m_paintLayer.layoutObject()->opacity() && !m_paintLayer.layoutObject()- >hasBackdropFilter()) 88 if (!m_paintLayer.layoutObject()->opacity() && !m_paintLayer.layoutObject()- >hasBackdropFilter())
89 return FullyPainted; 89 return FullyPainted;
90 90
91 if (m_paintLayer.paintsWithTransparency(paintingInfo.globalPaintFlags())) 91 if (m_paintLayer.paintsWithTransparency(paintingInfo.globalPaintFlags()))
92 paintFlags |= PaintLayerHaveTransparency; 92 paintFlags |= PaintLayerHaveTransparency;
93 93
94 LayerFixedPositionRecorder fixedPositionRecorder(context, *m_paintLayer.layo utObject()); 94 LayerFixedPositionRecorder fixedPositionRecorder(context, *m_paintLayer.layo utObject());
95 95
96 // Transforms will be applied by property nodes directly for SPv2.
96 // PaintLayerAppliedTransform is used in LayoutReplica, to avoid applying th e transform twice. 97 // PaintLayerAppliedTransform is used in LayoutReplica, to avoid applying th e transform twice.
97 if (m_paintLayer.paintsWithTransform(paintingInfo.globalPaintFlags()) && !(p aintFlags & PaintLayerAppliedTransform)) 98 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && m_paintLayer.paints WithTransform(paintingInfo.globalPaintFlags()) && !(paintFlags & PaintLayerAppli edTransform))
98 return paintLayerWithTransform(context, paintingInfo, paintFlags); 99 return paintLayerWithTransform(context, paintingInfo, paintFlags);
99 100
100 return paintLayerContentsAndReflection(context, paintingInfo, paintFlags); 101 return paintLayerContentsAndReflection(context, paintingInfo, paintFlags);
101 } 102 }
102 103
103 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContentsAndReflectio n(GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLay erFlags paintFlags, FragmentPolicy fragmentPolicy) 104 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContentsAndReflectio n(GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLay erFlags paintFlags, FragmentPolicy fragmentPolicy)
104 { 105 {
105 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant()); 106 ASSERT(m_paintLayer.isSelfPaintingLayer() || m_paintLayer.hasSelfPaintingLay erDescendant());
106 107
107 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ; 108 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform) ;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 m_paintLayer.layoutObject()->opacity(), &compositingBounds); 320 m_paintLayer.layoutObject()->opacity(), &compositingBounds);
320 } 321 }
321 322
322 PaintLayerPaintingInfo localPaintingInfo(paintingInfo); 323 PaintLayerPaintingInfo localPaintingInfo(paintingInfo);
323 localPaintingInfo.subPixelAccumulation = subpixelAccumulation; 324 localPaintingInfo.subPixelAccumulation = subpixelAccumulation;
324 325
325 PaintLayerFragments layerFragments; 326 PaintLayerFragments layerFragments;
326 if (shouldPaintContent || shouldPaintSelfOutline || isPaintingOverlayScrollb ars) { 327 if (shouldPaintContent || shouldPaintSelfOutline || isPaintingOverlayScrollb ars) {
327 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment. 328 // Collect the fragments. This will compute the clip rectangles and pain t offsets for each layer fragment.
328 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects; 329 ClipRectsCacheSlot cacheSlot = (paintFlags & PaintLayerUncachedClipRects ) ? UncachedClipRects : PaintingClipRects;
329 if (fragmentPolicy == ForceSingleFragment) 330 // TODO(trchen): We haven't decided how to handle visual fragmentation w ith SPv2.
331 // Related thread https://groups.google.com/a/chromium.org/forum/#!topic /graphics-dev/81XuWFf-mxM
332 if (fragmentPolicy == ForceSingleFragment || RuntimeEnabledFeatures::sli mmingPaintV2Enabled())
330 m_paintLayer.appendSingleFragmentIgnoringPagination(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect, cacheSlot, Ignore OverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.su bPixelAccumulation); 333 m_paintLayer.appendSingleFragmentIgnoringPagination(layerFragments, localPaintingInfo.rootLayer, localPaintingInfo.paintDirtyRect, cacheSlot, Ignore OverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.su bPixelAccumulation);
331 else 334 else
332 m_paintLayer.collectFragments(layerFragments, localPaintingInfo.root Layer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation); 335 m_paintLayer.collectFragments(layerFragments, localPaintingInfo.root Layer, localPaintingInfo.paintDirtyRect, cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, localPaintingInfo.subPixelAccumulation);
333 if (shouldPaintContent) { 336 if (shouldPaintContent) {
334 // TODO(wangxianzhu): This is for old slow scrolling. Implement simi lar optimization for slimming paint v2. 337 // TODO(wangxianzhu): This is for old slow scrolling. Implement simi lar optimization for slimming paint v2.
335 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot); 338 shouldPaintContent = atLeastOneFragmentIntersectsDamageRect(layerFra gments, localPaintingInfo, paintFlags, offsetFromRoot);
336 if (!shouldPaintContent) 339 if (!shouldPaintContent)
337 result = MayBeClippedByPaintDirtyRect; 340 result = MayBeClippedByPaintDirtyRect;
338 } 341 }
339 } 342 }
340 343
341 bool selectionOnly = localPaintingInfo.globalPaintFlags() & GlobalPaintSelec tionOnly; 344 bool selectionOnly = localPaintingInfo.globalPaintFlags() & GlobalPaintSelec tionOnly;
342 345
343 { // Begin block for the lifetime of any filter. 346 { // Begin block for the lifetime of any filter.
344 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti ngInfo, paintFlags, 347 FilterPainter filterPainter(m_paintLayer, context, offsetFromRoot, layer Fragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect, localPainti ngInfo, paintFlags,
345 rootRelativeBounds, rootRelativeBoundsComputed); 348 rootRelativeBounds, rootRelativeBoundsComputed);
346 349
347 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties; 350 Optional<ScopedPaintChunkProperties> scopedPaintChunkProperties;
348 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 351 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
349 if (const auto* objectProperties = m_paintLayer.layoutObject()->obje ctPaintProperties()) { 352 ObjectPaintProperties* objectPaintProperties = m_paintLayer.layoutOb ject()->objectPaintProperties();
350 PaintChunkProperties properties(context.paintController().curren tPaintChunkProperties()); 353 ASSERT(objectPaintProperties && objectPaintProperties->localBorderBo xProperties());
351 if (TransformPaintPropertyNode* transform = objectProperties->tr ansformForLayerContents()) 354 scopedPaintChunkProperties.emplace(context.paintController(), objec tPaintProperties->localBorderBoxProperties()->properties);
352 properties.transform = transform;
353 if (EffectPaintPropertyNode* effect = objectProperties->effect() )
354 properties.effect = effect;
355 scopedPaintChunkProperties.emplace(context.paintController(), pr operties);
356 }
357 } 355 }
358 356
359 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly; 357 bool shouldPaintBackground = isPaintingCompositedBackground && shouldPai ntContent && !selectionOnly;
360 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound); 358 bool shouldPaintNegZOrderList = (isPaintingScrollingContent && isPaintin gOverflowContents) || (!isPaintingScrollingContent && isPaintingCompositedBackgr ound);
361 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent; 359 bool shouldPaintOwnContents = isPaintingCompositedForeground && shouldPa intContent;
362 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound; 360 bool shouldPaintNormalFlowAndPosZOrderLists = isPaintingCompositedForegr ound;
363 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars; 361 bool shouldPaintOverlayScrollbars = isPaintingOverlayScrollbars;
364 362
365 if (shouldPaintBackground) { 363 if (shouldPaintBackground) {
366 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect, 364 paintBackgroundForFragments(layerFragments, context, paintingInfo.pa intDirtyRect,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // for this is that fragment.layerBounds is set to the border box, not t he bounding box, of 423 // for this is that fragment.layerBounds is set to the border box, not t he bounding box, of
426 // the layer. 424 // the layer.
427 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, fragment.bac kgroundRect.rect(), newOffsetFromRoot)) 425 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, fragment.bac kgroundRect.rect(), newOffsetFromRoot))
428 return true; 426 return true;
429 } 427 }
430 return false; 428 return false;
431 } 429 }
432 430
433 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerWithTransform(Graphi csContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 431 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerWithTransform(Graphi csContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
434 { 432 {
433 // Transforms will be applied by property nodes directly for SPv2.
434 ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled());
435
435 TransformationMatrix layerTransform = m_paintLayer.renderableTransform(paint ingInfo.globalPaintFlags()); 436 TransformationMatrix layerTransform = m_paintLayer.renderableTransform(paint ingInfo.globalPaintFlags());
436 // If the transform can't be inverted, then don't paint anything. 437 // If the transform can't be inverted, then don't paint anything.
437 if (!layerTransform.isInvertible()) 438 if (!layerTransform.isInvertible())
438 return FullyPainted; 439 return FullyPainted;
439 440
440 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer here. 441 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer here.
441 // m_paintLayer may be the "root", and then we should avoid looking at its p arent. 442 // m_paintLayer may be the "root", and then we should avoid looking at its p arent.
442 PaintLayer* parentLayer = m_paintLayer.parent(); 443 PaintLayer* parentLayer = m_paintLayer.parent();
443 444
444 ClipRect ancestorBackgroundClipRect; 445 ClipRect ancestorBackgroundClipRect;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 } 494 }
494 } 495 }
495 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, fragment.paginationOffset) == MayBeClippedByPaintDirtyRect) 496 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, fragment.paginationOffset) == MayBeClippedByPaintDirtyRect)
496 result = MayBeClippedByPaintDirtyRect; 497 result = MayBeClippedByPaintDirtyRect;
497 } 498 }
498 return result; 499 return result;
499 } 500 }
500 501
501 PaintLayerPainter::PaintResult PaintLayerPainter::paintFragmentByApplyingTransfo rm(GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLa yerFlags paintFlags, const LayoutPoint& fragmentTranslation) 502 PaintLayerPainter::PaintResult PaintLayerPainter::paintFragmentByApplyingTransfo rm(GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLa yerFlags paintFlags, const LayoutPoint& fragmentTranslation)
502 { 503 {
504 // Transforms will be applied by property nodes directly for SPv2.
505 ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled());
506
503 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving 507 // This involves subtracting out the position of the layer in our current co ordinate space, but preserving
504 // the accumulated error for sub-pixel layout. 508 // the accumulated error for sub-pixel layout.
505 LayoutPoint delta; 509 LayoutPoint delta;
506 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); 510 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta);
507 delta.moveBy(fragmentTranslation); 511 delta.moveBy(fragmentTranslation);
508 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo .globalPaintFlags())); 512 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo .globalPaintFlags()));
509 IntPoint roundedDelta = roundedIntPoint(delta); 513 IntPoint roundedDelta = roundedIntPoint(delta);
510 transform.translateRight(roundedDelta.x(), roundedDelta.y()); 514 transform.translateRight(roundedDelta.x(), roundedDelta.y());
511 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta); 515 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation + (delta - roundedDelta);
512 516
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 default: 619 default:
616 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius; 620 clippingRule = LayerClipRecorder::IncludeSelfForBorderRadius;
617 break; 621 break;
618 } 622 }
619 623
620 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, cl ipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule); 624 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), clipType, cl ipRect, &paintingInfo, fragment.paginationOffset, paintFlags, clippingRule);
621 } 625 }
622 626
623 LayoutRect newCullRect(clipRect.rect()); 627 LayoutRect newCullRect(clipRect.rect());
624 Optional<ScrollRecorder> scrollRecorder; 628 Optional<ScrollRecorder> scrollRecorder;
625 LayoutPoint paintOffset = toPoint(fragment.layerBounds.location() - m_paintL ayer.layoutBoxLocation()); 629 LayoutPoint paintOffset;
pdr. 2016/02/05 07:34:43 WDYT about just starting with -m_paintLayer.layout
626 if (!paintingInfo.scrollOffsetAccumulation.isZero()) { 630 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
627 // As a descendant of the root layer, m_paintLayer's painting is not con trolled by the ScrollRecorders 631 ObjectPaintProperties* objectPaintProperties = m_paintLayer.layoutObject ()->objectPaintProperties();
628 // created by BlockPainter of the ancestor layers up to the root layer, so we need to issue ScrollRecorder 632 ASSERT(objectPaintProperties && objectPaintProperties->localBorderBoxPro perties());
629 // for this layer seperately, with the scroll offset accumulated from th e root layer to the parent of this 633 paintOffset = toPoint(objectPaintProperties->localBorderBoxProperties()- >paintOffset - m_paintLayer.layoutBoxLocation());
630 // layer, to get the same result as ScrollRecorder in BlockPainter. 634 } else {
631 paintOffset += paintingInfo.scrollOffsetAccumulation; 635 paintOffset = toPoint(fragment.layerBounds.location() - m_paintLayer.lay outBoxLocation());
636 if (!paintingInfo.scrollOffsetAccumulation.isZero()) {
637 // As a descendant of the root layer, m_paintLayer's painting is not controlled by the ScrollRecorders
638 // created by BlockPainter of the ancestor layers up to the root lay er, so we need to issue ScrollRecorder
639 // for this layer seperately, with the scroll offset accumulated fro m the root layer to the parent of this
640 // layer, to get the same result as ScrollRecorder in BlockPainter.
641 paintOffset += paintingInfo.scrollOffsetAccumulation;
632 642
633 newCullRect.move(paintingInfo.scrollOffsetAccumulation); 643 newCullRect.move(paintingInfo.scrollOffsetAccumulation);
634 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), phase, pai ntingInfo.scrollOffsetAccumulation); 644 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), phase, paintingInfo.scrollOffsetAccumulation);
645 }
635 } 646 }
636 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase, 647 PaintInfo paintInfo(context, pixelSnappedIntRect(newCullRect), phase,
637 paintingInfo.globalPaintFlags(), paintFlags, paintingInfo.rootLayer->lay outObject()); 648 paintingInfo.globalPaintFlags(), paintFlags, paintingInfo.rootLayer->lay outObject());
638 649
639 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset); 650 m_paintLayer.layoutObject()->paint(paintInfo, paintOffset);
640 } 651 }
641 652
642 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments, 653 void PaintLayerPainter::paintBackgroundForFragments(const PaintLayerFragments& l ayerFragments,
643 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect, 654 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect,
644 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags) 655 const PaintLayerPaintingInfo& localPaintingInfo, PaintLayerFlags paintFlags)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 if (!m_paintLayer.containsDirtyOverlayScrollbars()) 749 if (!m_paintLayer.containsDirtyOverlayScrollbars())
739 return; 750 return;
740 751
741 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize()); 752 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe ct(damageRect)), paintFlags, LayoutSize());
742 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 753 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
743 754
744 m_paintLayer.setContainsDirtyOverlayScrollbars(false); 755 m_paintLayer.setContainsDirtyOverlayScrollbars(false);
745 } 756 }
746 757
747 } // namespace blink 758 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/ObjectPaintProperties.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698