chromium/components/viz/common/resources/resource_id.h

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_VIZ_COMMON_RESOURCES_RESOURCE_ID_H_
#define COMPONENTS_VIZ_COMMON_RESOURCES_RESOURCE_ID_H_

#include <stdint.h>

#include <functional>
#include <limits>
#include <map>

#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/types/id_type.h"
#include "components/viz/common/viz_common_export.h"

namespace viz {

struct ResourceIdTypeMarker {};

// Note that if you need to generate new ResourceIds, please use
// ResourceIdGenerator below, since it will skip generating reserved ids.
ResourceId;
ResourceIdSet;
inline constexpr ResourceId kInvalidResourceId(0);
inline constexpr uint32_t kNumReservedResourceIds =;
inline constexpr ResourceId kVizReservedRangeStartId(
    std::numeric_limits<uint32_t>::max() - kNumReservedResourceIds);

class VIZ_COMMON_EXPORT ResourceIdGenerator {};

struct VIZ_COMMON_EXPORT ResourceIdHasher {};

// ReservedResourceIdTracker is used for keeping track of refcounts on viz
// reserved resources and allocating unused resource IDs. Since the resource ID
// space for reserved resources is much smaller than the client resource ID
// space, we keep track of which resource IDs are used individually, so we can
// allocate resource IDs that are no longer used and avoid reusing IDs that are
// still in use.
class VIZ_COMMON_EXPORT ReservedResourceIdTracker {};

}  // namespace viz

#endif  // COMPONENTS_VIZ_COMMON_RESOURCES_RESOURCE_ID_H_