| 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 "platform/graphics/paint/ClipDisplayItem.h" | 6 #include "platform/graphics/paint/ClipDisplayItem.h" |
| 7 | 7 |
| 8 #include "platform/geometry/FloatRoundedRect.h" | 8 #include "platform/geometry/FloatRoundedRect.h" |
| 9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
| 10 #include "public/platform/WebDisplayItemList.h" | 10 #include "public/platform/WebDisplayItemList.h" |
| 11 #include "third_party/skia/include/core/SkScalar.h" | 11 #include "third_party/skia/include/core/SkScalar.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 void ClipDisplayItem::replay(GraphicsContext& context) | 15 void ClipDisplayItem::replay(GraphicsContext& context) |
| 16 { | 16 { |
| 17 context.save(); | 17 context.save(); |
| 18 context.clipRect(m_clipRect, NotAntiAliased, m_operation); | 18 context.clipRect(m_clipRect, NotAntiAliased, SkRegion::kIntersect_Op); |
| 19 for (FloatRoundedRect roundedRect : m_roundedRectClips) | 19 for (FloatRoundedRect roundedRect : m_roundedRectClips) |
| 20 context.clipRoundedRect(roundedRect, m_operation); | 20 context.clipRoundedRect(roundedRect, SkRegion::kIntersect_Op); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void ClipDisplayItem::appendToWebDisplayItemList(WebDisplayItemList* list) const | 23 void ClipDisplayItem::appendToWebDisplayItemList(WebDisplayItemList* list) const |
| 24 { | 24 { |
| 25 WebVector<SkRRect> webRoundedRects(m_roundedRectClips.size()); | 25 WebVector<SkRRect> webRoundedRects(m_roundedRectClips.size()); |
| 26 for (size_t i = 0; i < m_roundedRectClips.size(); ++i) { | 26 for (size_t i = 0; i < m_roundedRectClips.size(); ++i) { |
| 27 FloatRoundedRect::Radii rectRadii = m_roundedRectClips[i].radii(); | 27 FloatRoundedRect::Radii rectRadii = m_roundedRectClips[i].radii(); |
| 28 SkVector skRadii[4]; | 28 SkVector skRadii[4]; |
| 29 skRadii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(rectRadii.topLeft(
).width()), | 29 skRadii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(rectRadii.topLeft(
).width()), |
| 30 SkIntToScalar(rectRadii.topLeft().height())); | 30 SkIntToScalar(rectRadii.topLeft().height())); |
| 31 skRadii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(rectRadii.topRigh
t().width()), | 31 skRadii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(rectRadii.topRigh
t().width()), |
| 32 SkIntToScalar(rectRadii.topRight().height())); | 32 SkIntToScalar(rectRadii.topRight().height())); |
| 33 skRadii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(rectRadii.bottomR
ight().width()), | 33 skRadii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(rectRadii.bottomR
ight().width()), |
| 34 SkIntToScalar(rectRadii.bottomRight().height())); | 34 SkIntToScalar(rectRadii.bottomRight().height())); |
| 35 skRadii[SkRRect::kLowerLeft_Corner].set(SkIntToScalar(rectRadii.bottomLe
ft().width()), | 35 skRadii[SkRRect::kLowerLeft_Corner].set(SkIntToScalar(rectRadii.bottomLe
ft().width()), |
| 36 SkIntToScalar(rectRadii.bottomLeft().height())); | 36 SkIntToScalar(rectRadii.bottomLeft().height())); |
| 37 SkRRect skRoundedRect; | 37 SkRRect skRoundedRect; |
| 38 skRoundedRect.setRectRadii(m_roundedRectClips[i].rect(), skRadii); | 38 skRoundedRect.setRectRadii(m_roundedRectClips[i].rect(), skRadii); |
| 39 webRoundedRects[i] = skRoundedRect; | 39 webRoundedRects[i] = skRoundedRect; |
| 40 } | 40 } |
| 41 // FIXME: needs to include the SkRegion::Op | |
| 42 list->appendClipItem(m_clipRect, webRoundedRects); | 41 list->appendClipItem(m_clipRect, webRoundedRects); |
| 43 } | 42 } |
| 44 | 43 |
| 45 void EndClipDisplayItem::replay(GraphicsContext& context) | 44 void EndClipDisplayItem::replay(GraphicsContext& context) |
| 46 { | 45 { |
| 47 context.restore(); | 46 context.restore(); |
| 48 } | 47 } |
| 49 | 48 |
| 50 void EndClipDisplayItem::appendToWebDisplayItemList(WebDisplayItemList* list) co
nst | 49 void EndClipDisplayItem::appendToWebDisplayItemList(WebDisplayItemList* list) co
nst |
| 51 { | 50 { |
| 52 list->appendEndClipItem(); | 51 list->appendEndClipItem(); |
| 53 } | 52 } |
| 54 | 53 |
| 55 #ifndef NDEBUG | 54 #ifndef NDEBUG |
| 56 void ClipDisplayItem::dumpPropertiesAsDebugString(WTF::StringBuilder& stringBuil
der) const | 55 void ClipDisplayItem::dumpPropertiesAsDebugString(WTF::StringBuilder& stringBuil
der) const |
| 57 { | 56 { |
| 58 DisplayItem::dumpPropertiesAsDebugString(stringBuilder); | 57 DisplayItem::dumpPropertiesAsDebugString(stringBuilder); |
| 59 stringBuilder.append(WTF::String::format(", clipRect: [%d,%d,%d,%d]", | 58 stringBuilder.append(WTF::String::format(", clipRect: [%d,%d,%d,%d]", |
| 60 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height())
); | 59 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height())
); |
| 61 } | 60 } |
| 62 #endif | 61 #endif |
| 63 | 62 |
| 64 } // namespace blink | 63 } // namespace blink |
| OLD | NEW |