Index: cc/surfaces/surface_id.h |
diff --git a/cc/surfaces/surface_id.h b/cc/surfaces/surface_id.h |
index bbc485f9009f90eaf577205f31dd7d2533310b6e..0ba30a102b6912970a9fef3b4df95f53b23cdff6 100644 |
--- a/cc/surfaces/surface_id.h |
+++ b/cc/surfaces/surface_id.h |
@@ -10,22 +10,26 @@ |
#include <functional> |
+#include "base/hash.h" |
+ |
namespace cc { |
struct SurfaceId { |
- SurfaceId() : id(0) {} |
- explicit SurfaceId(uint64_t id) : id(id) {} |
+ SurfaceId() : id_namespace(0), local_id(0) {} |
+ SurfaceId(const SurfaceId& other) |
+ : id_namespace(other.id_namespace), local_id(other.local_id) {} |
+ SurfaceId(uint32_t id_namespace, uint64_t local_id) |
+ : id_namespace(id_namespace), local_id(local_id) {} |
- bool is_null() const { return id == 0; } |
+ bool is_null() const { return id_namespace == 0 && local_id == 0; } |
// See SurfaceIdAllocator::GenerateId. |
- uint32_t id_namespace() const { return id >> 32; } |
- |
- uint64_t id; |
+ uint32_t id_namespace; |
+ uint64_t local_id; |
}; |
inline bool operator==(const SurfaceId& a, const SurfaceId& b) { |
- return a.id == b.id; |
+ return (a.id_namespace == b.id_namespace) && (a.local_id == b.local_id); |
Tom Sepez
2016/05/20 20:22:02
nit: overparenthesized, also line 40
Fady Samuel
2016/05/24 20:33:07
Done. I've switched to if statements for readabili
|
} |
inline bool operator!=(const SurfaceId& a, const SurfaceId& b) { |
@@ -33,12 +37,13 @@ inline bool operator!=(const SurfaceId& a, const SurfaceId& b) { |
} |
inline bool operator<(const SurfaceId& a, const SurfaceId& b) { |
- return a.id < b.id; |
+ return (a.id_namespace < b.id_namespace) || |
+ ((a.id_namespace == b.id_namespace) && (a.local_id < b.local_id)); |
} |
struct SurfaceIdHash { |
size_t operator()(const SurfaceId& key) const { |
- return std::hash<uint64_t>()(key.id); |
+ return base::HashInts64(key.id_namespace, key.local_id); |
danakj
2016/05/20 21:01:36
Just use HashInts() it picks the right function.
Fady Samuel
2016/05/24 20:33:07
Done.
|
} |
}; |