Show debug information for invalid display items

This may be helpful when we call showDebugData() during the merge
algorithm.

Review URL: https://codereview.chromium.org/1323263002

git-svn-id: svn://svn.chromium.org/blink/trunk@201817 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent df7df0d0
...@@ -203,8 +203,6 @@ WTF::String DisplayItem::typeAsDebugString(Type type) ...@@ -203,8 +203,6 @@ WTF::String DisplayItem::typeAsDebugString(Type type)
WTF::String DisplayItem::asDebugString() const WTF::String DisplayItem::asDebugString() const
{ {
if (!isValid())
return "null";
WTF::StringBuilder stringBuilder; WTF::StringBuilder stringBuilder;
stringBuilder.append('{'); stringBuilder.append('{');
dumpPropertiesAsDebugString(stringBuilder); dumpPropertiesAsDebugString(stringBuilder);
...@@ -214,7 +212,13 @@ WTF::String DisplayItem::asDebugString() const ...@@ -214,7 +212,13 @@ WTF::String DisplayItem::asDebugString() const
void DisplayItem::dumpPropertiesAsDebugString(WTF::StringBuilder& stringBuilder) const void DisplayItem::dumpPropertiesAsDebugString(WTF::StringBuilder& stringBuilder) const
{ {
ASSERT(isValid()); if (!isValid()) {
stringBuilder.append("valid: false, originalDebugString: ");
// This is the original debug string which is in json format.
stringBuilder.append(clientDebugString());
return;
}
stringBuilder.append(String::format("client: \"%p", client())); stringBuilder.append(String::format("client: \"%p", client()));
if (!clientDebugString().isEmpty()) { if (!clientDebugString().isEmpty()) {
stringBuilder.append(' '); stringBuilder.append(' ');
......
...@@ -328,6 +328,7 @@ public: ...@@ -328,6 +328,7 @@ public:
#ifndef NDEBUG #ifndef NDEBUG
static WTF::String typeAsDebugString(DisplayItem::Type); static WTF::String typeAsDebugString(DisplayItem::Type);
const WTF::String& clientDebugString() const { return m_clientDebugString; } const WTF::String& clientDebugString() const { return m_clientDebugString; }
void setClientDebugString(const WTF::String& s) { m_clientDebugString = s; }
WTF::String asDebugString() const; WTF::String asDebugString() const;
virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const; virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const;
#endif #endif
...@@ -344,9 +345,6 @@ private: ...@@ -344,9 +345,6 @@ private:
, m_type(UninitializedType) , m_type(UninitializedType)
, m_derivedSize(sizeof(*this)) , m_derivedSize(sizeof(*this))
, m_skippedCache(false) , m_skippedCache(false)
#ifndef NDEBUG
, m_clientDebugString("invalid")
#endif
{ } { }
DisplayItemClient m_client; DisplayItemClient m_client;
......
...@@ -281,7 +281,7 @@ void DisplayItemList::copyCachedSubsequence(DisplayItems::iterator& currentIt, D ...@@ -281,7 +281,7 @@ void DisplayItemList::copyCachedSubsequence(DisplayItems::iterator& currentIt, D
do { do {
// We should always find the EndSubsequence display item. // We should always find the EndSubsequence display item.
ASSERT(currentIt != m_currentDisplayItems.end()); ASSERT(currentIt != m_currentDisplayItems.end());
updatedList.appendByMoving(*currentIt, currentIt->derivedSize()); updatedList.appendByMoving(*currentIt);
++currentIt; ++currentIt;
} while (!endSubsequenceId.matches(updatedList.last())); } while (!endSubsequenceId.matches(updatedList.last()));
} }
...@@ -346,9 +346,7 @@ void DisplayItemList::commitNewDisplayItems(DisplayListDiff*) ...@@ -346,9 +346,7 @@ void DisplayItemList::commitNewDisplayItems(DisplayListDiff*)
#endif // ENABLE(ASSERT) #endif // ENABLE(ASSERT)
// TODO(jbroman): Consider revisiting this heuristic. // TODO(jbroman): Consider revisiting this heuristic.
DisplayItems updatedList( DisplayItems updatedList(std::max(m_currentDisplayItems.usedCapacityInBytes(), m_newDisplayItems.usedCapacityInBytes()));
kMaximumDisplayItemSize,
std::max(m_currentDisplayItems.usedCapacityInBytes(), m_newDisplayItems.usedCapacityInBytes()));
DisplayItems::iterator currentIt = m_currentDisplayItems.begin(); DisplayItems::iterator currentIt = m_currentDisplayItems.begin();
DisplayItems::iterator currentEnd = m_currentDisplayItems.end(); DisplayItems::iterator currentEnd = m_currentDisplayItems.end();
for (DisplayItems::iterator newIt = m_newDisplayItems.begin(); newIt != m_newDisplayItems.end(); ++newIt) { for (DisplayItems::iterator newIt = m_newDisplayItems.begin(); newIt != m_newDisplayItems.end(); ++newIt) {
...@@ -379,7 +377,7 @@ void DisplayItemList::commitNewDisplayItems(DisplayListDiff*) ...@@ -379,7 +377,7 @@ void DisplayItemList::commitNewDisplayItems(DisplayListDiff*)
} }
if (newDisplayItem.isCachedDrawing()) { if (newDisplayItem.isCachedDrawing()) {
updatedList.appendByMoving(*currentIt, currentIt->derivedSize()); updatedList.appendByMoving(*currentIt);
++currentIt; ++currentIt;
} else { } else {
ASSERT(newDisplayItem.type() == DisplayItem::CachedSubsequence); ASSERT(newDisplayItem.type() == DisplayItem::CachedSubsequence);
...@@ -397,7 +395,7 @@ void DisplayItemList::commitNewDisplayItems(DisplayListDiff*) ...@@ -397,7 +395,7 @@ void DisplayItemList::commitNewDisplayItems(DisplayListDiff*)
|| (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && paintOffsetWasInvalidated(newDisplayItem.client()))); || (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && paintOffsetWasInvalidated(newDisplayItem.client())));
} }
#endif #endif
updatedList.appendByMoving(*newIt, newIt->derivedSize()); updatedList.appendByMoving(*newIt);
if (isSynchronized) if (isSynchronized)
++currentIt; ++currentIt;
...@@ -601,14 +599,12 @@ WTF::String DisplayItemList::displayItemsAsDebugString(const DisplayItems& list) ...@@ -601,14 +599,12 @@ WTF::String DisplayItemList::displayItemsAsDebugString(const DisplayItems& list)
const DisplayItem& displayItem = *it; const DisplayItem& displayItem = *it;
if (i) if (i)
stringBuilder.append(",\n"); stringBuilder.append(",\n");
if (!displayItem.isValid()) {
stringBuilder.append("null");
continue;
}
stringBuilder.append(String::format("{index: %d, ", (int)i)); stringBuilder.append(String::format("{index: %d, ", (int)i));
displayItem.dumpPropertiesAsDebugString(stringBuilder); displayItem.dumpPropertiesAsDebugString(stringBuilder);
stringBuilder.append(", cacheIsValid: "); if (displayItem.isValid()) {
stringBuilder.append(clientCacheIsValid(displayItem.client()) ? "true" : "false"); stringBuilder.append(", cacheIsValid: ");
stringBuilder.append(clientCacheIsValid(displayItem.client()) ? "true" : "false");
}
stringBuilder.append('}'); stringBuilder.append('}');
} }
return stringBuilder.toString(); return stringBuilder.toString();
......
...@@ -33,7 +33,26 @@ static const size_t kMaximumDisplayItemSize = sizeof(BeginTransform3DDisplayItem ...@@ -33,7 +33,26 @@ static const size_t kMaximumDisplayItemSize = sizeof(BeginTransform3DDisplayItem
// which were invalidated on this frame and do not change SimpleLayers. // which were invalidated on this frame and do not change SimpleLayers.
using DisplayListDiff = HashMap<DisplayItemClient, DisplayItem*>; using DisplayListDiff = HashMap<DisplayItemClient, DisplayItem*>;
using DisplayItems = ContiguousContainer<DisplayItem, kDisplayItemAlignment>; class DisplayItems : public ContiguousContainer<DisplayItem, kDisplayItemAlignment> {
public:
DisplayItems(size_t initialSizeBytes)
: ContiguousContainer(kMaximumDisplayItemSize, initialSizeBytes) {}
DisplayItem& appendByMoving(DisplayItem& item)
{
#ifndef NDEBUG
WTF::String originalDebugString = item.asDebugString();
#endif
DisplayItem& result = ContiguousContainer::appendByMoving(item, item.derivedSize());
// ContiguousContainer::appendByMoving() called in-place constructor on item, which invalidated it.
ASSERT(!item.isValid());
#ifndef NDEBUG
// Save original debug string in the old item to help debugging.
item.setClientDebugString(originalDebugString);
#endif
return result;
}
};
class PLATFORM_EXPORT DisplayItemList { class PLATFORM_EXPORT DisplayItemList {
WTF_MAKE_NONCOPYABLE(DisplayItemList); WTF_MAKE_NONCOPYABLE(DisplayItemList);
...@@ -141,8 +160,8 @@ public: ...@@ -141,8 +160,8 @@ public:
protected: protected:
DisplayItemList() DisplayItemList()
: m_currentDisplayItems(kMaximumDisplayItemSize, 0) : m_currentDisplayItems(0)
, m_newDisplayItems(kMaximumDisplayItemSize, kInitialDisplayItemsCapacity * kMaximumDisplayItemSize) , m_newDisplayItems(kInitialDisplayItemsCapacity * kMaximumDisplayItemSize)
, m_validlyCachedClientsDirty(false) , m_validlyCachedClientsDirty(false)
, m_constructionDisabled(false) , m_constructionDisabled(false)
, m_skippingCacheCount(0) , m_skippingCacheCount(0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment