OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DisplayItemClient_h | 5 #ifndef DisplayItemClient_h |
6 #define DisplayItemClient_h | 6 #define DisplayItemClient_h |
7 | 7 |
8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "platform/geometry/LayoutRect.h" | 9 #include "platform/geometry/LayoutRect.h" |
10 #include "platform/graphics/PaintInvalidationReason.h" | 10 #include "platform/graphics/PaintInvalidationReason.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // Clear should-keep-alive of DisplayItemClients in a subsequence if thi
s | 58 // Clear should-keep-alive of DisplayItemClients in a subsequence if thi
s |
59 // object is a subsequence. | 59 // object is a subsequence. |
60 endShouldKeepAliveAllClients(this); | 60 endShouldKeepAliveAllClients(this); |
61 #endif | 61 #endif |
62 } | 62 } |
63 | 63 |
64 PaintInvalidationReason getPaintInvalidationReason() const { return m_cacheG
enerationOrInvalidationReason.getPaintInvalidationReason(); } | 64 PaintInvalidationReason getPaintInvalidationReason() const { return m_cacheG
enerationOrInvalidationReason.getPaintInvalidationReason(); } |
65 | 65 |
66 // A client is considered "just created" if its display items have never bee
n committed. | 66 // A client is considered "just created" if its display items have never bee
n committed. |
67 bool isJustCreated() const { return m_cacheGenerationOrInvalidationReason.is
JustCreated(); } | 67 bool isJustCreated() const { return m_cacheGenerationOrInvalidationReason.is
JustCreated(); } |
| 68 void clearIsJustCreated() const { m_cacheGenerationOrInvalidationReason.clea
rIsJustCreated(); } |
68 | 69 |
69 private: | 70 private: |
70 friend class FakeDisplayItemClient; | 71 friend class FakeDisplayItemClient; |
71 friend class PaintController; | 72 friend class PaintController; |
72 | 73 |
73 // Holds a unique cache generation id of DisplayItemClients and PaintControl
lers, | 74 // Holds a unique cache generation id of DisplayItemClients and PaintControl
lers, |
74 // or PaintInvalidationReason if the DisplayItemClient or PaintController is | 75 // or PaintInvalidationReason if the DisplayItemClient or PaintController is |
75 // invalidated. | 76 // invalidated. |
76 // | 77 // |
77 // A paint controller sets its cache generation to DisplayItemCacheGeneratio
n::next() | 78 // A paint controller sets its cache generation to DisplayItemCacheGeneratio
n::next() |
(...skipping 30 matching lines...) Expand all Loading... |
108 { | 109 { |
109 return m_value >= kFirstValidGeneration && other.m_value >= kFirstVa
lidGeneration && m_value == other.m_value; | 110 return m_value >= kFirstValidGeneration && other.m_value >= kFirstVa
lidGeneration && m_value == other.m_value; |
110 } | 111 } |
111 | 112 |
112 PaintInvalidationReason getPaintInvalidationReason() const | 113 PaintInvalidationReason getPaintInvalidationReason() const |
113 { | 114 { |
114 return m_value < kJustCreated ? static_cast<PaintInvalidationReason>
(m_value) : PaintInvalidationNone; | 115 return m_value < kJustCreated ? static_cast<PaintInvalidationReason>
(m_value) : PaintInvalidationNone; |
115 } | 116 } |
116 | 117 |
117 bool isJustCreated() const { return m_value == kJustCreated; } | 118 bool isJustCreated() const { return m_value == kJustCreated; } |
| 119 void clearIsJustCreated() { m_value = static_cast<ValueType>(PaintInvali
dationFull); } |
118 | 120 |
119 private: | 121 private: |
120 typedef uint32_t ValueType; | 122 typedef uint32_t ValueType; |
121 explicit CacheGenerationOrInvalidationReason(ValueType value) : m_value(
value) { } | 123 explicit CacheGenerationOrInvalidationReason(ValueType value) : m_value(
value) { } |
122 | 124 |
123 static const ValueType kJustCreated = static_cast<ValueType>(PaintInvali
dationReasonMax) + 1; | 125 static const ValueType kJustCreated = static_cast<ValueType>(PaintInvali
dationReasonMax) + 1; |
124 static const ValueType kFirstValidGeneration = static_cast<ValueType>(Pa
intInvalidationReasonMax) + 2; | 126 static const ValueType kFirstValidGeneration = static_cast<ValueType>(Pa
intInvalidationReasonMax) + 2; |
125 static ValueType s_nextGeneration; | 127 static ValueType s_nextGeneration; |
126 ValueType m_value; | 128 ValueType m_value; |
127 }; | 129 }; |
128 | 130 |
129 bool displayItemsAreCached(CacheGenerationOrInvalidationReason other) const
{ return m_cacheGenerationOrInvalidationReason.matches(other); } | 131 bool displayItemsAreCached(CacheGenerationOrInvalidationReason other) const
{ return m_cacheGenerationOrInvalidationReason.matches(other); } |
130 void setDisplayItemsCached(CacheGenerationOrInvalidationReason cacheGenerati
on) const { m_cacheGenerationOrInvalidationReason = cacheGeneration; } | 132 void setDisplayItemsCached(CacheGenerationOrInvalidationReason cacheGenerati
on) const { m_cacheGenerationOrInvalidationReason = cacheGeneration; } |
131 | 133 |
132 mutable CacheGenerationOrInvalidationReason m_cacheGenerationOrInvalidationR
eason; | 134 mutable CacheGenerationOrInvalidationReason m_cacheGenerationOrInvalidationR
eason; |
133 }; | 135 }; |
134 | 136 |
135 inline bool operator==(const DisplayItemClient& client1, const DisplayItemClient
& client2) { return &client1 == &client2; } | 137 inline bool operator==(const DisplayItemClient& client1, const DisplayItemClient
& client2) { return &client1 == &client2; } |
136 inline bool operator!=(const DisplayItemClient& client1, const DisplayItemClient
& client2) { return &client1 != &client2; } | 138 inline bool operator!=(const DisplayItemClient& client1, const DisplayItemClient
& client2) { return &client1 != &client2; } |
137 | 139 |
138 } // namespace blink | 140 } // namespace blink |
139 | 141 |
140 #endif // DisplayItemClient_h | 142 #endif // DisplayItemClient_h |
OLD | NEW |