| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "platform/graphics/paint/DisplayItemList.h" | 5 #include "platform/graphics/paint/DisplayItemList.h" |
| 6 | 6 |
| 7 #include "platform/graphics/LoggingCanvas.h" | 7 #include "platform/graphics/LoggingCanvas.h" |
| 8 #include "platform/graphics/paint/DrawingDisplayItem.h" | 8 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 9 #include "platform/graphics/paint/PaintChunk.h" | 9 #include "platform/graphics/paint/PaintChunk.h" |
| 10 | 10 |
| 11 #ifndef NDEBUG | 11 #ifndef NDEBUG |
| 12 #include "platform/wtf/text/WTFString.h" | 12 #include "platform/wtf/text/WTFString.h" |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 DisplayItem& DisplayItemList::AppendByMoving(DisplayItem& item) { |
| 18 #ifndef NDEBUG |
| 19 String original_debug_string = item.AsDebugString(); |
| 20 #endif |
| 21 DCHECK(item.HasValidClient()); |
| 22 DisplayItem& result = |
| 23 ContiguousContainer::AppendByMoving(item, item.DerivedSize()); |
| 24 // ContiguousContainer::appendByMoving() calls an in-place constructor |
| 25 // on item which replaces it with a tombstone/"dead display item" that |
| 26 // can be safely destructed but should never be used. |
| 27 DCHECK(!item.HasValidClient()); |
| 28 #ifndef NDEBUG |
| 29 // Save original debug string in the old item to help debugging. |
| 30 item.SetClientDebugString(original_debug_string); |
| 31 #endif |
| 32 return result; |
| 33 } |
| 34 |
| 35 void DisplayItemList::AppendVisualRect(const IntRect& visual_rect) { |
| 36 visual_rects_.push_back(visual_rect); |
| 37 } |
| 38 |
| 17 DisplayItemList::Range<DisplayItemList::iterator> | 39 DisplayItemList::Range<DisplayItemList::iterator> |
| 18 DisplayItemList::ItemsInPaintChunk(const PaintChunk& paint_chunk) { | 40 DisplayItemList::ItemsInPaintChunk(const PaintChunk& paint_chunk) { |
| 19 return Range<iterator>(begin() + paint_chunk.begin_index, | 41 return Range<iterator>(begin() + paint_chunk.begin_index, |
| 20 begin() + paint_chunk.end_index); | 42 begin() + paint_chunk.end_index); |
| 21 } | 43 } |
| 22 | 44 |
| 23 DisplayItemList::Range<DisplayItemList::const_iterator> | 45 DisplayItemList::Range<DisplayItemList::const_iterator> |
| 24 DisplayItemList::ItemsInPaintChunk(const PaintChunk& paint_chunk) const { | 46 DisplayItemList::ItemsInPaintChunk(const PaintChunk& paint_chunk) const { |
| 25 return Range<const_iterator>(begin() + paint_chunk.begin_index, | 47 return Range<const_iterator>(begin() + paint_chunk.begin_index, |
| 26 begin() + paint_chunk.end_index); | 48 begin() + paint_chunk.end_index); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 #ifndef NDEBUG | 91 #ifndef NDEBUG |
| 70 if ((options & kShowPaintRecords) && display_item.IsDrawing()) { | 92 if ((options & kShowPaintRecords) && display_item.IsDrawing()) { |
| 71 const DrawingDisplayItem& item = | 93 const DrawingDisplayItem& item = |
| 72 static_cast<const DrawingDisplayItem&>(display_item); | 94 static_cast<const DrawingDisplayItem&>(display_item); |
| 73 if (const PaintRecord* record = item.GetPaintRecord().get()) { | 95 if (const PaintRecord* record = item.GetPaintRecord().get()) { |
| 74 json->SetString("record", RecordAsDebugString(record)); | 96 json->SetString("record", RecordAsDebugString(record)); |
| 75 } | 97 } |
| 76 } | 98 } |
| 77 #endif | 99 #endif |
| 78 } | 100 } |
| 79 | 101 if (HasVisualRect(i)) { |
| 80 json->SetString("visualRect", display_item.VisualRect().ToString()); | 102 IntRect local_visual_rect = VisualRect(i); |
| 81 | 103 json->SetString( |
| 104 "visualRect", |
| 105 String::Format("[%d,%d %dx%d]", local_visual_rect.X(), |
| 106 local_visual_rect.Y(), local_visual_rect.Width(), |
| 107 local_visual_rect.Height())); |
| 108 } |
| 82 json_array->PushObject(std::move(json)); | 109 json_array->PushObject(std::move(json)); |
| 83 } | 110 } |
| 84 return json_array; | 111 return json_array; |
| 85 } | 112 } |
| 86 | 113 |
| 87 } // namespace blink | 114 } // namespace blink |
| OLD | NEW |