Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: Source/core/paint/ViewDisplayList.cpp

Issue 653303003: Generalize paint chunks to clips, and implement clips in LayerPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 ClipRecorder::ClipRecorder(RenderLayer* renderLayer, GraphicsContext* graphicsCo ntext, ClipDisplayItem::ClipType clipType, const ClipRect& clipRect)
55 : m_graphicsContext(graphicsContext)
56 , m_renderLayer(renderLayer)
57 {
58 IntRect snappedClipRect = pixelSnappedIntRect(clipRect.rect());
59 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) {
60 graphicsContext->save();
61 graphicsContext->clip(snappedClipRect);
62 } else {
63 m_clipDisplayItem = adoptPtr(new ClipDisplayItem);
64 m_clipDisplayItem->layer = renderLayer;
65 m_clipDisplayItem->clipType = clipType;
66 m_clipDisplayItem->clipRect = snappedClipRect;
67 }
68 }
69
70 void ClipRecorder::addRoundedRectClip(const RoundedRect& roundedRect)
71 {
72 if (RuntimeEnabledFeatures::slimmingPaintEnabled())
73 m_clipDisplayItem->roundedRectClips.append(roundedRect);
74 else
75 m_graphicsContext->clipRoundedRect(roundedRect);
76 }
77
78 ClipRecorder::~ClipRecorder()
79 {
80 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
81 OwnPtr<EndClipDisplayItem> endClip = adoptPtr(new EndClipDisplayItem);
82 m_renderLayer->renderer()->view()->viewDisplayList().add(endClip.release ());
83 } else {
84 m_graphicsContext->restore();
85 }
86 }
87
88 const PaintList& ViewDisplayList::paintList()
36 { 89 {
37 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); 90 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
38 91
39 updatePaintCommandList(); 92 updatePaintList();
40 return m_newPaints; 93 return m_newPaints;
41 } 94 }
42 95
43 void ViewDisplayList::add(WTF::PassOwnPtr<AtomicPaintChunk> atomicPaintChunk) 96 void ViewDisplayList::add(WTF::PassOwnPtr<DisplayItem> displayItem)
44 { 97 {
45 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); 98 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
46 m_newPaints.append(atomicPaintChunk); 99 m_newPaints.append(displayItem);
47 } 100 }
48 101
49 void ViewDisplayList::invalidate(const RenderObject* renderer) 102 void ViewDisplayList::invalidate(const RenderObject* renderer)
50 { 103 {
51 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); 104 ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
52 m_invalidated.add(renderer); 105 m_invalidated.add(renderer);
53 } 106 }
54 107
55 bool ViewDisplayList::isRepaint(PaintCommandList::iterator begin, const AtomicPa intChunk& atomicPaintChunk) 108 bool ViewDisplayList::isRepaint(PaintList::iterator begin, const DisplayItem& di splayItem)
56 { 109 {
57 notImplemented(); 110 notImplemented();
58 return false; 111 return false;
59 } 112 }
60 113
61 // Update the existing paintList by removing invalidated entries, updating repai nted existing ones, and 114 // Update the existing paintList by removing invalidated entries, updating repai nted existing ones, and
62 // appending new items. 115 // appending new items.
63 // 116 //
64 // The algorithm should be O(|existing paint list| + |newly painted list|). By u sing the ordering 117 // 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. 118 // implied by the existing paint list, extra treewalks are avoided.
66 void ViewDisplayList::updatePaintCommandList() 119 void ViewDisplayList::updatePaintList()
67 { 120 {
68 notImplemented(); 121 notImplemented();
69 } 122 }
70 123
71 } // namespace blink 124 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/ViewDisplayList.h ('k') | Source/core/rendering/compositing/CompositedLayerMapping.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698