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)
WTF::String DisplayItem::asDebugString() const
{
if (!isValid())
return "null";
WTF::StringBuilder stringBuilder;
stringBuilder.append('{');
dumpPropertiesAsDebugString(stringBuilder);
......@@ -214,7 +212,13 @@ WTF::String DisplayItem::asDebugString() 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()));
if (!clientDebugString().isEmpty()) {
stringBuilder.append(' ');
......
......@@ -328,6 +328,7 @@ public:
#ifndef NDEBUG
static WTF::String typeAsDebugString(DisplayItem::Type);
const WTF::String& clientDebugString() const { return m_clientDebugString; }
void setClientDebugString(const WTF::String& s) { m_clientDebugString = s; }
WTF::String asDebugString() const;
virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const;
#endif
......@@ -344,9 +345,6 @@ private:
, m_type(UninitializedType)
, m_derivedSize(sizeof(*this))
, m_skippedCache(false)
#ifndef NDEBUG
, m_clientDebugString("invalid")
#endif
{ }
DisplayItemClient m_client;
......
......@@ -281,7 +281,7 @@ void DisplayItemList::copyCachedSubsequence(DisplayItems::iterator& currentIt, D
do {
// We should always find the EndSubsequence display item.
ASSERT(currentIt != m_currentDisplayItems.end());
updatedList.appendByMoving(*currentIt, currentIt->derivedSize());
updatedList.appendByMoving(*currentIt);
++currentIt;
} while (!endSubsequenceId.matches(updatedList.last()));
}
......@@ -346,9 +346,7 @@ void DisplayItemList::commitNewDisplayItems(DisplayListDiff*)
#endif // ENABLE(ASSERT)
// TODO(jbroman): Consider revisiting this heuristic.
DisplayItems updatedList(
kMaximumDisplayItemSize,
std::max(m_currentDisplayItems.usedCapacityInBytes(), m_newDisplayItems.usedCapacityInBytes()));
DisplayItems updatedList(std::max(m_currentDisplayItems.usedCapacityInBytes(), m_newDisplayItems.usedCapacityInBytes()));
DisplayItems::iterator currentIt = m_currentDisplayItems.begin();
DisplayItems::iterator currentEnd = m_currentDisplayItems.end();
for (DisplayItems::iterator newIt = m_newDisplayItems.begin(); newIt != m_newDisplayItems.end(); ++newIt) {
......@@ -379,7 +377,7 @@ void DisplayItemList::commitNewDisplayItems(DisplayListDiff*)
}
if (newDisplayItem.isCachedDrawing()) {
updatedList.appendByMoving(*currentIt, currentIt->derivedSize());
updatedList.appendByMoving(*currentIt);
++currentIt;
} else {
ASSERT(newDisplayItem.type() == DisplayItem::CachedSubsequence);
......@@ -397,7 +395,7 @@ void DisplayItemList::commitNewDisplayItems(DisplayListDiff*)
|| (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && paintOffsetWasInvalidated(newDisplayItem.client())));
}
#endif
updatedList.appendByMoving(*newIt, newIt->derivedSize());
updatedList.appendByMoving(*newIt);
if (isSynchronized)
++currentIt;
......@@ -601,14 +599,12 @@ WTF::String DisplayItemList::displayItemsAsDebugString(const DisplayItems& list)
const DisplayItem& displayItem = *it;
if (i)
stringBuilder.append(",\n");
if (!displayItem.isValid()) {
stringBuilder.append("null");
continue;
}
stringBuilder.append(String::format("{index: %d, ", (int)i));
displayItem.dumpPropertiesAsDebugString(stringBuilder);
if (displayItem.isValid()) {
stringBuilder.append(", cacheIsValid: ");
stringBuilder.append(clientCacheIsValid(displayItem.client()) ? "true" : "false");
}
stringBuilder.append('}');
}
return stringBuilder.toString();
......
......@@ -33,7 +33,26 @@ static const size_t kMaximumDisplayItemSize = sizeof(BeginTransform3DDisplayItem
// which were invalidated on this frame and do not change SimpleLayers.
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 {
WTF_MAKE_NONCOPYABLE(DisplayItemList);
......@@ -141,8 +160,8 @@ public:
protected:
DisplayItemList()
: m_currentDisplayItems(kMaximumDisplayItemSize, 0)
, m_newDisplayItems(kMaximumDisplayItemSize, kInitialDisplayItemsCapacity * kMaximumDisplayItemSize)
: m_currentDisplayItems(0)
, m_newDisplayItems(kInitialDisplayItemsCapacity * kMaximumDisplayItemSize)
, m_validlyCachedClientsDirty(false)
, m_constructionDisabled(false)
, 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