| 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() | 11 #if DCHECK_IS_ON() |
| 12 static bool gNullPaintPropertyChecksDisabled = false; | 12 static bool gNullPaintPropertyChecksDisabled = false; |
| 13 DisableNullPaintPropertyChecks::DisableNullPaintPropertyChecks() | 13 DisableNullPaintPropertyChecks::DisableNullPaintPropertyChecks() |
| 14 : m_disabler(&gNullPaintPropertyChecksDisabled, true) {} | 14 : m_disabler(&gNullPaintPropertyChecksDisabled, true) {} |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 PaintChunker::PaintChunker() {} | 17 PaintChunker::PaintChunker() : m_nextDisplayItemBehavior(DefaultBehavior) {} |
| 18 | 18 |
| 19 PaintChunker::~PaintChunker() {} | 19 PaintChunker::~PaintChunker() {} |
| 20 | 20 |
| 21 void PaintChunker::updateCurrentPaintChunkProperties( | 21 void PaintChunker::updateCurrentPaintChunkProperties( |
| 22 const PaintChunk::Id* chunkId, | 22 const PaintChunk::Id* chunkId, |
| 23 const PaintChunkProperties& properties) { | 23 const PaintChunkProperties& properties) { |
| 24 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 24 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 25 | 25 |
| 26 m_currentChunkId = WTF::nullopt; | 26 m_currentChunkId = WTF::nullopt; |
| 27 if (chunkId) | 27 if (chunkId) |
| 28 m_currentChunkId.emplace(*chunkId); | 28 m_currentChunkId.emplace(*chunkId); |
| 29 |
| 30 // TODO(chrishtr): why not just compare properties != m_currentProperties? |
| 31 // It seems this would solve the "are the property tree states the same"? |
| 32 if (properties.backfaceHidden != m_currentProperties.backfaceHidden || |
| 33 properties.willChangeTransform != m_currentProperties.willChangeTransform) |
| 34 m_nextDisplayItemBehavior = RequiresSeparateChunk; |
| 35 |
| 29 m_currentProperties = properties; | 36 m_currentProperties = properties; |
| 30 } | 37 } |
| 31 | 38 |
| 32 bool PaintChunker::incrementDisplayItemIndex(const DisplayItem& item) { | 39 bool PaintChunker::incrementDisplayItemIndex(const DisplayItem& item) { |
| 33 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 40 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 34 | 41 |
| 35 #if DCHECK_IS_ON() | 42 #if DCHECK_IS_ON() |
| 36 if (!gNullPaintPropertyChecksDisabled) { | 43 if (!gNullPaintPropertyChecksDisabled) { |
| 37 // Property nodes should never be null because they should either be set to | 44 // 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 | 45 // 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 | 46 // root node. If these DCHECKs are hit we are missing a call to update the |
| 40 // properties. See: ScopedPaintChunkProperties. | 47 // properties. See: ScopedPaintChunkProperties. |
| 41 DCHECK(m_currentProperties.transform); | 48 DCHECK(m_currentProperties.transform); |
| 42 DCHECK(m_currentProperties.clip); | 49 DCHECK(m_currentProperties.clip); |
| 43 DCHECK(m_currentProperties.effect); | 50 DCHECK(m_currentProperties.effect); |
| 44 DCHECK(m_currentProperties.scroll); | 51 DCHECK(m_currentProperties.scroll); |
| 45 } | 52 } |
| 46 #endif | 53 #endif |
| 47 | 54 |
| 48 ItemBehavior behavior; | 55 ItemBehavior behavior; |
| 49 Optional<PaintChunk::Id> newChunkId; | 56 Optional<PaintChunk::Id> newChunkId; |
| 50 if (DisplayItem::isForeignLayerType(item.getType())) { | 57 if (m_nextDisplayItemBehavior == RequiresSeparateChunk) { |
| 58 behavior = RequiresSeparateChunk; |
| 59 if (!item.skippedCache() && m_currentChunkId) |
| 60 newChunkId.emplace(*m_currentChunkId); |
| 61 } else if (DisplayItem::isForeignLayerType(item.getType())) { |
| 51 behavior = RequiresSeparateChunk; | 62 behavior = RequiresSeparateChunk; |
| 52 // Use null chunkId if we are skipping cache, so that the chunk will not | 63 // Use null chunkId if we are skipping cache, so that the chunk will not |
| 53 // match any old chunk and will be treated as brand new. | 64 // match any old chunk and will be treated as brand new. |
| 54 if (!item.skippedCache()) | 65 if (!item.skippedCache()) |
| 55 newChunkId.emplace(item.getId()); | 66 newChunkId.emplace(item.getId()); |
| 56 | 67 |
| 57 // Clear m_currentChunkId so that any display items after the foreign layer | 68 // Clear m_currentChunkId so that any display items after the foreign layer |
| 58 // without a new chunk id will be treated as having no id to avoid the chunk | 69 // without a new chunk id will be treated as having no id to avoid the chunk |
| 59 // from using the same id as the chunk before the foreign layer chunk. | 70 // from using the same id as the chunk before the foreign layer chunk. |
| 60 m_currentChunkId = WTF::nullopt; | 71 m_currentChunkId = WTF::nullopt; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 Vector<PaintChunk> PaintChunker::releasePaintChunks() { | 124 Vector<PaintChunk> PaintChunker::releasePaintChunks() { |
| 114 Vector<PaintChunk> chunks; | 125 Vector<PaintChunk> chunks; |
| 115 chunks.swap(m_chunks); | 126 chunks.swap(m_chunks); |
| 116 m_chunkBehavior.clear(); | 127 m_chunkBehavior.clear(); |
| 117 m_currentChunkId = WTF::nullopt; | 128 m_currentChunkId = WTF::nullopt; |
| 118 m_currentProperties = PaintChunkProperties(); | 129 m_currentProperties = PaintChunkProperties(); |
| 119 return chunks; | 130 return chunks; |
| 120 } | 131 } |
| 121 | 132 |
| 122 } // namespace blink | 133 } // namespace blink |
| OLD | NEW |