chromium/third_party/webrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc

/*
 *  Copyright 2021 The WebRTC 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 in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "modules/desktop_capture/linux/wayland/egl_dmabuf.h"

#include <asm/ioctl.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <libdrm/drm_fourcc.h>
#include <linux/types.h>
#include <spa/param/video/format-utils.h>
#include <unistd.h>
#include <xf86drm.h>

#include "absl/memory/memory.h"
#include "absl/types/optional.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/sanitizer.h"
#include "rtc_base/string_encode.h"

namespace webrtc {

// EGL
eglBindAPI_func;
eglCreateContext_func;
eglDestroyContext_func;
eglTerminate_func;
eglCreateImageKHR_func;
eglDestroyImageKHR_func;
eglGetError_func;
eglGetProcAddress_func;
eglGetPlatformDisplayEXT_func;
eglGetPlatformDisplay_func;

eglInitialize_func;
eglMakeCurrent_func;
eglQueryDmaBufFormatsEXT_func;
eglQueryDmaBufModifiersEXT_func;
eglQueryString_func;
glEGLImageTargetTexture2DOES_func;

// This doesn't follow naming conventions in WebRTC, where the naming
// should look like e.g. egl_bind_api instead of EglBindAPI, however
// we named them according to the exported functions they map to for
// consistency.
eglBindAPI_func EglBindAPI =;
eglCreateContext_func EglCreateContext =;
eglDestroyContext_func EglDestroyContext =;
eglTerminate_func EglTerminate =;
eglCreateImageKHR_func EglCreateImageKHR =;
eglDestroyImageKHR_func EglDestroyImageKHR =;
eglGetError_func EglGetError =;
eglGetProcAddress_func EglGetProcAddress =;
eglGetPlatformDisplayEXT_func EglGetPlatformDisplayEXT =;
eglGetPlatformDisplay_func EglGetPlatformDisplay =;
eglInitialize_func EglInitialize =;
eglMakeCurrent_func EglMakeCurrent =;
eglQueryDmaBufFormatsEXT_func EglQueryDmaBufFormatsEXT =;
eglQueryDmaBufModifiersEXT_func EglQueryDmaBufModifiersEXT =;
eglQueryString_func EglQueryString =;
glEGLImageTargetTexture2DOES_func GlEGLImageTargetTexture2DOES =;

// GL
glBindTexture_func;
glDeleteTextures_func;
glGenTextures_func;
glGetError_func;
glGetString_func;
glReadPixels_func;
glGenFramebuffers_func;
glDeleteFramebuffers_func;
glBindFramebuffer_func;
glFramebufferTexture2D_func;
glCheckFramebufferStatus_func;
glTexParameteri_func;
glXGetProcAddressARB_func;

// This doesn't follow naming conventions in WebRTC, where the naming
// should look like e.g. egl_bind_api instead of EglBindAPI, however
// we named them according to the exported functions they map to for
// consistency.
glBindTexture_func GlBindTexture =;
glDeleteTextures_func GlDeleteTextures =;
glGenTextures_func GlGenTextures =;
glGetError_func GlGetError =;
glGetString_func GlGetString =;
glReadPixels_func GlReadPixels =;
glGenFramebuffers_func GlGenFramebuffers =;
glDeleteFramebuffers_func GlDeleteFramebuffers =;
glBindFramebuffer_func GlBindFramebuffer =;
glFramebufferTexture2D_func GlFramebufferTexture2D =;
glCheckFramebufferStatus_func GlCheckFramebufferStatus =;
glTexParameteri_func GlTexParameteri =;
glXGetProcAddressARB_func GlXGetProcAddressARB =;

static const std::string FormatGLError(GLenum err) {}

static const std::string FormatEGLError(EGLint err) {}

static uint32_t SpaPixelFormatToDrmFormat(uint32_t spa_format) {}

static void CloseLibrary(void* library) {}

static void* g_lib_egl =;

RTC_NO_SANITIZE("cfi-icall")
static bool OpenEGL() {}

RTC_NO_SANITIZE("cfi-icall")
static bool LoadEGL() {}

static void* g_lib_gl =;

RTC_NO_SANITIZE("cfi-icall")
static bool OpenGL() {}

RTC_NO_SANITIZE("cfi-icall")
static bool LoadGL() {}

RTC_NO_SANITIZE("cfi-icall")
EglDmaBuf::EglDmaBuf() {}

RTC_NO_SANITIZE("cfi-icall")
EglDmaBuf::~EglDmaBuf() {}

RTC_NO_SANITIZE("cfi-icall")
bool EglDmaBuf::GetClientExtensions(EGLDisplay dpy, EGLint name) {}

RTC_NO_SANITIZE("cfi-icall")
bool EglDmaBuf::ImageFromDmaBuf(const DesktopSize& size,
                                uint32_t format,
                                const std::vector<PlaneData>& plane_datas,
                                uint64_t modifier,
                                const DesktopVector& offset,
                                const DesktopSize& buffer_size,
                                uint8_t* data) {}

RTC_NO_SANITIZE("cfi-icall")
std::vector<uint64_t> EglDmaBuf::QueryDmaBufModifiers(uint32_t format) {}

absl::optional<std::string> EglDmaBuf::GetRenderNode() {}

}  // namespace webrtc