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 "platform/graphics/paint/ClipDisplayItem.h" | 5 #include "platform/graphics/paint/ClipDisplayItem.h" |
6 | 6 |
7 #include "platform/geometry/FloatRoundedRect.h" | 7 #include "platform/geometry/FloatRoundedRect.h" |
8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
9 #include "public/platform/WebDisplayItemList.h" | 9 #include "public/platform/WebDisplayItemList.h" |
10 #include "third_party/skia/include/core/SkScalar.h" | 10 #include "third_party/skia/include/core/SkScalar.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 void ClipDisplayItem::replay(GraphicsContext& context) const | 14 void ClipDisplayItem::replay(GraphicsContext& context) const |
15 { | 15 { |
16 context.save(); | 16 context.save(); |
17 // TODO(chrishtr): make this AntiAliased. Not anti-aliasing here is a workar
ound for a PDF rendering issue. | 17 // TODO(chrishtr): make this AntiAliased. Not anti-aliasing here is a workar
ound for a PDF rendering issue. |
18 // See crbug.com/590971. | 18 // See crbug.com/590971. |
19 context.clipRect(m_clipRect, NotAntiAliased); | 19 context.clipRect(m_clipRect, NotAntiAliased); |
20 | 20 |
21 for (const FloatRoundedRect& roundedRect : m_roundedRectClips) | 21 for (const FloatRoundedRect& roundedRect : m_roundedRectClips) |
22 context.clipRoundedRect(roundedRect); | 22 context.clipRoundedRect(roundedRect); |
23 } | 23 } |
24 | 24 |
25 void ClipDisplayItem::appendToWebDisplayItemList(const IntRect& visualRect, WebD
isplayItemList* list) const | 25 void ClipDisplayItem::appendToWebDisplayItemList(const IntRect& visualRect, WebD
isplayItemList* list) const |
26 { | 26 { |
27 WebVector<SkRRect> webRoundedRects(m_roundedRectClips.size()); | 27 WebVector<SkRRect> webRoundedRects(m_roundedRectClips.size()); |
28 for (size_t i = 0; i < m_roundedRectClips.size(); ++i) { | 28 for (size_t i = 0; i < m_roundedRectClips.size(); ++i) { |
29 FloatRoundedRect::Radii rectRadii = m_roundedRectClips[i].radii(); | 29 FloatRoundedRect::Radii rectRadii = m_roundedRectClips[i].getRadii(); |
30 SkVector skRadii[4]; | 30 SkVector skRadii[4]; |
31 skRadii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(rectRadii.topLeft(
).width()), | 31 skRadii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(rectRadii.topLeft(
).width()), |
32 SkIntToScalar(rectRadii.topLeft().height())); | 32 SkIntToScalar(rectRadii.topLeft().height())); |
33 skRadii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(rectRadii.topRigh
t().width()), | 33 skRadii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(rectRadii.topRigh
t().width()), |
34 SkIntToScalar(rectRadii.topRight().height())); | 34 SkIntToScalar(rectRadii.topRight().height())); |
35 skRadii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(rectRadii.bottomR
ight().width()), | 35 skRadii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(rectRadii.bottomR
ight().width()), |
36 SkIntToScalar(rectRadii.bottomRight().height())); | 36 SkIntToScalar(rectRadii.bottomRight().height())); |
37 skRadii[SkRRect::kLowerLeft_Corner].set(SkIntToScalar(rectRadii.bottomLe
ft().width()), | 37 skRadii[SkRRect::kLowerLeft_Corner].set(SkIntToScalar(rectRadii.bottomLe
ft().width()), |
38 SkIntToScalar(rectRadii.bottomLeft().height())); | 38 SkIntToScalar(rectRadii.bottomLeft().height())); |
39 SkRRect skRoundedRect; | 39 SkRRect skRoundedRect; |
(...skipping 16 matching lines...) Expand all Loading... |
56 #ifndef NDEBUG | 56 #ifndef NDEBUG |
57 void ClipDisplayItem::dumpPropertiesAsDebugString(WTF::StringBuilder& stringBuil
der) const | 57 void ClipDisplayItem::dumpPropertiesAsDebugString(WTF::StringBuilder& stringBuil
der) const |
58 { | 58 { |
59 DisplayItem::dumpPropertiesAsDebugString(stringBuilder); | 59 DisplayItem::dumpPropertiesAsDebugString(stringBuilder); |
60 stringBuilder.append(WTF::String::format(", clipRect: [%d,%d,%d,%d]", | 60 stringBuilder.append(WTF::String::format(", clipRect: [%d,%d,%d,%d]", |
61 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height())
); | 61 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height())
); |
62 } | 62 } |
63 #endif | 63 #endif |
64 | 64 |
65 } // namespace blink | 65 } // namespace blink |
OLD | NEW |