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

Side by Side Diff: Source/platform/graphics/paint/DisplayItem.h

Issue 892293002: First version of new merge algorithm (not enabled yet) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 #ifndef DisplayItem_h 5 #ifndef DisplayItem_h
6 #define DisplayItem_h 6 #define DisplayItem_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/graphics/paint/DisplayItemClient.h" 9 #include "platform/graphics/paint/DisplayItemClient.h"
10 #include "wtf/Assertions.h" 10 #include "wtf/Assertions.h"
11 #include "wtf/HashTraits.h"
11 #include "wtf/PassOwnPtr.h" 12 #include "wtf/PassOwnPtr.h"
12 13
13 #ifndef NDEBUG 14 #ifndef NDEBUG
14 #include "wtf/text/StringBuilder.h" 15 #include "wtf/text/StringBuilder.h"
15 #include "wtf/text/WTFString.h" 16 #include "wtf/text/WTFString.h"
16 #endif 17 #endif
17 18
18 19
19 namespace blink { 20 namespace blink {
20 21
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 EndScrollLast = EndScrollFirst + ScrollLast - ScrollFirst, 112 EndScrollLast = EndScrollFirst + ScrollLast - ScrollFirst,
112 113
113 BeginFilter, 114 BeginFilter,
114 EndFilter, 115 EndFilter,
115 BeginCompositing, 116 BeginCompositing,
116 EndCompositing, 117 EndCompositing,
117 BeginTransform, 118 BeginTransform,
118 EndTransform, 119 EndTransform,
119 BeginClipPath, 120 BeginClipPath,
120 EndClipPath, 121 EndClipPath,
122
123 SubtreeCachedFirst,
124 SubtreeCachedPaintPhaseFirst = SubtreeCachedFirst,
125 SubtreeCachedPaintPhaseLast = SubtreeCachedPaintPhaseFirst + PaintPhaseM ax,
126 SubtreeCachedLast = SubtreeCachedPaintPhaseLast,
127
128 BeginSubtreeFirst,
129 BeginSubtreePaintPhaseFirst = BeginSubtreeFirst,
130 BeginSubtreePaintPhaseLast = BeginSubtreePaintPhaseFirst + PaintPhaseMax ,
131 BeginSubtreeLast = BeginSubtreePaintPhaseLast,
132
133 EndSubtreeFirst,
134 EndSubtreePaintPhaseFirst = EndSubtreeFirst,
135 EndSubtreePaintPhaseLast = EndSubtreePaintPhaseFirst + PaintPhaseMax,
136 EndSubtreeLast = EndSubtreePaintPhaseLast,
137
138 BeginScope,
139 EndScope,
140 };
141
142 struct Id {
143 Id(DisplayItemClient c, Type t) : client(c), type(t) { }
144
145 bool operator==(const Id& other) const { return client == other.client & & type == other.type; }
146 bool operator!=(const Id& other) const { return !(*this == other); }
147
148 DisplayItemClient client;
149 Type type;
121 }; 150 };
122 151
123 // Create a dummy display item which just holds the id but has no display op eration. 152 // Create a dummy display item which just holds the id but has no display op eration.
124 // It helps a CachedDisplayItem to match the corresponding original empty di splay item. 153 // It helps a CachedDisplayItem to match the corresponding original empty di splay item.
125 static PassOwnPtr<DisplayItem> create(DisplayItemClient client, Type type) { return adoptPtr(new DisplayItem(client, type)); } 154 static PassOwnPtr<DisplayItem> create(DisplayItemClient client, Type type) { return adoptPtr(new DisplayItem(client, type)); }
126 155
127 virtual ~DisplayItem() { } 156 virtual ~DisplayItem() { }
128 157
129 virtual void replay(GraphicsContext*) { } 158 virtual void replay(GraphicsContext*) { }
130 159
131 DisplayItemClient client() const { return m_id.client; } 160 DisplayItemClient client() const { return m_id.client; }
132 Type type() const { return m_id.type; } 161 Type type() const { return m_id.type; }
133 bool idsEqual(const DisplayItem& other) const { return m_id.client == other. m_id.client && m_id.type == other.m_id.type; } 162 const Id& id() const { return m_id; }
163 bool idsEqual(const DisplayItem& other) const { return m_id == other.m_id; }
134 164
135 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const { } 165 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const { }
136 166
137 // See comments of enum Type for usage of the following macros. 167 // See comments of enum Type for usage of the following macros.
138 #define DEFINE_CATEGORY_METHODS(Category) \ 168 #define DEFINE_CATEGORY_METHODS(Category) \
139 static bool is##Category##Type(Type type) { return type >= Category##First & & type <= Category##Last; } \ 169 static bool is##Category##Type(Type type) { return type >= Category##First & & type <= Category##Last; } \
140 bool is##Category() const { return is##Category##Type(type()); } 170 bool is##Category() const { return is##Category##Type(type()); }
141 171
142 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \ 172 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \
143 static Type category1##TypeTo##Category2##Type(Type type) \ 173 static Type category1##TypeTo##Category2##Type(Type type) \
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipLayerFragment) 205 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipLayerFragment)
176 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipBox) 206 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipBox)
177 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipColumnBounds) 207 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipColumnBounds)
178 208
179 DEFINE_PAIRED_CATEGORY_METHODS(FloatClip, floatClip) 209 DEFINE_PAIRED_CATEGORY_METHODS(FloatClip, floatClip)
180 DEFINE_PAINT_PHASE_CONVERSION_METHOD(FloatClip) 210 DEFINE_PAINT_PHASE_CONVERSION_METHOD(FloatClip)
181 211
182 DEFINE_PAIRED_CATEGORY_METHODS(Scroll, scroll) 212 DEFINE_PAIRED_CATEGORY_METHODS(Scroll, scroll)
183 DEFINE_PAINT_PHASE_CONVERSION_METHOD(Scroll) 213 DEFINE_PAINT_PHASE_CONVERSION_METHOD(Scroll)
184 214
215 DEFINE_CATEGORY_METHODS(SubtreeCached)
216 DEFINE_PAINT_PHASE_CONVERSION_METHOD(SubtreeCached)
217 DEFINE_CATEGORY_METHODS(BeginSubtree)
218 DEFINE_PAINT_PHASE_CONVERSION_METHOD(BeginSubtree)
219 DEFINE_CATEGORY_METHODS(EndSubtree)
220 DEFINE_PAINT_PHASE_CONVERSION_METHOD(EndSubtree)
221 DEFINE_CONVERSION_METHODS(SubtreeCached, subtreeCached, BeginSubtree, beginS ubtree)
222 DEFINE_CONVERSION_METHODS(SubtreeCached, subtreeCached, EndSubtree, endSubtr ee)
223 DEFINE_CONVERSION_METHODS(BeginSubtree, beginSubtree, EndSubtree, endSubtree )
224
225 bool isBegin() const { return isClip() || isFloatClip() || isScroll() || isB eginSubtree() || type() == BeginFilter || type() == BeginCompositing || type() = = BeginTransform || type() == BeginClipPath || type() == BeginScope; }
226 bool isEnd() const { return isEndClip() || isEndFloatClip() || isEndScroll() || isEndSubtree() || type() == EndFilter || type() == EndCompositing || type() == EndTransform || type() == EndClipPath || type() == EndScope; }
227
228 #if ENABLE(ASSERT)
229 bool isEndAndPairedWith(DisplayItem& other) const
230 {
231 return client() == other.client()
232 && ((isEndClip() && other.isClip() && type() == clipTypeToEndClipTyp e(other.type()))
233 || (isEndFloatClip() && other.isFloatClip() && type() == floatCl ipTypeToEndFloatClipType(other.type()))
234 || (isEndScroll() && other.isScroll() && type() == scrollTypeToE ndScrollType(other.type()))
235 || (isEndSubtree() && other.isBeginSubtree() && type() == beginS ubtreeTypeToEndSubtreeType(other.type()))
236 || (type() == EndFilter && other.type() == BeginFilter)
237 || (type() == EndCompositing && other.type() == BeginCompositing )
238 || (type() == EndTransform && other.type() == BeginTransform)
239 || (type() == EndClipPath && other.type() == BeginClipPath)
240 || (type() == EndScope && other.type() == BeginScope));
241 }
242 #endif
243
185 #ifndef NDEBUG 244 #ifndef NDEBUG
186 static WTF::String typeAsDebugString(DisplayItem::Type); 245 static WTF::String typeAsDebugString(DisplayItem::Type);
187 246
188 void setClientDebugString(const WTF::String& clientDebugString) { m_clientDe bugString = clientDebugString; } 247 void setClientDebugString(const WTF::String& clientDebugString) { m_clientDe bugString = clientDebugString; }
189 const WTF::String& clientDebugString() const { return m_clientDebugString; } 248 const WTF::String& clientDebugString() const { return m_clientDebugString; }
190 249
191 WTF::String asDebugString() const; 250 WTF::String asDebugString() const;
192 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const; 251 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const;
193 #endif 252 #endif
194 253
195 protected: 254 protected:
196 DisplayItem(DisplayItemClient client, Type type) 255 DisplayItem(DisplayItemClient client, Type type)
197 : m_id(client, type) 256 : m_id(client, type)
198 { 257 {
199 ASSERT(client); 258 ASSERT(client);
200 } 259 }
201 260
202 private: 261 private:
203 struct Id { 262 const Id m_id;
204 Id(DisplayItemClient c, Type t)
205 : client(c)
206 , type(t)
207 {
208 ASSERT(client);
209 }
210
211 const DisplayItemClient client;
212 const Type type;
213 } m_id;
214 #ifndef NDEBUG 263 #ifndef NDEBUG
215 WTF::String m_clientDebugString; 264 WTF::String m_clientDebugString;
216 #endif 265 #endif
217 }; 266 };
218 267
219 } 268 } // namespace blink
269
270 // Allow DisplayItem::Id to be hash key.
271 namespace WTF {
272
273 template<> struct DefaultHash<blink::DisplayItem::Id> {
274 struct Hash {
275 static unsigned hash(const blink::DisplayItem::Id& id) { return pairIntH ash(PtrHash<blink::DisplayItemClient>::hash(id.client), static_cast<unsigned>(id .type)); }
276 static bool equal(const blink::DisplayItem::Id& a, const blink::DisplayI tem::Id& b) { return a == b; }
277 static const bool safeToCompareToEmptyOrDeleted = true;
278 };
279 };
280 template<> struct HashTraits<blink::DisplayItem::Id> : GenericHashTraits<blink:: DisplayItem::Id> {
281 static const bool emptyValueIsZero = true;
282 static const bool needsDestruction = false;
283 static blink::DisplayItem::Id emptyValue() { return blink::DisplayItem::Id(n ullptr, static_cast<blink::DisplayItem::Type>(0)); }
284 static void constructDeletedValue(blink::DisplayItem::Id& slot, bool) { new (NotNull, &slot) blink::DisplayItem::Id(nullptr, static_cast<blink::DisplayItem: :Type>(-1)); }
285 static bool isDeletedValue(const blink::DisplayItem::Id& id) { return id.typ e == static_cast<blink::DisplayItem::Type>(-1); }
286 };
287
288 } // namespace WTF
220 289
221 #endif // DisplayItem_h 290 #endif // DisplayItem_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698