Chromium Code Reviews| Index: cc/surfaces/surface_id.h |
| diff --git a/cc/surfaces/surface_id.h b/cc/surfaces/surface_id.h |
| index bbc485f9009f90eaf577205f31dd7d2533310b6e..5482464e452cdbf82a1dec6df55f832d9f28230d 100644 |
| --- a/cc/surfaces/surface_id.h |
| +++ b/cc/surfaces/surface_id.h |
| @@ -13,19 +13,19 @@ |
| namespace cc { |
| struct SurfaceId { |
| - SurfaceId() : id(0) {} |
| - explicit SurfaceId(uint64_t id) : id(id) {} |
| + SurfaceId() : id_namespace(0), id(0) {} |
| + SurfaceId(uint32_t id_namespace, uint64_t id) |
| + : id_namespace(id_namespace), id(id) {} |
| - bool is_null() const { return id == 0; } |
| + bool is_null() const { return id_namespace == 0 && id == 0; } |
| // See SurfaceIdAllocator::GenerateId. |
| - uint32_t id_namespace() const { return id >> 32; } |
| - |
| + uint32_t id_namespace; |
| uint64_t id; |
| }; |
| inline bool operator==(const SurfaceId& a, const SurfaceId& b) { |
| - return a.id == b.id; |
| + return (a.id_namespace == a.id_namespace) && (a.id == b.id); |
| } |
| inline bool operator!=(const SurfaceId& a, const SurfaceId& b) { |
| @@ -33,12 +33,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.id < b.id); |
| } |
| struct SurfaceIdHash { |
| size_t operator()(const SurfaceId& key) const { |
| - return std::hash<uint64_t>()(key.id); |
| + return std::hash<uint64_t>()((key.id_namespace) | (key.id << 32)); |
|
jbauman
2016/05/20 00:29:00
Probably better to use base::HashInts64.
Fady Samuel
2016/05/20 00:40:31
Done.
|
| } |
| }; |