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 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 DisplayItems; |
21 class GraphicsContext; | 22 class GraphicsContext; |
22 class WebDisplayItemList; | 23 class WebDisplayItemList; |
23 | 24 |
24 class PLATFORM_EXPORT DisplayItem { | 25 class PLATFORM_EXPORT DisplayItem { |
25 public: | 26 public: |
26 enum { | 27 enum { |
27 // Must be kept in sync with core/layout/PaintPhase.h. | 28 // Must be kept in sync with core/layout/PaintPhase.h. |
28 PaintPhaseMax = 12, | 29 PaintPhaseMax = 12, |
29 }; | 30 }; |
30 | 31 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 { | 227 { |
227 m_scopeId = scopeId; | 228 m_scopeId = scopeId; |
228 m_scopeContainer = scopeContainer; | 229 m_scopeContainer = scopeContainer; |
229 } | 230 } |
230 | 231 |
231 // For DisplayItemList only. Painters should use DisplayItemCacheSkipper ins
tead. | 232 // For DisplayItemList only. Painters should use DisplayItemCacheSkipper ins
tead. |
232 void setSkippedCache() { m_skippedCache = true; } | 233 void setSkippedCache() { m_skippedCache = true; } |
233 bool skippedCache() const { return m_skippedCache; } | 234 bool skippedCache() const { return m_skippedCache; } |
234 | 235 |
235 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const { } | 236 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const { } |
| 237 virtual void appendByMoving(DisplayItems&) = 0; |
236 | 238 |
237 // See comments of enum Type for usage of the following macros. | 239 // See comments of enum Type for usage of the following macros. |
238 #define DEFINE_CATEGORY_METHODS(Category) \ | 240 #define DEFINE_CATEGORY_METHODS(Category) \ |
239 static bool is##Category##Type(Type type) { return type >= Category##First &
& type <= Category##Last; } \ | 241 static bool is##Category##Type(Type type) { return type >= Category##First &
& type <= Category##Last; } \ |
240 bool is##Category() const { return is##Category##Type(type()); } | 242 bool is##Category() const { return is##Category##Type(type()); } |
241 | 243 |
242 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \ | 244 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \ |
243 static Type category1##TypeTo##Category2##Type(Type type) \ | 245 static Type category1##TypeTo##Category2##Type(Type type) \ |
244 { \ | 246 { \ |
245 static_assert(Category1##Last - Category1##First == Category2##Last - Ca
tegory2##First, \ | 247 static_assert(Category1##Last - Category1##First == Category2##Last - Ca
tegory2##First, \ |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 const DisplayItemClient m_client; | 328 const DisplayItemClient m_client; |
327 DisplayItemClient m_scopeContainer; | 329 DisplayItemClient m_scopeContainer; |
328 int m_scopeId; | 330 int m_scopeId; |
329 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits
"); | 331 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits
"); |
330 const Type m_type : 16; | 332 const Type m_type : 16; |
331 unsigned m_skippedCache : 1; | 333 unsigned m_skippedCache : 1; |
332 | 334 |
333 #ifndef NDEBUG | 335 #ifndef NDEBUG |
334 WTF::String m_clientDebugString; | 336 WTF::String m_clientDebugString; |
335 #endif | 337 #endif |
| 338 |
| 339 // TODO(jbroman): Copying this data in appendByMoving would be better than |
| 340 // friendship, but this is just hacked up. |
| 341 friend class DisplayItems; |
336 }; | 342 }; |
337 | 343 |
338 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { | 344 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { |
339 protected: | 345 protected: |
340 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type) :
DisplayItem(client, type) { } | 346 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type) :
DisplayItem(client, type) { } |
341 | 347 |
342 private: | 348 private: |
343 virtual bool isBegin() const override final { return true; } | 349 virtual bool isBegin() const override final { return true; } |
344 }; | 350 }; |
345 | 351 |
346 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { | 352 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { |
347 protected: | 353 protected: |
348 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type) : Di
splayItem(client, type) { } | 354 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type) : Di
splayItem(client, type) { } |
349 | 355 |
350 #if ENABLE(ASSERT) | 356 #if ENABLE(ASSERT) |
351 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const override
= 0; | 357 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const override
= 0; |
352 #endif | 358 #endif |
353 | 359 |
354 private: | 360 private: |
355 virtual bool isEnd() const override final { return true; } | 361 virtual bool isEnd() const override final { return true; } |
356 }; | 362 }; |
357 | 363 |
| 364 // Allows a DisplayItemClientWrapper to be constructed from a DisplayItem, in |
| 365 // order to facilitate copying it. |
| 366 // TODO(jbroman): This is a bad class name. |
| 367 class DisplayItemClientWrapperHelper { |
| 368 DISALLOW_ALLOCATION(); |
| 369 public: |
| 370 DisplayItemClientWrapperHelper(const DisplayItem& wrapped) : m_wrapped(wrapp
ed) { } |
| 371 DisplayItemClient displayItemClient() const { return m_wrapped.client(); } |
| 372 String debugName() const |
| 373 { |
| 374 #ifndef NDEBUG |
| 375 return m_wrapped.clientDebugString(); |
| 376 #else |
| 377 return String(); |
| 378 #endif |
| 379 } |
| 380 private: |
| 381 const DisplayItem& m_wrapped; |
| 382 }; |
| 383 |
| 384 |
358 } // namespace blink | 385 } // namespace blink |
359 | 386 |
360 #endif // DisplayItem_h | 387 #endif // DisplayItem_h |
OLD | NEW |