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

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h

Issue 1508223005: Client side display item cache flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ScrollbarTheme
Patch Set: Fix unit tests Created 4 years, 8 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: third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
index 784aa638560e0a48fbaf3b4cdf80129dc29ac672..1a85eed17914a6bd12632ded16d520785003e040 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
+++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
@@ -11,6 +11,33 @@
namespace blink {
+// Holds a unique cache generation id of display items and paint controllers.
+// A paint controller sets its cache generation to DisplayItemCacheGeneration::next()
+// at the end of each commitNewDisplayItems, and updates the cache generation of each
+// client with cached drawings by calling DisplayItemClient::setDisplayItemsCached().
+// A display item is treated as validly cached in a paint controller if its cache generation
+// matches the paint controller's cache generation.
+class PLATFORM_EXPORT DisplayItemCacheGeneration {
+ DISALLOW_NEW();
+public:
+ DisplayItemCacheGeneration() : m_value(kInvalidGeneration) { }
+
+ void invalidate() { m_value = kInvalidGeneration; }
+ static DisplayItemCacheGeneration next() { return DisplayItemCacheGeneration(s_nextGeneration++); }
+ bool matches(const DisplayItemCacheGeneration& other)
+ {
+ return m_value != kInvalidGeneration && other.m_value != kInvalidGeneration && m_value == other.m_value;
+ }
+
+private:
+ typedef uint32_t Generation;
+ DisplayItemCacheGeneration(Generation value) : m_value(value) { }
+
+ static const Generation kInvalidGeneration = 0;
+ static Generation s_nextGeneration;
+ Generation m_value;
+};
+
// The interface for objects that can be associated with display items.
// A DisplayItemClient object should live at least longer than the document cycle
// in which its display items are created during painting.
@@ -31,12 +58,29 @@ public:
// offset by offsetFromLayoutObjectWithSubpixelAccumulation().
virtual LayoutRect visualRect() const = 0;
+ virtual bool displayItemsAreCached(DisplayItemCacheGeneration) const = 0;
+ virtual void setDisplayItemsCached(DisplayItemCacheGeneration) const = 0;
+ virtual void setDisplayItemsUncached() const = 0;
+
#if ENABLE(ASSERT)
// Tests if a DisplayItemClient object has been created and has not been deleted yet.
static bool isAlive(const DisplayItemClient&);
#endif
+
+protected:
};
+#define DISPLAY_ITEM_CACHE_STATUS_IMPLEMENTATION \
+ bool displayItemsAreCached(DisplayItemCacheGeneration cacheGeneration) const final { return m_cacheGeneration.matches(cacheGeneration); } \
+ void setDisplayItemsCached(DisplayItemCacheGeneration cacheGeneration) const final { m_cacheGeneration = cacheGeneration; } \
+ void setDisplayItemsUncached() const final { m_cacheGeneration.invalidate(); } \
+ mutable DisplayItemCacheGeneration m_cacheGeneration;
+
+#define DISPLAY_ITEM_CACHE_STATUS_UNCACHEABLE_IMPLEMENTATION \
+ bool displayItemsAreCached(DisplayItemCacheGeneration) const final { return false; } \
+ void setDisplayItemsCached(DisplayItemCacheGeneration) const final { } \
+ void setDisplayItemsUncached() const final { }
+
inline bool operator==(const DisplayItemClient& client1, const DisplayItemClient& client2) { return &client1 == &client2; }
inline bool operator!=(const DisplayItemClient& client1, const DisplayItemClient& client2) { return &client1 != &client2; }

Powered by Google App Engine
This is Rietveld 408576698