Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h

Issue 1425593007: Separate display item clients for negative and normal/positive z-order children (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ae3b4d05f63e407470a8191d37bbaf5990ac5e72 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
+++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h
@@ -16,12 +16,20 @@ using DisplayItemClient = const DisplayItemClientInternalVoid*;
inline DisplayItemClient toDisplayItemClient(const void* object) { return static_cast<DisplayItemClient>(object); }
+// Allows one object to create multiple sub display item clients, each identified by subClientId.
+template <size_t subClientId, typename T>
+inline DisplayItemClient toSubDisplayItemClient(const T* object)
+{
+ static_assert(subClientId > 0 && subClientId < sizeof(T), "subClientId must be non-zero and within the size of the object");
+ return reinterpret_cast<DisplayItemClient>(reinterpret_cast<const char*>(object) + subClientId);
chrishtr 2015/11/04 23:37:11 This is kind of hacky. Why do it this way?
Xianzhu 2015/11/05 00:30:28 To allow one object to have multiple DisplayItemCl
+}
+
// 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 +38,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 +63,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;
};

Powered by Google App Engine
This is Rietveld 408576698