chromium/third_party/angle/src/common/linux/dma_buf_utils.h

//
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

// dma_buf_utils.h: Utilities to interact with Linux dma bufs.

#ifndef COMMON_LINUX_DMA_BUF_UTILS_H_
#define COMMON_LINUX_DMA_BUF_UTILS_H_

#include <angle_gl.h>

#if defined(ANGLE_ENABLE_VULKAN)
#    include <vulkan/vulkan_core.h>
#    include <vector>
#endif

// Refer to:
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/drm/drm_fourcc.h
// https://source.chromium.org/chromium/chromium/src/+/main:ui/gl/gl_image_native_pixmap.cc;l=24
#define FOURCC(a, b, c, d)

#define DRM_FORMAT_R8
#define DRM_FORMAT_R16
#define DRM_FORMAT_GR88
#define DRM_FORMAT_RGB565
#define DRM_FORMAT_RGB888
#define DRM_FORMAT_BGR888
#define DRM_FORMAT_ARGB8888
#define DRM_FORMAT_ABGR8888
#define DRM_FORMAT_XRGB8888
#define DRM_FORMAT_XBGR8888
#define DRM_FORMAT_ABGR2101010
#define DRM_FORMAT_ARGB2101010
#define DRM_FORMAT_YVU420
#define DRM_FORMAT_NV12
#define DRM_FORMAT_P010
#define DRM_FORMAT_ABGR16161616F

namespace angle
{
GLenum DrmFourCCFormatToGLInternalFormat(int format, bool *isYUV);

#if defined(ANGLE_PLATFORM_LINUX) && defined(ANGLE_USES_GBM)
int GLInternalFormatToGbmFourCCFormat(GLenum internalFormat);
#endif

#if defined(ANGLE_ENABLE_VULKAN)
std::vector<int> VkFormatToDrmFourCCFormat(VkFormat format);
std::vector<VkFormat> DrmFourCCFormatToVkFormats(int fourccFormat);
#endif

}  // namespace angle

#endif  // COMMON_LINUX_DMA_BUF_UTILS_H_