OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 PaintController_h | 5 #ifndef PaintController_h |
6 #define PaintController_h | 6 #define PaintController_h |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 #include "platform/PlatformExport.h" | 10 #include "platform/PlatformExport.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 void SetDisplayItemConstructionIsDisabled(const bool disable) { | 154 void SetDisplayItemConstructionIsDisabled(const bool disable) { |
155 construction_disabled_ = disable; | 155 construction_disabled_ = disable; |
156 } | 156 } |
157 bool SubsequenceCachingIsDisabled() const { | 157 bool SubsequenceCachingIsDisabled() const { |
158 return subsequence_caching_disabled_; | 158 return subsequence_caching_disabled_; |
159 } | 159 } |
160 void SetSubsequenceCachingIsDisabled(bool disable) { | 160 void SetSubsequenceCachingIsDisabled(bool disable) { |
161 subsequence_caching_disabled_ = disable; | 161 subsequence_caching_disabled_ = disable; |
162 } | 162 } |
163 | 163 |
164 bool FirstPainted() const { return first_painted_; } | 164 bool FirstPainted(const void* frame) const; |
165 void SetFirstPainted() { first_painted_ = true; } | 165 void SetFirstPainted(); |
166 bool TextPainted() const { return text_painted_; } | 166 bool TextPainted(const void* frame) const; |
167 void SetTextPainted() { text_painted_ = true; } | 167 void SetTextPainted(); |
168 bool ImagePainted() const { return image_painted_; } | 168 bool ImagePainted(const void* frame) const; |
169 void SetImagePainted() { image_painted_ = true; } | 169 void SetImagePainted(); |
170 | 170 |
171 // Returns displayItemList added using createAndAppend() since beginning or | 171 // Returns displayItemList added using createAndAppend() since beginning or |
172 // the last commitNewDisplayItems(). Use with care. | 172 // the last commitNewDisplayItems(). Use with care. |
173 DisplayItemList& NewDisplayItemList() { return new_display_item_list_; } | 173 DisplayItemList& NewDisplayItemList() { return new_display_item_list_; } |
174 | 174 |
175 void AppendDebugDrawingAfterCommit( | 175 void AppendDebugDrawingAfterCommit( |
176 const DisplayItemClient&, | 176 const DisplayItemClient&, |
177 sk_sp<PaintRecord>, | 177 sk_sp<PaintRecord>, |
178 const LayoutSize& offset_from_layout_object); | 178 const LayoutSize& offset_from_layout_object); |
179 | 179 |
(...skipping 24 matching lines...) Expand all Loading... | |
204 void BeginSubsequence(const DisplayItemClient& client) { | 204 void BeginSubsequence(const DisplayItemClient& client) { |
205 current_subsequence_clients_.push_back(&client); | 205 current_subsequence_clients_.push_back(&client); |
206 BeginShouldKeepAlive(client); | 206 BeginShouldKeepAlive(client); |
207 } | 207 } |
208 | 208 |
209 void EndSubsequence() { current_subsequence_clients_.pop_back(); } | 209 void EndSubsequence() { current_subsequence_clients_.pop_back(); } |
210 #endif | 210 #endif |
211 | 211 |
212 bool LastDisplayItemIsSubsequenceEnd() const; | 212 bool LastDisplayItemIsSubsequenceEnd() const; |
213 | 213 |
214 void BeginFrame(const void* frame); | |
215 void EndFrame(const void* frame); | |
216 | |
214 protected: | 217 protected: |
215 PaintController() | 218 PaintController() |
216 : new_display_item_list_(0), | 219 : new_display_item_list_(0), |
217 construction_disabled_(false), | 220 construction_disabled_(false), |
218 subsequence_caching_disabled_(false), | 221 subsequence_caching_disabled_(false), |
219 first_painted_(false), | |
220 text_painted_(false), | |
221 image_painted_(false), | |
222 skipping_cache_count_(0), | 222 skipping_cache_count_(0), |
223 num_cached_new_items_(0), | 223 num_cached_new_items_(0), |
224 current_cached_subsequence_begin_index_in_new_list_(kNotFound), | 224 current_cached_subsequence_begin_index_in_new_list_(kNotFound), |
225 #ifndef NDEBUG | 225 #ifndef NDEBUG |
226 num_sequential_matches_(0), | 226 num_sequential_matches_(0), |
227 num_out_of_order_matches_(0), | 227 num_out_of_order_matches_(0), |
228 num_indexed_items_(0), | 228 num_indexed_items_(0), |
229 #endif | 229 #endif |
230 under_invalidation_checking_begin_(0), | 230 under_invalidation_checking_begin_(0), |
231 under_invalidation_checking_end_(0), | 231 under_invalidation_checking_end_(0), |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 | 334 |
335 // Allows display item construction to be disabled to isolate the costs of | 335 // Allows display item construction to be disabled to isolate the costs of |
336 // construction in performance metrics. | 336 // construction in performance metrics. |
337 bool construction_disabled_; | 337 bool construction_disabled_; |
338 | 338 |
339 // Allows subsequence caching to be disabled to test the cost of display item | 339 // Allows subsequence caching to be disabled to test the cost of display item |
340 // caching. | 340 // caching. |
341 bool subsequence_caching_disabled_; | 341 bool subsequence_caching_disabled_; |
342 | 342 |
343 // The following fields indicate that this PaintController has ever had | 343 // The following fields indicate that this PaintController has ever had |
344 // first-paint, text or image painted. They are never reset to false. | 344 // first-paint, text or image painted for each frame. They are never reset to |
345 // First-paint is defined in https://github.com/WICG/paint-timing. It excludes | 345 // false. First-paint is defined in https://github.com/WICG/paint-timing. It |
346 // default background paint. | 346 // excludes default background paint. |
347 bool first_painted_; | 347 HashMap<const void*, bool> first_painted_; |
348 bool text_painted_; | 348 HashMap<const void*, bool> text_painted_; |
349 bool image_painted_; | 349 HashMap<const void*, bool> image_painted_; |
Xianzhu
2017/05/08 22:44:46
HashMap is much slower than direct field to access
Zhen Wang
2017/05/09 20:13:43
Done.
| |
350 | |
351 // A stack recording current frames. | |
352 Vector<const void*> current_frames_; | |
350 | 353 |
351 int skipping_cache_count_; | 354 int skipping_cache_count_; |
352 | 355 |
353 int num_cached_new_items_; | 356 int num_cached_new_items_; |
354 | 357 |
355 // Stores indices to valid cacheable display items in | 358 // Stores indices to valid cacheable display items in |
356 // m_currentPaintArtifact.displayItemList() that have not been matched by | 359 // m_currentPaintArtifact.displayItemList() that have not been matched by |
357 // requests of cached display items (using useCachedDrawingIfPossible() and | 360 // requests of cached display items (using useCachedDrawingIfPossible() and |
358 // useCachedSubsequenceIfPossible()) during sequential matching. The indexed | 361 // useCachedSubsequenceIfPossible()) during sequential matching. The indexed |
359 // items will be matched by later out-of-order requests of cached display | 362 // items will be matched by later out-of-order requests of cached display |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
424 CachedSubsequenceMap new_cached_subsequences_; | 427 CachedSubsequenceMap new_cached_subsequences_; |
425 size_t last_cached_subsequence_end_; | 428 size_t last_cached_subsequence_end_; |
426 | 429 |
427 FRIEND_TEST_ALL_PREFIXES(PaintControllerTest, CachedSubsequenceSwapOrder); | 430 FRIEND_TEST_ALL_PREFIXES(PaintControllerTest, CachedSubsequenceSwapOrder); |
428 FRIEND_TEST_ALL_PREFIXES(PaintControllerTest, CachedNestedSubsequenceUpdate); | 431 FRIEND_TEST_ALL_PREFIXES(PaintControllerTest, CachedNestedSubsequenceUpdate); |
429 }; | 432 }; |
430 | 433 |
431 } // namespace blink | 434 } // namespace blink |
432 | 435 |
433 #endif // PaintController_h | 436 #endif // PaintController_h |
OLD | NEW |