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

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

Issue 2277443003: [SPv2] Rasterization invalidation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 years, 3 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 #include "platform/graphics/paint/PaintChunker.h" 5 #include "platform/graphics/paint/PaintChunker.h"
6 6
7 #include "platform/RuntimeEnabledFeatures.h" 7 #include "platform/RuntimeEnabledFeatures.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 PaintChunker::PaintChunker() 11 PaintChunker::PaintChunker()
12 { 12 {
13 } 13 }
14 14
15 PaintChunker::~PaintChunker() 15 PaintChunker::~PaintChunker()
16 { 16 {
17 } 17 }
18 18
19 void PaintChunker::updateCurrentPaintChunkProperties(const PaintChunk::Id* chunk Id, const PaintChunkProperties& properties) 19 void PaintChunker::updateCurrentPaintChunkProperties(const PaintChunk::Id* chunk Id, const PaintChunkProperties& properties)
20 { 20 {
21 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 21 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
22 22
23 m_currentChunkId = WTF::nullopt; 23 m_currentChunkId = WTF::nullopt;
24 if (chunkId) 24 if (chunkId)
25 m_currentChunkId.emplace(*chunkId); 25 m_currentChunkId.emplace(*chunkId);
26 m_currentProperties = properties; 26 m_currentProperties = properties;
27 } 27 }
28 28
29 void PaintChunker::incrementDisplayItemIndex(const DisplayItem& item) 29 bool PaintChunker::incrementDisplayItemIndex(const DisplayItem& item)
30 { 30 {
31 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 31 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
32 32
33 ItemBehavior behavior; 33 ItemBehavior behavior;
34 Optional<PaintChunk::Id> newChunkId; 34 Optional<PaintChunk::Id> newChunkId;
35 if (DisplayItem::isForeignLayerType(item.getType())) { 35 if (DisplayItem::isForeignLayerType(item.getType())) {
36 behavior = RequiresSeparateChunk; 36 behavior = RequiresSeparateChunk;
37 // Use null chunkId if we are skipping cache, so that the chunk will not 37 // Use null chunkId if we are skipping cache, so that the chunk will not
38 // match any old chunk and will be treated as brand new. 38 // match any old chunk and will be treated as brand new.
39 if (!item.skippedCache()) 39 if (!item.skippedCache())
40 newChunkId.emplace(item.getId()); 40 newChunkId.emplace(item.getId());
41 41
42 // Clear m_currentChunkId so that any display items after the foreign la yer 42 // Clear m_currentChunkId so that any display items after the foreign la yer
43 // without a new chunk id will be treated as having no id to avoid the c hunk 43 // without a new chunk id will be treated as having no id to avoid the c hunk
44 // from using the same id as the chunk before the foreign layer chunk. 44 // from using the same id as the chunk before the foreign layer chunk.
45 m_currentChunkId = WTF::nullopt; 45 m_currentChunkId = WTF::nullopt;
46 } else { 46 } else {
47 behavior = DefaultBehavior; 47 behavior = DefaultBehavior;
48 if (!item.skippedCache() && m_currentChunkId) 48 if (!item.skippedCache() && m_currentChunkId)
49 newChunkId.emplace(*m_currentChunkId); 49 newChunkId.emplace(*m_currentChunkId);
50 } 50 }
51 51
52 if (m_chunks.isEmpty()) { 52 if (m_chunks.isEmpty()) {
53 PaintChunk newChunk(0, 1, newChunkId ? &*newChunkId : nullptr, m_current Properties); 53 PaintChunk newChunk(0, 1, newChunkId ? &*newChunkId : nullptr, m_current Properties);
54 m_chunks.append(newChunk); 54 m_chunks.append(newChunk);
55 m_chunkBehavior.append(behavior); 55 m_chunkBehavior.append(behavior);
56 return; 56 return true;
57 } 57 }
58 58
59 auto& lastChunk = m_chunks.last(); 59 auto& lastChunk = m_chunks.last();
60 bool canContinueChunk = m_currentProperties == lastChunk.properties 60 bool canContinueChunk = m_currentProperties == lastChunk.properties
61 && behavior != RequiresSeparateChunk 61 && behavior != RequiresSeparateChunk
62 && m_chunkBehavior.last() != RequiresSeparateChunk; 62 && m_chunkBehavior.last() != RequiresSeparateChunk;
63 if (canContinueChunk) { 63 if (canContinueChunk) {
64 lastChunk.endIndex++; 64 lastChunk.endIndex++;
65 return; 65 return false;
66 } 66 }
67 67
68 PaintChunk newChunk(lastChunk.endIndex, lastChunk.endIndex + 1, newChunkId ? &*newChunkId : nullptr, m_currentProperties); 68 PaintChunk newChunk(lastChunk.endIndex, lastChunk.endIndex + 1, newChunkId ? &*newChunkId : nullptr, m_currentProperties);
69 m_chunks.append(newChunk); 69 m_chunks.append(newChunk);
70 m_chunkBehavior.append(behavior); 70 m_chunkBehavior.append(behavior);
71 return true;
71 } 72 }
72 73
73 void PaintChunker::decrementDisplayItemIndex() 74 bool PaintChunker::decrementDisplayItemIndex()
74 { 75 {
75 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 76 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
76 ASSERT(!m_chunks.isEmpty()); 77 DCHECK(!m_chunks.isEmpty());
77 78
78 auto& lastChunk = m_chunks.last(); 79 auto& lastChunk = m_chunks.last();
79 if ((lastChunk.endIndex - lastChunk.beginIndex) > 1) { 80 if ((lastChunk.endIndex - lastChunk.beginIndex) > 1) {
80 lastChunk.endIndex--; 81 lastChunk.endIndex--;
81 } else { 82 return false;
82 m_chunks.removeLast();
83 m_chunkBehavior.removeLast();
84 } 83 }
84
85 m_chunks.removeLast();
86 m_chunkBehavior.removeLast();
87 return true;
85 } 88 }
86 89
87 void PaintChunker::clear() 90 void PaintChunker::clear()
88 { 91 {
89 m_chunks.clear(); 92 m_chunks.clear();
90 m_chunkBehavior.clear(); 93 m_chunkBehavior.clear();
91 m_currentChunkId = WTF::nullopt; 94 m_currentChunkId = WTF::nullopt;
92 m_currentProperties = PaintChunkProperties(); 95 m_currentProperties = PaintChunkProperties();
93 } 96 }
94 97
95 Vector<PaintChunk> PaintChunker::releasePaintChunks() 98 Vector<PaintChunk> PaintChunker::releasePaintChunks()
96 { 99 {
97 Vector<PaintChunk> chunks; 100 Vector<PaintChunk> chunks;
98 chunks.swap(m_chunks); 101 chunks.swap(m_chunks);
99 m_chunkBehavior.clear(); 102 m_chunkBehavior.clear();
100 m_currentChunkId = WTF::nullopt; 103 m_currentChunkId = WTF::nullopt;
101 m_currentProperties = PaintChunkProperties(); 104 m_currentProperties = PaintChunkProperties();
102 return chunks; 105 return chunks;
103 } 106 }
104 107
105 } // namespace blink 108 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698