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