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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/LayerClipRecorder.h" | 6 #include "core/paint/LayerClipRecorder.h" |
7 | 7 |
8 #include "core/layout/ClipRect.h" | 8 #include "core/layout/ClipRect.h" |
9 #include "core/layout/Layer.h" | 9 #include "core/layout/Layer.h" |
10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 ASSERT(m_graphicsContext->displayItemList()); | 35 ASSERT(m_graphicsContext->displayItemList()); |
36 m_graphicsContext->displayItemList()->add(clipDisplayItem.release()); | 36 m_graphicsContext->displayItemList()->add(clipDisplayItem.release()); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 static bool inContainingBlockChain(Layer* startLayer, Layer* endLayer) | 40 static bool inContainingBlockChain(Layer* startLayer, Layer* endLayer) |
41 { | 41 { |
42 if (startLayer == endLayer) | 42 if (startLayer == endLayer) |
43 return true; | 43 return true; |
44 | 44 |
45 LayoutView* view = startLayer->renderer()->view(); | 45 LayoutView* view = startLayer->layoutObject()->view(); |
46 for (LayoutBlock* currentBlock = startLayer->renderer()->containingBlock();
currentBlock && currentBlock != view; currentBlock = currentBlock->containingBlo
ck()) { | 46 for (LayoutBlock* currentBlock = startLayer->layoutObject()->containingBlock
(); currentBlock && currentBlock != view; currentBlock = currentBlock->containin
gBlock()) { |
47 if (currentBlock->layer() == endLayer) | 47 if (currentBlock->layer() == endLayer) |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
54 void LayerClipRecorder::collectRoundedRectClips(Layer& renderLayer, const LayerP
aintingInfo& localPaintingInfo, GraphicsContext* context, const LayoutPoint& fra
gmentOffset, PaintLayerFlags paintFlags, | 54 void LayerClipRecorder::collectRoundedRectClips(Layer& renderLayer, const LayerP
aintingInfo& localPaintingInfo, GraphicsContext* context, const LayoutPoint& fra
gmentOffset, PaintLayerFlags paintFlags, |
55 BorderRadiusClippingRule rule, Vector<FloatRoundedRect>& roundedRectClips) | 55 BorderRadiusClippingRule rule, Vector<FloatRoundedRect>& roundedRectClips) |
56 { | 56 { |
57 // If the clip rect has been tainted by a border radius, then we have to wal
k up our layer chain applying the clips from | 57 // If the clip rect has been tainted by a border radius, then we have to wal
k up our layer chain applying the clips from |
58 // any layers with overflow. The condition for being able to apply these cli
ps is that the overflow object be in our | 58 // any layers with overflow. The condition for being able to apply these cli
ps is that the overflow object be in our |
59 // containing block chain so we check that also. | 59 // containing block chain so we check that also. |
60 for (Layer* layer = rule == IncludeSelfForBorderRadius ? &renderLayer : rend
erLayer.parent(); layer; layer = layer->parent()) { | 60 for (Layer* layer = rule == IncludeSelfForBorderRadius ? &renderLayer : rend
erLayer.parent(); layer; layer = layer->parent()) { |
61 // Composited scrolling layers handle border-radius clip in the composit
or via a mask layer. We do not | 61 // Composited scrolling layers handle border-radius clip in the composit
or via a mask layer. We do not |
62 // want to apply a border-radius clip to the layer contents itself, beca
use that would require re-rastering | 62 // want to apply a border-radius clip to the layer contents itself, beca
use that would require re-rastering |
63 // every frame to update the clip. We only want to make sure that the ma
sk layer is properly clipped so | 63 // every frame to update the clip. We only want to make sure that the ma
sk layer is properly clipped so |
64 // that it can in turn clip the scrolled contents in the compositor. | 64 // that it can in turn clip the scrolled contents in the compositor. |
65 if (layer->needsCompositedScrolling() && !(paintFlags & PaintLayerPainti
ngChildClippingMaskPhase)) | 65 if (layer->needsCompositedScrolling() && !(paintFlags & PaintLayerPainti
ngChildClippingMaskPhase)) |
66 break; | 66 break; |
67 | 67 |
68 if (layer->renderer()->hasOverflowClip() && layer->renderer()->style()->
hasBorderRadius() && inContainingBlockChain(&renderLayer, layer)) { | 68 if (layer->layoutObject()->hasOverflowClip() && layer->layoutObject()->s
tyle()->hasBorderRadius() && inContainingBlockChain(&renderLayer, layer)) { |
69 LayoutPoint delta(fragmentOffset); | 69 LayoutPoint delta(fragmentOffset); |
70 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); | 70 layer->convertToLayerCoords(localPaintingInfo.rootLayer, delta); |
71 roundedRectClips.append(layer->renderer()->style()->getRoundedInnerB
orderFor(LayoutRect(delta, LayoutSize(layer->size())))); | 71 roundedRectClips.append(layer->layoutObject()->style()->getRoundedIn
nerBorderFor(LayoutRect(delta, LayoutSize(layer->size())))); |
72 } | 72 } |
73 | 73 |
74 if (layer == localPaintingInfo.rootLayer) | 74 if (layer == localPaintingInfo.rootLayer) |
75 break; | 75 break; |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 LayerClipRecorder::~LayerClipRecorder() | 79 LayerClipRecorder::~LayerClipRecorder() |
80 { | 80 { |
81 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 81 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
82 DisplayItem::Type endType = DisplayItem::clipTypeToEndClipType(m_clipTyp
e); | 82 DisplayItem::Type endType = DisplayItem::clipTypeToEndClipType(m_clipTyp
e); |
83 OwnPtr<EndClipDisplayItem> endClip = EndClipDisplayItem::create(m_render
er->displayItemClient(), endType); | 83 OwnPtr<EndClipDisplayItem> endClip = EndClipDisplayItem::create(m_render
er->displayItemClient(), endType); |
84 ASSERT(m_graphicsContext->displayItemList()); | 84 ASSERT(m_graphicsContext->displayItemList()); |
85 m_graphicsContext->displayItemList()->add(endClip.release()); | 85 m_graphicsContext->displayItemList()->add(endClip.release()); |
86 } else { | 86 } else { |
87 m_graphicsContext->restore(); | 87 m_graphicsContext->restore(); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 } // namespace blink | 91 } // namespace blink |
OLD | NEW |