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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/DrawingRecorder.h" | 6 #include "core/paint/DrawingRecorder.h" |
7 | 7 |
| 8 #include "core/rendering/RenderLayer.h" |
8 #include "core/rendering/RenderObject.h" | 9 #include "core/rendering/RenderObject.h" |
9 #include "core/rendering/RenderView.h" | |
10 #include "platform/RuntimeEnabledFeatures.h" | 10 #include "platform/RuntimeEnabledFeatures.h" |
| 11 #include "platform/graphics/DisplayList.h" |
11 #include "platform/graphics/GraphicsContext.h" | 12 #include "platform/graphics/GraphicsContext.h" |
| 13 #include "platform/graphics/GraphicsLayer.h" |
| 14 #include "platform/graphics/paint/DisplayItemList.h" |
| 15 #include "platform/graphics/paint/DrawingDisplayItem.h" |
12 | 16 |
13 namespace blink { | 17 namespace blink { |
14 | 18 |
15 void DrawingDisplayItem::replay(GraphicsContext* context) | |
16 { | |
17 context->drawPicture(m_picture.get(), m_location); | |
18 } | |
19 | |
20 #if ENABLE(ASSERT) | 19 #if ENABLE(ASSERT) |
21 static bool s_inDrawingRecorder = false; | 20 static bool s_inDrawingRecorder = false; |
22 #endif | 21 #endif |
23 | 22 |
24 DrawingRecorder::DrawingRecorder(GraphicsContext* context, const RenderObject* r
enderer, PaintPhase phase, const FloatRect& clip) | 23 DrawingRecorder::DrawingRecorder(GraphicsContext* context, const RenderObject* r
enderer, PaintPhase phase, const FloatRect& clip) |
25 : m_context(context) | 24 : m_context(context) |
26 , m_renderer(renderer) | 25 , m_renderer(renderer) |
27 , m_phase(phase) | 26 , m_phase(phase) |
28 , m_bounds(clip) | 27 , m_bounds(clip) |
29 { | 28 { |
(...skipping 15 matching lines...) Expand all Loading... |
45 | 44 |
46 #if ENABLE(ASSERT) | 45 #if ENABLE(ASSERT) |
47 s_inDrawingRecorder = false; | 46 s_inDrawingRecorder = false; |
48 #endif | 47 #endif |
49 | 48 |
50 RefPtr<DisplayList> displayList = m_context->endRecording(); | 49 RefPtr<DisplayList> displayList = m_context->endRecording(); |
51 if (!displayList->picture()->approximateOpCount()) | 50 if (!displayList->picture()->approximateOpCount()) |
52 return; | 51 return; |
53 ASSERT(displayList->bounds() == m_bounds); | 52 ASSERT(displayList->bounds() == m_bounds); |
54 OwnPtr<DrawingDisplayItem> drawingItem = adoptPtr( | 53 OwnPtr<DrawingDisplayItem> drawingItem = adoptPtr( |
55 new DrawingDisplayItem(displayList->picture(), m_bounds.location(), m_ph
ase, m_renderer)); | 54 new DrawingDisplayItem(m_renderer->displayItemClient(), (DisplayItem::Ty
pe)m_phase, displayList->picture(), m_bounds.location())); |
56 ASSERT(m_renderer->view()); | 55 #ifndef NDEBUG |
57 m_renderer->view()->viewDisplayList().add(drawingItem.release()); | 56 if (!m_renderer) |
| 57 drawingItem->setClientDebugString("nullptr"); |
| 58 else if (m_renderer->node()) |
| 59 drawingItem->setClientDebugString(String::format("nodeName: \"%s\", rend
erer: \"%p\"", m_renderer->node()->nodeName().utf8().data(), m_renderer)); |
| 60 else |
| 61 drawingItem->setClientDebugString(String::format("renderer: \"%p\"", m_r
enderer)); |
| 62 #endif |
| 63 |
| 64 if (RenderLayer* container = m_renderer->enclosingLayer()->enclosingLayerFor
PaintInvalidationCrossingFrameBoundaries()) |
| 65 container->graphicsLayerBacking()->displayItemList().add(drawingItem.rel
ease()); |
58 } | 66 } |
59 | 67 |
60 #ifndef NDEBUG | |
61 WTF::String DrawingDisplayItem::asDebugString() const | |
62 { | |
63 return String::format("{%s, type: \"%s\", location: [%f,%f]}", | |
64 rendererDebugString(renderer()).utf8().data(), typeAsDebugString(type())
.utf8().data(), | |
65 m_location.x(), m_location.y()); | |
66 } | |
67 #endif | |
68 | |
69 } // namespace blink | 68 } // namespace blink |
OLD | NEW |