Chromium Code Reviews| Index: cc/surfaces/surface_id.h |
| diff --git a/cc/surfaces/surface_id.h b/cc/surfaces/surface_id.h |
| index c48e8129192ddc8b98287a5e846c157bc910f396..a8c9a4162dac80ca754532e64d1507925d36f967 100644 |
| --- a/cc/surfaces/surface_id.h |
| +++ b/cc/surfaces/surface_id.h |
| @@ -18,58 +18,66 @@ namespace cc { |
| class SurfaceId { |
| public: |
| - SurfaceId() : id_namespace_(0), local_id_(0), nonce_(0) {} |
| + SurfaceId() : gpu_id_(0), client_id_(0), local_id_(0), nonce_(0) {} |
| - SurfaceId(const SurfaceId& other) |
| - : id_namespace_(other.id_namespace_), |
| - local_id_(other.local_id_), |
| - nonce_(other.nonce_) {} |
| + SurfaceId(const SurfaceId& other) = default; |
| // A SurfaceId consists of three components: namespace, local Id, and nonce. |
| - // An |id_namespace| is a display compositor service allocated ID that |
| + // An |client_id| is a display compositor service allocated ID that |
| // uniquely identifies a client. |
| // A |local_id| is a sequentially allocated ID generated by the display |
| // compositor client. |
| // A |nonce| is a cryptographically secure random int that makes a SurfaceId |
| // unguessable by other clients. |
| - SurfaceId(uint32_t id_namespace, uint32_t local_id, uint64_t nonce) |
| - : id_namespace_(id_namespace), local_id_(local_id), nonce_(nonce) {} |
| + SurfaceId(uint32_t gpu_id, |
| + uint32_t client_id, |
| + uint32_t local_id, |
| + uint64_t nonce) |
| + : gpu_id_(gpu_id), |
| + client_id_(client_id), |
| + local_id_(local_id), |
| + nonce_(nonce) {} |
| bool is_null() const { |
| - return id_namespace_ == 0 && nonce_ == 0 && local_id_ == 0; |
| + return gpu_id_ == 0 && client_id_ == 0 && nonce_ == 0 && local_id_ == 0; |
| } |
| size_t hash() const { |
| - size_t interim = base::HashInts(id_namespace_, local_id_); |
| - return base::HashInts(static_cast<uint64_t>(interim), nonce_); |
| + size_t first = base::HashInts(gpu_id_, client_id_); |
| + size_t second = base::HashInts(static_cast<uint64_t>(local_id_), nonce_); |
| + return base::HashInts(first, second); |
| } |
| - uint32_t id_namespace() const { return id_namespace_; } |
| + uint32_t gpu_id() const { return gpu_id_; } |
| + |
| + uint32_t client_id() const { return client_id_; } |
| uint32_t local_id() const { return local_id_; } |
| uint64_t nonce() const { return nonce_; } |
| std::string ToString() const { |
| - return base::StringPrintf("%d:%d:%" PRIu64, id_namespace_, local_id_, |
| - nonce_); |
| + return base::StringPrintf("%d:%d:%d:%" PRIu64, gpu_id_, client_id_, |
| + local_id_, nonce_); |
| } |
| bool operator==(const SurfaceId& other) const { |
| - return id_namespace_ == other.id_namespace_ && |
| + return gpu_id_ == other.gpu_id_ && client_id_ == other.client_id_ && |
| local_id_ == other.local_id_ && nonce_ == other.nonce_; |
| } |
| bool operator!=(const SurfaceId& other) const { return !(*this == other); } |
| bool operator<(const SurfaceId& other) const { |
| - return std::tie(id_namespace_, local_id_, nonce_) < |
| - std::tie(other.id_namespace_, other.local_id_, other.nonce_); |
| + return std::tie(gpu_id_, client_id_, local_id_, nonce_) < |
| + std::tie(other.gpu_id_, other.client_id_, other.local_id_, |
| + other.nonce_); |
| } |
| private: |
| // See SurfaceIdAllocator::GenerateId. |
| - uint32_t id_namespace_; |
| + uint32_t gpu_id_; |
| + uint32_t client_id_; |
| uint32_t local_id_; |
| uint64_t nonce_; |
|
piman
2016/07/12 20:57:19
nit: can we order the fields so that it's more com
Fady Samuel
2016/07/12 22:45:34
tsepez@ preferred nonce at the end for readability
piman
2016/07/12 22:47:50
ok - it doesn't matter any more.
|
| }; |