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 #ifndef ClipDisplayItem_h | 5 #ifndef ClipDisplayItem_h |
6 #define ClipDisplayItem_h | 6 #define ClipDisplayItem_h |
7 | 7 |
8 #include "SkRegion.h" | 8 #include "SkRegion.h" |
9 #include "platform/PlatformExport.h" | 9 #include "platform/PlatformExport.h" |
10 #include "platform/geometry/FloatRoundedRect.h" | 10 #include "platform/geometry/FloatRoundedRect.h" |
11 #include "platform/geometry/IntRect.h" | 11 #include "platform/geometry/IntRect.h" |
12 #include "platform/graphics/paint/DisplayItem.h" | 12 #include "platform/graphics/paint/DisplayItem.h" |
13 #include "wtf/PassOwnPtr.h" | 13 #include "wtf/PassOwnPtr.h" |
14 #include "wtf/Vector.h" | 14 #include "wtf/Vector.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 class PLATFORM_EXPORT ClipDisplayItem final : public PairedBeginDisplayItem { | 18 class PLATFORM_EXPORT ClipDisplayItem final : public PairedBeginDisplayItem { |
19 public: | 19 public: |
20 ClipDisplayItem(const DisplayItemClientWrapper& client, Type type, const Int
Rect& clipRect) | 20 ClipDisplayItem(const DisplayItemClient& client, Type type, const IntRect& c
lipRect) |
21 : PairedBeginDisplayItem(client, type, sizeof(*this)) | 21 : PairedBeginDisplayItem(client, type, sizeof(*this)) |
22 , m_clipRect(clipRect) | 22 , m_clipRect(clipRect) |
23 { | 23 { |
24 ASSERT(isClipType(type)); | 24 ASSERT(isClipType(type)); |
25 } | 25 } |
26 | 26 |
27 ClipDisplayItem(const DisplayItemClientWrapper& client, Type type, const Int
Rect& clipRect, Vector<FloatRoundedRect>& roundedRectClips) | 27 ClipDisplayItem(const DisplayItemClient& client, Type type, const IntRect& c
lipRect, Vector<FloatRoundedRect>& roundedRectClips) |
28 : ClipDisplayItem(client, type, clipRect) | 28 : ClipDisplayItem(client, type, clipRect) |
29 { | 29 { |
30 m_roundedRectClips.swap(roundedRectClips); | 30 m_roundedRectClips.swap(roundedRectClips); |
31 } | 31 } |
32 | 32 |
33 void replay(GraphicsContext&) const override; | 33 void replay(GraphicsContext&) const override; |
34 void appendToWebDisplayItemList(const IntRect&, WebDisplayItemList*) const o
verride; | 34 void appendToWebDisplayItemList(const IntRect&, WebDisplayItemList*) const o
verride; |
35 | 35 |
36 private: | 36 private: |
37 #ifndef NDEBUG | 37 #ifndef NDEBUG |
38 void dumpPropertiesAsDebugString(WTF::StringBuilder&) const override; | 38 void dumpPropertiesAsDebugString(WTF::StringBuilder&) const override; |
39 #endif | 39 #endif |
40 #if ENABLE(ASSERT) | 40 #if ENABLE(ASSERT) |
41 bool equals(const DisplayItem& other) const final | 41 bool equals(const DisplayItem& other) const final |
42 { | 42 { |
43 return DisplayItem::equals(other) | 43 return DisplayItem::equals(other) |
44 && m_clipRect == static_cast<const ClipDisplayItem&>(other).m_clipRe
ct | 44 && m_clipRect == static_cast<const ClipDisplayItem&>(other).m_clipRe
ct |
45 && m_roundedRectClips == static_cast<const ClipDisplayItem&>(other).
m_roundedRectClips; | 45 && m_roundedRectClips == static_cast<const ClipDisplayItem&>(other).
m_roundedRectClips; |
46 } | 46 } |
47 #endif | 47 #endif |
48 | 48 |
49 const IntRect m_clipRect; | 49 const IntRect m_clipRect; |
50 Vector<FloatRoundedRect> m_roundedRectClips; | 50 Vector<FloatRoundedRect> m_roundedRectClips; |
51 }; | 51 }; |
52 | 52 |
53 class PLATFORM_EXPORT EndClipDisplayItem final : public PairedEndDisplayItem { | 53 class PLATFORM_EXPORT EndClipDisplayItem final : public PairedEndDisplayItem { |
54 public: | 54 public: |
55 EndClipDisplayItem(const DisplayItemClientWrapper& client, Type type) | 55 EndClipDisplayItem(const DisplayItemClient& client, Type type) |
56 : PairedEndDisplayItem(client, type, sizeof(*this)) | 56 : PairedEndDisplayItem(client, type, sizeof(*this)) |
57 { | 57 { |
58 ASSERT(isEndClipType(type)); | 58 ASSERT(isEndClipType(type)); |
59 } | 59 } |
60 | 60 |
61 void replay(GraphicsContext&) const override; | 61 void replay(GraphicsContext&) const override; |
62 void appendToWebDisplayItemList(const IntRect&, WebDisplayItemList*) const o
verride; | 62 void appendToWebDisplayItemList(const IntRect&, WebDisplayItemList*) const o
verride; |
63 | 63 |
64 private: | 64 private: |
65 #if ENABLE(ASSERT) | 65 #if ENABLE(ASSERT) |
66 bool isEndAndPairedWith(DisplayItem::Type otherType) const final { return Di
splayItem::isClipType(otherType); } | 66 bool isEndAndPairedWith(DisplayItem::Type otherType) const final { return Di
splayItem::isClipType(otherType); } |
67 #endif | 67 #endif |
68 }; | 68 }; |
69 | 69 |
70 } // namespace blink | 70 } // namespace blink |
71 | 71 |
72 #endif // ClipDisplayItem_h | 72 #endif // ClipDisplayItem_h |
OLD | NEW |