blob: e094a467fd64667e552aee8ca59228cce0747233 [file] [log] [blame] [edit]
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/ui/scenic/lib/allocation/id.h"
#include <atomic>
namespace allocation {
const GlobalBufferCollectionId kInvalidId = ZX_KOID_INVALID;
GlobalBufferCollectionId GenerateUniqueBufferCollectionId() {
// This function will be called from multiple threads, and thus needs an atomic
// incrementor for the id.
static std::atomic<GlobalBufferCollectionId> buffer_collection_id = 0;
return ++buffer_collection_id;
}
display::ImageId GenerateUniqueImageId() {
// This function will be called from multiple threads, and thus needs an atomic
// incrementor for the id.
static std::atomic<display::ImageId::ValueType> image_id = 0;
return display::ImageId(++image_id);
}
} // namespace allocation