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 : public DisplayItem { | 18 class PLATFORM_EXPORT ClipDisplayItem : public PairedBeginDisplayItem { |
19 WTF_MAKE_FAST_ALLOCATED; | 19 WTF_MAKE_FAST_ALLOCATED; |
20 public: | 20 public: |
21 static PassOwnPtr<ClipDisplayItem> create(DisplayItemClient client, Type typ
e, const IntRect& clipRect, SkRegion::Op operation = SkRegion::kIntersect_Op) | 21 static PassOwnPtr<ClipDisplayItem> create(DisplayItemClient client, Type typ
e, const IntRect& clipRect, SkRegion::Op operation = SkRegion::kIntersect_Op) |
22 { | 22 { |
23 return adoptPtr(new ClipDisplayItem(client, type, clipRect, operation)); | 23 return adoptPtr(new ClipDisplayItem(client, type, clipRect, operation)); |
24 } | 24 } |
25 | 25 |
26 ClipDisplayItem(DisplayItemClient client, Type type, const IntRect& clipRect
, SkRegion::Op operation = SkRegion::kIntersect_Op) | 26 ClipDisplayItem(DisplayItemClient client, Type type, const IntRect& clipRect
, SkRegion::Op operation = SkRegion::kIntersect_Op) |
27 : DisplayItem(client, type) | 27 : PairedBeginDisplayItem(client, type) |
28 , m_clipRect(clipRect) | 28 , m_clipRect(clipRect) |
29 , m_operation(operation) | 29 , m_operation(operation) |
30 { | 30 { |
31 ASSERT(isClipType(type)); | 31 ASSERT(isClipType(type)); |
32 } | 32 } |
33 | 33 |
34 virtual void replay(GraphicsContext*) override; | 34 virtual void replay(GraphicsContext*) override; |
35 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override; | 35 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override; |
36 | 36 |
37 Vector<FloatRoundedRect>& roundedRectClips() { return m_roundedRectClips; } | 37 Vector<FloatRoundedRect>& roundedRectClips() { return m_roundedRectClips; } |
38 | 38 |
39 private: | 39 private: |
40 #ifndef NDEBUG | 40 #ifndef NDEBUG |
41 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const override
; | 41 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const override
; |
42 #endif | 42 #endif |
43 IntRect m_clipRect; | 43 IntRect m_clipRect; |
44 Vector<FloatRoundedRect> m_roundedRectClips; | 44 Vector<FloatRoundedRect> m_roundedRectClips; |
45 SkRegion::Op m_operation; | 45 SkRegion::Op m_operation; |
46 }; | 46 }; |
47 | 47 |
48 class PLATFORM_EXPORT EndClipDisplayItem : public DisplayItem { | 48 class PLATFORM_EXPORT EndClipDisplayItem : public PairedEndDisplayItem { |
49 WTF_MAKE_FAST_ALLOCATED; | 49 WTF_MAKE_FAST_ALLOCATED; |
50 public: | 50 public: |
51 static PassOwnPtr<EndClipDisplayItem> create(DisplayItemClient client, Type
type) | 51 static PassOwnPtr<EndClipDisplayItem> create(DisplayItemClient client, Type
type) |
52 { | 52 { |
53 return adoptPtr(new EndClipDisplayItem(client, type)); | 53 return adoptPtr(new EndClipDisplayItem(client, type)); |
54 } | 54 } |
55 | 55 |
56 EndClipDisplayItem(DisplayItemClient client, Type type) | 56 EndClipDisplayItem(DisplayItemClient client, Type type) |
57 : DisplayItem(client, type) | 57 : PairedEndDisplayItem(client, type) |
58 { | 58 { |
59 isEndClipType(type); | 59 ASSERT(isEndClipType(type)); |
60 } | 60 } |
61 | 61 |
62 virtual void replay(GraphicsContext*) override; | 62 virtual void replay(GraphicsContext*) override; |
63 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override; | 63 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override; |
| 64 |
| 65 private: |
| 66 #if ENABLE(ASSERT) |
| 67 virtual bool isEndAndPairedWith(const DisplayItem& other) const override fin
al { return other.isClip(); } |
| 68 #endif |
64 }; | 69 }; |
65 | 70 |
66 } // namespace blink | 71 } // namespace blink |
67 | 72 |
68 #endif // ClipDisplayItem_h | 73 #endif // ClipDisplayItem_h |
OLD | NEW |