| 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 static PassOwnPtr<DrawingDisplayItem> create(const DisplayItemClientWrapper&
client | 25 DrawingDisplayItem() : m_picture(nullptr) { } |
| 26 , Type type | 26 |
| 27 , PassRefPtr<const SkPicture> picture | 27 void setNew(PassRefPtr<const SkPicture> picture |
| 28 #if ENABLE(ASSERT) | 28 #if ENABLE(ASSERT) |
| 29 , UnderInvalidationCheckingMode underInvalidationCheckingMode = CheckPic
ture | 29 , UnderInvalidationCheckingMode underInvalidationCheckingMode = CheckPic
ture |
| 30 #endif | 30 #endif |
| 31 ) | 31 ) |
| 32 { | 32 { |
| 33 return adoptPtr(new DrawingDisplayItem(client | 33 if (picture && picture->approximateOpCount()) |
| 34 , type | 34 m_picture = picture; |
| 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 ) | |
| 49 : DisplayItem(client, type) | |
| 50 , m_picture(picture && picture->approximateOpCount() ? picture : nullptr
) | |
| 51 { | |
| 52 #if ENABLE(ASSERT) | 35 #if ENABLE(ASSERT) |
| 53 m_underInvalidationCheckingMode = underInvalidationCheckingMode; | 36 m_underInvalidationCheckingMode = underInvalidationCheckingMode; |
| 54 #endif | 37 #endif |
| 55 ASSERT(isDrawingType(type)); | 38 ASSERT(isDrawingType(type())); |
| 56 } | 39 } |
| 57 | 40 |
| 58 virtual void replay(GraphicsContext&); | 41 virtual void replay(GraphicsContext&); |
| 59 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override; | 42 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override; |
| 60 virtual bool drawsContent() const override; | 43 virtual bool drawsContent() const override; |
| 61 | 44 |
| 62 const SkPicture* picture() const { return m_picture.get(); } | 45 const SkPicture* picture() const { return m_picture.get(); } |
| 63 | 46 |
| 64 #if ENABLE(ASSERT) | 47 #if ENABLE(ASSERT) |
| 65 UnderInvalidationCheckingMode underInvalidationCheckingMode() const { return
m_underInvalidationCheckingMode; } | 48 UnderInvalidationCheckingMode underInvalidationCheckingMode() const { return
m_underInvalidationCheckingMode; } |
| 66 #endif | 49 #endif |
| 67 | 50 |
| 68 private: | 51 private: |
| 69 #ifndef NDEBUG | 52 #ifndef NDEBUG |
| 70 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const override
; | 53 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const override
; |
| 71 #endif | 54 #endif |
| 72 | 55 |
| 73 RefPtr<const SkPicture> m_picture; | 56 RefPtr<const SkPicture> m_picture; |
| 74 | 57 |
| 75 #if ENABLE(ASSERT) | 58 #if ENABLE(ASSERT) |
| 76 UnderInvalidationCheckingMode m_underInvalidationCheckingMode; | 59 UnderInvalidationCheckingMode m_underInvalidationCheckingMode; |
| 77 #endif | 60 #endif |
| 78 }; | 61 }; |
| 79 | 62 |
| 80 } // namespace blink | 63 } // namespace blink |
| 81 | 64 |
| 82 #endif // DrawingDisplayItem_h | 65 #endif // DrawingDisplayItem_h |
| OLD | NEW |