Chromium Code Reviews| 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" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 // Repaint subsequence if the layer is marked for needing repaint. | 220 // Repaint subsequence if the layer is marked for needing repaint. |
| 221 // We don't set needsResetEmptyPaintPhase here, but clear the empty paint | 221 // We don't set needsResetEmptyPaintPhase here, but clear the empty paint |
| 222 // phase flags in PaintLayer::setNeedsPaintPhaseXXX(), to ensure that we won't | 222 // phase flags in PaintLayer::setNeedsPaintPhaseXXX(), to ensure that we won't |
| 223 // clear previousPaintPhaseXXXEmpty flags when unrelated things changed which | 223 // clear previousPaintPhaseXXXEmpty flags when unrelated things changed which |
| 224 // won't cause the paint phases to become non-empty. | 224 // won't cause the paint phases to become non-empty. |
| 225 if (paintLayer.needsRepaint()) | 225 if (paintLayer.needsRepaint()) |
| 226 needsRepaint = true; | 226 needsRepaint = true; |
| 227 | 227 |
| 228 // Repaint if layer's clip changes. | 228 // Repaint if layer's clip changes. |
| 229 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { | 229 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { |
| 230 ClipRects& clipRects = paintLayer.clipper().paintingClipRects( | 230 ClipRects& clipRects = |
| 231 paintingInfo.rootLayer, respectOverflowClip, subpixelAccumulation); | 231 paintLayer.clipper(PaintLayer::DoNotUseGeometryMapper) |
|
pdr.
2017/02/10 23:19:20
Should we use the mapper here since it's called th
chrishtr
2017/02/10 23:21:22
No, because of line 229.
pdr.
2017/02/10 23:23:37
d'oh!
| |
| 232 .paintingClipRects(paintingInfo.rootLayer, respectOverflowClip, | |
| 233 subpixelAccumulation); | |
| 232 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); | 234 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); |
| 233 if (&clipRects != previousClipRects && | 235 if (&clipRects != previousClipRects && |
| 234 (!previousClipRects || clipRects != *previousClipRects)) { | 236 (!previousClipRects || clipRects != *previousClipRects)) { |
| 235 needsRepaint = true; | 237 needsRepaint = true; |
| 236 shouldClearEmptyPaintPhaseFlags = true; | 238 shouldClearEmptyPaintPhaseFlags = true; |
| 237 } | 239 } |
| 238 paintLayer.setPreviousPaintingClipRects(clipRects); | 240 paintLayer.setPreviousPaintingClipRects(clipRects); |
| 239 } | 241 } |
| 240 | 242 |
| 241 // Repaint if previously the layer might be clipped by paintDirtyRect and | 243 // Repaint if previously the layer might be clipped by paintDirtyRect and |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 // the clipper's layer to simplify coordinate system adjustments. | 432 // the clipper's layer to simplify coordinate system adjustments. |
| 431 // The change to rootLayer must persist to correctly record the clips. | 433 // The change to rootLayer must persist to correctly record the clips. |
| 432 paintLayerForFragments = | 434 paintLayerForFragments = |
| 433 m_paintLayer.clippingContainer()->enclosingLayer(); | 435 m_paintLayer.clippingContainer()->enclosingLayer(); |
| 434 localPaintingInfo.rootLayer = paintLayerForFragments; | 436 localPaintingInfo.rootLayer = paintLayerForFragments; |
| 435 m_paintLayer.convertToLayerCoords(localPaintingInfo.rootLayer, | 437 m_paintLayer.convertToLayerCoords(localPaintingInfo.rootLayer, |
| 436 offsetToClipper); | 438 offsetToClipper); |
| 437 localPaintingInfo.paintDirtyRect.moveBy(offsetToClipper); | 439 localPaintingInfo.paintDirtyRect.moveBy(offsetToClipper); |
| 438 } | 440 } |
| 439 | 441 |
| 442 PaintLayer::GeometryMapperOption geometryMapperOption = | |
| 443 PaintLayer::DoNotUseGeometryMapper; | |
| 444 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) | |
| 445 geometryMapperOption = PaintLayer::UseGeometryMapper; | |
| 446 | |
| 440 // TODO(trchen): We haven't decided how to handle visual fragmentation with | 447 // TODO(trchen): We haven't decided how to handle visual fragmentation with |
| 441 // SPv2. Related thread | 448 // SPv2. Related thread |
| 442 // https://groups.google.com/a/chromium.org/forum/#!topic/graphics-dev/81XuW Ff-mxM | 449 // https://groups.google.com/a/chromium.org/forum/#!topic/graphics-dev/81XuW Ff-mxM |
| 443 if (fragmentPolicy == ForceSingleFragment || | 450 if (fragmentPolicy == ForceSingleFragment || |
| 444 RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 451 RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 445 paintLayerForFragments->appendSingleFragmentIgnoringPagination( | 452 paintLayerForFragments->appendSingleFragmentIgnoringPagination( |
| 446 layerFragments, localPaintingInfo.rootLayer, | 453 layerFragments, localPaintingInfo.rootLayer, |
| 447 localPaintingInfo.paintDirtyRect, cacheSlot, | 454 localPaintingInfo.paintDirtyRect, cacheSlot, geometryMapperOption, |
| 448 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, | 455 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, |
| 449 localPaintingInfo.subPixelAccumulation); | 456 localPaintingInfo.subPixelAccumulation); |
| 450 } else if (isFixedPositionObjectInPagedMedia()) { | 457 } else if (isFixedPositionObjectInPagedMedia()) { |
| 451 PaintLayerFragments singleFragment; | 458 PaintLayerFragments singleFragment; |
| 452 paintLayerForFragments->appendSingleFragmentIgnoringPagination( | 459 paintLayerForFragments->appendSingleFragmentIgnoringPagination( |
| 453 singleFragment, localPaintingInfo.rootLayer, | 460 singleFragment, localPaintingInfo.rootLayer, |
| 454 localPaintingInfo.paintDirtyRect, cacheSlot, | 461 localPaintingInfo.paintDirtyRect, cacheSlot, geometryMapperOption, |
| 455 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, | 462 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, |
| 456 localPaintingInfo.subPixelAccumulation); | 463 localPaintingInfo.subPixelAccumulation); |
| 457 repeatFixedPositionObjectInPages(singleFragment[0], paintingInfo, | 464 repeatFixedPositionObjectInPages(singleFragment[0], paintingInfo, |
| 458 layerFragments); | 465 layerFragments); |
| 459 } else { | 466 } else { |
| 460 paintLayerForFragments->collectFragments( | 467 paintLayerForFragments->collectFragments( |
| 461 layerFragments, localPaintingInfo.rootLayer, | 468 layerFragments, localPaintingInfo.rootLayer, |
| 462 localPaintingInfo.paintDirtyRect, cacheSlot, | 469 localPaintingInfo.paintDirtyRect, cacheSlot, geometryMapperOption, |
| 463 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, | 470 IgnoreOverlayScrollbarSize, respectOverflowClip, &offsetFromRoot, |
| 464 localPaintingInfo.subPixelAccumulation); | 471 localPaintingInfo.subPixelAccumulation); |
| 465 } | 472 } |
| 466 | 473 |
| 467 if (paintFlags & PaintLayerPaintingAncestorClippingMaskPhase) { | 474 if (paintFlags & PaintLayerPaintingAncestorClippingMaskPhase) { |
| 468 // Fragment offsets have been computed in the clipping container's | 475 // Fragment offsets have been computed in the clipping container's |
| 469 // layer's coordinate system, but for the rest of painting we need | 476 // layer's coordinate system, but for the rest of painting we need |
| 470 // them in the layer coordinate. So move them and the foreground rect | 477 // them in the layer coordinate. So move them and the foreground rect |
| 471 // that is also in the clipper's space. | 478 // that is also in the clipper's space. |
| 472 LayoutSize negativeOffset(-offsetToClipper.x(), -offsetToClipper.y()); | 479 LayoutSize negativeOffset(-offsetToClipper.x(), -offsetToClipper.y()); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 677 m_paintLayer.renderableTransform(paintingInfo.getGlobalPaintFlags()); | 684 m_paintLayer.renderableTransform(paintingInfo.getGlobalPaintFlags()); |
| 678 // If the transform can't be inverted, then don't paint anything. | 685 // If the transform can't be inverted, then don't paint anything. |
| 679 if (!layerTransform.isInvertible()) | 686 if (!layerTransform.isInvertible()) |
| 680 return FullyPainted; | 687 return FullyPainted; |
| 681 | 688 |
| 682 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer | 689 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer |
| 683 // here. m_paintLayer may be the "root", and then we should avoid looking at | 690 // here. m_paintLayer may be the "root", and then we should avoid looking at |
| 684 // its parent. | 691 // its parent. |
| 685 PaintLayer* parentLayer = m_paintLayer.parent(); | 692 PaintLayer* parentLayer = m_paintLayer.parent(); |
| 686 | 693 |
| 694 PaintLayer::GeometryMapperOption geometryMapperOption = | |
| 695 PaintLayer::DoNotUseGeometryMapper; | |
| 696 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) | |
| 697 geometryMapperOption = PaintLayer::UseGeometryMapper; | |
| 698 | |
| 687 PaintLayer* paginationLayer = m_paintLayer.enclosingPaginationLayer(); | 699 PaintLayer* paginationLayer = m_paintLayer.enclosingPaginationLayer(); |
| 688 PaintLayerFragments layerFragments; | 700 PaintLayerFragments layerFragments; |
| 689 bool isFixedPositionObjectInPagedMedia = | 701 bool isFixedPositionObjectInPagedMedia = |
| 690 this->isFixedPositionObjectInPagedMedia(); | 702 this->isFixedPositionObjectInPagedMedia(); |
| 691 if (!paginationLayer || isFixedPositionObjectInPagedMedia) { | 703 if (!paginationLayer || isFixedPositionObjectInPagedMedia) { |
| 692 // We don't need to collect any fragments in the regular way here. We have | 704 // We don't need to collect any fragments in the regular way here. We have |
| 693 // already calculated a clip rectangle for the ancestry if it was needed, | 705 // already calculated a clip rectangle for the ancestry if it was needed, |
| 694 // and clipping this layer is something that can be done further down the | 706 // and clipping this layer is something that can be done further down the |
| 695 // path, when the transform has been applied. | 707 // path, when the transform has been applied. |
| 696 PaintLayerFragment fragment; | 708 PaintLayerFragment fragment; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 707 ? UncachedClipRects | 719 ? UncachedClipRects |
| 708 : PaintingClipRects; | 720 : PaintingClipRects; |
| 709 ShouldRespectOverflowClipType respectOverflowClip = | 721 ShouldRespectOverflowClipType respectOverflowClip = |
| 710 shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()); | 722 shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()); |
| 711 // Calculate the transformed bounding box in the current coordinate space, | 723 // Calculate the transformed bounding box in the current coordinate space, |
| 712 // to figure out which fragmentainers (e.g. columns) we need to visit. | 724 // to figure out which fragmentainers (e.g. columns) we need to visit. |
| 713 LayoutRect transformedExtent = PaintLayer::transparencyClipBox( | 725 LayoutRect transformedExtent = PaintLayer::transparencyClipBox( |
| 714 &m_paintLayer, paginationLayer, PaintLayer::PaintingTransparencyClipBox, | 726 &m_paintLayer, paginationLayer, PaintLayer::PaintingTransparencyClipBox, |
| 715 PaintLayer::RootOfTransparencyClipBox, | 727 PaintLayer::RootOfTransparencyClipBox, |
| 716 paintingInfo.subPixelAccumulation, paintingInfo.getGlobalPaintFlags()); | 728 paintingInfo.subPixelAccumulation, paintingInfo.getGlobalPaintFlags()); |
| 729 | |
| 717 // FIXME: we don't check if paginationLayer is within | 730 // FIXME: we don't check if paginationLayer is within |
| 718 // paintingInfo.rootLayer | 731 // paintingInfo.rootLayer |
| 719 // here. | 732 // here. |
| 720 paginationLayer->collectFragments( | 733 paginationLayer->collectFragments( |
| 721 layerFragments, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, | 734 layerFragments, paintingInfo.rootLayer, paintingInfo.paintDirtyRect, |
| 722 cacheSlot, IgnoreOverlayScrollbarSize, respectOverflowClip, nullptr, | 735 cacheSlot, geometryMapperOption, IgnoreOverlayScrollbarSize, |
| 723 paintingInfo.subPixelAccumulation, &transformedExtent); | 736 respectOverflowClip, nullptr, paintingInfo.subPixelAccumulation, |
| 737 &transformedExtent); | |
| 724 } | 738 } |
| 725 | 739 |
| 726 Optional<DisplayItemCacheSkipper> cacheSkipper; | 740 Optional<DisplayItemCacheSkipper> cacheSkipper; |
| 727 if (layerFragments.size() > 1) | 741 if (layerFragments.size() > 1) |
| 728 cacheSkipper.emplace(context); | 742 cacheSkipper.emplace(context); |
| 729 | 743 |
| 730 ClipRect ancestorBackgroundClipRect; | 744 ClipRect ancestorBackgroundClipRect; |
| 731 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 745 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 732 if (parentLayer) { | 746 if (parentLayer) { |
| 733 // Calculate the clip rectangle that the ancestors establish. | 747 // Calculate the clip rectangle that the ancestors establish. |
| 734 ClipRectsContext clipRectsContext( | 748 ClipRectsContext clipRectsContext( |
| 735 paintingInfo.rootLayer, | 749 paintingInfo.rootLayer, |
| 736 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects | 750 (paintFlags & PaintLayerUncachedClipRects) ? UncachedClipRects |
| 737 : PaintingClipRects, | 751 : PaintingClipRects, |
| 738 IgnoreOverlayScrollbarSize); | 752 IgnoreOverlayScrollbarSize); |
| 739 if (shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()) == | 753 if (shouldRespectOverflowClip(paintFlags, m_paintLayer.layoutObject()) == |
| 740 IgnoreOverflowClip) | 754 IgnoreOverflowClip) |
| 741 clipRectsContext.setIgnoreOverflowClip(); | 755 clipRectsContext.setIgnoreOverflowClip(); |
| 742 ancestorBackgroundClipRect = | 756 ancestorBackgroundClipRect = m_paintLayer.clipper(geometryMapperOption) |
| 743 m_paintLayer.clipper().backgroundClipRect(clipRectsContext); | 757 .backgroundClipRect(clipRectsContext); |
| 744 } | 758 } |
| 745 } | 759 } |
| 746 | 760 |
| 747 PaintResult result = FullyPainted; | 761 PaintResult result = FullyPainted; |
| 748 for (const auto& fragment : layerFragments) { | 762 for (const auto& fragment : layerFragments) { |
| 749 Optional<LayerClipRecorder> clipRecorder; | 763 Optional<LayerClipRecorder> clipRecorder; |
| 750 if (parentLayer && !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 764 if (parentLayer && !RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 751 ClipRect clipRectForFragment(ancestorBackgroundClipRect); | 765 ClipRect clipRectForFragment(ancestorBackgroundClipRect); |
| 752 // A fixed-position object is repeated on every page instead of paginated, | 766 // A fixed-position object is repeated on every page instead of paginated, |
| 753 // so we should apply the original ancestor clip rect. | 767 // so we should apply the original ancestor clip rect. |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1186 context, layoutObject, PaintPhaseClippingMask)) | 1200 context, layoutObject, PaintPhaseClippingMask)) |
| 1187 return; | 1201 return; |
| 1188 | 1202 |
| 1189 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); | 1203 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); |
| 1190 LayoutObjectDrawingRecorder drawingRecorder( | 1204 LayoutObjectDrawingRecorder drawingRecorder( |
| 1191 context, layoutObject, PaintPhaseClippingMask, snappedClipRect); | 1205 context, layoutObject, PaintPhaseClippingMask, snappedClipRect); |
| 1192 context.fillRect(snappedClipRect, Color::black); | 1206 context.fillRect(snappedClipRect, Color::black); |
| 1193 } | 1207 } |
| 1194 | 1208 |
| 1195 } // namespace blink | 1209 } // namespace blink |
| OLD | NEW |