summaryrefslogtreecommitdiff
path: root/chromium/components/viz/common/shared_element_resource_id.h
blob: 2e028fddcf6c552ef1c1b62fa638bb3193af6343 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_VIZ_COMMON_SHARED_ELEMENT_RESOURCE_ID_H_
#define COMPONENTS_VIZ_COMMON_SHARED_ELEMENT_RESOURCE_ID_H_

#include <cstdint>
#include <string>
#include <vector>

#include "components/viz/common/viz_common_export.h"

namespace viz {

// See share_element_resource_id.mojom for details.
class VIZ_COMMON_EXPORT SharedElementResourceId {
 public:
  // Generates a new id.
  static SharedElementResourceId Generate();

  // For mojo deserialization.
  explicit SharedElementResourceId(uint32_t id);

  // Creates an invalid id.
  SharedElementResourceId();
  ~SharedElementResourceId();

  bool operator==(const SharedElementResourceId& o) const {
    return id_ == o.id_;
  }
  bool operator!=(const SharedElementResourceId& o) const {
    return !(*this == o);
  }
  bool operator<(const SharedElementResourceId& o) const { return id_ < o.id_; }

  bool IsValid() const;
  std::string ToString() const;

  uint32_t id() const { return id_; }

 private:
  uint32_t id_;
};

}  // namespace viz

#endif  // COMPONENTS_VIZ_COMMON_SHARED_ELEMENT_RESOURCE_ID_H_