| 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/paint/DrawingDisplayItem.h" | 8 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 8 #include "platform/graphics/paint/PaintChunk.h" | 9 #include "platform/graphics/paint/PaintChunk.h" |
| 9 #include "third_party/skia/include/core/SkPictureAnalyzer.h" | 10 #include "third_party/skia/include/core/SkPictureAnalyzer.h" |
| 10 | 11 |
| 11 #ifndef NDEBUG | 12 #ifndef NDEBUG |
| 12 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
| 13 #endif | 14 #endif |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 41 return Range<iterator>(begin() + paintChunk.beginIndex, | 42 return Range<iterator>(begin() + paintChunk.beginIndex, |
| 42 begin() + paintChunk.endIndex); | 43 begin() + paintChunk.endIndex); |
| 43 } | 44 } |
| 44 | 45 |
| 45 DisplayItemList::Range<DisplayItemList::const_iterator> | 46 DisplayItemList::Range<DisplayItemList::const_iterator> |
| 46 DisplayItemList::itemsInPaintChunk(const PaintChunk& paintChunk) const { | 47 DisplayItemList::itemsInPaintChunk(const PaintChunk& paintChunk) const { |
| 47 return Range<const_iterator>(begin() + paintChunk.beginIndex, | 48 return Range<const_iterator>(begin() + paintChunk.beginIndex, |
| 48 begin() + paintChunk.endIndex); | 49 begin() + paintChunk.endIndex); |
| 49 } | 50 } |
| 50 | 51 |
| 52 std::unique_ptr<JSONArray> DisplayItemList::subsequenceAsJSON( |
| 53 size_t beginIndex, |
| 54 size_t endIndex, |
| 55 bool showPictures, |
| 56 bool skipNonDrawings) const { |
| 57 std::unique_ptr<JSONArray> jsonArray = JSONArray::create(); |
| 58 size_t i = 0; |
| 59 for (auto it = begin(); it != end(); ++it, ++i) { |
| 60 std::unique_ptr<JSONObject> json = JSONObject::create(); |
| 61 if (i < beginIndex || i >= endIndex) |
| 62 continue; |
| 63 |
| 64 const DisplayItem& displayItem = *it; |
| 65 if (skipNonDrawings && !displayItem.isDrawing()) |
| 66 continue; |
| 67 |
| 68 if (!skipNonDrawings) |
| 69 json->setInteger("index", i); |
| 70 #ifndef NDEBUG |
| 71 StringBuilder stringBuilder; |
| 72 displayItem.dumpPropertiesAsDebugString(stringBuilder); |
| 73 json->setString("properties", stringBuilder.toString()); |
| 74 #endif |
| 75 |
| 76 if (displayItem.hasValidClient()) { |
| 77 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 78 if (!displayItem.client().isAlive()) { |
| 79 json->setBoolean("clientIsAlive", true); |
| 80 } else { |
| 81 #else |
| 82 // debugName() and clientCacheIsValid() can only be called on a live |
| 83 // client, so only output it for m_newDisplayItemList, in which we are |
| 84 // sure the clients are all alive. |
| 85 if (&list == &m_newDisplayItemList) { |
| 86 #endif |
| 87 #ifdef NDEBUG |
| 88 json->setString( |
| 89 "clientDebugName", |
| 90 String::format("clientDebugName: \"%s\"", |
| 91 displayItem.client().debugName().ascii().data())); |
| 92 #endif |
| 93 } |
| 94 #ifndef NDEBUG |
| 95 if (showPictures && displayItem.isDrawing()) { |
| 96 if (const SkPicture* picture = |
| 97 static_cast<const DrawingDisplayItem&>(displayItem).picture()) { |
| 98 json->setString("picture", pictureAsDebugString(picture)); |
| 99 } |
| 100 } |
| 101 #endif |
| 102 } |
| 103 if (hasVisualRect(i)) { |
| 104 IntRect localVisualRect = visualRect(i); |
| 105 json->setString( |
| 106 "visualRect", |
| 107 String::format("[%d,%d %dx%d]", localVisualRect.x(), |
| 108 localVisualRect.y(), localVisualRect.width(), |
| 109 localVisualRect.height())); |
| 110 } |
| 111 |
| 112 jsonArray->pushObject(std::move(json)); |
| 113 } |
| 114 return jsonArray; |
| 115 } |
| 116 |
| 51 } // namespace blink | 117 } // namespace blink |
| OLD | NEW |