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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 static ShouldRespectOverflowClipType shouldRespectOverflowClip( | 56 static ShouldRespectOverflowClipType shouldRespectOverflowClip( |
57 PaintLayerFlags paintFlags, | 57 PaintLayerFlags paintFlags, |
58 const LayoutObject* layoutObject) { | 58 const LayoutObject* layoutObject) { |
59 return (paintFlags & PaintLayerPaintingOverflowContents || | 59 return (paintFlags & PaintLayerPaintingOverflowContents || |
60 (paintFlags & PaintLayerPaintingChildClippingMaskPhase && | 60 (paintFlags & PaintLayerPaintingChildClippingMaskPhase && |
61 layoutObject->hasClipPath())) | 61 layoutObject->hasClipPath())) |
62 ? IgnoreOverflowClip | 62 ? IgnoreOverflowClip |
63 : RespectOverflowClip; | 63 : RespectOverflowClip; |
64 } | 64 } |
65 | 65 |
66 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayer( | 66 PaintResult PaintLayerPainter::paintLayer( |
67 GraphicsContext& context, | 67 GraphicsContext& context, |
68 const PaintLayerPaintingInfo& paintingInfo, | 68 const PaintLayerPaintingInfo& paintingInfo, |
69 PaintLayerFlags paintFlags) { | 69 PaintLayerFlags paintFlags) { |
70 // https://code.google.com/p/chromium/issues/detail?id=343772 | 70 // https://code.google.com/p/chromium/issues/detail?id=343772 |
71 DisableCompositingQueryAsserts disabler; | 71 DisableCompositingQueryAsserts disabler; |
72 | 72 |
73 if (m_paintLayer.compositingState() != NotComposited) { | 73 if (m_paintLayer.compositingState() != NotComposited) { |
74 if (paintingInfo.getGlobalPaintFlags() & | 74 if (paintingInfo.getGlobalPaintFlags() & |
75 GlobalPaintFlattenCompositingLayers) { | 75 GlobalPaintFlattenCompositingLayers) { |
76 // FIXME: ok, but what about GlobalPaintFlattenCompositingLayers? That's | 76 // FIXME: ok, but what about GlobalPaintFlattenCompositingLayers? That's |
(...skipping 26 matching lines...) Expand all Loading... |
103 paintFlags |= PaintLayerHaveTransparency; | 103 paintFlags |= PaintLayerHaveTransparency; |
104 | 104 |
105 if (m_paintLayer.paintsWithTransform(paintingInfo.getGlobalPaintFlags()) && | 105 if (m_paintLayer.paintsWithTransform(paintingInfo.getGlobalPaintFlags()) && |
106 !(paintFlags & PaintLayerAppliedTransform)) | 106 !(paintFlags & PaintLayerAppliedTransform)) |
107 return paintLayerWithTransform(context, paintingInfo, paintFlags); | 107 return paintLayerWithTransform(context, paintingInfo, paintFlags); |
108 | 108 |
109 return paintLayerContentsCompositingAllPhases(context, paintingInfo, | 109 return paintLayerContentsCompositingAllPhases(context, paintingInfo, |
110 paintFlags); | 110 paintFlags); |
111 } | 111 } |
112 | 112 |
113 PaintLayerPainter::PaintResult | 113 PaintResult PaintLayerPainter::paintLayerContentsCompositingAllPhases( |
114 PaintLayerPainter::paintLayerContentsCompositingAllPhases( | |
115 GraphicsContext& context, | 114 GraphicsContext& context, |
116 const PaintLayerPaintingInfo& paintingInfo, | 115 const PaintLayerPaintingInfo& paintingInfo, |
117 PaintLayerFlags paintFlags, | 116 PaintLayerFlags paintFlags, |
118 FragmentPolicy fragmentPolicy) { | 117 FragmentPolicy fragmentPolicy) { |
119 DCHECK(m_paintLayer.isSelfPaintingLayer() || | 118 DCHECK(m_paintLayer.isSelfPaintingLayer() || |
120 m_paintLayer.hasSelfPaintingLayerDescendant()); | 119 m_paintLayer.hasSelfPaintingLayerDescendant()); |
121 | 120 |
122 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform); | 121 PaintLayerFlags localPaintFlags = paintFlags & ~(PaintLayerAppliedTransform); |
123 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; | 122 localPaintFlags |= PaintLayerPaintingCompositingAllPhases; |
124 return paintLayerContents(context, paintingInfo, localPaintFlags, | 123 return paintLayerContents(context, paintingInfo, localPaintFlags, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 if (&clipRects != previousClipRects && | 199 if (&clipRects != previousClipRects && |
201 (!previousClipRects || clipRects != *previousClipRects)) { | 200 (!previousClipRects || clipRects != *previousClipRects)) { |
202 needsRepaint = true; | 201 needsRepaint = true; |
203 shouldClearEmptyPaintPhaseFlags = true; | 202 shouldClearEmptyPaintPhaseFlags = true; |
204 } | 203 } |
205 paintLayer.setPreviousPaintingClipRects(clipRects); | 204 paintLayer.setPreviousPaintingClipRects(clipRects); |
206 } | 205 } |
207 | 206 |
208 // Repaint if previously the layer might be clipped by paintDirtyRect and | 207 // Repaint if previously the layer might be clipped by paintDirtyRect and |
209 // paintDirtyRect changes. | 208 // paintDirtyRect changes. |
210 if (paintLayer.previousPaintResult() == | 209 if (paintLayer.previousPaintResult() == MayBeClippedByPaintDirtyRect && |
211 PaintLayerPainter::MayBeClippedByPaintDirtyRect && | |
212 paintLayer.previousPaintDirtyRect() != paintingInfo.paintDirtyRect) { | 210 paintLayer.previousPaintDirtyRect() != paintingInfo.paintDirtyRect) { |
213 needsRepaint = true; | 211 needsRepaint = true; |
214 shouldClearEmptyPaintPhaseFlags = true; | 212 shouldClearEmptyPaintPhaseFlags = true; |
215 } | 213 } |
216 paintLayer.setPreviousPaintDirtyRect(paintingInfo.paintDirtyRect); | 214 paintLayer.setPreviousPaintDirtyRect(paintingInfo.paintDirtyRect); |
217 | 215 |
218 // Repaint if scroll offset accumulation changes. | 216 // Repaint if scroll offset accumulation changes. |
219 if (paintingInfo.scrollOffsetAccumulation != | 217 if (paintingInfo.scrollOffsetAccumulation != |
220 paintLayer.previousScrollOffsetAccumulationForPainting()) { | 218 paintLayer.previousScrollOffsetAccumulationForPainting()) { |
221 needsRepaint = true; | 219 needsRepaint = true; |
222 shouldClearEmptyPaintPhaseFlags = true; | 220 shouldClearEmptyPaintPhaseFlags = true; |
223 } | 221 } |
224 paintLayer.setPreviousScrollOffsetAccumulationForPainting( | 222 paintLayer.setPreviousScrollOffsetAccumulationForPainting( |
225 paintingInfo.scrollOffsetAccumulation); | 223 paintingInfo.scrollOffsetAccumulation); |
226 | 224 |
227 return needsRepaint; | 225 return needsRepaint; |
228 } | 226 } |
229 | 227 |
230 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerContents( | 228 PaintResult PaintLayerPainter::paintLayerContents( |
231 GraphicsContext& context, | 229 GraphicsContext& context, |
232 const PaintLayerPaintingInfo& paintingInfoArg, | 230 const PaintLayerPaintingInfo& paintingInfoArg, |
233 PaintLayerFlags paintFlags, | 231 PaintLayerFlags paintFlags, |
234 FragmentPolicy fragmentPolicy) { | 232 FragmentPolicy fragmentPolicy) { |
235 DCHECK(m_paintLayer.isSelfPaintingLayer() || | 233 DCHECK(m_paintLayer.isSelfPaintingLayer() || |
236 m_paintLayer.hasSelfPaintingLayerDescendant()); | 234 m_paintLayer.hasSelfPaintingLayerDescendant()); |
237 DCHECK(!(paintFlags & PaintLayerAppliedTransform)); | 235 DCHECK(!(paintFlags & PaintLayerAppliedTransform)); |
238 | 236 |
239 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer(); | 237 bool isSelfPaintingLayer = m_paintLayer.isSelfPaintingLayer(); |
240 bool isPaintingOverlayScrollbars = | 238 bool isPaintingOverlayScrollbars = |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 // fragment.layerBounds is set to the border box, not the bounding box, of | 540 // fragment.layerBounds is set to the border box, not the bounding box, of |
543 // the layer. | 541 // the layer. |
544 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, | 542 if (m_paintLayer.intersectsDamageRect(fragment.layerBounds, |
545 fragment.backgroundRect.rect(), | 543 fragment.backgroundRect.rect(), |
546 newOffsetFromRoot)) | 544 newOffsetFromRoot)) |
547 return true; | 545 return true; |
548 } | 546 } |
549 return false; | 547 return false; |
550 } | 548 } |
551 | 549 |
552 PaintLayerPainter::PaintResult PaintLayerPainter::paintLayerWithTransform( | 550 PaintResult PaintLayerPainter::paintLayerWithTransform( |
553 GraphicsContext& context, | 551 GraphicsContext& context, |
554 const PaintLayerPaintingInfo& paintingInfo, | 552 const PaintLayerPaintingInfo& paintingInfo, |
555 PaintLayerFlags paintFlags) { | 553 PaintLayerFlags paintFlags) { |
556 TransformationMatrix layerTransform = | 554 TransformationMatrix layerTransform = |
557 m_paintLayer.renderableTransform(paintingInfo.getGlobalPaintFlags()); | 555 m_paintLayer.renderableTransform(paintingInfo.getGlobalPaintFlags()); |
558 // If the transform can't be inverted, then don't paint anything. | 556 // If the transform can't be inverted, then don't paint anything. |
559 if (!layerTransform.isInvertible()) | 557 if (!layerTransform.isInvertible()) |
560 return FullyPainted; | 558 return FullyPainted; |
561 | 559 |
562 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer | 560 // FIXME: We should make sure that we don't walk past paintingInfo.rootLayer |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 } | 670 } |
673 } | 671 } |
674 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, | 672 if (paintFragmentByApplyingTransform(context, paintingInfo, paintFlags, |
675 fragment.paginationOffset) == | 673 fragment.paginationOffset) == |
676 MayBeClippedByPaintDirtyRect) | 674 MayBeClippedByPaintDirtyRect) |
677 result = MayBeClippedByPaintDirtyRect; | 675 result = MayBeClippedByPaintDirtyRect; |
678 } | 676 } |
679 return result; | 677 return result; |
680 } | 678 } |
681 | 679 |
682 PaintLayerPainter::PaintResult | 680 PaintResult PaintLayerPainter::paintFragmentByApplyingTransform( |
683 PaintLayerPainter::paintFragmentByApplyingTransform( | |
684 GraphicsContext& context, | 681 GraphicsContext& context, |
685 const PaintLayerPaintingInfo& paintingInfo, | 682 const PaintLayerPaintingInfo& paintingInfo, |
686 PaintLayerFlags paintFlags, | 683 PaintLayerFlags paintFlags, |
687 const LayoutPoint& fragmentTranslation) { | 684 const LayoutPoint& fragmentTranslation) { |
688 // This involves subtracting out the position of the layer in our current | 685 // This involves subtracting out the position of the layer in our current |
689 // coordinate space, but preserving the accumulated error for sub-pixel | 686 // coordinate space, but preserving the accumulated error for sub-pixel |
690 // layout. | 687 // layout. |
691 LayoutPoint delta; | 688 LayoutPoint delta; |
692 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); | 689 m_paintLayer.convertToLayerCoords(paintingInfo.rootLayer, delta); |
693 delta.moveBy(fragmentTranslation); | 690 delta.moveBy(fragmentTranslation); |
(...skipping 20 matching lines...) Expand all Loading... |
714 paintingInfo.ancestorHasClipPathClipping; | 711 paintingInfo.ancestorHasClipPathClipping; |
715 | 712 |
716 // Remove skip root background flag when we're painting with a new root. | 713 // Remove skip root background flag when we're painting with a new root. |
717 if (&m_paintLayer != paintingInfo.rootLayer) | 714 if (&m_paintLayer != paintingInfo.rootLayer) |
718 paintFlags &= ~PaintLayerPaintingSkipRootBackground; | 715 paintFlags &= ~PaintLayerPaintingSkipRootBackground; |
719 | 716 |
720 return paintLayerContentsCompositingAllPhases( | 717 return paintLayerContentsCompositingAllPhases( |
721 context, transformedPaintingInfo, paintFlags, ForceSingleFragment); | 718 context, transformedPaintingInfo, paintFlags, ForceSingleFragment); |
722 } | 719 } |
723 | 720 |
724 PaintLayerPainter::PaintResult PaintLayerPainter::paintChildren( | 721 PaintResult PaintLayerPainter::paintChildren( |
725 unsigned childrenToVisit, | 722 unsigned childrenToVisit, |
726 GraphicsContext& context, | 723 GraphicsContext& context, |
727 const PaintLayerPaintingInfo& paintingInfo, | 724 const PaintLayerPaintingInfo& paintingInfo, |
728 PaintLayerFlags paintFlags) { | 725 PaintLayerFlags paintFlags) { |
729 PaintResult result = FullyPainted; | 726 PaintResult result = FullyPainted; |
730 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) | 727 if (!m_paintLayer.hasSelfPaintingLayerDescendant()) |
731 return result; | 728 return result; |
732 | 729 |
733 #if ENABLE(ASSERT) | 730 #if ENABLE(ASSERT) |
734 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); | 731 LayerListMutationDetector mutationChecker(m_paintLayer.stackingNode()); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 | 1067 |
1071 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, | 1068 PaintLayerPaintingInfo paintingInfo(&m_paintLayer, |
1072 LayoutRect(enclosingIntRect(damageRect)), | 1069 LayoutRect(enclosingIntRect(damageRect)), |
1073 paintFlags, LayoutSize()); | 1070 paintFlags, LayoutSize()); |
1074 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); | 1071 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); |
1075 | 1072 |
1076 m_paintLayer.setContainsDirtyOverlayScrollbars(false); | 1073 m_paintLayer.setContainsDirtyOverlayScrollbars(false); |
1077 } | 1074 } |
1078 | 1075 |
1079 } // namespace blink | 1076 } // namespace blink |
OLD | NEW |