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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/DisplayItemList.h

Issue 2894093002: Don't access DisplayItemClient::VisualRect() for cached display items. (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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 DisplayItemList_h 5 #ifndef DisplayItemList_h
6 #define DisplayItemList_h 6 #define DisplayItemList_h
7 7
8 #include "platform/graphics/ContiguousContainer.h" 8 #include "platform/graphics/ContiguousContainer.h"
9 #include "platform/graphics/paint/DisplayItem.h" 9 #include "platform/graphics/paint/DisplayItem.h"
10 #include "platform/graphics/paint/Transform3DDisplayItem.h" 10 #include "platform/graphics/paint/Transform3DDisplayItem.h"
(...skipping 14 matching lines...) Expand all
25 static const size_t kMaximumDisplayItemSize = 25 static const size_t kMaximumDisplayItemSize =
26 sizeof(BeginTransform3DDisplayItem); 26 sizeof(BeginTransform3DDisplayItem);
27 27
28 // A container for a list of display items. 28 // A container for a list of display items.
29 class PLATFORM_EXPORT DisplayItemList 29 class PLATFORM_EXPORT DisplayItemList
30 : public ContiguousContainer<DisplayItem, kDisplayItemAlignment> { 30 : public ContiguousContainer<DisplayItem, kDisplayItemAlignment> {
31 public: 31 public:
32 DisplayItemList(size_t initial_size_bytes) 32 DisplayItemList(size_t initial_size_bytes)
33 : ContiguousContainer(kMaximumDisplayItemSize, initial_size_bytes) {} 33 : ContiguousContainer(kMaximumDisplayItemSize, initial_size_bytes) {}
34 DisplayItemList(DisplayItemList&& source) 34 DisplayItemList(DisplayItemList&& source)
35 : ContiguousContainer(std::move(source)), 35 : ContiguousContainer(std::move(source)) {}
36 visual_rects_(std::move(source.visual_rects_)) {}
37 36
38 DisplayItemList& operator=(DisplayItemList&& source) { 37 DisplayItemList& operator=(DisplayItemList&& source) {
39 ContiguousContainer::operator=(std::move(source)); 38 ContiguousContainer::operator=(std::move(source));
40 visual_rects_ = std::move(source.visual_rects_);
41 return *this; 39 return *this;
42 } 40 }
43 41
44 DisplayItem& AppendByMoving(DisplayItem&); 42 DisplayItem& AppendByMoving(DisplayItem& item) {
Xianzhu 2017/05/19 00:27:42 This is inlined because this function is a hot spo
wkorman 2017/05/19 00:55:08 When do we use ALWAYS_INLINE? I see PaintPropertyT
Xianzhu 2017/05/19 01:25:11 We added ALWAYS_INLINE for some big private functi
45 43 #ifndef NDEBUG
46 bool HasVisualRect(size_t index) const { 44 String original_debug_string = item.AsDebugString();
47 return index < visual_rects_.size(); 45 #endif
46 DCHECK(item.HasValidClient());
47 DisplayItem& result =
48 ContiguousContainer::AppendByMoving(item, item.DerivedSize());
49 // ContiguousContainer::AppendByMoving() calls an in-place constructor
50 // on item which replaces it with a tombstone/"dead display item" that
51 // can be safely destructed but should never be used.
52 DCHECK(!item.HasValidClient());
53 #ifndef NDEBUG
54 // Save original debug string in the old item to help debugging.
55 item.SetClientDebugString(original_debug_string);
56 #endif
57 item.visual_rect_ = result.visual_rect_;
Xianzhu 2017/05/19 00:27:42 The above line is new, to save the old visual rect
58 return result;
48 } 59 }
49 IntRect VisualRect(size_t index) const {
50 DCHECK(HasVisualRect(index));
51 return visual_rects_[index];
52 }
53
54 void AppendVisualRect(const IntRect& visual_rect);
55 60
56 // Useful for iterating with a range-based for loop. 61 // Useful for iterating with a range-based for loop.
57 template <typename Iterator> 62 template <typename Iterator>
58 class Range { 63 class Range {
59 public: 64 public:
60 Range(const Iterator& begin, const Iterator& end) 65 Range(const Iterator& begin, const Iterator& end)
61 : begin_(begin), end_(end) {} 66 : begin_(begin), end_(end) {}
62 Iterator begin() const { return begin_; } 67 Iterator begin() const { return begin_; }
63 Iterator end() const { return end_; } 68 Iterator end() const { return end_; }
64 69
65 private: 70 private:
66 Iterator begin_; 71 Iterator begin_;
67 Iterator end_; 72 Iterator end_;
68 }; 73 };
69 Range<iterator> ItemsInPaintChunk(const PaintChunk&); 74 Range<iterator> ItemsInPaintChunk(const PaintChunk&);
70 Range<const_iterator> ItemsInPaintChunk(const PaintChunk&) const; 75 Range<const_iterator> ItemsInPaintChunk(const PaintChunk&) const;
71 76
72 enum JsonOptions { 77 enum JsonOptions {
73 kDefault = 0, 78 kDefault = 0,
74 kShowPaintRecords = 1, 79 kShowPaintRecords = 1,
75 kSkipNonDrawings = 1 << 1, 80 kSkipNonDrawings = 1 << 1,
76 kShowClientDebugName = 1 << 2, 81 kShowClientDebugName = 1 << 2,
77 kShownOnlyDisplayItemTypes = 1 << 3 82 kShownOnlyDisplayItemTypes = 1 << 3
78 }; 83 };
79 typedef unsigned JsonFlags; 84 typedef unsigned JsonFlags;
80 85
81 std::unique_ptr<JSONArray> SubsequenceAsJSON(size_t begin_index, 86 std::unique_ptr<JSONArray> SubsequenceAsJSON(size_t begin_index,
82 size_t end_index, 87 size_t end_index,
83 JsonFlags options) const; 88 JsonFlags options) const;
84
85 private:
86 Vector<IntRect> visual_rects_;
87 }; 89 };
88 90
89 } // namespace blink 91 } // namespace blink
90 92
91 #endif // DisplayItemList_h 93 #endif // DisplayItemList_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698