#ifndef UI_GFX_GENERIC_SHARED_MEMORY_ID_H_
#define UI_GFX_GENERIC_SHARED_MEMORY_ID_H_
#include <stddef.h>
#include <stdint.h>
#include <functional>
#include "base/hash/hash.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "ui/gfx/gfx_export.h"
namespace gfx {
class GFX_EXPORT GenericSharedMemoryId {
public:
int id;
constexpr GenericSharedMemoryId() : id(-1) {}
constexpr explicit GenericSharedMemoryId(int id) : id(id) {}
GenericSharedMemoryId(const GenericSharedMemoryId& other) = default;
GenericSharedMemoryId& operator=(const GenericSharedMemoryId& other) =
default;
bool is_valid() const { return id >= 0; }
bool operator==(const GenericSharedMemoryId& other) const {
return id == other.id;
}
bool operator<(const GenericSharedMemoryId& other) const {
return id < other.id;
}
};
GFX_EXPORT base::trace_event::MemoryAllocatorDumpGuid
GetGenericSharedGpuMemoryGUIDForTracing(
uint64_t tracing_process_id,
GenericSharedMemoryId generic_shared_memory_id);
}
namespace std {
template <>
struct hash<gfx::GenericSharedMemoryId> {
size_t operator()(gfx::GenericSharedMemoryId key) const {
return std::hash<int>()(key.id);
}
};
template <typename Second>
struct hash<std::pair<gfx::GenericSharedMemoryId, Second>> {
size_t operator()(
const std::pair<gfx::GenericSharedMemoryId, Second>& pair) const {
return base::HashInts(pair.first.id, pair.second);
}
};
}
#endif