2020#include < ostream>
2121#include < string>
2222
23- #include < ftl/hash.h>
2423#include < ftl/optional.h>
2524
2625namespace android {
@@ -31,16 +30,12 @@ struct DisplayId {
3130 // Flag indicating that the display is virtual.
3231 static constexpr uint64_t FLAG_VIRTUAL = 1ULL << 63 ;
3332
34- // Flag indicating that the ID is stable across reboots.
35- static constexpr uint64_t FLAG_STABLE = 1ULL << 62 ;
36-
3733 // TODO(b/162612135) Remove default constructor
3834 DisplayId () = default ;
3935 constexpr DisplayId (const DisplayId&) = default;
4036 DisplayId& operator =(const DisplayId&) = default ;
4137
4238 constexpr bool isVirtual () const { return value & FLAG_VIRTUAL; }
43- constexpr bool isStable () const { return value & FLAG_STABLE; }
4439
4540 uint64_t value;
4641
@@ -102,10 +97,12 @@ struct PhysicalDisplayId : DisplayId {
10297 // TODO(b/162612135) Remove default constructor
10398 PhysicalDisplayId () = default ;
10499
105- constexpr uint16_t getManufacturerId () const { return static_cast <uint16_t >(value >> 40 ); }
106100 constexpr uint8_t getPort () const { return static_cast <uint8_t >(value); }
107101
108102private:
103+ // Flag indicating that the ID is stable across reboots.
104+ static constexpr uint64_t FLAG_STABLE = 1ULL << 62 ;
105+
109106 constexpr PhysicalDisplayId (uint64_t flags, uint8_t port, uint16_t manufacturerId,
110107 uint32_t modelHash)
111108 : DisplayId(flags | (static_cast <uint64_t >(manufacturerId) << 40) |
@@ -149,13 +146,6 @@ struct HalVirtualDisplayId : VirtualDisplayId {
149146struct GpuVirtualDisplayId : VirtualDisplayId {
150147 explicit constexpr GpuVirtualDisplayId (BaseId baseId) : VirtualDisplayId(FLAG_GPU | baseId) {}
151148
152- static constexpr std::optional<GpuVirtualDisplayId> fromUniqueId (const std::string& uniqueId) {
153- if (const auto hashOpt = ftl::stable_hash (uniqueId)) {
154- return GpuVirtualDisplayId (HashTag{}, *hashOpt);
155- }
156- return {};
157- }
158-
159149 static constexpr std::optional<GpuVirtualDisplayId> tryCast (DisplayId id) {
160150 if (id.isVirtual () && (id.value & FLAG_GPU)) {
161151 return GpuVirtualDisplayId (id);
@@ -164,10 +154,6 @@ struct GpuVirtualDisplayId : VirtualDisplayId {
164154 }
165155
166156private:
167- struct HashTag {}; // Disambiguate with BaseId constructor.
168- constexpr GpuVirtualDisplayId (HashTag, uint64_t hash)
169- : VirtualDisplayId(FLAG_STABLE | FLAG_GPU | hash) {}
170-
171157 explicit constexpr GpuVirtualDisplayId (DisplayId other) : VirtualDisplayId(other) {}
172158};
173159
0 commit comments