Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: Source/platform/graphics/paint/DisplayItemList.h

Issue 1315993004: Implement a paint offset cache for slimming paint v2 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix bugs caught by unittest failures Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/platform/graphics/paint/DisplayItemList.h
diff --git a/Source/platform/graphics/paint/DisplayItemList.h b/Source/platform/graphics/paint/DisplayItemList.h
index 164f94160f061d035a3d185fd06fd0032c7055b0..0de35753d62888da710b5714099e8e3a6402dd77 100644
--- a/Source/platform/graphics/paint/DisplayItemList.h
+++ b/Source/platform/graphics/paint/DisplayItemList.h
@@ -6,6 +6,7 @@
#define DisplayItemList_h
#include "platform/PlatformExport.h"
+#include "platform/geometry/LayoutPoint.h"
#include "platform/graphics/ContiguousContainer.h"
#include "platform/graphics/paint/DisplayItem.h"
#include "platform/graphics/paint/Transform3DDisplayItem.h"
@@ -46,6 +47,17 @@ public:
void invalidate(DisplayItemClient);
void invalidateAll();
+ // Record when paint offsets change during paint.
+ void invalidatePaintOffset(DisplayItemClient);
+#if ENABLE(ASSERT)
+ bool paintOffsetWasInvalidated(DisplayItemClient) const;
+#endif
+
+ // Record a new paint offset.
+ // TODO(pdr): Remove these once the paint offset cache is on LayoutObject.
+ void recordPaintOffset(DisplayItemClient, const LayoutPoint&);
+ bool paintOffsetWasRecorded(DisplayItemClient, const LayoutPoint&) const;
+
// These methods are called during painting.
template <typename DisplayItemClass, typename... Args>
DisplayItemClass& createAndAppend(Args&&... args)
@@ -124,6 +136,7 @@ private:
friend class DisplayItemListPaintTest;
friend class DisplayItemListPaintTestForSlimmingPaintV2;
friend class LayoutObjectDrawingRecorderTest;
+ friend class LayoutObjectDrawingRecorderTestForSlimmingPaintV2;
// Set new item state (scopes, cache skipping, etc) for a new item.
// TODO(pdr): This only passes a pointer to make the patch easier to review. Change to a reference.
@@ -131,6 +144,11 @@ private:
void updateValidlyCachedClientsIfNeeded() const;
+ // Update the recorded paint offsets to remove any items that no longer have
+ // corresponding cached display items.
+ // TODO(pdr): Remove this once the paint offset cache is on LayoutObject.
+ void removeUnneededPaintOffsetEntries();
+
#ifndef NDEBUG
WTF::String displayItemsAsDebugString(const DisplayItems&) const;
#endif
@@ -166,6 +184,12 @@ private:
mutable HashSet<DisplayItemClient> m_validlyCachedClients;
mutable bool m_validlyCachedClientsDirty;
+#if ENABLE(ASSERT)
+ // Set of clients which had paint offset changes since the last commit. This is used for
+ // ensuring paint offsets are only updated once and are the same in all phases.
+ HashSet<DisplayItemClient> m_clientsWithPaintOffsetInvalidations;
+#endif
+
// Allow display item construction to be disabled to isolate the costs of construction
// in performance metrics.
bool m_constructionDisabled;
@@ -177,6 +201,13 @@ private:
unsigned m_nextScope;
Vector<unsigned> m_scopeStack;
+ // Cache of LayoutObject paint offsets.
+ // TODO(pdr): This should be on LayoutObject itself and is only on the display
+ // item list temporarily until paint invalidation for v2 frees up space on
+ // LayoutObject.
+ using PreviousPaintOffsets = HashMap<DisplayItemClient, LayoutPoint>;
+ PreviousPaintOffsets m_previousPaintOffsets;
+
#if ENABLE(ASSERT)
// This is used to check duplicated ids during add(). We could also check during
// updatePaintList(), but checking during add() helps developer easily find where

Powered by Google App Engine
This is Rietveld 408576698