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

Unified Diff: third_party/WebKit/Source/platform/graphics/CompositorElementId.h

Issue 2724083002: [SPv2] Decomposite otherwise-compositable animations that paint nothing. (Closed)
Patch Set: Progress. Created 3 years, 9 months 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/CompositorElementId.h
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorElementId.h b/third_party/WebKit/Source/platform/graphics/CompositorElementId.h
index 230d3dfcd9ed7fe07fed154f83c38be88150c88f..19dcb15fafa33384f2efe4a0f3768b46662e224c 100644
--- a/third_party/WebKit/Source/platform/graphics/CompositorElementId.h
+++ b/third_party/WebKit/Source/platform/graphics/CompositorElementId.h
@@ -7,6 +7,8 @@
#include "cc/trees/element_id.h"
#include "platform/PlatformExport.h"
+#include "wtf/HashFunctions.h"
+#include "wtf/HashTraits.h"
namespace blink {
@@ -17,6 +19,34 @@ using CompositorElementId = cc::ElementId;
CompositorElementId PLATFORM_EXPORT
createCompositorElementId(int domNodeId, CompositorSubElementId);
+// Note cc::ElementId has a hash function already implemented via
+// ElementIdHash::operator(). However for consistency's sake we choose to use
+// Blink's hash functions with Blink specific data structures.
+struct CompositorElementIdHash {
+ static unsigned hash(const CompositorElementId& p) {
+ return WTF::hashInts(p.primaryId, p.secondaryId);
+ }
+ static bool equal(const CompositorElementId& a,
+ const CompositorElementId& b) {
+ return a.primaryId == b.primaryId && a.secondaryId == b.secondaryId;
+ }
+ static const bool safeToCompareToEmptyOrDeleted = true;
+};
+
+struct CompositorElementIdHashTraits
+ : WTF::GenericHashTraits<CompositorElementId> {
+ static CompositorElementId emptyValue() { return CompositorElementId(); }
+ // TODO(wkorman): Should we optimize below to keep a single static
+ // pre-constructed CompositorElementId() rather than constructing each
+ // function call?
+ static void constructDeletedValue(CompositorElementId& slot, bool) {
+ slot = CompositorElementId();
+ }
+ static bool isDeletedValue(CompositorElementId value) {
+ return value == CompositorElementId();
+ }
+};
+
} // namespace blink
#endif // CompositorElementId_h

Powered by Google App Engine
This is Rietveld 408576698