| 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/LayerClipRecorder.h" | 5 #include "core/paint/LayerClipRecorder.h" |
| 6 | 6 |
| 7 #include "core/layout/ClipRect.h" | 7 #include "core/layout/ClipRect.h" |
| 8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
| 9 #include "core/paint/PaintLayer.h" | 9 #include "core/paint/PaintLayer.h" |
| 10 #include "platform/geometry/IntRect.h" | 10 #include "platform/geometry/IntRect.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 void LayerClipRecorder::collectRoundedRectClips( | 59 void LayerClipRecorder::collectRoundedRectClips( |
| 60 PaintLayer& paintLayer, | 60 PaintLayer& paintLayer, |
| 61 const PaintLayerPaintingInfo& localPaintingInfo, | 61 const PaintLayerPaintingInfo& localPaintingInfo, |
| 62 GraphicsContext& context, | 62 GraphicsContext& context, |
| 63 const LayoutPoint& fragmentOffset, | 63 const LayoutPoint& fragmentOffset, |
| 64 PaintLayerFlags paintFlags, | 64 PaintLayerFlags paintFlags, |
| 65 BorderRadiusClippingRule rule, | 65 BorderRadiusClippingRule rule, |
| 66 Vector<FloatRoundedRect>& roundedRectClips) { | 66 Vector<FloatRoundedRect>& roundedRectClips) { |
| 67 // If the clip rect has been tainted by a border radius, then we have to walk
up our layer chain applying the clips from | 67 // If the clip rect has been tainted by a border radius, then we have to walk |
| 68 // any layers with overflow. The condition for being able to apply these clips
is that the overflow object be in our | 68 // up our layer chain applying the clips from any layers with overflow. The |
| 69 // containing block chain so we check that also. | 69 // condition for being able to apply these clips is that the overflow object |
| 70 // be in our containing block chain so we check that also. |
| 70 for (PaintLayer* layer = rule == IncludeSelfForBorderRadius | 71 for (PaintLayer* layer = rule == IncludeSelfForBorderRadius |
| 71 ? &paintLayer | 72 ? &paintLayer |
| 72 : paintLayer.parent(); | 73 : paintLayer.parent(); |
| 73 layer; layer = layer->parent()) { | 74 layer; layer = layer->parent()) { |
| 74 // Composited scrolling layers handle border-radius clip in the compositor v
ia a mask layer. We do not | 75 // Composited scrolling layers handle border-radius clip in the compositor |
| 75 // want to apply a border-radius clip to the layer contents itself, because
that would require re-rastering | 76 // via a mask layer. We do not want to apply a border-radius clip to the |
| 76 // every frame to update the clip. We only want to make sure that the mask l
ayer is properly clipped so | 77 // layer contents itself, because that would require re-rastering every |
| 77 // that it can in turn clip the scrolled contents in the compositor. | 78 // frame to update the clip. We only want to make sure that the mask layer |
| 79 // is properly clipped so that it can in turn clip the scrolled contents in |
| 80 // the compositor. |
| 78 if (layer->needsCompositedScrolling() && | 81 if (layer->needsCompositedScrolling() && |
| 79 !(paintFlags & PaintLayerPaintingChildClippingMaskPhase)) | 82 !(paintFlags & PaintLayerPaintingChildClippingMaskPhase)) |
| 80 break; | 83 break; |
| 81 | 84 |
| 82 if (layer->layoutObject()->hasOverflowClip() && | 85 if (layer->layoutObject()->hasOverflowClip() && |
| 83 layer->layoutObject()->style()->hasBorderRadius() && | 86 layer->layoutObject()->style()->hasBorderRadius() && |
| 84 inContainingBlockChain(&paintLayer, layer)) { | 87 inContainingBlockChain(&paintLayer, layer)) { |
| 85 LayoutPoint delta(fragmentOffset); | 88 LayoutPoint delta(fragmentOffset); |
| 86 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); | 89 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); |
| 87 | 90 |
| 88 // The PaintLayer's size is pixel-snapped if it is a LayoutBox. We can't u
se a pre-snapped border rect for clipping, since getRoundedInnerBorderFor assume
s | 91 // The PaintLayer's size is pixel-snapped if it is a LayoutBox. We can't |
| 89 // it has not been snapped yet. | 92 // use a pre-snapped border rect for clipping, since |
| 93 // getRoundedInnerBorderFor assumes it has not been snapped yet. |
| 90 LayoutSize size(layer->layoutBox() | 94 LayoutSize size(layer->layoutBox() |
| 91 ? toLayoutBox(layer->layoutObject())->size() | 95 ? toLayoutBox(layer->layoutObject())->size() |
| 92 : LayoutSize(layer->size())); | 96 : LayoutSize(layer->size())); |
| 93 roundedRectClips.append( | 97 roundedRectClips.append( |
| 94 layer->layoutObject()->style()->getRoundedInnerBorderFor( | 98 layer->layoutObject()->style()->getRoundedInnerBorderFor( |
| 95 LayoutRect(delta, size))); | 99 LayoutRect(delta, size))); |
| 96 } | 100 } |
| 97 | 101 |
| 98 if (layer == localPaintingInfo.rootLayer) | 102 if (layer == localPaintingInfo.rootLayer) |
| 99 break; | 103 break; |
| 100 } | 104 } |
| 101 } | 105 } |
| 102 | 106 |
| 103 LayerClipRecorder::~LayerClipRecorder() { | 107 LayerClipRecorder::~LayerClipRecorder() { |
| 104 m_graphicsContext.getPaintController().endItem<EndClipDisplayItem>( | 108 m_graphicsContext.getPaintController().endItem<EndClipDisplayItem>( |
| 105 m_layoutObject, DisplayItem::clipTypeToEndClipType(m_clipType)); | 109 m_layoutObject, DisplayItem::clipTypeToEndClipType(m_clipType)); |
| 106 } | 110 } |
| 107 | 111 |
| 108 } // namespace blink | 112 } // namespace blink |
| OLD | NEW |