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/ViewDisplayList.h" | 6 #include "core/paint/ViewDisplayList.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 "core/rendering/RenderView.h" |
10 #include "platform/NotImplemented.h" | 11 #include "platform/NotImplemented.h" |
11 #include "platform/RuntimeEnabledFeatures.h" | 12 #include "platform/RuntimeEnabledFeatures.h" |
12 #include "platform/graphics/GraphicsContext.h" | 13 #include "platform/graphics/GraphicsContext.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
| 17 void AtomicPaintChunk::replay(GraphicsContext* context) |
| 18 { |
| 19 context->drawDisplayList(displayList.get()); |
| 20 } |
| 21 |
| 22 void ClipDisplayItem::replay(GraphicsContext* context) |
| 23 { |
| 24 context->save(); |
| 25 context->clip(clipRect); |
| 26 for (RoundedRect roundedRect : roundedRectClips) |
| 27 context->clipRoundedRect(roundedRect); |
| 28 } |
| 29 |
| 30 void EndClipDisplayItem::replay(GraphicsContext* context) |
| 31 { |
| 32 context->restore(); |
| 33 } |
| 34 |
16 PaintCommandRecorder::PaintCommandRecorder(GraphicsContext* context, RenderObjec
t* renderer, PaintPhase phase, const FloatRect& clip) | 35 PaintCommandRecorder::PaintCommandRecorder(GraphicsContext* context, RenderObjec
t* renderer, PaintPhase phase, const FloatRect& clip) |
17 : m_context(context) | 36 : m_context(context) |
18 , m_renderer(renderer) | 37 , m_renderer(renderer) |
19 , m_phase(phase) | 38 , m_phase(phase) |
20 { | 39 { |
21 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | 40 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
22 m_context->beginRecording(clip); | 41 m_context->beginRecording(clip); |
23 } | 42 } |
24 | 43 |
25 PaintCommandRecorder::~PaintCommandRecorder() | 44 PaintCommandRecorder::~PaintCommandRecorder() |
26 { | 45 { |
27 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) | 46 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) |
28 return; | 47 return; |
29 | 48 |
30 OwnPtr<AtomicPaintChunk> paintChunk = adoptPtr(new AtomicPaintChunk(m_contex
t->endRecording(), m_renderer, m_phase)); | 49 OwnPtr<AtomicPaintChunk> paintChunk = adoptPtr(new AtomicPaintChunk(m_contex
t->endRecording(), m_renderer, m_phase)); |
31 ASSERT(m_renderer->view()); | 50 ASSERT(m_renderer->view()); |
32 m_renderer->view()->viewDisplayList().add(paintChunk.release()); | 51 m_renderer->view()->viewDisplayList().add(paintChunk.release()); |
33 } | 52 } |
34 | 53 |
35 const PaintCommandList& ViewDisplayList::paintCommandList() | 54 PaintClipRecorder::PaintClipRecorder(RenderLayer* layer, ClipDisplayItem::ClipTy
pe clipType) |
| 55 |
| 56 { |
| 57 clipDisplayItem = adoptPtr(new ClipDisplayItem); |
| 58 clipDisplayItem->layer = layer; |
| 59 clipDisplayItem->clipType = clipType; |
| 60 } |
| 61 |
| 62 void PaintClipRecorder::setClipRect(IntRect clipRect) |
| 63 { |
| 64 clipDisplayItem->clipRect = clipRect; |
| 65 } |
| 66 |
| 67 void PaintClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect) |
| 68 { |
| 69 clipDisplayItem->roundedRectClips.append(roundedRect); |
| 70 } |
| 71 |
| 72 void PaintClipRecorder::startClip() |
| 73 { |
| 74 clipDisplayItem->layer->renderer()->view()->viewDisplayList().add(clipDispla
yItem.release()); |
| 75 } |
| 76 |
| 77 void PaintClipRecorder::endClip() |
| 78 { |
| 79 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem); |
| 80 clipDisplayItem->layer->renderer()->view()->viewDisplayList().add(endClip.re
lease()); |
| 81 } |
| 82 |
| 83 const PaintList& ViewDisplayList::paintList() |
36 { | 84 { |
37 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 85 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
38 | 86 |
39 updatePaintCommandList(); | 87 updatePaintList(); |
40 return m_newPaints; | 88 return m_newPaints; |
41 } | 89 } |
42 | 90 |
43 void ViewDisplayList::add(WTF::PassOwnPtr<AtomicPaintChunk> atomicPaintChunk) | 91 void ViewDisplayList::add(WTF::PassOwnPtr<DisplayItem> displayItem) |
44 { | 92 { |
45 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 93 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
46 m_newPaints.append(atomicPaintChunk); | 94 m_newPaints.append(displayItem); |
47 } | 95 } |
48 | 96 |
49 void ViewDisplayList::invalidate(const RenderObject* renderer) | 97 void ViewDisplayList::invalidate(const RenderObject* renderer) |
50 { | 98 { |
51 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 99 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
52 m_invalidated.add(renderer); | 100 m_invalidated.add(renderer); |
53 } | 101 } |
54 | 102 |
55 bool ViewDisplayList::isRepaint(PaintCommandList::iterator begin, const AtomicPa
intChunk& atomicPaintChunk) | 103 bool ViewDisplayList::isRepaint(PaintList::iterator begin, const DisplayItem& di
splayItem) |
56 { | 104 { |
57 notImplemented(); | 105 notImplemented(); |
58 return false; | 106 return false; |
59 } | 107 } |
60 | 108 |
61 // Update the existing paintList by removing invalidated entries, updating repai
nted existing ones, and | 109 // Update the existing paintList by removing invalidated entries, updating repai
nted existing ones, and |
62 // appending new items. | 110 // appending new items. |
63 // | 111 // |
64 // The algorithm should be O(|existing paint list| + |newly painted list|). By u
sing the ordering | 112 // The algorithm should be O(|existing paint list| + |newly painted list|). By u
sing the ordering |
65 // implied by the existing paint list, extra treewalks are avoided. | 113 // implied by the existing paint list, extra treewalks are avoided. |
66 void ViewDisplayList::updatePaintCommandList() | 114 void ViewDisplayList::updatePaintList() |
67 { | 115 { |
68 notImplemented(); | 116 notImplemented(); |
69 } | 117 } |
70 | 118 |
71 } // namespace blink | 119 } // namespace blink |
OLD | NEW |