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

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

Issue 1203343002: WIP for display item list backed by ListContainer Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 DisplayItem()
27 : m_client(nullptr)
28 , m_scopeContainer(nullptr)
29 , m_scopeId(0)
30 , m_type(UninitializedType)
31 , m_skippedCache(false)
32 #ifndef NDEBUG
33 , m_clientDebugString("invalid")
34 #endif
35 { }
36
26 enum { 37 enum {
27 // Must be kept in sync with core/layout/PaintPhase.h. 38 // Must be kept in sync with core/layout/PaintPhase.h.
28 PaintPhaseMax = 12, 39 PaintPhaseMax = 12,
29 }; 40 };
30 41
31 // A display item type uniquely identifies a display item of a client. 42 // A display item type uniquely identifies a display item of a client.
32 // Some display item types can be categorized using the following directives : 43 // Some display item types can be categorized using the following directives :
33 // - In enum Type: 44 // - In enum Type:
34 // - enum value <Category>First; 45 // - enum value <Category>First;
35 // - enum values of the category, first of which should equal <Category>Fi rst; 46 // - enum values of the category, first of which should equal <Category>Fi rst;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 BeginSubtreeFirst, 177 BeginSubtreeFirst,
167 BeginSubtreePaintPhaseFirst = BeginSubtreeFirst, 178 BeginSubtreePaintPhaseFirst = BeginSubtreeFirst,
168 BeginSubtreePaintPhaseLast = BeginSubtreePaintPhaseFirst + PaintPhaseMax , 179 BeginSubtreePaintPhaseLast = BeginSubtreePaintPhaseFirst + PaintPhaseMax ,
169 BeginSubtreeLast = BeginSubtreePaintPhaseLast, 180 BeginSubtreeLast = BeginSubtreePaintPhaseLast,
170 181
171 EndSubtreeFirst, 182 EndSubtreeFirst,
172 EndSubtreePaintPhaseFirst = EndSubtreeFirst, 183 EndSubtreePaintPhaseFirst = EndSubtreeFirst,
173 EndSubtreePaintPhaseLast = EndSubtreePaintPhaseFirst + PaintPhaseMax, 184 EndSubtreePaintPhaseLast = EndSubtreePaintPhaseFirst + PaintPhaseMax,
174 EndSubtreeLast = EndSubtreePaintPhaseLast, 185 EndSubtreeLast = EndSubtreePaintPhaseLast,
175 186
176 TypeLast = EndSubtreeLast 187 UninitializedType,
188 TypeLast = UninitializedType
177 }; 189 };
178 190
179 struct Id { 191 struct Id {
180 Id(DisplayItemClient c, Type t) : client(c), type(t), scopeId(0), scopeC ontainer(nullptr) 192 Id(DisplayItemClient c, Type t) : client(c), type(t), scopeId(0), scopeC ontainer(nullptr)
181 { 193 {
182 ASSERT(c); 194 ASSERT(c);
183 } 195 }
184 196
185 bool operator==(const Id& other) const 197 bool operator==(const Id& other) const
186 { 198 {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 virtual bool drawsContent() const { return false; } 316 virtual bool drawsContent() const { return false; }
305 317
306 #ifndef NDEBUG 318 #ifndef NDEBUG
307 static WTF::String typeAsDebugString(DisplayItem::Type); 319 static WTF::String typeAsDebugString(DisplayItem::Type);
308 const WTF::String& clientDebugString() const { return m_clientDebugString; } 320 const WTF::String& clientDebugString() const { return m_clientDebugString; }
309 WTF::String asDebugString() const; 321 WTF::String asDebugString() const;
310 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const; 322 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const;
311 #endif 323 #endif
312 324
313 protected: 325 protected:
314 DisplayItem(const DisplayItemClientWrapper& client, Type type) 326 // TODO(pdr): friend just the function DisplayItemList::createAndAppend(...) .
315 : m_client(client.displayItemClient()) 327 friend class DisplayItemList;
316 , m_scopeContainer(nullptr) 328 void setClientAndType(const DisplayItemClientWrapper& clientWrapper, Type ty pe)
317 , m_scopeId(0) 329 {
318 , m_type(type) 330 // Clients should never change once set.
319 , m_skippedCache(false) 331 ASSERT(m_client == nullptr);
332 m_client = clientWrapper.displayItemClient();
333
334 // Types should never change once set.
335 ASSERT(m_type = UninitializedType);
336 m_type = type;
337
320 #ifndef NDEBUG 338 #ifndef NDEBUG
321 , m_clientDebugString(client.debugName()) 339 m_clientDebugString = clientWrapper.debugName();
322 #endif 340 #endif
323 { } 341 }
324 342
325 private: 343 private:
326 const DisplayItemClient m_client; 344 DisplayItemClient m_client;
327 DisplayItemClient m_scopeContainer; 345 DisplayItemClient m_scopeContainer;
328 int m_scopeId; 346 int m_scopeId;
329 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits "); 347 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits ");
330 const Type m_type : 16; 348 Type m_type : 16;
331 unsigned m_skippedCache : 1; 349 unsigned m_skippedCache : 1;
332 350
333 #ifndef NDEBUG 351 #ifndef NDEBUG
334 WTF::String m_clientDebugString; 352 WTF::String m_clientDebugString;
335 #endif 353 #endif
336 }; 354 };
337 355
338 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { 356 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem {
339 protected: 357 protected:
340 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type) : DisplayItem(client, type) { } 358 PairedBeginDisplayItem() { }
341 359
342 private: 360 private:
343 virtual bool isBegin() const override final { return true; } 361 virtual bool isBegin() const override final { return true; }
344 }; 362 };
345 363
346 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { 364 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem {
347 protected: 365 protected:
348 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type) : Di splayItem(client, type) { } 366 PairedEndDisplayItem() { }
349 367
350 #if ENABLE(ASSERT) 368 #if ENABLE(ASSERT)
351 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0; 369 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0;
352 #endif 370 #endif
353 371
354 private: 372 private:
355 virtual bool isEnd() const override final { return true; } 373 virtual bool isEnd() const override final { return true; }
356 }; 374 };
357 375
358 } // namespace blink 376 } // namespace blink
359 377
360 #endif // DisplayItem_h 378 #endif // DisplayItem_h
OLDNEW
« no previous file with comments | « Source/platform/graphics/paint/CompositingDisplayItem.h ('k') | Source/platform/graphics/paint/DisplayItemList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698