OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/paint/LayerDescendantClipRecorder.h" |
| 7 |
| 8 #include "core/layout/LayoutBox.h" |
| 9 #include "platform/RuntimeEnabledFeatures.h" |
| 10 #include "platform/geometry/IntRect.h" |
| 11 #include "platform/geometry/LayoutPoint.h" |
| 12 #include "platform/graphics/GraphicsContext.h" |
| 13 #include "platform/graphics/paint/ClipDisplayItem.h" |
| 14 #include "platform/graphics/paint/DisplayItemList.h" |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 LayerDescendantClipRecorder::LayerDescendantClipRecorder(GraphicsContext& contex
t, const LayoutBox& layoutBox, const LayoutPoint& paintOffset) |
| 19 : m_graphicsContext(context) |
| 20 , m_layoutBox(layoutBox) |
| 21 { |
| 22 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 23 ASSERT(layoutBox.hasOverflowClip()); |
| 24 |
| 25 LayoutRect clipRect = layoutBox.overflowClipRect(paintOffset); |
| 26 Vector<FloatRoundedRect> roundedRects; |
| 27 if (layoutBox.style()->hasBorderRadius()) |
| 28 roundedRects.append(layoutBox.style()->getRoundedInnerBorderFor(LayoutRe
ct(paintOffset, layoutBox.size()))); |
| 29 |
| 30 if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabled()
) |
| 31 return; |
| 32 m_graphicsContext.displayItemList()->createAndAppend<ClipDisplayItem>(m_layo
utBox, DisplayItem::ClipDescendantStackingContext, pixelSnappedIntRect(clipRect)
, roundedRects); |
| 33 } |
| 34 |
| 35 LayerDescendantClipRecorder::~LayerDescendantClipRecorder() |
| 36 { |
| 37 ASSERT(m_graphicsContext.displayItemList()); |
| 38 if (!m_graphicsContext.displayItemList()->displayItemConstructionIsDisabled(
)) { |
| 39 if (m_graphicsContext.displayItemList()->lastDisplayItemIsNoopBegin()) |
| 40 m_graphicsContext.displayItemList()->removeLastDisplayItem(); |
| 41 else |
| 42 m_graphicsContext.displayItemList()->createAndAppend<EndClipDisplayI
tem>(m_layoutBox, DisplayItem::clipTypeToEndClipType(DisplayItem::ClipDescendant
StackingContext)); |
| 43 } |
| 44 } |
| 45 |
| 46 } // namespace blink |
OLD | NEW |