| 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 StartClipRecorder::StartClipRecorder(RenderLayer* layer, GraphicsContext* graphi
csContext, ClipDisplayItem::ClipType clipType, const ClipRect& clipRect) |
| 55 : m_graphicsContext(graphicsContext) |
| 56 { |
| 57 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect()); |
| 58 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
| 59 graphicsContext->save(); |
| 60 graphicsContext->clip(snappedClipRect); |
| 61 } else { |
| 62 m_clipDisplayItem = adoptPtr(new ClipDisplayItem); |
| 63 m_clipDisplayItem->layer = layer; |
| 64 m_clipDisplayItem->clipType = clipType; |
| 65 m_clipDisplayItem->clipRect = snappedClipRect; |
| 66 } |
| 67 } |
| 68 |
| 69 void StartClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect) |
| 70 { |
| 71 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
| 72 m_clipDisplayItem->roundedRectClips.append(roundedRect); |
| 73 else |
| 74 m_graphicsContext->clipRoundedRect(roundedRect); |
| 75 } |
| 76 |
| 77 EndClipRecorder::EndClipRecorder(RenderLayer* layer, GraphicsContext* graphicsCo
ntext) |
| 78 { |
| 79 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
| 80 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem); |
| 81 layer->renderer()->view()->viewDisplayList().add(endClip.release()); |
| 82 } else { |
| 83 graphicsContext->restore(); |
| 84 } |
| 85 } |
| 86 |
| 87 const PaintList& ViewDisplayList::paintList() |
| 36 { | 88 { |
| 37 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 89 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 38 | 90 |
| 39 updatePaintCommandList(); | 91 updatePaintList(); |
| 40 return m_newPaints; | 92 return m_newPaints; |
| 41 } | 93 } |
| 42 | 94 |
| 43 void ViewDisplayList::add(WTF::PassOwnPtr<AtomicPaintChunk> atomicPaintChunk) | 95 void ViewDisplayList::add(WTF::PassOwnPtr<DisplayItem> displayItem) |
| 44 { | 96 { |
| 45 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 97 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 46 m_newPaints.append(atomicPaintChunk); | 98 m_newPaints.append(displayItem); |
| 47 } | 99 } |
| 48 | 100 |
| 49 void ViewDisplayList::invalidate(const RenderObject* renderer) | 101 void ViewDisplayList::invalidate(const RenderObject* renderer) |
| 50 { | 102 { |
| 51 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 103 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 52 m_invalidated.add(renderer); | 104 m_invalidated.add(renderer); |
| 53 } | 105 } |
| 54 | 106 |
| 55 bool ViewDisplayList::isRepaint(PaintCommandList::iterator begin, const AtomicPa
intChunk& atomicPaintChunk) | 107 bool ViewDisplayList::isRepaint(PaintList::iterator begin, const DisplayItem& di
splayItem) |
| 56 { | 108 { |
| 57 notImplemented(); | 109 notImplemented(); |
| 58 return false; | 110 return false; |
| 59 } | 111 } |
| 60 | 112 |
| 61 // Update the existing paintList by removing invalidated entries, updating repai
nted existing ones, and | 113 // Update the existing paintList by removing invalidated entries, updating repai
nted existing ones, and |
| 62 // appending new items. | 114 // appending new items. |
| 63 // | 115 // |
| 64 // The algorithm should be O(|existing paint list| + |newly painted list|). By u
sing the ordering | 116 // 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. | 117 // implied by the existing paint list, extra treewalks are avoided. |
| 66 void ViewDisplayList::updatePaintCommandList() | 118 void ViewDisplayList::updatePaintList() |
| 67 { | 119 { |
| 68 notImplemented(); | 120 notImplemented(); |
| 69 } | 121 } |
| 70 | 122 |
| 71 } // namespace blink | 123 } // namespace blink |
| OLD | NEW |