| Index: third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
|
| diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
|
| index 3ac0892254400cae02cc177e05f224df4ca63c20..b9762fff5a8cc0be5b0958adca9caed03e9de3e5 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
|
| +++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
|
| @@ -12,16 +12,40 @@
|
| namespace blink {
|
|
|
| class DisplayItemClientInternalVoid;
|
| -using DisplayItemClient = const DisplayItemClientInternalVoid*;
|
| +using DisplayItemClientObject = const DisplayItemClientInternalVoid*;
|
|
|
| -inline DisplayItemClient toDisplayItemClient(const void* object) { return static_cast<DisplayItemClient>(object); }
|
| +const unsigned kMaxSubDisplayItemClientId = (1 << 6) - 1;
|
| +
|
| +struct DisplayItemClient {
|
| + // subClientId allows multiple display item client per object.
|
| + // This is useful when we need to cache the display item separately for each sub clients.
|
| + DisplayItemClient(const void* inObject, unsigned inSubClientId = 0)
|
| + : object(static_cast<DisplayItemClientObject>(inObject))
|
| + , subClientId(inSubClientId)
|
| + {
|
| + ASSERT(inSubClientId <= kMaxSubDisplayItemClientId);
|
| + }
|
| +
|
| + bool operator==(const DisplayItemClient& other) const
|
| + {
|
| + return object == other.object && subClientId == other.subClientId;
|
| + }
|
| +
|
| + bool operator!=(const DisplayItemClient& other) const
|
| + {
|
| + return !(*this == other);
|
| + }
|
| +
|
| + DisplayItemClientObject object;
|
| + size_t subClientId;
|
| +};
|
|
|
| // Used to pass DisplayItemClient and debugName() (called only when needed) from
|
| // core/layout module etc. to platform/paint module.
|
| // The instance must not out-live the object. Long-time reference to a client must
|
| // use DisplayItemClient.
|
| class PLATFORM_EXPORT DisplayItemClientWrapper {
|
| - DISALLOW_NEW(); // Allow allocated in stack or in another object only.
|
| + DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); // Allow allocated in stack or in another object only.
|
| public:
|
| template <typename T>
|
| DisplayItemClientWrapper(const T& object)
|
| @@ -30,6 +54,15 @@ public:
|
| , m_debugNameInvoker(&invokeDebugName<T>)
|
| { }
|
|
|
| + // Allows one object to create multiple sub display item clients. Use like:
|
| + // DisplayItemClientWrapper(object, toSubDisplayItemClient<SubClientId>(&object), functionToGetDebugNameOfSubClient)
|
| + template <typename T>
|
| + DisplayItemClientWrapper(const T& object, DisplayItemClient displayItemClient, String (*debugNameInvoker)(const T&))
|
| + : m_displayItemClient(displayItemClient)
|
| + , m_object(reinterpret_cast<const GenericClass&>(object))
|
| + , m_debugNameInvoker(reinterpret_cast<DebugNameInvoker>(debugNameInvoker))
|
| + { }
|
| +
|
| DisplayItemClientWrapper(const DisplayItemClientWrapper& other)
|
| : m_displayItemClient(other.m_displayItemClient)
|
| , m_object(other.m_object)
|
| @@ -46,9 +79,9 @@ private:
|
| template <typename T>
|
| static String invokeDebugName(const GenericClass& object) { return reinterpret_cast<const T&>(object).debugName(); }
|
|
|
| + using DebugNameInvoker = String (*)(const GenericClass&);
|
| DisplayItemClient m_displayItemClient;
|
| const GenericClass& m_object;
|
| - using DebugNameInvoker = String(*)(const GenericClass&);
|
| DebugNameInvoker m_debugNameInvoker;
|
| };
|
|
|
|
|