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 #ifndef ViewDisplayList_h | 5 #ifndef ViewDisplayList_h |
6 #define ViewDisplayList_h | 6 #define ViewDisplayList_h |
7 | 7 |
8 #include "core/rendering/PaintPhase.h" | 8 #include "core/rendering/PaintPhase.h" |
| 9 #include "platform/geometry/RoundedRect.h" |
9 #include "platform/graphics/DisplayList.h" | 10 #include "platform/graphics/DisplayList.h" |
10 #include "wtf/HashSet.h" | 11 #include "wtf/HashSet.h" |
11 #include "wtf/OwnPtr.h" | 12 #include "wtf/OwnPtr.h" |
12 #include "wtf/Vector.h" | 13 #include "wtf/Vector.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
| 17 class ClipRect; |
16 class GraphicsContext; | 18 class GraphicsContext; |
17 class RenderObject; | 19 class RenderObject; |
| 20 class RenderLayer; |
18 struct AtomicPaintChunk; | 21 struct AtomicPaintChunk; |
19 | 22 |
20 typedef Vector<OwnPtr<AtomicPaintChunk> > PaintCommandList; | |
21 | 23 |
22 struct AtomicPaintChunk { | 24 struct DisplayItem { |
| 25 virtual void replay(GraphicsContext*) = 0; |
| 26 |
| 27 virtual ~DisplayItem() { } |
| 28 }; |
| 29 |
| 30 struct ClipDisplayItem : DisplayItem { |
| 31 RenderLayer* layer; |
| 32 enum ClipType { |
| 33 LayerOverflowControls, |
| 34 LayerBackground, |
| 35 LayerParent, |
| 36 LayerFilter, |
| 37 LayerForeground, |
| 38 LayerFragmentFloat, |
| 39 LayerFragmentForeground, |
| 40 LayerFragmentChildOutline, |
| 41 LayerFragmentOutline, |
| 42 LayerFragmentMask, |
| 43 LayerFragmentClippingMask, |
| 44 LayerFragmentParent |
| 45 }; |
| 46 ClipType clipType; |
| 47 IntRect clipRect; |
| 48 Vector<RoundedRect> roundedRectClips; |
| 49 |
| 50 virtual void replay(GraphicsContext*); |
| 51 }; |
| 52 |
| 53 struct EndClipDisplayItem : DisplayItem { |
| 54 RenderLayer* layer; |
| 55 virtual void replay(GraphicsContext*); |
| 56 }; |
| 57 |
| 58 struct AtomicPaintChunk : DisplayItem { |
23 AtomicPaintChunk(PassRefPtr<DisplayList> inDisplayList, RenderObject* inRend
erer, PaintPhase inPhase) | 59 AtomicPaintChunk(PassRefPtr<DisplayList> inDisplayList, RenderObject* inRend
erer, PaintPhase inPhase) |
24 : displayList(inDisplayList), renderer(inRenderer), phase(inPhase) { }; | 60 : displayList(inDisplayList), renderer(inRenderer), phase(inPhase) { }; |
25 | 61 |
26 RefPtr<DisplayList> displayList; | 62 RefPtr<DisplayList> displayList; |
27 | 63 |
28 // This auxillary data can be moved off the chunk if needed. | 64 // This auxillary data can be moved off the chunk if needed. |
29 RenderObject* renderer; | 65 RenderObject* renderer; |
30 PaintPhase phase; | 66 PaintPhase phase; |
| 67 |
| 68 virtual void replay(GraphicsContext*); |
31 }; | 69 }; |
32 | 70 |
| 71 typedef Vector<OwnPtr<DisplayItem> > PaintList; |
| 72 |
33 class PaintCommandRecorder { | 73 class PaintCommandRecorder { |
34 public: | 74 public: |
35 explicit PaintCommandRecorder(GraphicsContext*, RenderObject*, PaintPhase, c
onst FloatRect&); | 75 explicit PaintCommandRecorder(GraphicsContext*, RenderObject*, PaintPhase, c
onst FloatRect&); |
36 ~PaintCommandRecorder(); | 76 ~PaintCommandRecorder(); |
37 | 77 |
38 private: | 78 private: |
39 GraphicsContext* m_context; | 79 GraphicsContext* m_context; |
40 RenderObject* m_renderer; | 80 RenderObject* m_renderer; |
41 PaintPhase m_phase; | 81 PaintPhase m_phase; |
42 }; | 82 }; |
43 | 83 |
| 84 class ClipRecorder { |
| 85 public: |
| 86 explicit ClipRecorder(RenderLayer*, GraphicsContext*, ClipDisplayItem::ClipT
ype, const ClipRect&); |
| 87 void addRoundedRectClip(const RoundedRect&); |
| 88 |
| 89 ~ClipRecorder(); |
| 90 |
| 91 private: |
| 92 OwnPtr<ClipDisplayItem> m_clipDisplayItem; |
| 93 GraphicsContext* m_graphicsContext; |
| 94 RenderLayer* m_renderLayer; |
| 95 }; |
| 96 |
44 class ViewDisplayList { | 97 class ViewDisplayList { |
45 public: | 98 public: |
46 ViewDisplayList() { }; | 99 ViewDisplayList() { }; |
47 | 100 |
48 const PaintCommandList& paintCommandList(); | 101 const PaintList& paintList(); |
49 void add(WTF::PassOwnPtr<AtomicPaintChunk>); | 102 void add(WTF::PassOwnPtr<DisplayItem>); |
50 void invalidate(const RenderObject*); | 103 void invalidate(const RenderObject*); |
51 | 104 |
52 private: | 105 private: |
53 bool isRepaint(PaintCommandList::iterator, const AtomicPaintChunk&); | 106 bool isRepaint(PaintList::iterator, const DisplayItem&); |
54 // Update m_paintList with any invalidations or new paints. | 107 // Update m_paintList with any invalidations or new paints. |
55 void updatePaintCommandList(); | 108 void updatePaintList(); |
56 | 109 |
57 PaintCommandList m_paintList; | 110 PaintList m_paintList; |
58 HashSet<const RenderObject*> m_invalidated; | 111 HashSet<const RenderObject*> m_invalidated; |
59 PaintCommandList m_newPaints; | 112 PaintList m_newPaints; |
60 }; | 113 }; |
61 | 114 |
62 } // namespace blink | 115 } // namespace blink |
63 | 116 |
64 #endif // ViewDisplayList_h | 117 #endif // ViewDisplayList_h |
OLD | NEW |