OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/DrawingRecorder.h" | 5 #include "platform/graphics/paint/DrawingRecorder.h" |
6 | 6 |
7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
9 #include "platform/graphics/GraphicsLayer.h" | 9 #include "platform/graphics/GraphicsLayer.h" |
10 #include "platform/graphics/paint/PaintController.h" | 10 #include "platform/graphics/paint/PaintController.h" |
11 #include "platform/graphics/paint/PaintRecord.h" | 11 #include "platform/graphics/paint/PaintRecord.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
| 15 #if DCHECK_IS_ON() |
| 16 static bool gListModificationCheckDisabled = false; |
| 17 DisableListModificationCheck::DisableListModificationCheck() |
| 18 : m_disabler(&gListModificationCheckDisabled, true) {} |
| 19 #endif |
| 20 |
15 DrawingRecorder::DrawingRecorder(GraphicsContext& context, | 21 DrawingRecorder::DrawingRecorder(GraphicsContext& context, |
16 const DisplayItemClient& displayItemClient, | 22 const DisplayItemClient& displayItemClient, |
17 DisplayItem::Type displayItemType, | 23 DisplayItem::Type displayItemType, |
18 const FloatRect& floatCullRect) | 24 const FloatRect& floatCullRect) |
19 : m_context(context), | 25 : m_context(context), |
20 m_displayItemClient(displayItemClient), | 26 m_displayItemClient(displayItemClient), |
21 m_displayItemType(displayItemType), | 27 m_displayItemType(displayItemType), |
22 m_knownToBeOpaque(false) | 28 m_knownToBeOpaque(false) |
23 #if DCHECK_IS_ON() | 29 #if DCHECK_IS_ON() |
24 , | 30 , |
25 m_displayItemPosition( | 31 m_initialDisplayItemListSize( |
26 m_context.getPaintController().newDisplayItemList().size()) | 32 m_context.getPaintController().newDisplayItemList().size()) |
27 #endif | 33 #endif |
28 { | 34 { |
29 if (context.getPaintController().displayItemConstructionIsDisabled()) | 35 if (context.getPaintController().displayItemConstructionIsDisabled()) |
30 return; | 36 return; |
31 | 37 |
32 // Must check DrawingRecorder::useCachedDrawingIfPossible before creating the | 38 // Must check DrawingRecorder::useCachedDrawingIfPossible before creating the |
33 // DrawingRecorder. | 39 // DrawingRecorder. |
34 DCHECK(RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() || | 40 DCHECK(RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() || |
35 !useCachedDrawingIfPossible(m_context, m_displayItemClient, | 41 !useCachedDrawingIfPossible(m_context, m_displayItemClient, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 74 |
69 DrawingRecorder::~DrawingRecorder() { | 75 DrawingRecorder::~DrawingRecorder() { |
70 if (m_context.getPaintController().displayItemConstructionIsDisabled()) | 76 if (m_context.getPaintController().displayItemConstructionIsDisabled()) |
71 return; | 77 return; |
72 | 78 |
73 #if DCHECK_IS_ON() | 79 #if DCHECK_IS_ON() |
74 if (RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled()) | 80 if (RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled()) |
75 m_context.restore(); | 81 m_context.restore(); |
76 | 82 |
77 m_context.setInDrawingRecorder(false); | 83 m_context.setInDrawingRecorder(false); |
78 DCHECK(m_displayItemPosition == | 84 |
79 m_context.getPaintController().newDisplayItemList().size()); | 85 if (!gListModificationCheckDisabled) { |
| 86 DCHECK(m_initialDisplayItemListSize == |
| 87 m_context.getPaintController().newDisplayItemList().size()); |
| 88 } |
80 #endif | 89 #endif |
81 | 90 |
82 sk_sp<const SkPicture> picture = m_context.endRecording(); | 91 sk_sp<const SkPicture> picture = m_context.endRecording(); |
83 | 92 |
84 #if DCHECK_IS_ON() | 93 #if DCHECK_IS_ON() |
85 if (!RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled() && | 94 if (!RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled() && |
86 !m_context.getPaintController().isForSkPictureBuilder() && | 95 !m_context.getPaintController().isForSkPictureBuilder() && |
87 m_displayItemClient.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) { | 96 m_displayItemClient.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) { |
88 DCHECK_EQ(0, picture->approximateOpCount()) | 97 DCHECK_EQ(0, picture->approximateOpCount()) |
89 << m_displayItemClient.debugName(); | 98 << m_displayItemClient.debugName(); |
90 } | 99 } |
91 #endif | 100 #endif |
92 | 101 |
93 m_context.getPaintController().createAndAppend<DrawingDisplayItem>( | 102 m_context.getPaintController().createAndAppend<DrawingDisplayItem>( |
94 m_displayItemClient, m_displayItemType, picture, m_knownToBeOpaque); | 103 m_displayItemClient, m_displayItemType, picture, m_knownToBeOpaque); |
95 } | 104 } |
96 | 105 |
97 } // namespace blink | 106 } // namespace blink |
OLD | NEW |