| 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 DisplayItem_h |
| 6 #define ViewDisplayList_h | 6 #define DisplayItem_h |
| 7 | 7 |
| 8 #include "core/rendering/PaintPhase.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "wtf/HashSet.h" | 9 |
| 10 #include "wtf/PassOwnPtr.h" | 10 #ifndef NDEBUG |
| 11 #include "wtf/Vector.h" | 11 #include "wtf/text/WTFString.h" |
| 12 #endif |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 class GraphicsContext; | 16 class GraphicsContext; |
| 16 class RenderObject; | |
| 17 | 17 |
| 18 class DisplayItem { | 18 typedef void* DisplayItemClient; |
| 19 |
| 20 class PLATFORM_EXPORT DisplayItem { |
| 19 public: | 21 public: |
| 20 enum Type { | 22 enum Type { |
| 21 // DisplayItem types must be kept in sync with PaintPhase. | 23 // DisplayItem types must be kept in sync with PaintPhase. |
| 22 DrawingPaintPhaseBlockBackground = 0, | 24 DrawingPaintPhaseBlockBackground = 0, |
| 23 DrawingPaintPhaseChildBlockBackground = 1, | 25 DrawingPaintPhaseChildBlockBackground = 1, |
| 24 DrawingPaintPhaseChildBlockBackgrounds = 2, | 26 DrawingPaintPhaseChildBlockBackgrounds = 2, |
| 25 DrawingPaintPhaseFloat = 3, | 27 DrawingPaintPhaseFloat = 3, |
| 26 DrawingPaintPhaseForeground = 4, | 28 DrawingPaintPhaseForeground = 4, |
| 27 DrawingPaintPhaseOutline = 5, | 29 DrawingPaintPhaseOutline = 5, |
| 28 DrawingPaintPhaseChildOutlines = 6, | 30 DrawingPaintPhaseChildOutlines = 6, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 46 ClipLayerFragmentParent = 24, | 48 ClipLayerFragmentParent = 24, |
| 47 ClipLayerFragmentSelection = 25, | 49 ClipLayerFragmentSelection = 25, |
| 48 ClipLayerFragmentChildBlockBackgrounds = 26, | 50 ClipLayerFragmentChildBlockBackgrounds = 26, |
| 49 EndClip = 27, | 51 EndClip = 27, |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 virtual ~DisplayItem() { } | 54 virtual ~DisplayItem() { } |
| 53 | 55 |
| 54 virtual void replay(GraphicsContext*) = 0; | 56 virtual void replay(GraphicsContext*) = 0; |
| 55 | 57 |
| 56 const RenderObject* renderer() const { return m_id.renderer; } | 58 DisplayItemClient client() const { return m_id.client; } |
| 57 Type type() const { return m_id.type; } | 59 Type type() const { return m_id.type; } |
| 58 bool idsEqual(const DisplayItem& other) const { return m_id.renderer == othe
r.m_id.renderer && m_id.type == other.m_id.type; } | 60 bool idsEqual(const DisplayItem& other) const { return m_id.client == other.
m_id.client && m_id.type == other.m_id.type; } |
| 59 | 61 |
| 60 #ifndef NDEBUG | 62 #ifndef NDEBUG |
| 61 static WTF::String typeAsDebugString(DisplayItem::Type); | 63 static WTF::String typeAsDebugString(DisplayItem::Type); |
| 62 static WTF::String rendererDebugString(const RenderObject*); | 64 |
| 65 void setClientDebugString(const WTF::String& clientDebugString) { m_clientDe
bugString = clientDebugString; } |
| 66 const WTF::String& clientDebugString() const { return m_clientDebugString; } |
| 67 |
| 63 virtual WTF::String asDebugString() const; | 68 virtual WTF::String asDebugString() const; |
| 64 #endif | 69 #endif |
| 65 | 70 |
| 66 protected: | 71 protected: |
| 67 DisplayItem(const RenderObject* renderer, Type type) | 72 DisplayItem(DisplayItemClient client, Type type) |
| 68 : m_id(renderer, type) | 73 : m_id(client, type) |
| 69 { } | 74 { } |
| 70 | 75 |
| 71 private: | 76 private: |
| 72 struct Id { | 77 struct Id { |
| 73 Id(const RenderObject* r, Type t) | 78 Id(DisplayItemClient c, Type t) |
| 74 : renderer(r) | 79 : client(c) |
| 75 , type(t) | 80 , type(t) |
| 76 { } | 81 { } |
| 77 | 82 |
| 78 const RenderObject* renderer; | 83 const DisplayItemClient client; |
| 79 const Type type; | 84 const Type type; |
| 80 } m_id; | 85 } m_id; |
| 86 #ifndef NDEBUG |
| 87 WTF::String m_clientDebugString; |
| 88 #endif |
| 81 }; | 89 }; |
| 82 | 90 |
| 83 typedef Vector<OwnPtr<DisplayItem> > PaintList; | 91 } |
| 84 | 92 |
| 85 class ViewDisplayList { | 93 #endif // DisplayItem_h |
| 86 public: | |
| 87 ViewDisplayList() { }; | |
| 88 | |
| 89 const PaintList& paintList(); | |
| 90 void add(WTF::PassOwnPtr<DisplayItem>); | |
| 91 void invalidate(const RenderObject*); | |
| 92 | |
| 93 #ifndef NDEBUG | |
| 94 void showDebugData() const; | |
| 95 #endif | |
| 96 | |
| 97 private: | |
| 98 PaintList::iterator findDisplayItem(PaintList::iterator, const DisplayItem&)
; | |
| 99 bool wasInvalidated(const DisplayItem&) const; | |
| 100 void updatePaintList(); | |
| 101 | |
| 102 PaintList m_paintList; | |
| 103 HashSet<const RenderObject*> m_paintListRenderers; | |
| 104 HashSet<const RenderObject*> m_invalidated; | |
| 105 PaintList m_newPaints; | |
| 106 }; | |
| 107 | |
| 108 } // namespace blink | |
| 109 | |
| 110 #endif // ViewDisplayList_h | |
| OLD | NEW |