OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/RoundedInnerRectClipper.h" | 5 #include "core/paint/RoundedInnerRectClipper.h" |
6 | 6 |
7 #include "core/layout/LayoutObject.h" | 7 #include "core/layout/LayoutObject.h" |
8 #include "core/paint/PaintInfo.h" | 8 #include "core/paint/PaintInfo.h" |
9 #include "platform/graphics/paint/ClipDisplayItem.h" | 9 #include "platform/graphics/paint/ClipDisplayItem.h" |
10 #include "platform/graphics/paint/PaintController.h" | 10 #include "platform/graphics/paint/PaintController.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 RoundedInnerRectClipper::RoundedInnerRectClipper( | 14 RoundedInnerRectClipper::RoundedInnerRectClipper( |
15 const LayoutObject& layoutObject, | 15 const LayoutObject& layoutObject, |
16 const PaintInfo& paintInfo, | 16 const PaintInfo& paintInfo, |
17 const LayoutRect& rect, | 17 const LayoutRect& rect, |
18 const FloatRoundedRect& clipRect, | 18 const FloatRoundedRect& clipRect, |
19 RoundedInnerRectClipperBehavior behavior) | 19 RoundedInnerRectClipperBehavior behavior) |
20 : m_layoutObject(layoutObject), | 20 : m_layoutObject(layoutObject), |
21 m_paintInfo(paintInfo), | 21 m_paintInfo(paintInfo), |
22 m_usePaintController(behavior == ApplyToDisplayList), | 22 m_usePaintController(behavior == ApplyToDisplayList), |
23 m_clipType(m_usePaintController ? m_paintInfo.displayItemTypeForClipping() | 23 m_clipType(m_usePaintController ? m_paintInfo.displayItemTypeForClipping() |
24 : DisplayItem::kClipBoxPaintPhaseFirst) { | 24 : DisplayItem::kClipBoxPaintPhaseFirst) { |
25 Vector<FloatRoundedRect> roundedRectClips; | 25 Vector<FloatRoundedRect> roundedRectClips; |
26 if (clipRect.isRenderable()) { | 26 if (clipRect.isRenderable()) { |
27 roundedRectClips.append(clipRect); | 27 roundedRectClips.append(clipRect); |
28 } else { | 28 } else { |
29 // We create a rounded rect for each of the corners and clip it, while makin
g sure we clip opposing corners together. | 29 // We create a rounded rect for each of the corners and clip it, while |
| 30 // making sure we clip opposing corners together. |
30 if (!clipRect.getRadii().topLeft().isEmpty() || | 31 if (!clipRect.getRadii().topLeft().isEmpty() || |
31 !clipRect.getRadii().bottomRight().isEmpty()) { | 32 !clipRect.getRadii().bottomRight().isEmpty()) { |
32 FloatRect topCorner(clipRect.rect().x(), clipRect.rect().y(), | 33 FloatRect topCorner(clipRect.rect().x(), clipRect.rect().y(), |
33 rect.maxX() - clipRect.rect().x(), | 34 rect.maxX() - clipRect.rect().x(), |
34 rect.maxY() - clipRect.rect().y()); | 35 rect.maxY() - clipRect.rect().y()); |
35 FloatRoundedRect::Radii topCornerRadii; | 36 FloatRoundedRect::Radii topCornerRadii; |
36 topCornerRadii.setTopLeft(clipRect.getRadii().topLeft()); | 37 topCornerRadii.setTopLeft(clipRect.getRadii().topLeft()); |
37 roundedRectClips.append(FloatRoundedRect(topCorner, topCornerRadii)); | 38 roundedRectClips.append(FloatRoundedRect(topCorner, topCornerRadii)); |
38 | 39 |
39 FloatRect bottomCorner(rect.x().toFloat(), rect.y().toFloat(), | 40 FloatRect bottomCorner(rect.x().toFloat(), rect.y().toFloat(), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 if (m_usePaintController) { | 82 if (m_usePaintController) { |
82 m_paintInfo.context.getPaintController().endItem<EndClipDisplayItem>( | 83 m_paintInfo.context.getPaintController().endItem<EndClipDisplayItem>( |
83 m_layoutObject, endType); | 84 m_layoutObject, endType); |
84 } else { | 85 } else { |
85 EndClipDisplayItem endClipDisplayItem(m_layoutObject, endType); | 86 EndClipDisplayItem endClipDisplayItem(m_layoutObject, endType); |
86 endClipDisplayItem.replay(m_paintInfo.context); | 87 endClipDisplayItem.replay(m_paintInfo.context); |
87 } | 88 } |
88 } | 89 } |
89 | 90 |
90 } // namespace blink | 91 } // namespace blink |
OLD | NEW |