Chromium Code Reviews| 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" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 EndSubtreePaintPhaseLast = EndSubtreePaintPhaseFirst + PaintPhaseMax, | 174 EndSubtreePaintPhaseLast = EndSubtreePaintPhaseFirst + PaintPhaseMax, |
| 175 EndSubtreeLast = EndSubtreePaintPhaseLast, | 175 EndSubtreeLast = EndSubtreePaintPhaseLast, |
| 176 | 176 |
| 177 TypeLast = EndSubtreeLast | 177 TypeLast = EndSubtreeLast |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 virtual ~DisplayItem() { } | 180 virtual ~DisplayItem() { } |
| 181 | 181 |
| 182 virtual void replay(GraphicsContext&) { } | 182 virtual void replay(GraphicsContext&) { } |
| 183 | 183 |
| 184 DisplayItemClient client() const { return m_id.client; } | 184 DisplayItemClient client() const { return m_client; } |
| 185 Type type() const { return m_id.type; } | 185 Type type() const { return m_type; } |
| 186 bool idsEqual(const DisplayItem& other, Type overrideType) const | 186 bool idsEqual(const DisplayItem& other, Type overrideType) const |
| 187 { | 187 { |
| 188 return m_id.client == other.m_id.client | 188 return m_client == other.m_client |
| 189 && m_id.type == overrideType | 189 && m_type == overrideType |
| 190 && m_id.scopeId == other.m_id.scopeId | 190 && m_scopeId == other.m_scopeId |
| 191 && m_id.scopeContainer == other.m_id.scopeContainer; | 191 && m_scopeContainer == other.m_scopeContainer; |
| 192 } | 192 } |
| 193 | 193 |
| 194 void setScope(int scopeId, DisplayItemClient scopeContainer) | 194 void setScope(int scopeId, DisplayItemClient scopeContainer) |
| 195 { | 195 { |
| 196 m_id.scopeId = scopeId; | 196 m_scopeId = scopeId; |
| 197 m_id.scopeContainer = scopeContainer; | 197 m_scopeContainer = scopeContainer; |
| 198 } | 198 } |
| 199 | 199 |
| 200 void setSkippedCache() { m_skippedCache = true; } | |
| 201 bool skippedCache() const { return m_skippedCache; } | |
| 202 | |
| 200 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const { } | 203 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const { } |
| 201 | 204 |
| 202 // See comments of enum Type for usage of the following macros. | 205 // See comments of enum Type for usage of the following macros. |
| 203 #define DEFINE_CATEGORY_METHODS(Category) \ | 206 #define DEFINE_CATEGORY_METHODS(Category) \ |
| 204 static bool is##Category##Type(Type type) { return type >= Category##First & & type <= Category##Last; } \ | 207 static bool is##Category##Type(Type type) { return type >= Category##First & & type <= Category##Last; } \ |
| 205 bool is##Category() const { return is##Category##Type(type()); } | 208 bool is##Category() const { return is##Category##Type(type()); } |
| 206 | 209 |
| 207 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \ | 210 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \ |
| 208 static Type category1##TypeTo##Category2##Type(Type type) \ | 211 static Type category1##TypeTo##Category2##Type(Type type) \ |
| 209 { \ | 212 { \ |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 | 273 |
| 271 #ifndef NDEBUG | 274 #ifndef NDEBUG |
| 272 static WTF::String typeAsDebugString(DisplayItem::Type); | 275 static WTF::String typeAsDebugString(DisplayItem::Type); |
| 273 const WTF::String& clientDebugString() const { return m_clientDebugString; } | 276 const WTF::String& clientDebugString() const { return m_clientDebugString; } |
| 274 WTF::String asDebugString() const; | 277 WTF::String asDebugString() const; |
| 275 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const; | 278 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const; |
| 276 #endif | 279 #endif |
| 277 | 280 |
| 278 protected: | 281 protected: |
| 279 DisplayItem(const DisplayItemClientWrapper& client, Type type) | 282 DisplayItem(const DisplayItemClientWrapper& client, Type type) |
| 280 : m_id(client.displayItemClient(), type) | 283 : m_client(client.displayItemClient()) |
| 284 , m_scopeContainer(nullptr) | |
| 285 , m_scopeId(0) | |
| 286 , m_type(type) | |
| 287 , m_skippedCache(false) | |
| 281 #ifndef NDEBUG | 288 #ifndef NDEBUG |
| 282 , m_clientDebugString(client.debugName()) | 289 , m_clientDebugString(client.debugName()) |
| 283 #endif | 290 #endif |
| 284 { } | 291 { } |
| 285 | 292 |
| 286 private: | 293 private: |
| 287 struct Id { | 294 const DisplayItemClient m_client; |
| 288 Id(DisplayItemClient c, Type t) : client(c), type(t), scopeId(0), scopeC ontainer(nullptr) | 295 DisplayItemClient m_scopeContainer; |
| 289 { | 296 int m_scopeId; |
| 290 ASSERT(c); | 297 const Type m_type : 16; |
|
jbroman
2015/06/02 18:02:23
Why use a bitfield here when you could simply redu
Xianzhu
2015/06/02 18:41:59
Great! Didn't know this grammar before. Done.
Xianzhu
2015/06/02 22:37:47
MSVC failed to compile '+', '-' operators of the e
| |
| 291 } | 298 bool m_skippedCache : 1; |
| 292 | |
| 293 const DisplayItemClient client; | |
| 294 const Type type; | |
| 295 int scopeId; | |
| 296 DisplayItemClient scopeContainer; | |
| 297 } m_id; | |
| 298 | 299 |
| 299 #ifndef NDEBUG | 300 #ifndef NDEBUG |
| 300 WTF::String m_clientDebugString; | 301 WTF::String m_clientDebugString; |
| 301 #endif | 302 #endif |
| 302 }; | 303 }; |
| 303 | 304 |
| 304 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { | 305 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { |
| 305 protected: | 306 protected: |
| 306 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type) : DisplayItem(client, type) { } | 307 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type) : DisplayItem(client, type) { } |
| 307 | 308 |
| 308 private: | 309 private: |
| 309 virtual bool isBegin() const override final { return true; } | 310 virtual bool isBegin() const override final { return true; } |
| 310 }; | 311 }; |
| 311 | 312 |
| 312 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { | 313 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { |
| 313 protected: | 314 protected: |
| 314 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type) : Di splayItem(client, type) { } | 315 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type) : Di splayItem(client, type) { } |
| 315 | 316 |
| 316 #if ENABLE(ASSERT) | 317 #if ENABLE(ASSERT) |
| 317 virtual bool isEndAndPairedWith(const DisplayItem& other) const override = 0 ; | 318 virtual bool isEndAndPairedWith(const DisplayItem& other) const override = 0 ; |
| 318 #endif | 319 #endif |
| 319 | 320 |
| 320 private: | 321 private: |
| 321 virtual bool isEnd() const override final { return true; } | 322 virtual bool isEnd() const override final { return true; } |
| 322 }; | 323 }; |
| 323 | 324 |
| 324 } // namespace blink | 325 } // namespace blink |
| 325 | 326 |
| 326 #endif // DisplayItem_h | 327 #endif // DisplayItem_h |
| OLD | NEW |