| 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" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 TableSectionBoxShadowInset, | 109 TableSectionBoxShadowInset, |
| 110 TableSectionBoxShadowNormal, | 110 TableSectionBoxShadowNormal, |
| 111 TableRowBoxShadowInset, | 111 TableRowBoxShadowInset, |
| 112 TableRowBoxShadowNormal, | 112 TableRowBoxShadowNormal, |
| 113 VideoBitmap, | 113 VideoBitmap, |
| 114 WebPlugin, | 114 WebPlugin, |
| 115 WebFont, | 115 WebFont, |
| 116 ReflectionMask, | 116 ReflectionMask, |
| 117 DrawingLast = ReflectionMask, | 117 DrawingLast = ReflectionMask, |
| 118 | 118 |
| 119 CachedDrawingFirst, | |
| 120 CachedDrawingLast = CachedDrawingFirst + DrawingLast - DrawingFirst, | |
| 121 | |
| 122 ForeignLayerFirst, | 119 ForeignLayerFirst, |
| 123 ForeignLayerCanvas = ForeignLayerFirst, | 120 ForeignLayerCanvas = ForeignLayerFirst, |
| 124 ForeignLayerPlugin, | 121 ForeignLayerPlugin, |
| 125 ForeignLayerVideo, | 122 ForeignLayerVideo, |
| 126 ForeignLayerLast = ForeignLayerVideo, | 123 ForeignLayerLast = ForeignLayerVideo, |
| 127 | 124 |
| 128 ClipFirst, | 125 ClipFirst, |
| 129 ClipBoxPaintPhaseFirst = ClipFirst, | 126 ClipBoxPaintPhaseFirst = ClipFirst, |
| 130 ClipBoxPaintPhaseLast = ClipBoxPaintPhaseFirst + PaintPhaseMax, | 127 ClipBoxPaintPhaseLast = ClipBoxPaintPhaseFirst + PaintPhaseMax, |
| 131 ClipColumnBoundsPaintPhaseFirst, | 128 ClipColumnBoundsPaintPhaseFirst, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 EndFilter, | 174 EndFilter, |
| 178 BeginCompositing, | 175 BeginCompositing, |
| 179 EndCompositing, | 176 EndCompositing, |
| 180 BeginTransform, | 177 BeginTransform, |
| 181 EndTransform, | 178 EndTransform, |
| 182 BeginClipPath, | 179 BeginClipPath, |
| 183 EndClipPath, | 180 EndClipPath, |
| 184 | 181 |
| 185 Subsequence, | 182 Subsequence, |
| 186 EndSubsequence, | 183 EndSubsequence, |
| 187 CachedSubsequence, | |
| 188 | 184 |
| 189 UninitializedType, | 185 UninitializedType, |
| 190 TypeLast = UninitializedType | 186 TypeLast = UninitializedType |
| 191 }; | 187 }; |
| 192 | 188 |
| 193 static_assert(TableCollapsedBorderBase >= TableCollapsedBorderUnalignedBase,
"TableCollapsedBorder types overlap with other types"); | 189 static_assert(TableCollapsedBorderBase >= TableCollapsedBorderUnalignedBase,
"TableCollapsedBorder types overlap with other types"); |
| 194 static_assert((TableCollapsedBorderBase & 0xf) == 0, "The lowest 4 bits of T
ableCollapsedBorderBase should be zero"); | 190 static_assert((TableCollapsedBorderBase & 0xf) == 0, "The lowest 4 bits of T
ableCollapsedBorderBase should be zero"); |
| 195 // Bits or'ed onto TableCollapsedBorderBase to generate a real table collaps
ed border type. | 191 // Bits or'ed onto TableCollapsedBorderBase to generate a real table collaps
ed border type. |
| 196 enum TableCollapsedBorderSides { | 192 enum TableCollapsedBorderSides { |
| 197 TableCollapsedBorderTop = 1 << 0, | 193 TableCollapsedBorderTop = 1 << 0, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 217 | 213 |
| 218 virtual ~DisplayItem() { } | 214 virtual ~DisplayItem() { } |
| 219 | 215 |
| 220 // Ids are for matching new DisplayItems with existing DisplayItems. | 216 // Ids are for matching new DisplayItems with existing DisplayItems. |
| 221 struct Id { | 217 struct Id { |
| 222 STACK_ALLOCATED(); | 218 STACK_ALLOCATED(); |
| 223 Id(const DisplayItemClient& client, const Type type) | 219 Id(const DisplayItemClient& client, const Type type) |
| 224 : client(client) | 220 : client(client) |
| 225 , type(type) { } | 221 , type(type) { } |
| 226 | 222 |
| 227 bool matches(const DisplayItem& item) const | |
| 228 { | |
| 229 // We should always convert to non-cached types before matching. | |
| 230 ASSERT(!isCachedType(item.m_type)); | |
| 231 ASSERT(!isCachedType(type)); | |
| 232 return &client == item.m_client && type == item.m_type; | |
| 233 } | |
| 234 | |
| 235 const DisplayItemClient& client; | 223 const DisplayItemClient& client; |
| 236 const Type type; | 224 const Type type; |
| 237 }; | 225 }; |
| 238 | 226 |
| 239 // Convert cached type to non-cached type (e.g., Type::CachedSVGImage -> Typ
e::SVGImage). | 227 Id getId() const { return Id(*m_client, m_type); } |
| 240 static Type nonCachedType(Type type) | |
| 241 { | |
| 242 if (isCachedDrawingType(type)) | |
| 243 return cachedDrawingTypeToDrawingType(type); | |
| 244 if (type == CachedSubsequence) | |
| 245 return Subsequence; | |
| 246 return type; | |
| 247 } | |
| 248 | |
| 249 // Return the Id with cached type converted to non-cached type. | |
| 250 Id nonCachedId() const | |
| 251 { | |
| 252 return Id(*m_client, nonCachedType(m_type)); | |
| 253 } | |
| 254 | 228 |
| 255 virtual void replay(GraphicsContext&) const { } | 229 virtual void replay(GraphicsContext&) const { } |
| 256 | 230 |
| 257 const DisplayItemClient& client() const { ASSERT(m_client); return *m_client
; } | 231 const DisplayItemClient& client() const { ASSERT(m_client); return *m_client
; } |
| 258 Type getType() const { return m_type; } | 232 Type getType() const { return m_type; } |
| 259 | 233 |
| 260 // Size of this object in memory, used to move it with memcpy. | 234 // Size of this object in memory, used to move it with memcpy. |
| 261 // This is not sizeof(*this), because it needs to account for the size of | 235 // This is not sizeof(*this), because it needs to account for the size of |
| 262 // the derived class (i.e. runtime type). Derived classes are expected to | 236 // the derived class (i.e. runtime type). Derived classes are expected to |
| 263 // supply this to the DisplayItem constructor. | 237 // supply this to the DisplayItem constructor. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 #define DEFINE_PAINT_PHASE_CONVERSION_METHOD(Category) \ | 270 #define DEFINE_PAINT_PHASE_CONVERSION_METHOD(Category) \ |
| 297 static Type paintPhaseTo##Category##Type(int paintPhase) \ | 271 static Type paintPhaseTo##Category##Type(int paintPhase) \ |
| 298 { \ | 272 { \ |
| 299 static_assert(Category##PaintPhaseLast - Category##PaintPhaseFirst == Pa
intPhaseMax, \ | 273 static_assert(Category##PaintPhaseLast - Category##PaintPhaseFirst == Pa
intPhaseMax, \ |
| 300 "Invalid paint-phase-based category " #Category ". See comments of D
isplayItem::Type"); \ | 274 "Invalid paint-phase-based category " #Category ". See comments of D
isplayItem::Type"); \ |
| 301 return static_cast<Type>(paintPhase + Category##PaintPhaseFirst); \ | 275 return static_cast<Type>(paintPhase + Category##PaintPhaseFirst); \ |
| 302 } | 276 } |
| 303 | 277 |
| 304 DEFINE_CATEGORY_METHODS(Drawing) | 278 DEFINE_CATEGORY_METHODS(Drawing) |
| 305 DEFINE_PAINT_PHASE_CONVERSION_METHOD(Drawing) | 279 DEFINE_PAINT_PHASE_CONVERSION_METHOD(Drawing) |
| 306 DEFINE_CATEGORY_METHODS(CachedDrawing) | |
| 307 DEFINE_CONVERSION_METHODS(Drawing, drawing, CachedDrawing, cachedDrawing) | |
| 308 | 280 |
| 309 DEFINE_CATEGORY_METHODS(ForeignLayer) | 281 DEFINE_CATEGORY_METHODS(ForeignLayer) |
| 310 | 282 |
| 311 DEFINE_PAIRED_CATEGORY_METHODS(Clip, clip) | 283 DEFINE_PAIRED_CATEGORY_METHODS(Clip, clip) |
| 312 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipLayerFragment) | 284 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipLayerFragment) |
| 313 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipBox) | 285 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipBox) |
| 314 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipColumnBounds) | 286 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipColumnBounds) |
| 315 | 287 |
| 316 DEFINE_PAIRED_CATEGORY_METHODS(FloatClip, floatClip) | 288 DEFINE_PAIRED_CATEGORY_METHODS(FloatClip, floatClip) |
| 317 DEFINE_PAINT_PHASE_CONVERSION_METHOD(FloatClip) | 289 DEFINE_PAINT_PHASE_CONVERSION_METHOD(FloatClip) |
| 318 | 290 |
| 319 DEFINE_PAIRED_CATEGORY_METHODS(Scroll, scroll) | 291 DEFINE_PAIRED_CATEGORY_METHODS(Scroll, scroll) |
| 320 DEFINE_PAINT_PHASE_CONVERSION_METHOD(Scroll) | 292 DEFINE_PAINT_PHASE_CONVERSION_METHOD(Scroll) |
| 321 | 293 |
| 322 DEFINE_PAIRED_CATEGORY_METHODS(Transform3D, transform3D) | 294 DEFINE_PAIRED_CATEGORY_METHODS(Transform3D, transform3D) |
| 323 | 295 |
| 324 static bool isCachedType(Type type) { return isCachedDrawingType(type) || ty
pe == CachedSubsequence; } | |
| 325 bool isCached() const { return isCachedType(m_type); } | |
| 326 static bool isCacheableType(Type type) { return isDrawingType(type) || type
== Subsequence; } | 296 static bool isCacheableType(Type type) { return isDrawingType(type) || type
== Subsequence; } |
| 327 bool isCacheable() const { return !skippedCache() && isCacheableType(m_type)
; } | 297 bool isCacheable() const { return !skippedCache() && isCacheableType(m_type)
; } |
| 328 | 298 |
| 329 virtual bool isBegin() const { return false; } | 299 virtual bool isBegin() const { return false; } |
| 330 virtual bool isEnd() const { return false; } | 300 virtual bool isEnd() const { return false; } |
| 331 | 301 |
| 332 #if DCHECK_IS_ON() | 302 #if DCHECK_IS_ON() |
| 333 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return
false; } | 303 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return
false; } |
| 334 virtual bool equals(const DisplayItem& other) const | 304 virtual bool equals(const DisplayItem& other) const |
| 335 { | 305 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits
"); | 346 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits
"); |
| 377 const Type m_type : 16; | 347 const Type m_type : 16; |
| 378 const unsigned m_derivedSize : 8; // size of the actual derived class | 348 const unsigned m_derivedSize : 8; // size of the actual derived class |
| 379 unsigned m_skippedCache : 1; | 349 unsigned m_skippedCache : 1; |
| 380 | 350 |
| 381 #ifndef NDEBUG | 351 #ifndef NDEBUG |
| 382 WTF::String m_clientDebugString; | 352 WTF::String m_clientDebugString; |
| 383 #endif | 353 #endif |
| 384 }; | 354 }; |
| 385 | 355 |
| 356 inline bool operator==(const DisplayItem::Id& a, const DisplayItem::Id& b) |
| 357 { |
| 358 return a.client == b.client && a.type == b.type; |
| 359 } |
| 360 |
| 361 inline bool operator!=(const DisplayItem::Id& a, const DisplayItem::Id& b) |
| 362 { |
| 363 return !(a == b); |
| 364 } |
| 365 |
| 386 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { | 366 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { |
| 387 protected: | 367 protected: |
| 388 PairedBeginDisplayItem(const DisplayItemClient& client, Type type, size_t de
rivedSize) : DisplayItem(client, type, derivedSize) { } | 368 PairedBeginDisplayItem(const DisplayItemClient& client, Type type, size_t de
rivedSize) : DisplayItem(client, type, derivedSize) { } |
| 389 | 369 |
| 390 private: | 370 private: |
| 391 bool isBegin() const final { return true; } | 371 bool isBegin() const final { return true; } |
| 392 }; | 372 }; |
| 393 | 373 |
| 394 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { | 374 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { |
| 395 protected: | 375 protected: |
| 396 PairedEndDisplayItem(const DisplayItemClient& client, Type type, size_t deri
vedSize) : DisplayItem(client, type, derivedSize) { } | 376 PairedEndDisplayItem(const DisplayItemClient& client, Type type, size_t deri
vedSize) : DisplayItem(client, type, derivedSize) { } |
| 397 | 377 |
| 398 #if ENABLE(ASSERT) | 378 #if ENABLE(ASSERT) |
| 399 bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0; | 379 bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0; |
| 400 #endif | 380 #endif |
| 401 | 381 |
| 402 private: | 382 private: |
| 403 bool isEnd() const final { return true; } | 383 bool isEnd() const final { return true; } |
| 404 }; | 384 }; |
| 405 | 385 |
| 406 } // namespace blink | 386 } // namespace blink |
| 407 | 387 |
| 408 #endif // DisplayItem_h | 388 #endif // DisplayItem_h |
| OLD | NEW |