| 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 "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "platform/PlatformExport.h" | 9 #include "platform/PlatformExport.h" |
| 10 #include "platform/RuntimeEnabledFeatures.h" | 10 #include "platform/RuntimeEnabledFeatures.h" |
| 11 #include "platform/geometry/FloatPoint.h" | 11 #include "platform/geometry/FloatPoint.h" |
| 12 #include "platform/graphics/paint/DisplayItem.h" | 12 #include "platform/graphics/paint/DisplayItem.h" |
| 13 #include "platform/graphics/paint/PaintRecord.h" | 13 #include "platform/graphics/paint/PaintRecord.h" |
| 14 #include "third_party/skia/include/core/SkDrawable.h" |
| 14 #include "third_party/skia/include/core/SkRefCnt.h" | 15 #include "third_party/skia/include/core/SkRefCnt.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 class PLATFORM_EXPORT DrawingDisplayItem final : public DisplayItem { | 19 class PLATFORM_EXPORT DrawingDisplayItem final : public DisplayItem { |
| 19 public: | 20 public: |
| 20 DISABLE_CFI_PERF | 21 DISABLE_CFI_PERF |
| 21 DrawingDisplayItem(const DisplayItemClient& client, | 22 DrawingDisplayItem(const DisplayItemClient& client, |
| 22 Type type, | 23 Type type, |
| 23 sk_sp<const PaintRecord> record, | 24 sk_sp<const PaintRecord> record, |
| 24 bool knownToBeOpaque = false) | 25 bool knownToBeOpaque = false) |
| 25 : DisplayItem(client, type, sizeof(*this)), | 26 : DisplayItem(client, type, sizeof(*this)), |
| 26 m_record(record && record->approximateOpCount() ? std::move(record) | 27 m_record(record && record->approximateOpCount() ? std::move(record) |
| 27 : nullptr), | 28 : nullptr), |
| 28 m_knownToBeOpaque(knownToBeOpaque) { | 29 m_knownToBeOpaque(knownToBeOpaque) { |
| 29 DCHECK(isDrawingType(type)); | 30 DCHECK(isDrawingType(type)); |
| 30 } | 31 } |
| 31 | 32 |
| 33 DrawingDisplayItem(const DisplayItemClient& client, |
| 34 Type type, |
| 35 sk_sp<const SkDrawable> drawable, |
| 36 bool knownToBeOpaque = false) |
| 37 : DisplayItem(client, type, sizeof(*this)), |
| 38 m_drawable(drawable), |
| 39 m_knownToBeOpaque(knownToBeOpaque) { |
| 40 DCHECK(isDrawingType(type)); |
| 41 } |
| 42 |
| 32 void replay(GraphicsContext&) const override; | 43 void replay(GraphicsContext&) const override; |
| 33 void appendToWebDisplayItemList(const IntRect&, | 44 void appendToWebDisplayItemList(const IntRect&, |
| 34 WebDisplayItemList*) const override; | 45 WebDisplayItemList*) const override; |
| 35 bool drawsContent() const override; | 46 bool drawsContent() const override; |
| 36 | 47 |
| 37 const PaintRecord* GetPaintRecord() const { return m_record.get(); } | 48 const PaintRecord* GetPaintRecord() const { return m_record.get(); } |
| 38 | 49 |
| 39 bool knownToBeOpaque() const { | 50 bool knownToBeOpaque() const { |
| 40 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 51 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 41 return m_knownToBeOpaque; | 52 return m_knownToBeOpaque; |
| 42 } | 53 } |
| 43 | 54 |
| 44 void analyzeForGpuRasterization(SkPictureGpuAnalyzer&) const override; | 55 void analyzeForGpuRasterization(SkPictureGpuAnalyzer&) const override; |
| 45 | 56 |
| 46 private: | 57 private: |
| 47 #ifndef NDEBUG | 58 #ifndef NDEBUG |
| 48 void dumpPropertiesAsDebugString(WTF::StringBuilder&) const override; | 59 void dumpPropertiesAsDebugString(WTF::StringBuilder&) const override; |
| 49 #endif | 60 #endif |
| 50 bool equals(const DisplayItem& other) const final; | 61 bool equals(const DisplayItem& other) const final; |
| 51 | 62 |
| 52 sk_sp<const PaintRecord> m_record; | 63 sk_sp<const PaintRecord> m_record; |
| 53 | 64 |
| 65 sk_sp<const SkDrawable> m_drawable; |
| 66 |
| 54 // True if there are no transparent areas. Only used for SlimmingPaintV2. | 67 // True if there are no transparent areas. Only used for SlimmingPaintV2. |
| 55 const bool m_knownToBeOpaque; | 68 const bool m_knownToBeOpaque; |
| 56 }; | 69 }; |
| 57 | 70 |
| 58 } // namespace blink | 71 } // namespace blink |
| 59 | 72 |
| 60 #endif // DrawingDisplayItem_h | 73 #endif // DrawingDisplayItem_h |
| OLD | NEW |