chromium/third_party/dawn/third_party/glfw/src/internal.h

//========================================================================
// GLFW 3.5 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <[email protected]>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
//    claim that you wrote the original software. If you use this software
//    in a product, an acknowledgment in the product documentation would
//    be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
//    be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
//    distribution.
//
//========================================================================

#pragma once

#if defined(_GLFW_USE_CONFIG_H)
 #include "glfw_config.h"
#endif

#if defined(GLFW_INCLUDE_GLCOREARB) || \
    defined(GLFW_INCLUDE_ES1)       || \
    defined(GLFW_INCLUDE_ES2)       || \
    defined(GLFW_INCLUDE_ES3)       || \
    defined(GLFW_INCLUDE_ES31)      || \
    defined(GLFW_INCLUDE_ES32)      || \
    defined(GLFW_INCLUDE_NONE)      || \
    defined(GLFW_INCLUDE_GLEXT)     || \
    defined(GLFW_INCLUDE_GLU)       || \
    defined(GLFW_INCLUDE_VULKAN)    || \
    defined(GLFW_DLL)
 #error "You must not define any header option macros when compiling GLFW"
#endif

#define GLFW_INCLUDE_NONE
#include "../include/GLFW/glfw3.h"

#include <stdbool.h>

#define _GLFW_INSERT_FIRST
#define _GLFW_INSERT_LAST

#define _GLFW_POLL_PRESENCE
#define _GLFW_POLL_AXES
#define _GLFW_POLL_BUTTONS
#define _GLFW_POLL_ALL

#define _GLFW_MESSAGE_SIZE

GLFWbool;
GLFWproc;

_GLFWerror;
_GLFWinitconfig;
_GLFWwndconfig;
_GLFWctxconfig;
_GLFWfbconfig;
_GLFWcontext;
_GLFWwindow;
_GLFWplatform;
_GLFWlibrary;
_GLFWmonitor;
_GLFWcursor;
_GLFWmapelement;
_GLFWmapping;
_GLFWjoystick;
_GLFWtls;
_GLFWmutex;

#define GL_VERSION
#define GL_NONE
#define GL_COLOR_BUFFER_BIT
#define GL_UNSIGNED_BYTE
#define GL_EXTENSIONS
#define GL_NUM_EXTENSIONS
#define GL_CONTEXT_FLAGS
#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT
#define GL_CONTEXT_FLAG_DEBUG_BIT
#define GL_CONTEXT_PROFILE_MASK
#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT
#define GL_CONTEXT_CORE_PROFILE_BIT
#define GL_RESET_NOTIFICATION_STRATEGY_ARB
#define GL_LOSE_CONTEXT_ON_RESET_ARB
#define GL_NO_RESET_NOTIFICATION_ARB
#define GL_CONTEXT_RELEASE_BEHAVIOR
#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH
#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR

GLint;
GLuint;
GLenum;
GLbitfield;
GLubyte;

PFNGLCLEARPROC;
PFNGLGETSTRINGPROC;
PFNGLGETINTEGERVPROC;
PFNGLGETSTRINGIPROC;

#define EGL_SUCCESS
#define EGL_NOT_INITIALIZED
#define EGL_BAD_ACCESS
#define EGL_BAD_ALLOC
#define EGL_BAD_ATTRIBUTE
#define EGL_BAD_CONFIG
#define EGL_BAD_CONTEXT
#define EGL_BAD_CURRENT_SURFACE
#define EGL_BAD_DISPLAY
#define EGL_BAD_MATCH
#define EGL_BAD_NATIVE_PIXMAP
#define EGL_BAD_NATIVE_WINDOW
#define EGL_BAD_PARAMETER
#define EGL_BAD_SURFACE
#define EGL_CONTEXT_LOST
#define EGL_COLOR_BUFFER_TYPE
#define EGL_RGB_BUFFER
#define EGL_SURFACE_TYPE
#define EGL_WINDOW_BIT
#define EGL_RENDERABLE_TYPE
#define EGL_OPENGL_ES_BIT
#define EGL_OPENGL_ES2_BIT
#define EGL_OPENGL_BIT
#define EGL_ALPHA_SIZE
#define EGL_BLUE_SIZE
#define EGL_GREEN_SIZE
#define EGL_RED_SIZE
#define EGL_DEPTH_SIZE
#define EGL_STENCIL_SIZE
#define EGL_SAMPLES
#define EGL_OPENGL_ES_API
#define EGL_OPENGL_API
#define EGL_NONE
#define EGL_RENDER_BUFFER
#define EGL_SINGLE_BUFFER
#define EGL_EXTENSIONS
#define EGL_CONTEXT_CLIENT_VERSION
#define EGL_NATIVE_VISUAL_ID
#define EGL_NO_SURFACE
#define EGL_NO_DISPLAY
#define EGL_NO_CONTEXT
#define EGL_DEFAULT_DISPLAY
#define EGL_PBUFFER_BIT
#define EGL_WIDTH
#define EGL_HEIGHT

#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR
#define EGL_NO_RESET_NOTIFICATION_KHR
#define EGL_LOSE_CONTEXT_ON_RESET_KHR
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR
#define EGL_CONTEXT_MAJOR_VERSION_KHR
#define EGL_CONTEXT_MINOR_VERSION_KHR
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR
#define EGL_CONTEXT_FLAGS_KHR
#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR
#define EGL_GL_COLORSPACE_KHR
#define EGL_GL_COLORSPACE_SRGB_KHR
#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR
#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR
#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR
#define EGL_PLATFORM_X11_EXT
#define EGL_PLATFORM_WAYLAND_EXT
#define EGL_PRESENT_OPAQUE_EXT
#define EGL_PLATFORM_ANGLE_ANGLE
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE
#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE
#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE
#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE
#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE
#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE
#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE
#define EGL_PLATFORM_SURFACELESS_MESA

EGLint;
EGLBoolean;
EGLenum;
EGLConfig;
EGLContext;
EGLDisplay;
EGLSurface;

EGLNativeDisplayType;
EGLNativeWindowType;

// EGL function pointer typedefs
PFN_eglGetConfigAttrib;
PFN_eglGetConfigs;
PFN_eglGetDisplay;
PFN_eglGetError;
PFN_eglInitialize;
PFN_eglTerminate;
PFN_eglBindAPI;
PFN_eglCreateContext;
PFN_eglDestroySurface;
PFN_eglDestroyContext;
PFN_eglCreateWindowSurface;
PFN_eglCreatePbufferSurface;
PFN_eglMakeCurrent;
PFN_eglSwapBuffers;
PFN_eglSwapInterval;
PFN_eglQueryString;
PFN_eglGetProcAddress;
#define eglGetConfigAttrib
#define eglGetConfigs
#define eglGetDisplay
#define eglGetError
#define eglInitialize
#define eglTerminate
#define eglBindAPI
#define eglCreateContext
#define eglDestroySurface
#define eglDestroyContext
#define eglCreateWindowSurface
#define eglCreatePbufferSurface
#define eglMakeCurrent
#define eglSwapBuffers
#define eglSwapInterval
#define eglQueryString
#define eglGetProcAddress

PFNEGLGETPLATFORMDISPLAYEXTPROC;
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC;
#define eglGetPlatformDisplayEXT
#define eglCreatePlatformWindowSurfaceEXT

#define OSMESA_RGBA
#define OSMESA_FORMAT
#define OSMESA_DEPTH_BITS
#define OSMESA_STENCIL_BITS
#define OSMESA_ACCUM_BITS
#define OSMESA_PROFILE
#define OSMESA_CORE_PROFILE
#define OSMESA_COMPAT_PROFILE
#define OSMESA_CONTEXT_MAJOR_VERSION
#define OSMESA_CONTEXT_MINOR_VERSION

OSMesaContext;
OSMESAproc;

PFN_OSMesaCreateContextExt;
PFN_OSMesaCreateContextAttribs;
PFN_OSMesaDestroyContext;
PFN_OSMesaMakeCurrent;
PFN_OSMesaGetColorBuffer;
PFN_OSMesaGetDepthBuffer;
PFN_OSMesaGetProcAddress;
#define OSMesaCreateContextExt
#define OSMesaCreateContextAttribs
#define OSMesaDestroyContext
#define OSMesaMakeCurrent
#define OSMesaGetColorBuffer
#define OSMesaGetDepthBuffer
#define OSMesaGetProcAddress

#define VK_NULL_HANDLE

VkInstance;
VkPhysicalDevice;
VkSurfaceKHR;
VkFlags;
VkBool32;

VkStructureType;

VkResult;

VkAllocationCallbacks;

VkExtensionProperties;

PFN_vkVoidFunction;

PFN_vkGetInstanceProcAddr;
PFN_vkEnumerateInstanceExtensionProperties;
#define vkGetInstanceProcAddr

#include "platform.h"

#define GLFW_NATIVE_INCLUDE_NONE
#include "../include/GLFW/glfw3native.h"

// Checks for whether the library has been initialized
#define _GLFW_REQUIRE_INIT()
#define _GLFW_REQUIRE_INIT_OR_RETURN(x)

// Swaps the provided pointers
#define _GLFW_SWAP(type, x, y)

// Per-thread error structure
//
struct _GLFWerror
{};

// Initialization configuration
//
// Parameters relating to the initialization of the library
//
struct _GLFWinitconfig
{};

// Window configuration
//
// Parameters relating to the creation of the window but not directly related
// to the framebuffer.  This is used to pass window creation parameters from
// shared code to the platform API.
//
struct _GLFWwndconfig
{};

// Context configuration
//
// Parameters relating to the creation of the context but not directly related
// to the framebuffer.  This is used to pass context creation parameters from
// shared code to the platform API.
//
struct _GLFWctxconfig
{};

// Framebuffer configuration
//
// This describes buffers and their sizes.  It also contains
// a platform-specific ID used to map back to the backend API object.
//
// It is used to pass framebuffer parameters from shared code to the platform
// API and also to enumerate and select available framebuffer configs.
//
struct _GLFWfbconfig
{};

// Context structure
//
struct _GLFWcontext
{};

// Window and context structure
//
struct _GLFWwindow
{};

// Monitor structure
//
struct _GLFWmonitor
{};

// Cursor structure
//
struct _GLFWcursor
{};

// Gamepad mapping element structure
//
struct _GLFWmapelement
{};

// Gamepad mapping structure
//
struct _GLFWmapping
{};

// Joystick structure
//
struct _GLFWjoystick
{};

// Thread local storage structure
//
struct _GLFWtls
{};

// Mutex structure
//
struct _GLFWmutex
{};

// Platform API structure
//
struct _GLFWplatform
{};

// Library global data
//
struct _GLFWlibrary
{};

// Global state shared between compilation units of GLFW
//
extern _GLFWlibrary _glfw;


//////////////////////////////////////////////////////////////////////////
//////                       GLFW platform API                      //////
//////////////////////////////////////////////////////////////////////////

void _glfwPlatformInitTimer(void);
uint64_t _glfwPlatformGetTimerValue(void);
uint64_t _glfwPlatformGetTimerFrequency(void);

GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls);
void _glfwPlatformDestroyTls(_GLFWtls* tls);
void* _glfwPlatformGetTls(_GLFWtls* tls);
void _glfwPlatformSetTls(_GLFWtls* tls, void* value);

GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex);
void _glfwPlatformDestroyMutex(_GLFWmutex* mutex);
void _glfwPlatformLockMutex(_GLFWmutex* mutex);
void _glfwPlatformUnlockMutex(_GLFWmutex* mutex);

void* _glfwPlatformLoadModule(const char* path);
void _glfwPlatformFreeModule(void* module);
GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name);


//////////////////////////////////////////////////////////////////////////
//////                         GLFW event API                       //////
//////////////////////////////////////////////////////////////////////////

void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused);
void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos);
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
void _glfwInputWindowContentScale(_GLFWwindow* window,
                                  float xscale, float yscale);
void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified);
void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized);
void _glfwInputWindowDamage(_GLFWwindow* window);
void _glfwInputWindowCloseRequest(_GLFWwindow* window);
void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);

void _glfwInputKey(_GLFWwindow* window,
                   int key, int scancode, int action, int mods);
void _glfwInputChar(_GLFWwindow* window,
                    uint32_t codepoint, int mods, GLFWbool plain);
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered);
void _glfwInputDrop(_GLFWwindow* window, int count, const char** names);
void _glfwInputJoystick(_GLFWjoystick* js, int event);
void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value);
void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value);
void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value);

void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement);
void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window);

#if defined(__GNUC__)
void _glfwInputError(int code, const char* format, ...)
    __attribute__((format(printf, 2, 3)));
#else
void _glfwInputError(int code, const char* format, ...);
#endif


//////////////////////////////////////////////////////////////////////////
//////                       GLFW internal API                      //////
//////////////////////////////////////////////////////////////////////////

GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform* platform);

GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions);
const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
                                         const _GLFWfbconfig* alternatives,
                                         unsigned int count);
GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
                                    const _GLFWctxconfig* ctxconfig);
GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);

const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
                                        const GLFWvidmode* desired);
int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second);
_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM);
void _glfwFreeMonitor(_GLFWmonitor* monitor);
void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);

void _glfwInitGamepadMappings(void);
_GLFWjoystick* _glfwAllocJoystick(const char* name,
                                  const char* guid,
                                  int axisCount,
                                  int buttonCount,
                                  int hatCount);
void _glfwFreeJoystick(_GLFWjoystick* js);
void _glfwCenterCursorInContentArea(_GLFWwindow* window);

GLFWbool _glfwInitEGL(void);
void _glfwTerminateEGL(void);
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
                               const _GLFWctxconfig* ctxconfig,
                               const _GLFWfbconfig* fbconfig);
#if defined(_GLFW_X11)
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
                              const _GLFWctxconfig* ctxconfig,
                              const _GLFWfbconfig* fbconfig,
                              Visual** visual, int* depth);
#endif /*_GLFW_X11*/

GLFWbool _glfwInitOSMesa(void);
void _glfwTerminateOSMesa(void);
GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
                                  const _GLFWctxconfig* ctxconfig,
                                  const _GLFWfbconfig* fbconfig);

GLFWbool _glfwInitVulkan(int mode);
void _glfwTerminateVulkan(void);
const char* _glfwGetVulkanResultString(VkResult result);

size_t _glfwEncodeUTF8(char* s, uint32_t codepoint);
char** _glfwParseUriList(char* text, int* count);

char* _glfw_strdup(const char* source);
int _glfw_min(int a, int b);
int _glfw_max(int a, int b);

void* _glfw_calloc(size_t count, size_t size);
void* _glfw_realloc(void* pointer, size_t size);
void _glfw_free(void* pointer);