| 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 // A fixed-position object is repeated on every page, but if it is c
lipped by an ancestor layer then | 475 // A fixed-position object is repeated on every page, but if it is c
lipped by an ancestor layer then |
| 476 // the repetitions are clipped out. | 476 // the repetitions are clipped out. |
| 477 if (!isFixedPosObjectInPagedMedia) | 477 if (!isFixedPosObjectInPagedMedia) |
| 478 clipRectForFragment.moveBy(fragment.paginationOffset); | 478 clipRectForFragment.moveBy(fragment.paginationOffset); |
| 479 clipRectForFragment.intersect(fragment.backgroundRect); | 479 clipRectForFragment.intersect(fragment.backgroundRect); |
| 480 if (clipRectForFragment.isEmpty()) | 480 if (clipRectForFragment.isEmpty()) |
| 481 continue; | 481 continue; |
| 482 if (needsToClip(paintingInfo, clipRectForFragment)) { | 482 if (needsToClip(paintingInfo, clipRectForFragment)) { |
| 483 if (m_paintLayer.layoutObject()->isPositioned() && clipRectForFr
agment.isClippedByClipCss()) | 483 if (m_paintLayer.layoutObject()->isPositioned() && clipRectForFr
agment.isClippedByClipCss()) |
| 484 UseCounter::count(m_paintLayer.layoutObject()->document(), U
seCounter::ClipCssOfPositionedElement); | 484 UseCounter::count(m_paintLayer.layoutObject()->document(), U
seCounter::ClipCssOfPositionedElement); |
| 485 clipRecorder.emplace(context, *parentLayer->layoutObject(), Disp
layItem::ClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginatio
nOffset, paintFlags); | 485 clipRecorder.emplace(context, *parentLayer->layoutObject(), Disp
layItem::kClipLayerParent, clipRectForFragment, &paintingInfo, fragment.paginati
onOffset, paintFlags); |
| 486 } | 486 } |
| 487 } | 487 } |
| 488 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags,
fragment.paginationOffset) == MayBeClippedByPaintDirtyRect) | 488 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags,
fragment.paginationOffset) == MayBeClippedByPaintDirtyRect) |
| 489 result = MayBeClippedByPaintDirtyRect; | 489 result = MayBeClippedByPaintDirtyRect; |
| 490 } | 490 } |
| 491 return result; | 491 return result; |
| 492 } | 492 } |
| 493 | 493 |
| 494 PaintLayerPainter::PaintResult PaintLayerPainter::paintFragmentByApplyingTransfo
rm(GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLa
yerFlags paintFlags, const LayoutPoint& fragmentTranslation) | 494 PaintLayerPainter::PaintResult PaintLayerPainter::paintFragmentByApplyingTransfo
rm(GraphicsContext& context, const PaintLayerPaintingInfo& paintingInfo, PaintLa
yerFlags paintFlags, const LayoutPoint& fragmentTranslation) |
| 495 { | 495 { |
| 496 // Transforms will be applied by property nodes directly for SPv2. | 496 // Transforms will be applied by property nodes directly for SPv2. |
| 497 ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 497 ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 498 | 498 |
| 499 // This involves subtracting out the position of the layer in our current co
ordinate space, but preserving | 499 // This involves subtracting out the position of the layer in our current co
ordinate space, but preserving |
| 500 // the accumulated error for sub-pixel layout. | 500 // the accumulated error for sub-pixel layout. |
| 501 LayoutPoint delta; | 501 LayoutPoint delta; |
| 502 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); | 502 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); |
| 503 delta.moveBy(fragmentTranslation); | 503 delta.moveBy(fragmentTranslation); |
| 504 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo
.getGlobalPaintFlags())); | 504 TransformationMatrix transform(m_paintLayer.renderableTransform(paintingInfo
.getGlobalPaintFlags())); |
| 505 IntPoint roundedDelta = roundedIntPoint(delta); | 505 IntPoint roundedDelta = roundedIntPoint(delta); |
| 506 transform.translateRight(roundedDelta.x(), roundedDelta.y()); | 506 transform.translateRight(roundedDelta.x(), roundedDelta.y()); |
| 507 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation
+ (delta - roundedDelta); | 507 LayoutSize adjustedSubPixelAccumulation = paintingInfo.subPixelAccumulation
+ (delta - roundedDelta); |
| 508 | 508 |
| 509 // TODO(jbroman): Put the real transform origin here, instead of using a | 509 // TODO(jbroman): Put the real transform origin here, instead of using a |
| 510 // matrix with the origin baked in. | 510 // matrix with the origin baked in. |
| 511 FloatPoint3D transformOrigin; | 511 FloatPoint3D transformOrigin; |
| 512 Transform3DRecorder transform3DRecorder(context, *m_paintLayer.layoutObject(
), DisplayItem::Transform3DElementTransform, transform, transformOrigin); | 512 Transform3DRecorder transform3DRecorder(context, *m_paintLayer.layoutObject(
), DisplayItem::kTransform3DElementTransform, transform, transformOrigin); |
| 513 | 513 |
| 514 // Now do a paint with the root layer shifted to be us. | 514 // Now do a paint with the root layer shifted to be us. |
| 515 PaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, LayoutRect(enc
losingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect))), painti
ngInfo.getGlobalPaintFlags(), | 515 PaintLayerPaintingInfo transformedPaintingInfo(&m_paintLayer, LayoutRect(enc
losingIntRect(transform.inverse().mapRect(paintingInfo.paintDirtyRect))), painti
ngInfo.getGlobalPaintFlags(), |
| 516 adjustedSubPixelAccumulation); | 516 adjustedSubPixelAccumulation); |
| 517 transformedPaintingInfo.ancestorHasClipPathClipping = paintingInfo.ancestorH
asClipPathClipping; | 517 transformedPaintingInfo.ancestorHasClipPathClipping = paintingInfo.ancestorH
asClipPathClipping; |
| 518 | 518 |
| 519 // Remove skip root background flag when we're painting with a new root. | 519 // Remove skip root background flag when we're painting with a new root. |
| 520 if (&m_paintLayer != paintingInfo.rootLayer) | 520 if (&m_paintLayer != paintingInfo.rootLayer) |
| 521 paintFlags &= ~PaintLayerPaintingSkipRootBackground; | 521 paintFlags &= ~PaintLayerPaintingSkipRootBackground; |
| 522 | 522 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 if (layerFragments.size() > 1) | 590 if (layerFragments.size() > 1) |
| 591 cacheSkipper.emplace(context); | 591 cacheSkipper.emplace(context); |
| 592 | 592 |
| 593 for (auto& fragment : layerFragments) { | 593 for (auto& fragment : layerFragments) { |
| 594 // We need to apply the same clips and transforms that | 594 // We need to apply the same clips and transforms that |
| 595 // paintFragmentWithPhase would have. | 595 // paintFragmentWithPhase would have. |
| 596 LayoutRect cullRect = fragment.backgroundRect.rect(); | 596 LayoutRect cullRect = fragment.backgroundRect.rect(); |
| 597 | 597 |
| 598 Optional<LayerClipRecorder> clipRecorder; | 598 Optional<LayerClipRecorder> clipRecorder; |
| 599 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) | 599 if (needsToClip(localPaintingInfo, fragment.backgroundRect)) |
| 600 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayI
tem::ClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fra
gment.paginationOffset, paintFlags); | 600 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayI
tem::kClipLayerOverflowControls, fragment.backgroundRect, &localPaintingInfo, fr
agment.paginationOffset, paintFlags); |
| 601 | 601 |
| 602 Optional<ScrollRecorder> scrollRecorder; | 602 Optional<ScrollRecorder> scrollRecorder; |
| 603 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && !localPaintingI
nfo.scrollOffsetAccumulation.isZero()) { | 603 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && !localPaintingI
nfo.scrollOffsetAccumulation.isZero()) { |
| 604 cullRect.move(localPaintingInfo.scrollOffsetAccumulation); | 604 cullRect.move(localPaintingInfo.scrollOffsetAccumulation); |
| 605 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), Displa
yItem::ScrollOverflowControls, localPaintingInfo.scrollOffsetAccumulation); | 605 scrollRecorder.emplace(context, *m_paintLayer.layoutObject(), Displa
yItem::kScrollOverflowControls, localPaintingInfo.scrollOffsetAccumulation); |
| 606 } | 606 } |
| 607 | 607 |
| 608 // We pass IntPoint() as the paint offset here, because | 608 // We pass IntPoint() as the paint offset here, because |
| 609 // ScrollableArea::paintOverflowControls just ignores it and uses the | 609 // ScrollableArea::paintOverflowControls just ignores it and uses the |
| 610 // offset found in a previous pass. | 610 // offset found in a previous pass. |
| 611 CullRect snappedCullRect(pixelSnappedIntRect(cullRect)); | 611 CullRect snappedCullRect(pixelSnappedIntRect(cullRect)); |
| 612 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context, In
tPoint(), snappedCullRect, true); | 612 ScrollableAreaPainter(*scrollableArea).paintOverflowControls(context, In
tPoint(), snappedCullRect, true); |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 | 615 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 675 |
| 676 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l
ayerFragments, | 676 void PaintLayerPainter::paintForegroundForFragments(const PaintLayerFragments& l
ayerFragments, |
| 677 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect, | 677 GraphicsContext& context, const LayoutRect& transparencyPaintDirtyRect, |
| 678 const PaintLayerPaintingInfo& localPaintingInfo, bool selectionOnly, PaintLa
yerFlags paintFlags) | 678 const PaintLayerPaintingInfo& localPaintingInfo, bool selectionOnly, PaintLa
yerFlags paintFlags) |
| 679 { | 679 { |
| 680 // Optimize clipping for the single fragment case. | 680 // Optimize clipping for the single fragment case. |
| 681 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size()
== 1 && !layerFragments[0].foregroundRect.isEmpty(); | 681 bool shouldClip = localPaintingInfo.clipToDirtyRect && layerFragments.size()
== 1 && !layerFragments[0].foregroundRect.isEmpty(); |
| 682 ClipState clipState = HasNotClipped; | 682 ClipState clipState = HasNotClipped; |
| 683 Optional<LayerClipRecorder> clipRecorder; | 683 Optional<LayerClipRecorder> clipRecorder; |
| 684 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun
dRect)) { | 684 if (shouldClip && needsToClip(localPaintingInfo, layerFragments[0].foregroun
dRect)) { |
| 685 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayItem:
:ClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, laye
rFragments[0].paginationOffset, paintFlags); | 685 clipRecorder.emplace(context, *m_paintLayer.layoutObject(), DisplayItem:
:kClipLayerForeground, layerFragments[0].foregroundRect, &localPaintingInfo, lay
erFragments[0].paginationOffset, paintFlags); |
| 686 clipState = HasClipped; | 686 clipState = HasClipped; |
| 687 } | 687 } |
| 688 | 688 |
| 689 // We have to loop through every fragment multiple times, since we have to i
ssue paint invalidations in each specific phase in order for | 689 // We have to loop through every fragment multiple times, since we have to i
ssue paint invalidations in each specific phase in order for |
| 690 // interleaving of the fragments to work properly. | 690 // interleaving of the fragments to work properly. |
| 691 if (selectionOnly) { | 691 if (selectionOnly) { |
| 692 paintForegroundForFragmentsWithPhase(PaintPhaseSelection, layerFragments
, context, localPaintingInfo, paintFlags, clipState); | 692 paintForegroundForFragmentsWithPhase(PaintPhaseSelection, layerFragments
, context, localPaintingInfo, paintFlags, clipState); |
| 693 } else { | 693 } else { |
| 694 if (m_paintLayer.needsPaintPhaseDescendantBlockBackgrounds()) | 694 if (m_paintLayer.needsPaintPhaseDescendantBlockBackgrounds()) |
| 695 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantBlockBackgr
oundsOnly, layerFragments, context, localPaintingInfo, paintFlags, clipState); | 695 paintForegroundForFragmentsWithPhase(PaintPhaseDescendantBlockBackgr
oundsOnly, layerFragments, context, localPaintingInfo, paintFlags, clipState); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 if (!m_paintLayer.containsDirtyOverlayScrollbars()) | 755 if (!m_paintLayer.containsDirtyOverlayScrollbars()) |
| 756 return; | 756 return; |
| 757 | 757 |
| 758 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe
ct(damageRect)), paintFlags, LayoutSize()); | 758 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, LayoutRect(enclosingIntRe
ct(damageRect)), paintFlags, LayoutSize()); |
| 759 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 759 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
| 760 | 760 |
| 761 m_paintLayer.setContainsDirtyOverlayScrollbars(false); | 761 m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
| 762 } | 762 } |
| 763 | 763 |
| 764 } // namespace blink | 764 } // namespace blink |
| OLD | NEW |