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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 TableCollapsedBorderBottom = 1 << 2, | 182 TableCollapsedBorderBottom = 1 << 2, |
183 TableCollapsedBorderLeft = 1 << 3, | 183 TableCollapsedBorderLeft = 1 << 3, |
184 }; | 184 }; |
185 | 185 |
186 DisplayItem(const DisplayItemClientWrapper& client, Type type, size_t derive dSize) | 186 DisplayItem(const DisplayItemClientWrapper& client, Type type, size_t derive dSize) |
187 : m_client(client.displayItemClient()) | 187 : m_client(client.displayItemClient()) |
188 , m_scope(0) | 188 , m_scope(0) |
189 , m_type(type) | 189 , m_type(type) |
190 , m_derivedSize(derivedSize) | 190 , m_derivedSize(derivedSize) |
191 , m_skippedCache(false) | 191 , m_skippedCache(false) |
192 , m_isUncacheable(false) | |
192 #ifndef NDEBUG | 193 #ifndef NDEBUG |
193 , m_clientDebugString(client.debugName()) | 194 , m_clientDebugString(client.debugName()) |
194 #endif | 195 #endif |
195 { | 196 { |
196 // derivedSize must fit in m_derivedSize. | 197 // derivedSize must fit in m_derivedSize. |
197 // If it doesn't, enlarge m_derivedSize and fix this assert. | 198 // If it doesn't, enlarge m_derivedSize and fix this assert. |
198 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize < (1 << 8)); | 199 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize < (1 << 8)); |
199 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize >= sizeof(*this)); | 200 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize >= sizeof(*this)); |
200 } | 201 } |
201 | 202 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 // Size of this object in memory, used to move it with memcpy. | 251 // Size of this object in memory, used to move it with memcpy. |
251 // This is not sizeof(*this), because it needs to account for the size of | 252 // This is not sizeof(*this), because it needs to account for the size of |
252 // the derived class (i.e. runtime type). Derived classes are expected to | 253 // the derived class (i.e. runtime type). Derived classes are expected to |
253 // supply this to the DisplayItem constructor. | 254 // supply this to the DisplayItem constructor. |
254 size_t derivedSize() const { return m_derivedSize; } | 255 size_t derivedSize() const { return m_derivedSize; } |
255 | 256 |
256 // For DisplayItemList only. Painters should use DisplayItemCacheSkipper ins tead. | 257 // For DisplayItemList only. Painters should use DisplayItemCacheSkipper ins tead. |
257 void setSkippedCache() { m_skippedCache = true; } | 258 void setSkippedCache() { m_skippedCache = true; } |
258 bool skippedCache() const { return m_skippedCache; } | 259 bool skippedCache() const { return m_skippedCache; } |
259 | 260 |
261 void setUncacheable() { m_isUncacheable = true; } | |
262 bool isUncacheable() const { return m_isUncacheable; } | |
chrishtr
2015/09/08 22:48:00
This can be private.
| |
263 | |
260 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const { } | 264 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const { } |
261 | 265 |
262 // See comments of enum Type for usage of the following macros. | 266 // See comments of enum Type for usage of the following macros. |
263 #define DEFINE_CATEGORY_METHODS(Category) \ | 267 #define DEFINE_CATEGORY_METHODS(Category) \ |
264 static bool is##Category##Type(Type type) { return type >= Category##First & & type <= Category##Last; } \ | 268 static bool is##Category##Type(Type type) { return type >= Category##First & & type <= Category##Last; } \ |
265 bool is##Category() const { return is##Category##Type(type()); } | 269 bool is##Category() const { return is##Category##Type(type()); } |
266 | 270 |
267 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \ | 271 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \ |
268 static Type category1##TypeTo##Category2##Type(Type type) \ | 272 static Type category1##TypeTo##Category2##Type(Type type) \ |
269 { \ | 273 { \ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 DEFINE_PAINT_PHASE_CONVERSION_METHOD(FloatClip) | 309 DEFINE_PAINT_PHASE_CONVERSION_METHOD(FloatClip) |
306 | 310 |
307 DEFINE_PAIRED_CATEGORY_METHODS(Scroll, scroll) | 311 DEFINE_PAIRED_CATEGORY_METHODS(Scroll, scroll) |
308 DEFINE_PAINT_PHASE_CONVERSION_METHOD(Scroll) | 312 DEFINE_PAINT_PHASE_CONVERSION_METHOD(Scroll) |
309 | 313 |
310 DEFINE_PAIRED_CATEGORY_METHODS(Transform3D, transform3D); | 314 DEFINE_PAIRED_CATEGORY_METHODS(Transform3D, transform3D); |
311 | 315 |
312 static bool isCachedType(Type type) { return isCachedDrawingType(type) || ty pe == CachedSubsequence; } | 316 static bool isCachedType(Type type) { return isCachedDrawingType(type) || ty pe == CachedSubsequence; } |
313 bool isCached() const { return isCachedType(m_type); } | 317 bool isCached() const { return isCachedType(m_type); } |
314 static bool isCacheableType(Type type) { return isDrawingType(type) || type == BeginSubsequence; } | 318 static bool isCacheableType(Type type) { return isDrawingType(type) || type == BeginSubsequence; } |
315 bool isCacheable() const { return !skippedCache() && isCacheableType(m_type) ; } | 319 bool isCacheable() const { return !isUncacheable() && isCacheableType(m_type ); } |
316 | 320 |
317 virtual bool isBegin() const { return false; } | 321 virtual bool isBegin() const { return false; } |
318 virtual bool isEnd() const { return false; } | 322 virtual bool isEnd() const { return false; } |
319 | 323 |
320 #if ENABLE(ASSERT) | 324 #if ENABLE(ASSERT) |
321 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return false; } | 325 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return false; } |
322 #endif | 326 #endif |
323 | 327 |
324 virtual bool drawsContent() const { return false; } | 328 virtual bool drawsContent() const { return false; } |
325 | 329 |
(...skipping 13 matching lines...) Expand all Loading... | |
339 // ContiguousContainer::appendByMoving where an invalid DisplaItem is | 343 // ContiguousContainer::appendByMoving where an invalid DisplaItem is |
340 // constructed at the source location. | 344 // constructed at the source location. |
341 template <typename T, unsigned alignment> friend class ContiguousContainer; | 345 template <typename T, unsigned alignment> friend class ContiguousContainer; |
342 | 346 |
343 DisplayItem() | 347 DisplayItem() |
344 : m_client(nullptr) | 348 : m_client(nullptr) |
345 , m_scope(0) | 349 , m_scope(0) |
346 , m_type(UninitializedType) | 350 , m_type(UninitializedType) |
347 , m_derivedSize(sizeof(*this)) | 351 , m_derivedSize(sizeof(*this)) |
348 , m_skippedCache(false) | 352 , m_skippedCache(false) |
353 , m_isUncacheable(false) | |
349 { } | 354 { } |
350 | 355 |
351 DisplayItemClient m_client; | 356 DisplayItemClient m_client; |
352 unsigned m_scope; | 357 unsigned m_scope; |
353 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits "); | 358 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits "); |
354 const Type m_type : 16; | 359 const Type m_type : 16; |
355 unsigned m_derivedSize : 8; // size of the actual derived class | 360 unsigned m_derivedSize : 8; // size of the actual derived class |
356 unsigned m_skippedCache : 1; | 361 unsigned m_skippedCache : 1; |
362 unsigned m_isUncacheable : 1; | |
357 | 363 |
358 #ifndef NDEBUG | 364 #ifndef NDEBUG |
359 WTF::String m_clientDebugString; | 365 WTF::String m_clientDebugString; |
360 #endif | 366 #endif |
361 }; | 367 }; |
362 | 368 |
363 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { | 369 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { |
364 protected: | 370 protected: |
365 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type, si ze_t derivedSize) : DisplayItem(client, type, derivedSize) { } | 371 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type, si ze_t derivedSize) : DisplayItem(client, type, derivedSize) { } |
366 | 372 |
367 private: | 373 private: |
368 bool isBegin() const final { return true; } | 374 bool isBegin() const final { return true; } |
369 }; | 375 }; |
370 | 376 |
371 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { | 377 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { |
372 protected: | 378 protected: |
373 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type, size _t derivedSize) : DisplayItem(client, type, derivedSize) { } | 379 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type, size _t derivedSize) : DisplayItem(client, type, derivedSize) { } |
374 | 380 |
375 #if ENABLE(ASSERT) | 381 #if ENABLE(ASSERT) |
376 bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0; | 382 bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0; |
377 #endif | 383 #endif |
378 | 384 |
379 private: | 385 private: |
380 bool isEnd() const final { return true; } | 386 bool isEnd() const final { return true; } |
381 }; | 387 }; |
382 | 388 |
383 } // namespace blink | 389 } // namespace blink |
384 | 390 |
385 #endif // DisplayItem_h | 391 #endif // DisplayItem_h |
OLD | NEW |