| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 UninitializedType, | 177 UninitializedType, |
| 178 TypeLast = UninitializedType | 178 TypeLast = UninitializedType |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 DisplayItem(const DisplayItemClientWrapper& client, Type type, size_t derive
dSize) | 181 DisplayItem(const DisplayItemClientWrapper& client, Type type, size_t derive
dSize) |
| 182 : m_client(client.displayItemClient()) | 182 : m_client(client.displayItemClient()) |
| 183 , m_scope(0) | 183 , m_scope(0) |
| 184 , m_type(type) | 184 , m_type(type) |
| 185 , m_derivedSize(derivedSize) | 185 , m_derivedSize(derivedSize) |
| 186 , m_skippedCache(false) | 186 , m_skippedCache(false) |
| 187 , m_ignoredFromList(false) | |
| 188 #ifndef NDEBUG | 187 #ifndef NDEBUG |
| 189 , m_clientDebugString(client.debugName()) | 188 , m_clientDebugString(client.debugName()) |
| 190 #endif | 189 #endif |
| 191 { | 190 { |
| 192 // derivedSize must fit in m_derivedSize. | 191 // derivedSize must fit in m_derivedSize. |
| 193 // If it doesn't, enlarge m_derivedSize and fix this assert. | 192 // If it doesn't, enlarge m_derivedSize and fix this assert. |
| 194 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize < (1 << 8)); | 193 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize < (1 << 8)); |
| 195 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize >= sizeof(*this)); | 194 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize >= sizeof(*this)); |
| 196 } | 195 } |
| 197 | 196 |
| 197 virtual ~DisplayItem() { } |
| 198 |
| 198 // Ids are for matching new DisplayItems with existing DisplayItems. | 199 // Ids are for matching new DisplayItems with existing DisplayItems. |
| 199 struct Id { | 200 struct Id { |
| 200 Id(const DisplayItemClient client, const Type type, const unsigned scope
) | 201 Id(const DisplayItemClient client, const Type type, const unsigned scope
) |
| 201 : client(client) | 202 : client(client) |
| 202 , type(type) | 203 , type(type) |
| 203 , scope(scope) { } | 204 , scope(scope) { } |
| 204 | 205 |
| 205 bool matches(const DisplayItem& item) const | 206 bool matches(const DisplayItem& item) const |
| 206 { | 207 { |
| 207 // We should always convert to non-cached types before matching. | 208 // We should always convert to non-cached types before matching. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 226 return cachedSubtreeTypeToBeginSubtreeType(m_type); | 227 return cachedSubtreeTypeToBeginSubtreeType(m_type); |
| 227 return m_type; | 228 return m_type; |
| 228 } | 229 } |
| 229 | 230 |
| 230 // Return the Id with cached type converted to non-cached type. | 231 // Return the Id with cached type converted to non-cached type. |
| 231 Id nonCachedId() const | 232 Id nonCachedId() const |
| 232 { | 233 { |
| 233 return Id(m_client, nonCachedType(), m_scope); | 234 return Id(m_client, nonCachedType(), m_scope); |
| 234 } | 235 } |
| 235 | 236 |
| 236 virtual ~DisplayItem() { } | |
| 237 | |
| 238 virtual void replay(GraphicsContext&) { } | 237 virtual void replay(GraphicsContext&) { } |
| 239 | 238 |
| 240 DisplayItemClient client() const { return m_client; } | 239 DisplayItemClient client() const { return m_client; } |
| 241 Type type() const { return m_type; } | 240 Type type() const { return m_type; } |
| 242 | 241 |
| 243 void setScope(unsigned scope) { m_scope = scope; } | 242 void setScope(unsigned scope) { m_scope = scope; } |
| 244 unsigned scope() { return m_scope; } | 243 unsigned scope() { return m_scope; } |
| 245 | 244 |
| 246 // Size of this object in memory, used to move it with memcpy. | 245 // Size of this object in memory, used to move it with memcpy. |
| 247 // This is not sizeof(*this), because it needs to account for the size of | 246 // This is not sizeof(*this), because it needs to account for the size of |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 321 |
| 323 virtual bool isBegin() const { return false; } | 322 virtual bool isBegin() const { return false; } |
| 324 virtual bool isEnd() const { return false; } | 323 virtual bool isEnd() const { return false; } |
| 325 | 324 |
| 326 #if ENABLE(ASSERT) | 325 #if ENABLE(ASSERT) |
| 327 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return
false; } | 326 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return
false; } |
| 328 #endif | 327 #endif |
| 329 | 328 |
| 330 virtual bool drawsContent() const { return false; } | 329 virtual bool drawsContent() const { return false; } |
| 331 | 330 |
| 332 bool ignoreFromDisplayList() const { return m_ignoredFromList; } | 331 bool isValid() const { return m_client; } |
| 333 void setIgnoredFromDisplayList() { m_ignoredFromList = true; } | 332 void clearClientForUnderInvalidationChecking() { m_client = nullptr; } |
| 334 | 333 |
| 335 #ifndef NDEBUG | 334 #ifndef NDEBUG |
| 336 static WTF::String typeAsDebugString(DisplayItem::Type); | 335 static WTF::String typeAsDebugString(DisplayItem::Type); |
| 337 const WTF::String& clientDebugString() const { return m_clientDebugString; } | 336 const WTF::String& clientDebugString() const { return m_clientDebugString; } |
| 338 WTF::String asDebugString() const; | 337 WTF::String asDebugString() const; |
| 339 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const; | 338 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const; |
| 340 #endif | 339 #endif |
| 341 | 340 |
| 342 private: | 341 private: |
| 343 // The default DisplayItem constructor is only used by | 342 // The default DisplayItem constructor is only used by |
| 344 // ContiguousContainer::appendByMoving where an invalid DisplaItem is | 343 // ContiguousContainer::appendByMoving where an invalid DisplaItem is |
| 345 // constructed at the source location. | 344 // constructed at the source location. |
| 346 template <typename T, unsigned alignment> friend class ContiguousContainer; | 345 template <typename T, unsigned alignment> friend class ContiguousContainer; |
| 347 | 346 |
| 348 DisplayItem() | 347 DisplayItem() |
| 349 : m_client(nullptr) | 348 : m_client(nullptr) |
| 350 , m_scope(0) | 349 , m_scope(0) |
| 351 , m_type(UninitializedType) | 350 , m_type(UninitializedType) |
| 352 , m_derivedSize(sizeof(*this)) | 351 , m_derivedSize(sizeof(*this)) |
| 353 , m_skippedCache(false) | 352 , m_skippedCache(false) |
| 354 , m_ignoredFromList(true) | |
| 355 #ifndef NDEBUG | 353 #ifndef NDEBUG |
| 356 , m_clientDebugString("invalid") | 354 , m_clientDebugString("invalid") |
| 357 #endif | 355 #endif |
| 358 { } | 356 { } |
| 359 | 357 |
| 360 const DisplayItemClient m_client; | 358 DisplayItemClient m_client; |
| 361 unsigned m_scope; | 359 unsigned m_scope; |
| 362 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits
"); | 360 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits
"); |
| 363 const Type m_type : 16; | 361 const Type m_type : 16; |
| 364 unsigned m_derivedSize : 8; // size of the actual derived class | 362 unsigned m_derivedSize : 8; // size of the actual derived class |
| 365 unsigned m_skippedCache : 1; | 363 unsigned m_skippedCache : 1; |
| 366 unsigned m_ignoredFromList : 1; | |
| 367 | 364 |
| 368 #ifndef NDEBUG | 365 #ifndef NDEBUG |
| 369 WTF::String m_clientDebugString; | 366 WTF::String m_clientDebugString; |
| 370 #endif | 367 #endif |
| 371 }; | 368 }; |
| 372 | 369 |
| 373 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { | 370 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { |
| 374 protected: | 371 protected: |
| 375 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type, si
ze_t derivedSize) : DisplayItem(client, type, derivedSize) { } | 372 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type, si
ze_t derivedSize) : DisplayItem(client, type, derivedSize) { } |
| 376 | 373 |
| 377 private: | 374 private: |
| 378 bool isBegin() const final { return true; } | 375 bool isBegin() const final { return true; } |
| 379 }; | 376 }; |
| 380 | 377 |
| 381 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { | 378 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { |
| 382 protected: | 379 protected: |
| 383 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type, size
_t derivedSize) : DisplayItem(client, type, derivedSize) { } | 380 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type, size
_t derivedSize) : DisplayItem(client, type, derivedSize) { } |
| 384 | 381 |
| 385 #if ENABLE(ASSERT) | 382 #if ENABLE(ASSERT) |
| 386 bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0; | 383 bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0; |
| 387 #endif | 384 #endif |
| 388 | 385 |
| 389 private: | 386 private: |
| 390 bool isEnd() const final { return true; } | 387 bool isEnd() const final { return true; } |
| 391 }; | 388 }; |
| 392 | 389 |
| 393 } // namespace blink | 390 } // namespace blink |
| 394 | 391 |
| 395 #endif // DisplayItem_h | 392 #endif // DisplayItem_h |
| OLD | NEW |