| 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/ContiguousContainer.h" | 9 #include "platform/graphics/ContiguousContainer.h" |
| 10 #include "platform/graphics/paint/DisplayItemClient.h" | 10 #include "platform/graphics/paint/DisplayItemClient.h" |
| 11 #include "platform/wtf/Allocator.h" | 11 #include "platform/wtf/Allocator.h" |
| 12 #include "platform/wtf/Assertions.h" | 12 #include "platform/wtf/Assertions.h" |
| 13 #include "platform/wtf/Noncopyable.h" | 13 #include "platform/wtf/Noncopyable.h" |
| 14 | 14 |
| 15 #ifndef NDEBUG | 15 #ifndef NDEBUG |
| 16 #include "platform/wtf/text/StringBuilder.h" | 16 #include "platform/wtf/text/StringBuilder.h" |
| 17 #include "platform/wtf/text/WTFString.h" | 17 #include "platform/wtf/text/WTFString.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 | 21 |
| 22 class GraphicsContext; | 22 class GraphicsContext; |
| 23 class LayoutSize; | 23 class IntRect; |
| 24 class WebDisplayItemList; | 24 class WebDisplayItemList; |
| 25 | 25 |
| 26 class PLATFORM_EXPORT DisplayItem { | 26 class PLATFORM_EXPORT DisplayItem { |
| 27 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 27 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 28 | 28 |
| 29 public: | 29 public: |
| 30 enum { | 30 enum { |
| 31 // Must be kept in sync with core/paint/PaintPhase.h. | 31 // Must be kept in sync with core/paint/PaintPhase.h. |
| 32 kPaintPhaseMax = 11, | 32 kPaintPhaseMax = 11, |
| 33 }; | 33 }; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // border type. | 192 // border type. |
| 193 enum TableCollapsedBorderSides { | 193 enum TableCollapsedBorderSides { |
| 194 kTableCollapsedBorderTop = 1 << 0, | 194 kTableCollapsedBorderTop = 1 << 0, |
| 195 kTableCollapsedBorderRight = 1 << 1, | 195 kTableCollapsedBorderRight = 1 << 1, |
| 196 kTableCollapsedBorderBottom = 1 << 2, | 196 kTableCollapsedBorderBottom = 1 << 2, |
| 197 kTableCollapsedBorderLeft = 1 << 3, | 197 kTableCollapsedBorderLeft = 1 << 3, |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 DisplayItem(const DisplayItemClient& client, Type type, size_t derived_size) | 200 DisplayItem(const DisplayItemClient& client, Type type, size_t derived_size) |
| 201 : client_(&client), | 201 : client_(&client), |
| 202 visual_rect_(client.VisualRect()), | |
| 203 type_(type), | 202 type_(type), |
| 204 derived_size_(derived_size), | 203 derived_size_(derived_size), |
| 205 skipped_cache_(false) | 204 skipped_cache_(false) |
| 206 #ifndef NDEBUG | 205 #ifndef NDEBUG |
| 207 , | 206 , |
| 208 client_debug_string_(client.DebugName()) | 207 client_debug_string_(client.DebugName()) |
| 209 #endif | 208 #endif |
| 210 { | 209 { |
| 211 // derivedSize must fit in m_derivedSize. | 210 // derivedSize must fit in m_derivedSize. |
| 212 // If it doesn't, enlarge m_derivedSize and fix this assert. | 211 // If it doesn't, enlarge m_derivedSize and fix this assert. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 227 }; | 226 }; |
| 228 | 227 |
| 229 Id GetId() const { return Id(*client_, type_); } | 228 Id GetId() const { return Id(*client_, type_); } |
| 230 | 229 |
| 231 virtual void Replay(GraphicsContext&) const {} | 230 virtual void Replay(GraphicsContext&) const {} |
| 232 | 231 |
| 233 const DisplayItemClient& Client() const { | 232 const DisplayItemClient& Client() const { |
| 234 DCHECK(client_); | 233 DCHECK(client_); |
| 235 return *client_; | 234 return *client_; |
| 236 } | 235 } |
| 237 | |
| 238 // This equals to Client().VisualRect() as long as the client is alive and is | |
| 239 // not invalidated. Otherwise it saves the previous visual rect of the client. | |
| 240 // See DisplayItemClient::VisualRect() about its coordinate space. | |
| 241 const LayoutRect& VisualRect() const { return visual_rect_; } | |
| 242 | |
| 243 Type GetType() const { return type_; } | 236 Type GetType() const { return type_; } |
| 244 | 237 |
| 245 // Size of this object in memory, used to move it with memcpy. | 238 // Size of this object in memory, used to move it with memcpy. |
| 246 // This is not sizeof(*this), because it needs to account for the size of | 239 // This is not sizeof(*this), because it needs to account for the size of |
| 247 // the derived class (i.e. runtime type). Derived classes are expected to | 240 // the derived class (i.e. runtime type). Derived classes are expected to |
| 248 // supply this to the DisplayItem constructor. | 241 // supply this to the DisplayItem constructor. |
| 249 size_t DerivedSize() const { return derived_size_; } | 242 size_t DerivedSize() const { return derived_size_; } |
| 250 | 243 |
| 251 // For PaintController only. Painters should use DisplayItemCacheSkipper | 244 // For PaintController only. Painters should use DisplayItemCacheSkipper |
| 252 // instead. | 245 // instead. |
| 253 void SetSkippedCache() { skipped_cache_ = true; } | 246 void SetSkippedCache() { skipped_cache_ = true; } |
| 254 bool SkippedCache() const { return skipped_cache_; } | 247 bool SkippedCache() const { return skipped_cache_; } |
| 255 | 248 |
| 256 // Appends this display item to the WebDisplayItemList, if applicable. | 249 // TODO(wkorman): Only DrawingDisplayItem needs the visual rect argument. |
| 257 // |visual_rect_offset| is the offset between the space of the GraphicsLayer | 250 // Consider refactoring class hierarchy to make this more explicit. |
| 258 // which owns the display item and the coordinate space of VisualRect(). | 251 virtual void AppendToWebDisplayItemList(const IntRect&, |
| 259 // TODO(wangxianzhu): Remove the parameter for slimming paint v2. | |
| 260 virtual void AppendToWebDisplayItemList(const LayoutSize& visual_rect_offset, | |
| 261 WebDisplayItemList*) const {} | 252 WebDisplayItemList*) const {} |
| 262 | 253 |
| 263 // See comments of enum Type for usage of the following macros. | 254 // See comments of enum Type for usage of the following macros. |
| 264 #define DEFINE_CATEGORY_METHODS(Category) \ | 255 #define DEFINE_CATEGORY_METHODS(Category) \ |
| 265 static bool Is##Category##Type(Type type) { \ | 256 static bool Is##Category##Type(Type type) { \ |
| 266 return type >= k##Category##First && type <= k##Category##Last; \ | 257 return type >= k##Category##First && type <= k##Category##Last; \ |
| 267 } \ | 258 } \ |
| 268 bool Is##Category() const { return Is##Category##Type(GetType()); } | 259 bool Is##Category() const { return Is##Category##Type(GetType()); } |
| 269 | 260 |
| 270 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \ | 261 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \ |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 WTF::String AsDebugString() const; | 344 WTF::String AsDebugString() const; |
| 354 virtual void DumpPropertiesAsDebugString(WTF::StringBuilder&) const; | 345 virtual void DumpPropertiesAsDebugString(WTF::StringBuilder&) const; |
| 355 #endif | 346 #endif |
| 356 | 347 |
| 357 private: | 348 private: |
| 358 // The default DisplayItem constructor is only used by | 349 // The default DisplayItem constructor is only used by |
| 359 // ContiguousContainer::appendByMoving where an invalid DisplaItem is | 350 // ContiguousContainer::appendByMoving where an invalid DisplaItem is |
| 360 // constructed at the source location. | 351 // constructed at the source location. |
| 361 template <typename T, unsigned alignment> | 352 template <typename T, unsigned alignment> |
| 362 friend class ContiguousContainer; | 353 friend class ContiguousContainer; |
| 363 friend class DisplayItemList; | |
| 364 | 354 |
| 365 DisplayItem() | 355 DisplayItem() |
| 366 : client_(nullptr), | 356 : client_(nullptr), |
| 367 type_(kUninitializedType), | 357 type_(kUninitializedType), |
| 368 derived_size_(sizeof(*this)), | 358 derived_size_(sizeof(*this)), |
| 369 skipped_cache_(false) {} | 359 skipped_cache_(false) {} |
| 370 | 360 |
| 371 const DisplayItemClient* client_; | 361 const DisplayItemClient* client_; |
| 372 LayoutRect visual_rect_; | |
| 373 | |
| 374 static_assert(kTypeLast < (1 << 16), | 362 static_assert(kTypeLast < (1 << 16), |
| 375 "DisplayItem::Type should fit in 16 bits"); | 363 "DisplayItem::Type should fit in 16 bits"); |
| 376 const Type type_ : 16; | 364 const Type type_ : 16; |
| 377 const unsigned derived_size_ : 8; // size of the actual derived class | 365 const unsigned derived_size_ : 8; // size of the actual derived class |
| 378 unsigned skipped_cache_ : 1; | 366 unsigned skipped_cache_ : 1; |
| 379 | 367 |
| 380 #ifndef NDEBUG | 368 #ifndef NDEBUG |
| 381 WTF::String client_debug_string_; | 369 WTF::String client_debug_string_; |
| 382 #endif | 370 #endif |
| 383 }; | 371 }; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 412 bool IsEndAndPairedWith(DisplayItem::Type other_type) const override = 0; | 400 bool IsEndAndPairedWith(DisplayItem::Type other_type) const override = 0; |
| 413 #endif | 401 #endif |
| 414 | 402 |
| 415 private: | 403 private: |
| 416 bool IsEnd() const final { return true; } | 404 bool IsEnd() const final { return true; } |
| 417 }; | 405 }; |
| 418 | 406 |
| 419 } // namespace blink | 407 } // namespace blink |
| 420 | 408 |
| 421 #endif // DisplayItem_h | 409 #endif // DisplayItem_h |
| OLD | NEW |