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