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 "third_party/skia/include/core/SkPicture.h" | 11 #include "third_party/skia/include/core/SkPicture.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 DrawingRecorder::DrawingRecorder(GraphicsContext& context, | 15 DrawingRecorder::DrawingRecorder(GraphicsContext& context, |
16 const DisplayItemClient& displayItemClient, | 16 const DisplayItemClient& displayItemClient, |
17 DisplayItem::Type displayItemType, | 17 DisplayItem::Type displayItemType, |
18 const FloatRect& floatCullRect) | 18 const FloatRect& floatCullRect) |
19 : m_context(context), | 19 : m_context(context), |
20 m_displayItemClient(displayItemClient), | 20 m_displayItemClient(displayItemClient), |
21 m_displayItemType(displayItemType), | 21 m_displayItemType(displayItemType), |
22 m_knownToBeOpaque(false) | 22 m_knownToBeOpaque(false) |
23 #if DCHECK_IS_ON() | |
24 , | |
25 m_displayItemPosition( | |
26 m_context.getPaintController().newDisplayItemList().size()) | |
27 #endif | |
28 { | 23 { |
29 if (context.getPaintController().displayItemConstructionIsDisabled()) | 24 if (context.getPaintController().displayItemConstructionIsDisabled()) |
30 return; | 25 return; |
31 | 26 |
32 // Must check DrawingRecorder::useCachedDrawingIfPossible before creating the | 27 // Must check DrawingRecorder::useCachedDrawingIfPossible before creating the |
33 // DrawingRecorder. | 28 // DrawingRecorder. |
34 DCHECK(RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() || | 29 DCHECK(RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() || |
35 !useCachedDrawingIfPossible(m_context, m_displayItemClient, | 30 !useCachedDrawingIfPossible(m_context, m_displayItemClient, |
36 m_displayItemType)); | 31 m_displayItemType)); |
37 | 32 |
(...skipping 28 matching lines...) Expand all Loading... | |
66 #endif | 61 #endif |
67 } | 62 } |
68 | 63 |
69 DrawingRecorder::~DrawingRecorder() { | 64 DrawingRecorder::~DrawingRecorder() { |
70 if (m_context.getPaintController().displayItemConstructionIsDisabled()) | 65 if (m_context.getPaintController().displayItemConstructionIsDisabled()) |
71 return; | 66 return; |
72 | 67 |
73 #if DCHECK_IS_ON() | 68 #if DCHECK_IS_ON() |
74 if (RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled()) | 69 if (RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled()) |
75 m_context.restore(); | 70 m_context.restore(); |
76 | |
77 m_context.setInDrawingRecorder(false); | 71 m_context.setInDrawingRecorder(false); |
78 DCHECK(m_displayItemPosition == | |
chrishtr
2017/02/02 23:52:07
This DCHECK still seems generally useful. Pass an
| |
79 m_context.getPaintController().newDisplayItemList().size()); | |
80 #endif | 72 #endif |
81 | 73 |
82 sk_sp<const SkPicture> picture = m_context.endRecording(); | 74 sk_sp<const SkPicture> picture = m_context.endRecording(); |
83 | 75 |
84 #if DCHECK_IS_ON() | 76 #if DCHECK_IS_ON() |
85 if (!RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled() && | 77 if (!RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled() && |
86 !m_context.getPaintController().isForSkPictureBuilder() && | 78 !m_context.getPaintController().isForSkPictureBuilder() && |
87 m_displayItemClient.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) { | 79 m_displayItemClient.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) { |
88 DCHECK_EQ(0, picture->approximateOpCount()) | 80 DCHECK_EQ(0, picture->approximateOpCount()) |
89 << m_displayItemClient.debugName(); | 81 << m_displayItemClient.debugName(); |
90 } | 82 } |
91 #endif | 83 #endif |
92 | 84 |
93 m_context.getPaintController().createAndAppend<DrawingDisplayItem>( | 85 m_context.getPaintController().createAndAppend<DrawingDisplayItem>( |
94 m_displayItemClient, m_displayItemType, picture, m_knownToBeOpaque); | 86 m_displayItemClient, m_displayItemType, picture, m_knownToBeOpaque); |
95 } | 87 } |
96 | 88 |
97 } // namespace blink | 89 } // namespace blink |
OLD | NEW |