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

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

Issue 2230513005: Move visual rect unioning between paired items to cc::DisplayItemList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review feedback. Created 4 years, 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "platform/graphics/paint/DisplayItemList.h" 5 #include "platform/graphics/paint/DisplayItemList.h"
6 6
7 #include "platform/graphics/paint/DrawingDisplayItem.h" 7 #include "platform/graphics/paint/DrawingDisplayItem.h"
8 #include "platform/graphics/paint/PaintChunk.h" 8 #include "platform/graphics/paint/PaintChunk.h"
9 #include "third_party/skia/include/core/SkPictureAnalyzer.h" 9 #include "third_party/skia/include/core/SkPictureAnalyzer.h"
10 10
(...skipping 16 matching lines...) Expand all
27 ASSERT(!item.hasValidClient()); 27 ASSERT(!item.hasValidClient());
28 #ifndef NDEBUG 28 #ifndef NDEBUG
29 // Save original debug string in the old item to help debugging. 29 // Save original debug string in the old item to help debugging.
30 item.setClientDebugString(originalDebugString); 30 item.setClientDebugString(originalDebugString);
31 #endif 31 #endif
32 return result; 32 return result;
33 } 33 }
34 34
35 void DisplayItemList::appendVisualRect(const IntRect& visualRect) 35 void DisplayItemList::appendVisualRect(const IntRect& visualRect)
36 { 36 {
37 size_t itemIndex = m_visualRects.size(); 37 m_visualRects.append(visualRect);
38 const DisplayItem& item = (*this)[itemIndex];
39
40 // For paired display items such as transforms, since we are not guaranteed containment, the
41 // visual rect must comprise the union of the visual rects for all items wit hin its block.
42
43 if (item.isBegin()) {
44 m_visualRects.append(visualRect);
45 m_beginItemIndices.append(itemIndex);
46
47 } else if (item.isEnd()) {
48 size_t lastBeginIndex = m_beginItemIndices.last();
49 m_beginItemIndices.removeLast();
50
51 // Ending bounds match the starting bounds.
52 m_visualRects.append(m_visualRects[lastBeginIndex]);
53
54 // The block that ended needs to be included in the bounds of the enclos ing block.
55 growCurrentBeginItemVisualRect(m_visualRects[lastBeginIndex]);
56
57 } else {
58 m_visualRects.append(visualRect);
59 growCurrentBeginItemVisualRect(visualRect);
60 }
61 }
62
63 void DisplayItemList::growCurrentBeginItemVisualRect(const IntRect& visualRect)
64 {
65 if (!m_beginItemIndices.isEmpty())
66 m_visualRects[m_beginItemIndices.last()].unite(visualRect);
67 } 38 }
68 39
69 DisplayItemList::Range<DisplayItemList::iterator> 40 DisplayItemList::Range<DisplayItemList::iterator>
70 DisplayItemList::itemsInPaintChunk(const PaintChunk& paintChunk) 41 DisplayItemList::itemsInPaintChunk(const PaintChunk& paintChunk)
71 { 42 {
72 return Range<iterator>(begin() + paintChunk.beginIndex, begin() + paintChunk .endIndex); 43 return Range<iterator>(begin() + paintChunk.beginIndex, begin() + paintChunk .endIndex);
73 } 44 }
74 45
75 DisplayItemList::Range<DisplayItemList::const_iterator> 46 DisplayItemList::Range<DisplayItemList::const_iterator>
76 DisplayItemList::itemsInPaintChunk(const PaintChunk& paintChunk) const 47 DisplayItemList::itemsInPaintChunk(const PaintChunk& paintChunk) const
77 { 48 {
78 return Range<const_iterator>(begin() + paintChunk.beginIndex, begin() + pain tChunk.endIndex); 49 return Range<const_iterator>(begin() + paintChunk.beginIndex, begin() + pain tChunk.endIndex);
79 } 50 }
80 51
81 } // namespace blink 52 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698