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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // effective painted output if it was set a non-empty size. It's used to skip | 64 // effective painted output if it was set a non-empty size. It's used to skip |
65 // unforced paint invalidation of LayoutObjects (which is when | 65 // unforced paint invalidation of LayoutObjects (which is when |
66 // shouldDoFullPaintInvalidation is false, but mayNeedPaintInvalidation or | 66 // shouldDoFullPaintInvalidation is false, but mayNeedPaintInvalidation or |
67 // childShouldCheckForPaintInvalidation is true) to avoid unnecessary paint | 67 // childShouldCheckForPaintInvalidation is true) to avoid unnecessary paint |
68 // invalidations of empty areas covered by such objects. | 68 // invalidations of empty areas covered by such objects. |
69 virtual bool PaintedOutputOfObjectHasNoEffectRegardlessOfSize() const { | 69 virtual bool PaintedOutputOfObjectHasNoEffectRegardlessOfSize() const { |
70 return false; | 70 return false; |
71 } | 71 } |
72 | 72 |
73 void SetDisplayItemsUncached( | 73 void SetDisplayItemsUncached( |
74 PaintInvalidationReason reason = kPaintInvalidationFull) const { | 74 PaintInvalidationReason reason = PaintInvalidationReason::kFull) const { |
75 cache_generation_or_invalidation_reason_.Invalidate(reason); | 75 cache_generation_or_invalidation_reason_.Invalidate(reason); |
76 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 76 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
77 // Clear should-keep-alive of DisplayItemClients in a subsequence if this | 77 // Clear should-keep-alive of DisplayItemClients in a subsequence if this |
78 // object is a subsequence. | 78 // object is a subsequence. |
79 EndShouldKeepAliveAllClients(this); | 79 EndShouldKeepAliveAllClients(this); |
80 #endif | 80 #endif |
81 } | 81 } |
82 | 82 |
83 PaintInvalidationReason GetPaintInvalidationReason() const { | 83 PaintInvalidationReason GetPaintInvalidationReason() const { |
84 return cache_generation_or_invalidation_reason_ | 84 return cache_generation_or_invalidation_reason_ |
(...skipping 30 matching lines...) Expand all Loading... |
115 // other paint controllers regardless if it's validly cached by these paint | 115 // other paint controllers regardless if it's validly cached by these paint |
116 // controllers. This situation is very rare (about 0.07% of clients were | 116 // controllers. This situation is very rare (about 0.07% of clients were |
117 // painted on multiple paint controllers) so the performance penalty is | 117 // painted on multiple paint controllers) so the performance penalty is |
118 // trivial. | 118 // trivial. |
119 class PLATFORM_EXPORT CacheGenerationOrInvalidationReason { | 119 class PLATFORM_EXPORT CacheGenerationOrInvalidationReason { |
120 DISALLOW_NEW(); | 120 DISALLOW_NEW(); |
121 | 121 |
122 public: | 122 public: |
123 CacheGenerationOrInvalidationReason() : value_(kJustCreated) {} | 123 CacheGenerationOrInvalidationReason() : value_(kJustCreated) {} |
124 | 124 |
125 void Invalidate(PaintInvalidationReason reason = kPaintInvalidationFull) { | 125 void Invalidate( |
| 126 PaintInvalidationReason reason = PaintInvalidationReason::kFull) { |
126 if (value_ != kJustCreated) | 127 if (value_ != kJustCreated) |
127 value_ = static_cast<ValueType>(reason); | 128 value_ = static_cast<ValueType>(reason); |
128 } | 129 } |
129 | 130 |
130 static CacheGenerationOrInvalidationReason Next() { | 131 static CacheGenerationOrInvalidationReason Next() { |
131 // In case the value overflowed in the previous call. | 132 // In case the value overflowed in the previous call. |
132 if (next_generation_ < kFirstValidGeneration) | 133 if (next_generation_ < kFirstValidGeneration) |
133 next_generation_ = kFirstValidGeneration; | 134 next_generation_ = kFirstValidGeneration; |
134 return CacheGenerationOrInvalidationReason(next_generation_++); | 135 return CacheGenerationOrInvalidationReason(next_generation_++); |
135 } | 136 } |
136 | 137 |
137 bool Matches(const CacheGenerationOrInvalidationReason& other) const { | 138 bool Matches(const CacheGenerationOrInvalidationReason& other) const { |
138 return value_ >= kFirstValidGeneration && | 139 return value_ >= kFirstValidGeneration && |
139 other.value_ >= kFirstValidGeneration && value_ == other.value_; | 140 other.value_ >= kFirstValidGeneration && value_ == other.value_; |
140 } | 141 } |
141 | 142 |
142 PaintInvalidationReason GetPaintInvalidationReason() const { | 143 PaintInvalidationReason GetPaintInvalidationReason() const { |
143 return value_ < kJustCreated | 144 return value_ < kJustCreated |
144 ? static_cast<PaintInvalidationReason>(value_) | 145 ? static_cast<PaintInvalidationReason>(value_) |
145 : kPaintInvalidationNone; | 146 : PaintInvalidationReason::kNone; |
146 } | 147 } |
147 | 148 |
148 bool IsJustCreated() const { return value_ == kJustCreated; } | 149 bool IsJustCreated() const { return value_ == kJustCreated; } |
149 void ClearIsJustCreated() { | 150 void ClearIsJustCreated() { |
150 value_ = static_cast<ValueType>(kPaintInvalidationFull); | 151 value_ = static_cast<ValueType>(PaintInvalidationReason::kFull); |
151 } | 152 } |
152 | 153 |
153 private: | 154 private: |
154 typedef uint32_t ValueType; | 155 typedef uint32_t ValueType; |
155 explicit CacheGenerationOrInvalidationReason(ValueType value) | 156 explicit CacheGenerationOrInvalidationReason(ValueType value) |
156 : value_(value) {} | 157 : value_(value) {} |
157 | 158 |
158 static const ValueType kJustCreated = | 159 static const ValueType kJustCreated = |
159 static_cast<ValueType>(kPaintInvalidationReasonMax) + 1; | 160 static_cast<ValueType>(PaintInvalidationReason::kMax) + 1; |
160 static const ValueType kFirstValidGeneration = | 161 static const ValueType kFirstValidGeneration = |
161 static_cast<ValueType>(kPaintInvalidationReasonMax) + 2; | 162 static_cast<ValueType>(PaintInvalidationReason::kMax) + 2; |
162 static ValueType next_generation_; | 163 static ValueType next_generation_; |
163 ValueType value_; | 164 ValueType value_; |
164 }; | 165 }; |
165 | 166 |
166 bool DisplayItemsAreCached(CacheGenerationOrInvalidationReason other) const { | 167 bool DisplayItemsAreCached(CacheGenerationOrInvalidationReason other) const { |
167 return cache_generation_or_invalidation_reason_.Matches(other); | 168 return cache_generation_or_invalidation_reason_.Matches(other); |
168 } | 169 } |
169 void SetDisplayItemsCached( | 170 void SetDisplayItemsCached( |
170 CacheGenerationOrInvalidationReason cache_generation) const { | 171 CacheGenerationOrInvalidationReason cache_generation) const { |
171 cache_generation_or_invalidation_reason_ = cache_generation; | 172 cache_generation_or_invalidation_reason_ = cache_generation; |
(...skipping 10 matching lines...) Expand all Loading... |
182 return &client1 == &client2; | 183 return &client1 == &client2; |
183 } | 184 } |
184 inline bool operator!=(const DisplayItemClient& client1, | 185 inline bool operator!=(const DisplayItemClient& client1, |
185 const DisplayItemClient& client2) { | 186 const DisplayItemClient& client2) { |
186 return &client1 != &client2; | 187 return &client1 != &client2; |
187 } | 188 } |
188 | 189 |
189 } // namespace blink | 190 } // namespace blink |
190 | 191 |
191 #endif // DisplayItemClient_h | 192 #endif // DisplayItemClient_h |
OLD | NEW |