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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/RoundedInnerRectClipper.h" | 6 #include "core/paint/RoundedInnerRectClipper.h" |
7 | 7 |
8 #include "core/layout/LayoutBox.h" | 8 #include "core/layout/LayoutBox.h" |
9 #include "core/paint/PaintInfo.h" | 9 #include "core/paint/PaintInfo.h" |
10 #include "platform/graphics/paint/ClipDisplayItem.h" | 10 #include "platform/graphics/paint/ClipDisplayItem.h" |
11 #include "platform/graphics/paint/DisplayItemList.h" | 11 #include "platform/graphics/paint/PaintController.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 RoundedInnerRectClipper::RoundedInnerRectClipper(const LayoutObject& layoutObjec
t, const PaintInfo& paintInfo, const LayoutRect& rect, const FloatRoundedRect& c
lipRect, RoundedInnerRectClipperBehavior behavior) | 15 RoundedInnerRectClipper::RoundedInnerRectClipper(const LayoutObject& layoutObjec
t, const PaintInfo& paintInfo, const LayoutRect& rect, const FloatRoundedRect& c
lipRect, RoundedInnerRectClipperBehavior behavior) |
16 : m_layoutObject(layoutObject) | 16 : m_layoutObject(layoutObject) |
17 , m_paintInfo(paintInfo) | 17 , m_paintInfo(paintInfo) |
18 , m_useDisplayItemList(behavior == ApplyToDisplayListIfEnabled) | 18 , m_usePaintController(behavior == ApplyToDisplayListIfEnabled) |
19 , m_clipType(m_useDisplayItemList ? m_paintInfo.displayItemTypeForClipping()
: DisplayItem::ClipBoxPaintPhaseFirst) | 19 , m_clipType(m_usePaintController ? m_paintInfo.displayItemTypeForClipping()
: DisplayItem::ClipBoxPaintPhaseFirst) |
20 { | 20 { |
21 Vector<FloatRoundedRect> roundedRectClips; | 21 Vector<FloatRoundedRect> roundedRectClips; |
22 if (clipRect.isRenderable()) { | 22 if (clipRect.isRenderable()) { |
23 roundedRectClips.append(clipRect); | 23 roundedRectClips.append(clipRect); |
24 } else { | 24 } else { |
25 // We create a rounded rect for each of the corners and clip it, while m
aking sure we clip opposing corners together. | 25 // We create a rounded rect for each of the corners and clip it, while m
aking sure we clip opposing corners together. |
26 if (!clipRect.radii().topLeft().isEmpty() || !clipRect.radii().bottomRig
ht().isEmpty()) { | 26 if (!clipRect.radii().topLeft().isEmpty() || !clipRect.radii().bottomRig
ht().isEmpty()) { |
27 FloatRect topCorner(clipRect.rect().x(), clipRect.rect().y(), rect.m
axX() - clipRect.rect().x(), rect.maxY() - clipRect.rect().y()); | 27 FloatRect topCorner(clipRect.rect().x(), clipRect.rect().y(), rect.m
axX() - clipRect.rect().x(), rect.maxY() - clipRect.rect().y()); |
28 FloatRoundedRect::Radii topCornerRadii; | 28 FloatRoundedRect::Radii topCornerRadii; |
29 topCornerRadii.setTopLeft(clipRect.radii().topLeft()); | 29 topCornerRadii.setTopLeft(clipRect.radii().topLeft()); |
(...skipping 11 matching lines...) Expand all Loading... |
41 topCornerRadii.setTopRight(clipRect.radii().topRight()); | 41 topCornerRadii.setTopRight(clipRect.radii().topRight()); |
42 roundedRectClips.append(FloatRoundedRect(topCorner, topCornerRadii))
; | 42 roundedRectClips.append(FloatRoundedRect(topCorner, topCornerRadii))
; |
43 | 43 |
44 FloatRect bottomCorner(clipRect.rect().x(), rect.y().toFloat(), rect
.maxX() - clipRect.rect().x(), clipRect.rect().maxY() - rect.y().toFloat()); | 44 FloatRect bottomCorner(clipRect.rect().x(), rect.y().toFloat(), rect
.maxX() - clipRect.rect().x(), clipRect.rect().maxY() - rect.y().toFloat()); |
45 FloatRoundedRect::Radii bottomCornerRadii; | 45 FloatRoundedRect::Radii bottomCornerRadii; |
46 bottomCornerRadii.setBottomLeft(clipRect.radii().bottomLeft()); | 46 bottomCornerRadii.setBottomLeft(clipRect.radii().bottomLeft()); |
47 roundedRectClips.append(FloatRoundedRect(bottomCorner, bottomCornerR
adii)); | 47 roundedRectClips.append(FloatRoundedRect(bottomCorner, bottomCornerR
adii)); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 if (m_useDisplayItemList) { | 51 if (m_usePaintController) { |
52 ASSERT(m_paintInfo.context->displayItemList()); | 52 ASSERT(m_paintInfo.context->paintController()); |
53 m_paintInfo.context->displayItemList()->createAndAppend<ClipDisplayItem>
(layoutObject, m_clipType, LayoutRect::infiniteIntRect(), roundedRectClips); | 53 m_paintInfo.context->paintController()->createAndAppend<ClipDisplayItem>
(layoutObject, m_clipType, LayoutRect::infiniteIntRect(), roundedRectClips); |
54 } else { | 54 } else { |
55 ClipDisplayItem clipDisplayItem(layoutObject, m_clipType, LayoutRect::in
finiteIntRect(), roundedRectClips); | 55 ClipDisplayItem clipDisplayItem(layoutObject, m_clipType, LayoutRect::in
finiteIntRect(), roundedRectClips); |
56 clipDisplayItem.replay(*paintInfo.context); | 56 clipDisplayItem.replay(*paintInfo.context); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 RoundedInnerRectClipper::~RoundedInnerRectClipper() | 60 RoundedInnerRectClipper::~RoundedInnerRectClipper() |
61 { | 61 { |
62 DisplayItem::Type endType = DisplayItem::clipTypeToEndClipType(m_clipType); | 62 DisplayItem::Type endType = DisplayItem::clipTypeToEndClipType(m_clipType); |
63 if (m_useDisplayItemList) { | 63 if (m_usePaintController) { |
64 ASSERT(m_paintInfo.context->displayItemList()); | 64 ASSERT(m_paintInfo.context->paintController()); |
65 m_paintInfo.context->displayItemList()->endItem<EndClipDisplayItem>(m_la
youtObject, endType); | 65 m_paintInfo.context->paintController()->endItem<EndClipDisplayItem>(m_la
youtObject, endType); |
66 } else { | 66 } else { |
67 EndClipDisplayItem endClipDisplayItem(m_layoutObject, endType); | 67 EndClipDisplayItem endClipDisplayItem(m_layoutObject, endType); |
68 endClipDisplayItem.replay(*m_paintInfo.context); | 68 endClipDisplayItem.replay(*m_paintInfo.context); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 } // namespace blink | 72 } // namespace blink |
OLD | NEW |