| 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 DrawingDisplayItem_h | 5 #ifndef DrawingDisplayItem_h |
| 6 #define DrawingDisplayItem_h | 6 #define DrawingDisplayItem_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/geometry/FloatPoint.h" | 9 #include "platform/geometry/FloatPoint.h" |
| 10 #include "platform/graphics/paint/DisplayItem.h" | 10 #include "platform/graphics/paint/DisplayItem.h" |
| 11 #include "third_party/skia/include/core/SkPicture.h" | 11 #include "third_party/skia/include/core/SkPicture.h" |
| 12 #include "wtf/PassOwnPtr.h" | 12 #include "wtf/PassOwnPtr.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class PLATFORM_EXPORT DrawingDisplayItem : public DisplayItem { | 16 class PLATFORM_EXPORT DrawingDisplayItem : public DisplayItem { |
| 17 public: | 17 public: |
| 18 #if ENABLE(ASSERT) | 18 #if ENABLE(ASSERT) |
| 19 enum UnderInvalidationCheckingMode { | 19 enum UnderInvalidationCheckingMode { |
| 20 CheckPicture, // Check if the new picture and the old picture are the sa
me | 20 CheckPicture, // Check if the new picture and the old picture are the sa
me |
| 21 CheckBitmap, // Check if the new picture and the old picture produce the
same bitmap | 21 CheckBitmap, // Check if the new picture and the old picture produce the
same bitmap |
| 22 }; | 22 }; |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 DrawingDisplayItem(const DisplayItemClientWrapper& client, Type type, PassRe
fPtr<const SkPicture> picture) | 25 static PassOwnPtr<DrawingDisplayItem> create(const DisplayItemClientWrapper&
client |
| 26 , Type type |
| 27 , PassRefPtr<const SkPicture> picture |
| 28 #if ENABLE(ASSERT) |
| 29 , UnderInvalidationCheckingMode underInvalidationCheckingMode = CheckPic
ture |
| 30 #endif |
| 31 ) |
| 32 { |
| 33 return adoptPtr(new DrawingDisplayItem(client |
| 34 , type |
| 35 , picture |
| 36 #if ENABLE(ASSERT) |
| 37 , underInvalidationCheckingMode |
| 38 #endif |
| 39 )); |
| 40 } |
| 41 |
| 42 DrawingDisplayItem(const DisplayItemClientWrapper& client |
| 43 , Type type |
| 44 , PassRefPtr<const SkPicture> picture |
| 45 #if ENABLE(ASSERT) |
| 46 , UnderInvalidationCheckingMode underInvalidationCheckingMode |
| 47 #endif |
| 48 ) |
| 26 : DisplayItem(client, type) | 49 : DisplayItem(client, type) |
| 27 , m_picture(picture && picture->approximateOpCount() ? picture : nullptr
) | 50 , m_picture(picture && picture->approximateOpCount() ? picture : nullptr
) |
| 51 { |
| 28 #if ENABLE(ASSERT) | 52 #if ENABLE(ASSERT) |
| 29 , m_underInvalidationCheckingMode(CheckPicture) | 53 m_underInvalidationCheckingMode = underInvalidationCheckingMode; |
| 30 #endif | 54 #endif |
| 31 { | |
| 32 ASSERT(isDrawingType(type)); | 55 ASSERT(isDrawingType(type)); |
| 33 } | 56 } |
| 34 | 57 |
| 35 static PassOwnPtr<DrawingDisplayItem> create(const DisplayItemClientWrapper&
client, Type type, PassRefPtr<const SkPicture> picture) | |
| 36 { | |
| 37 return adoptPtr(new DrawingDisplayItem(client, type, picture)); | |
| 38 } | |
| 39 | |
| 40 virtual void replay(GraphicsContext&); | 58 virtual void replay(GraphicsContext&); |
| 41 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override; | 59 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override; |
| 42 virtual bool drawsContent() const override; | 60 virtual bool drawsContent() const override; |
| 43 | 61 |
| 44 const SkPicture* picture() const { return m_picture.get(); } | 62 const SkPicture* picture() const { return m_picture.get(); } |
| 45 | 63 |
| 46 #if ENABLE(ASSERT) | 64 #if ENABLE(ASSERT) |
| 47 void setUnderInvalidationCheckingMode(UnderInvalidationCheckingMode mode) {
m_underInvalidationCheckingMode = mode; } | |
| 48 UnderInvalidationCheckingMode underInvalidationCheckingMode() const { return
m_underInvalidationCheckingMode; } | 65 UnderInvalidationCheckingMode underInvalidationCheckingMode() const { return
m_underInvalidationCheckingMode; } |
| 49 #endif | 66 #endif |
| 50 | 67 |
| 51 private: | 68 private: |
| 52 #ifndef NDEBUG | 69 #ifndef NDEBUG |
| 53 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const override
; | 70 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const override
; |
| 54 #endif | 71 #endif |
| 55 | 72 |
| 56 RefPtr<const SkPicture> m_picture; | 73 RefPtr<const SkPicture> m_picture; |
| 57 | 74 |
| 58 #if ENABLE(ASSERT) | 75 #if ENABLE(ASSERT) |
| 59 UnderInvalidationCheckingMode m_underInvalidationCheckingMode; | 76 UnderInvalidationCheckingMode m_underInvalidationCheckingMode; |
| 60 #endif | 77 #endif |
| 61 }; | 78 }; |
| 62 | 79 |
| 63 } // namespace blink | 80 } // namespace blink |
| 64 | 81 |
| 65 #endif // DrawingDisplayItem_h | 82 #endif // DrawingDisplayItem_h |
| OLD | NEW |