| 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 |
| 11 #if DCHECK_IS_ON() |
| 12 static bool gNullPaintPropertyChecksDisabled = false; |
| 13 DisableNullPaintPropertyChecks::DisableNullPaintPropertyChecks() |
| 14 : m_disabler(&gNullPaintPropertyChecksDisabled, true) {} |
| 15 #endif |
| 16 |
| 11 PaintChunker::PaintChunker() {} | 17 PaintChunker::PaintChunker() {} |
| 12 | 18 |
| 13 PaintChunker::~PaintChunker() {} | 19 PaintChunker::~PaintChunker() {} |
| 14 | 20 |
| 15 void PaintChunker::updateCurrentPaintChunkProperties( | 21 void PaintChunker::updateCurrentPaintChunkProperties( |
| 16 const PaintChunk::Id* chunkId, | 22 const PaintChunk::Id* chunkId, |
| 17 const PaintChunkProperties& properties) { | 23 const PaintChunkProperties& properties) { |
| 18 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 24 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 19 | 25 |
| 20 m_currentChunkId = WTF::nullopt; | 26 m_currentChunkId = WTF::nullopt; |
| 21 if (chunkId) | 27 if (chunkId) |
| 22 m_currentChunkId.emplace(*chunkId); | 28 m_currentChunkId.emplace(*chunkId); |
| 23 m_currentProperties = properties; | 29 m_currentProperties = properties; |
| 24 } | 30 } |
| 25 | 31 |
| 26 bool PaintChunker::incrementDisplayItemIndex(const DisplayItem& item) { | 32 bool PaintChunker::incrementDisplayItemIndex(const DisplayItem& item) { |
| 27 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 33 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 28 | 34 |
| 35 #if DCHECK_IS_ON() |
| 36 if (!gNullPaintPropertyChecksDisabled) { |
| 37 // Property nodes should never be null because they should either be set to |
| 38 // properties created by a LayoutObject/FrameView, or be set to a non-null |
| 39 // root node. If these DCHECKs are hit we are missing a call to update the |
| 40 // properties. See: ScopedPaintChunkProperties. |
| 41 DCHECK(m_currentProperties.transform); |
| 42 DCHECK(m_currentProperties.clip); |
| 43 DCHECK(m_currentProperties.effect); |
| 44 DCHECK(m_currentProperties.scroll); |
| 45 } |
| 46 #endif |
| 47 |
| 29 ItemBehavior behavior; | 48 ItemBehavior behavior; |
| 30 Optional<PaintChunk::Id> newChunkId; | 49 Optional<PaintChunk::Id> newChunkId; |
| 31 if (DisplayItem::isForeignLayerType(item.getType())) { | 50 if (DisplayItem::isForeignLayerType(item.getType())) { |
| 32 behavior = RequiresSeparateChunk; | 51 behavior = RequiresSeparateChunk; |
| 33 // Use null chunkId if we are skipping cache, so that the chunk will not | 52 // Use null chunkId if we are skipping cache, so that the chunk will not |
| 34 // match any old chunk and will be treated as brand new. | 53 // match any old chunk and will be treated as brand new. |
| 35 if (!item.skippedCache()) | 54 if (!item.skippedCache()) |
| 36 newChunkId.emplace(item.getId()); | 55 newChunkId.emplace(item.getId()); |
| 37 | 56 |
| 38 // Clear m_currentChunkId so that any display items after the foreign layer | 57 // Clear m_currentChunkId so that any display items after the foreign layer |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Vector<PaintChunk> PaintChunker::releasePaintChunks() { | 113 Vector<PaintChunk> PaintChunker::releasePaintChunks() { |
| 95 Vector<PaintChunk> chunks; | 114 Vector<PaintChunk> chunks; |
| 96 chunks.swap(m_chunks); | 115 chunks.swap(m_chunks); |
| 97 m_chunkBehavior.clear(); | 116 m_chunkBehavior.clear(); |
| 98 m_currentChunkId = WTF::nullopt; | 117 m_currentChunkId = WTF::nullopt; |
| 99 m_currentProperties = PaintChunkProperties(); | 118 m_currentProperties = PaintChunkProperties(); |
| 100 return chunks; | 119 return chunks; |
| 101 } | 120 } |
| 102 | 121 |
| 103 } // namespace blink | 122 } // namespace blink |
| OLD | NEW |