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

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

Issue 2116693002: PaintChunk::id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@CommitOnTheWay
Patch Set: Address chrishtr's comments. Created 4 years, 5 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 e3dc42b883a6c58de348012f02eefe01a20808d0..f076a8c606334772f77382089761c041fede8fad 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
+++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
@@ -63,7 +63,11 @@ public:
PaintInvalidationReason getPaintInvalidationReason() const { return m_cacheGenerationOrInvalidationReason.getPaintInvalidationReason(); }
+ // A client is considered "just created" if its display items have never been committed.
+ bool isJustCreated() const { return m_cacheGenerationOrInvalidationReason.isJustCreated(); }
+
private:
+ friend class FakeDisplayItemClient;
friend class PaintController;
// Holds a unique cache generation id of DisplayItemClients and PaintControllers,
@@ -81,12 +85,16 @@ private:
// only. The client will be treated as invalid on other paint controllers regardless if
// it's validly cached by these paint controllers. The situation is very rare (about 0.07%
// clients were painted on multiple paint controllers) so the performance penalty is trivial.
- class CacheGenerationOrInvalidationReason {
+ class PLATFORM_EXPORT CacheGenerationOrInvalidationReason {
DISALLOW_NEW();
public:
- CacheGenerationOrInvalidationReason() { invalidate(); }
+ CacheGenerationOrInvalidationReason() : m_value(kJustCreated) { }
- void invalidate(PaintInvalidationReason reason = PaintInvalidationFull) { m_value = static_cast<ValueType>(reason); }
+ void invalidate(PaintInvalidationReason reason = PaintInvalidationFull)
+ {
+ if (m_value != kJustCreated)
+ m_value = static_cast<ValueType>(reason);
+ }
static CacheGenerationOrInvalidationReason next()
{
@@ -103,14 +111,17 @@ private:
PaintInvalidationReason getPaintInvalidationReason() const
{
- return m_value < kFirstValidGeneration ? static_cast<PaintInvalidationReason>(m_value) : PaintInvalidationNone;
+ return m_value < kJustCreated ? static_cast<PaintInvalidationReason>(m_value) : PaintInvalidationNone;
}
+ bool isJustCreated() const { return m_value == kJustCreated; }
+
private:
typedef uint32_t ValueType;
explicit CacheGenerationOrInvalidationReason(ValueType value) : m_value(value) { }
- static const ValueType kFirstValidGeneration = static_cast<ValueType>(PaintInvalidationReasonMax) + 1;
+ static const ValueType kJustCreated = static_cast<ValueType>(PaintInvalidationReasonMax) + 1;
+ static const ValueType kFirstValidGeneration = static_cast<ValueType>(PaintInvalidationReasonMax) + 2;
static ValueType s_nextGeneration;
ValueType m_value;
};

Powered by Google App Engine
This is Rietveld 408576698