blob: 67c2644e31958f5d5dcf1a76ddcd65a2997c90d0 [file] [log] [blame]
// Copyright 2023 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.
#ifndef SRC_GRAPHICS_DISPLAY_LIB_API_TYPES_CPP_DRIVER_CAPTURE_IMAGE_ID_H_
#define SRC_GRAPHICS_DISPLAY_LIB_API_TYPES_CPP_DRIVER_CAPTURE_IMAGE_ID_H_
#include <fidl/fuchsia.hardware.display.engine/cpp/wire.h>
#include <fuchsia/hardware/display/controller/c/banjo.h>
#include <cstdint>
#include <fbl/strong_int.h>
namespace display {
// Type-safe wrapper around capture image IDs exposed to display drivers.
//
// The Banjo API between the Display Coordinator and drivers currently refers to
// this concept as "capture image handle". This name will be phased out when the
// API is migrated from Banjo to FIDL.
//
// TODO(https://fxbug.dev/42079544): Remove this type when unifying image ID namespaces.
DEFINE_STRONG_INT(DriverCaptureImageId, uint64_t);
constexpr DriverCaptureImageId ToDriverCaptureImageId(uint64_t banjo_driver_capture_image_id) {
return DriverCaptureImageId(banjo_driver_capture_image_id);
}
constexpr uint64_t ToBanjoDriverCaptureImageId(DriverCaptureImageId driver_capture_image_id) {
return driver_capture_image_id.value();
}
constexpr inline fuchsia_hardware_display_engine::wire::ImageId ToFidlDriverCaptureImageId(
DriverCaptureImageId driver_capture_image_id) {
return {.value = driver_capture_image_id.value()};
}
constexpr DriverCaptureImageId kInvalidDriverCaptureImageId(INVALID_ID);
} // namespace display
#endif // SRC_GRAPHICS_DISPLAY_LIB_API_TYPES_CPP_DRIVER_CAPTURE_IMAGE_ID_H_