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

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

Issue 1193433004: Blink-side contiguous allocation of display items. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Minor tweaks to make reviewing easier Created 5 years, 5 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
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/PassOwnPtr.h" 11 #include "wtf/PassOwnPtr.h"
12 12
13 #ifndef NDEBUG 13 #ifndef NDEBUG
14 #include "wtf/text/StringBuilder.h" 14 #include "wtf/text/StringBuilder.h"
15 #include "wtf/text/WTFString.h" 15 #include "wtf/text/WTFString.h"
16 #endif 16 #endif
17 17
18 18
19 namespace blink { 19 namespace blink {
20 20
21 class GraphicsContext; 21 class GraphicsContext;
22 class WebDisplayItemList; 22 class WebDisplayItemList;
23 23
24 class PLATFORM_EXPORT DisplayItem { 24 class PLATFORM_EXPORT DisplayItem {
25 public: 25 public:
26 enum { 26 enum {
27 // Must be kept in sync with core/layout/PaintPhase.h. 27 // Must be kept in sync with core/paint/PaintPhase.h.
28 PaintPhaseMax = 12, 28 PaintPhaseMax = 12,
29 }; 29 };
30 30
31 // A display item type uniquely identifies a display item of a client. 31 // A display item type uniquely identifies a display item of a client.
32 // Some display item types can be categorized using the following directives : 32 // Some display item types can be categorized using the following directives :
33 // - In enum Type: 33 // - In enum Type:
34 // - enum value <Category>First; 34 // - enum value <Category>First;
35 // - enum values of the category, first of which should equal <Category>Fi rst; 35 // - enum values of the category, first of which should equal <Category>Fi rst;
36 // (for ease of maintenance, the values should be in alphabetic order) 36 // (for ease of maintenance, the values should be in alphabetic order)
37 // - enum value <Category>Last which should be equal to the last of the en um values of the category 37 // - enum value <Category>Last which should be equal to the last of the en um values of the category
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 BeginSubtreeFirst, 166 BeginSubtreeFirst,
167 BeginSubtreePaintPhaseFirst = BeginSubtreeFirst, 167 BeginSubtreePaintPhaseFirst = BeginSubtreeFirst,
168 BeginSubtreePaintPhaseLast = BeginSubtreePaintPhaseFirst + PaintPhaseMax , 168 BeginSubtreePaintPhaseLast = BeginSubtreePaintPhaseFirst + PaintPhaseMax ,
169 BeginSubtreeLast = BeginSubtreePaintPhaseLast, 169 BeginSubtreeLast = BeginSubtreePaintPhaseLast,
170 170
171 EndSubtreeFirst, 171 EndSubtreeFirst,
172 EndSubtreePaintPhaseFirst = EndSubtreeFirst, 172 EndSubtreePaintPhaseFirst = EndSubtreeFirst,
173 EndSubtreePaintPhaseLast = EndSubtreePaintPhaseFirst + PaintPhaseMax, 173 EndSubtreePaintPhaseLast = EndSubtreePaintPhaseFirst + PaintPhaseMax,
174 EndSubtreeLast = EndSubtreePaintPhaseLast, 174 EndSubtreeLast = EndSubtreePaintPhaseLast,
175 175
176 TypeLast = EndSubtreeLast 176 UninitializedType,
jbroman 2015/06/29 18:11:56 Superduper nit: to me it seems nicer for the in-me
pdr. 2015/06/29 22:20:03 Oops, I landed this in the BoxClipper patch (https
177 TypeLast = UninitializedType
177 }; 178 };
178 179
180 DisplayItem()
chrishtr 2015/06/29 17:19:16 Add a comment about the use case. Also maybe priva
pdr. 2015/06/29 22:20:03 Moved to private and just friended ListContainer::
181 : m_client(nullptr)
182 , m_scopeContainer(nullptr)
183 , m_scopeId(0)
184 , m_type(UninitializedType)
185 , m_skippedCache(false)
186 , m_ignoredFromList(true)
187 #ifndef NDEBUG
188 , m_clientDebugString("invalid")
189 #endif
190 { }
191
192 DisplayItem(const DisplayItemClientWrapper& client, Type type)
193 : m_client(client.displayItemClient())
194 , m_scopeContainer(nullptr)
195 , m_scopeId(0)
196 , m_type(type)
197 , m_skippedCache(false)
198 , m_ignoredFromList(false)
199 #ifndef NDEBUG
200 , m_clientDebugString(client.debugName())
201 #endif
202 { }
203
179 struct Id { 204 struct Id {
180 Id(DisplayItemClient c, Type t) : client(c), type(t), scopeId(0), scopeC ontainer(nullptr) 205 Id(DisplayItemClient c, Type t) : client(c), type(t), scopeId(0), scopeC ontainer(nullptr)
181 { 206 {
182 ASSERT(c); 207 ASSERT(c);
183 } 208 }
184 209
185 bool operator==(const Id& other) const 210 bool operator==(const Id& other) const
186 { 211 {
187 return client == other.client 212 return client == other.client
188 && type == other.type 213 && type == other.type
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 321
297 virtual bool isBegin() const { return false; } 322 virtual bool isBegin() const { return false; }
298 virtual bool isEnd() const { return false; } 323 virtual bool isEnd() const { return false; }
299 324
300 #if ENABLE(ASSERT) 325 #if ENABLE(ASSERT)
301 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return false; } 326 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return false; }
302 #endif 327 #endif
303 328
304 virtual bool drawsContent() const { return false; } 329 virtual bool drawsContent() const { return false; }
305 330
331 bool ignoreFromDisplayList() const { return m_ignoredFromList; }
332 void setIgnoredFromDisplayList() { m_ignoredFromList = true; }
333
306 #ifndef NDEBUG 334 #ifndef NDEBUG
307 static WTF::String typeAsDebugString(DisplayItem::Type); 335 static WTF::String typeAsDebugString(DisplayItem::Type);
308 const WTF::String& clientDebugString() const { return m_clientDebugString; } 336 const WTF::String& clientDebugString() const { return m_clientDebugString; }
309 WTF::String asDebugString() const; 337 WTF::String asDebugString() const;
310 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const; 338 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const;
311 #endif 339 #endif
312 340
313 protected:
314 DisplayItem(const DisplayItemClientWrapper& client, Type type)
315 : m_client(client.displayItemClient())
316 , m_scopeContainer(nullptr)
317 , m_scopeId(0)
318 , m_type(type)
319 , m_skippedCache(false)
320 #ifndef NDEBUG
321 , m_clientDebugString(client.debugName())
322 #endif
323 { }
324
325 private: 341 private:
326 const DisplayItemClient m_client; 342 const DisplayItemClient m_client;
327 DisplayItemClient m_scopeContainer; 343 DisplayItemClient m_scopeContainer;
328 int m_scopeId; 344 int m_scopeId;
329 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits "); 345 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits ");
330 const Type m_type : 16; 346 const Type m_type : 16;
331 unsigned m_skippedCache : 1; 347 unsigned m_skippedCache : 1;
348 unsigned m_ignoredFromList : 1;
332 349
333 #ifndef NDEBUG 350 #ifndef NDEBUG
334 WTF::String m_clientDebugString; 351 WTF::String m_clientDebugString;
335 #endif 352 #endif
336 }; 353 };
337 354
338 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { 355 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem {
339 protected: 356 protected:
340 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type) : DisplayItem(client, type) { } 357 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type) : DisplayItem(client, type) { }
341 358
342 private: 359 private:
343 virtual bool isBegin() const override final { return true; } 360 virtual bool isBegin() const override final { return true; }
344 }; 361 };
345 362
346 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { 363 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem {
347 protected: 364 protected:
348 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type) : Di splayItem(client, type) { } 365 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type) : Di splayItem(client, type) { }
349 366
350 #if ENABLE(ASSERT) 367 #if ENABLE(ASSERT)
351 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0; 368 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0;
352 #endif 369 #endif
353 370
354 private: 371 private:
355 virtual bool isEnd() const override final { return true; } 372 virtual bool isEnd() const override final { return true; }
356 }; 373 };
357 374
358 } // namespace blink 375 } // namespace blink
359 376
360 #endif // DisplayItem_h 377 #endif // DisplayItem_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698