| 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 #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 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 if (m_chunks.isEmpty()) { | 67 if (m_chunks.isEmpty()) { |
| 68 PaintChunk newChunk(0, 1, newChunkId ? &*newChunkId : nullptr, | 68 PaintChunk newChunk(0, 1, newChunkId ? &*newChunkId : nullptr, |
| 69 m_currentProperties); | 69 m_currentProperties); |
| 70 m_chunks.append(newChunk); | 70 m_chunks.append(newChunk); |
| 71 m_chunkBehavior.append(behavior); | 71 m_chunkBehavior.append(behavior); |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 | 74 |
| 75 auto& lastChunk = m_chunks.last(); | 75 auto& lastChunk = m_chunks.back(); |
| 76 bool canContinueChunk = m_currentProperties == lastChunk.properties && | 76 bool canContinueChunk = m_currentProperties == lastChunk.properties && |
| 77 behavior != RequiresSeparateChunk && | 77 behavior != RequiresSeparateChunk && |
| 78 m_chunkBehavior.last() != RequiresSeparateChunk; | 78 m_chunkBehavior.back() != RequiresSeparateChunk; |
| 79 if (canContinueChunk) { | 79 if (canContinueChunk) { |
| 80 lastChunk.endIndex++; | 80 lastChunk.endIndex++; |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 | 83 |
| 84 PaintChunk newChunk(lastChunk.endIndex, lastChunk.endIndex + 1, | 84 PaintChunk newChunk(lastChunk.endIndex, lastChunk.endIndex + 1, |
| 85 newChunkId ? &*newChunkId : nullptr, m_currentProperties); | 85 newChunkId ? &*newChunkId : nullptr, m_currentProperties); |
| 86 m_chunks.append(newChunk); | 86 m_chunks.append(newChunk); |
| 87 m_chunkBehavior.append(behavior); | 87 m_chunkBehavior.append(behavior); |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool PaintChunker::decrementDisplayItemIndex() { | 91 bool PaintChunker::decrementDisplayItemIndex() { |
| 92 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 92 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 93 DCHECK(!m_chunks.isEmpty()); | 93 DCHECK(!m_chunks.isEmpty()); |
| 94 | 94 |
| 95 auto& lastChunk = m_chunks.last(); | 95 auto& lastChunk = m_chunks.back(); |
| 96 if ((lastChunk.endIndex - lastChunk.beginIndex) > 1) { | 96 if ((lastChunk.endIndex - lastChunk.beginIndex) > 1) { |
| 97 lastChunk.endIndex--; | 97 lastChunk.endIndex--; |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 m_chunks.pop_back(); | 101 m_chunks.pop_back(); |
| 102 m_chunkBehavior.pop_back(); | 102 m_chunkBehavior.pop_back(); |
| 103 return true; | 103 return true; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void PaintChunker::clear() { | 106 void PaintChunker::clear() { |
| 107 m_chunks.clear(); | 107 m_chunks.clear(); |
| 108 m_chunkBehavior.clear(); | 108 m_chunkBehavior.clear(); |
| 109 m_currentChunkId = WTF::nullopt; | 109 m_currentChunkId = WTF::nullopt; |
| 110 m_currentProperties = PaintChunkProperties(); | 110 m_currentProperties = PaintChunkProperties(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 Vector<PaintChunk> PaintChunker::releasePaintChunks() { | 113 Vector<PaintChunk> PaintChunker::releasePaintChunks() { |
| 114 Vector<PaintChunk> chunks; | 114 Vector<PaintChunk> chunks; |
| 115 chunks.swap(m_chunks); | 115 chunks.swap(m_chunks); |
| 116 m_chunkBehavior.clear(); | 116 m_chunkBehavior.clear(); |
| 117 m_currentChunkId = WTF::nullopt; | 117 m_currentChunkId = WTF::nullopt; |
| 118 m_currentProperties = PaintChunkProperties(); | 118 m_currentProperties = PaintChunkProperties(); |
| 119 return chunks; | 119 return chunks; |
| 120 } | 120 } |
| 121 | 121 |
| 122 } // namespace blink | 122 } // namespace blink |
| OLD | NEW |