Index: Source/platform/graphics/paint/DisplayItemList.h |
diff --git a/Source/platform/graphics/paint/DisplayItemList.h b/Source/platform/graphics/paint/DisplayItemList.h |
index c1949ad0a9d3f2bfdb2140a9089bf7e687794d61..8f665e5c3661a687535defc1a9cfa293c3ce2ced 100644 |
--- a/Source/platform/graphics/paint/DisplayItemList.h |
+++ b/Source/platform/graphics/paint/DisplayItemList.h |
@@ -7,7 +7,7 @@ |
#include "platform/PlatformExport.h" |
#include "platform/graphics/paint/DisplayItem.h" |
-#include "wtf/HashSet.h" |
+#include "wtf/HashMap.h" |
#include "wtf/PassOwnPtr.h" |
#include "wtf/Vector.h" |
@@ -30,7 +30,7 @@ public: |
void invalidate(DisplayItemClient); |
void invalidateAll(); |
- bool clientCacheIsValid(DisplayItemClient) const; |
+ bool clientCacheIsValid(DisplayItemClient client) const { return m_cachedDisplayItemsInfoByClient.contains(client); } |
// Plays back the current PaintList() into the given context. |
void replay(GraphicsContext*); |
@@ -43,16 +43,30 @@ protected: |
DisplayItemList() { }; |
private: |
- PaintList::iterator findNextMatchingCachedItem(PaintList::iterator, const DisplayItem&); |
- bool wasInvalidated(const DisplayItem&) const; |
+ size_t findNextMatchingCachedItem(const DisplayItem&); |
void updatePaintList(); |
#ifndef NDEBUG |
WTF::String paintListAsDebugString(const PaintList&) const; |
+ WTF::String cachedDisplayItemsInfoByClientAsDebugString() const; |
#endif |
+ struct DisplayItemsInfo { |
+ // A temporary offset of displayItemIndexes during updatePaintList() used as the |
+ // starting point to find the next matching cached display item of the client. |
+ // This helps reduce the total complexity of finding the matching display items |
+ // of a client from O(m*n) to O(m+n). |
+ // (m,n = number of existing/new display items of a client, respectively). |
+ size_t updateOffset; |
+ |
+ // Indexes into PaintList of all display items of a client. |
+ Vector<size_t> displayItemIndexes; |
+ }; |
+ typedef HashMap<DisplayItemClient, DisplayItemsInfo> DisplayItemsInfoByClientMap; |
+ static void appendDisplayItem(PaintList&, DisplayItemsInfoByClientMap&, WTF::PassOwnPtr<DisplayItem>); |
+ |
PaintList m_paintList; |
- HashSet<DisplayItemClient> m_cachedClients; |
+ DisplayItemsInfoByClientMap m_cachedDisplayItemsInfoByClient; |
PaintList m_newPaints; |
}; |