| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 DisplayItemList_h | 5 #ifndef DisplayItemList_h |
| 6 #define DisplayItemList_h | 6 #define DisplayItemList_h |
| 7 | 7 |
| 8 #include "platform/graphics/ContiguousContainer.h" | 8 #include "platform/graphics/ContiguousContainer.h" |
| 9 #include "platform/graphics/paint/DisplayItem.h" | 9 #include "platform/graphics/paint/DisplayItem.h" |
| 10 #include "platform/graphics/paint/Transform3DDisplayItem.h" | 10 #include "platform/graphics/paint/Transform3DDisplayItem.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 static const size_t kMaximumDisplayItemSize = | 25 static const size_t kMaximumDisplayItemSize = |
| 26 sizeof(BeginTransform3DDisplayItem); | 26 sizeof(BeginTransform3DDisplayItem); |
| 27 | 27 |
| 28 // A container for a list of display items. | 28 // A container for a list of display items. |
| 29 class PLATFORM_EXPORT DisplayItemList | 29 class PLATFORM_EXPORT DisplayItemList |
| 30 : public ContiguousContainer<DisplayItem, kDisplayItemAlignment> { | 30 : public ContiguousContainer<DisplayItem, kDisplayItemAlignment> { |
| 31 public: | 31 public: |
| 32 DisplayItemList(size_t initial_size_bytes) | 32 DisplayItemList(size_t initial_size_bytes) |
| 33 : ContiguousContainer(kMaximumDisplayItemSize, initial_size_bytes) {} | 33 : ContiguousContainer(kMaximumDisplayItemSize, initial_size_bytes) {} |
| 34 DisplayItemList(DisplayItemList&& source) | 34 DisplayItemList(DisplayItemList&& source) |
| 35 : ContiguousContainer(std::move(source)) {} | 35 : ContiguousContainer(std::move(source)), |
| 36 visual_rects_(std::move(source.visual_rects_)) {} |
| 36 | 37 |
| 37 DisplayItemList& operator=(DisplayItemList&& source) { | 38 DisplayItemList& operator=(DisplayItemList&& source) { |
| 38 ContiguousContainer::operator=(std::move(source)); | 39 ContiguousContainer::operator=(std::move(source)); |
| 40 visual_rects_ = std::move(source.visual_rects_); |
| 39 return *this; | 41 return *this; |
| 40 } | 42 } |
| 41 | 43 |
| 42 DisplayItem& AppendByMoving(DisplayItem& item) { | 44 DisplayItem& AppendByMoving(DisplayItem&); |
| 43 #ifndef NDEBUG | 45 |
| 44 String original_debug_string = item.AsDebugString(); | 46 bool HasVisualRect(size_t index) const { |
| 45 #endif | 47 return index < visual_rects_.size(); |
| 46 DCHECK(item.HasValidClient()); | |
| 47 DisplayItem& result = | |
| 48 ContiguousContainer::AppendByMoving(item, item.DerivedSize()); | |
| 49 // ContiguousContainer::AppendByMoving() calls an in-place constructor | |
| 50 // on item which replaces it with a tombstone/"dead display item" that | |
| 51 // can be safely destructed but should never be used. | |
| 52 DCHECK(!item.HasValidClient()); | |
| 53 #ifndef NDEBUG | |
| 54 // Save original debug string in the old item to help debugging. | |
| 55 item.SetClientDebugString(original_debug_string); | |
| 56 #endif | |
| 57 item.visual_rect_ = result.visual_rect_; | |
| 58 return result; | |
| 59 } | 48 } |
| 49 IntRect VisualRect(size_t index) const { |
| 50 DCHECK(HasVisualRect(index)); |
| 51 return visual_rects_[index]; |
| 52 } |
| 53 |
| 54 void AppendVisualRect(const IntRect& visual_rect); |
| 60 | 55 |
| 61 // Useful for iterating with a range-based for loop. | 56 // Useful for iterating with a range-based for loop. |
| 62 template <typename Iterator> | 57 template <typename Iterator> |
| 63 class Range { | 58 class Range { |
| 64 public: | 59 public: |
| 65 Range(const Iterator& begin, const Iterator& end) | 60 Range(const Iterator& begin, const Iterator& end) |
| 66 : begin_(begin), end_(end) {} | 61 : begin_(begin), end_(end) {} |
| 67 Iterator begin() const { return begin_; } | 62 Iterator begin() const { return begin_; } |
| 68 Iterator end() const { return end_; } | 63 Iterator end() const { return end_; } |
| 69 | 64 |
| 70 private: | 65 private: |
| 71 Iterator begin_; | 66 Iterator begin_; |
| 72 Iterator end_; | 67 Iterator end_; |
| 73 }; | 68 }; |
| 74 Range<iterator> ItemsInPaintChunk(const PaintChunk&); | 69 Range<iterator> ItemsInPaintChunk(const PaintChunk&); |
| 75 Range<const_iterator> ItemsInPaintChunk(const PaintChunk&) const; | 70 Range<const_iterator> ItemsInPaintChunk(const PaintChunk&) const; |
| 76 | 71 |
| 77 enum JsonOptions { | 72 enum JsonOptions { |
| 78 kDefault = 0, | 73 kDefault = 0, |
| 79 kShowPaintRecords = 1, | 74 kShowPaintRecords = 1, |
| 80 kSkipNonDrawings = 1 << 1, | 75 kSkipNonDrawings = 1 << 1, |
| 81 kShowClientDebugName = 1 << 2, | 76 kShowClientDebugName = 1 << 2, |
| 82 kShownOnlyDisplayItemTypes = 1 << 3 | 77 kShownOnlyDisplayItemTypes = 1 << 3 |
| 83 }; | 78 }; |
| 84 typedef unsigned JsonFlags; | 79 typedef unsigned JsonFlags; |
| 85 | 80 |
| 86 std::unique_ptr<JSONArray> SubsequenceAsJSON(size_t begin_index, | 81 std::unique_ptr<JSONArray> SubsequenceAsJSON(size_t begin_index, |
| 87 size_t end_index, | 82 size_t end_index, |
| 88 JsonFlags options) const; | 83 JsonFlags options) const; |
| 84 |
| 85 private: |
| 86 Vector<IntRect> visual_rects_; |
| 89 }; | 87 }; |
| 90 | 88 |
| 91 } // namespace blink | 89 } // namespace blink |
| 92 | 90 |
| 93 #endif // DisplayItemList_h | 91 #endif // DisplayItemList_h |
| OLD | NEW |