Blame interface/eglexternalplatform.h

rpm-build 87357e
/*
rpm-build 87357e
 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
rpm-build 87357e
 *
rpm-build 87357e
 * Permission is hereby granted, free of charge, to any person obtaining a
rpm-build 87357e
 * copy of this software and associated documentation files (the "Software"),
rpm-build 87357e
 * to deal in the Software without restriction, including without limitation
rpm-build 87357e
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
rpm-build 87357e
 * and/or sell copies of the Software, and to permit persons to whom the
rpm-build 87357e
 * Software is furnished to do so, subject to the following conditions:
rpm-build 87357e
 *
rpm-build 87357e
 * The above copyright notice and this permission notice shall be included in
rpm-build 87357e
 * all copies or substantial portions of the Software.
rpm-build 87357e
 *
rpm-build 87357e
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
rpm-build 87357e
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
rpm-build 87357e
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
rpm-build 87357e
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
rpm-build 87357e
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
rpm-build 87357e
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
rpm-build 87357e
 * DEALINGS IN THE SOFTWARE.
rpm-build 87357e
 */
rpm-build 87357e
rpm-build 87357e
#ifndef EGL_EXTERNAL_PLATFORM_H
rpm-build 87357e
#define EGL_EXTERNAL_PLATFORM_H
rpm-build 87357e
rpm-build 87357e
#include <EGL/egl.h>
rpm-build 87357e
#include <EGL/eglext.h>
rpm-build 87357e
#include "eglexternalplatformversion.h"
rpm-build 87357e
rpm-build 87357e
/* EGL external platform interface objects */
rpm-build 87357e
typedef struct EGLExtPlatformExports EGLExtPlatformExports;
rpm-build 87357e
typedef struct EGLExtPlatform        EGLExtPlatform;
rpm-build 87357e
typedef struct EGLExtDriver          EGLExtDriver;
rpm-build 87357e
rpm-build 87357e
/* EGLExtPlatformString enum. This indicates what string to query through
rpm-build 87357e
 * queryString() */
rpm-build 87357e
typedef enum {
rpm-build 87357e
    /*
rpm-build 87357e
     * Platform client extensions
rpm-build 87357e
     *
rpm-build 87357e
     * Returns a extension string including the specific platform client
rpm-build 87357e
     * extensions. E.g. EGL_EXT_platform_wayland on Wayland platform.
rpm-build 87357e
     *
rpm-build 87357e
     * The <dpy> parameter is EGL_NO_DISPLAY.
rpm-build 87357e
     */
rpm-build 87357e
    EGL_EXT_PLATFORM_PLATFORM_CLIENT_EXTENSIONS = 0,
rpm-build 87357e
rpm-build 87357e
    /*
rpm-build 87357e
     * Display extensions
rpm-build 87357e
     *
rpm-build 87357e
     * Returns a extension string including all display extensions supported on
rpm-build 87357e
     * the given display by the external platform implementation.
rpm-build 87357e
     */
rpm-build 87357e
    EGL_EXT_PLATFORM_DISPLAY_EXTENSIONS,
rpm-build 87357e
rpm-build 87357e
    EGL_EXT_PLATFORM_STRING_NAME_COUNT
rpm-build 87357e
} EGLExtPlatformString;
rpm-build 87357e
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * loadEGLExternalPlatform()
rpm-build 87357e
 *
rpm-build 87357e
 * Loads the EGL external platform and returns a EGLExtPlatform object where
rpm-build 87357e
 * external platform data and exported functions have been properly set
rpm-build 87357e
 * according to the given major and minor version numbers
rpm-build 87357e
 *
rpm-build 87357e
 * If a compatible external platform is found for <major>.<minor>, EGL_TRUE is
rpm-build 87357e
 * returned and <platform> is properly initialized. Otherwise, EGL_FALSE is
rpm-build 87357e
 * returned and <platform> remains unchanged
rpm-build 87357e
 *
rpm-build 87357e
 * A reference to the underlying EGL implementation that must be used is passed
rpm-build 87357e
 * in <driver>.
rpm-build 87357e
 */
rpm-build 87357e
typedef EGLBoolean (*PEGLEXTFNLOADEGLEXTERNALPLATFORM) (int major, int minor, const EGLExtDriver *driver, EGLExtPlatform *platform);
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * unloadEGLExternalPlatform()
rpm-build 87357e
 *
rpm-build 87357e
 * Unloads the EGL external platform, freeing any resources associated to the
rpm-build 87357e
 * given platform data structure that may have been allocated and not yet freed.
rpm-build 87357e
 *
rpm-build 87357e
 * If all resources are properly freed, EGL_TRUE is returned and the given
rpm-build 87357e
 * platform data pointer becomes invalid. Otherwise, EGL_FALSE is returned.
rpm-build 87357e
 */
rpm-build 87357e
typedef EGLBoolean (*PEGLEXTFNUNLOADEGLEXTERNALPLATFORM) (void *platformData);
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * getHookAddress()
rpm-build 87357e
 *
rpm-build 87357e
 * The EGL external platform interface defines a minimum set of functions that
rpm-build 87357e
 * must be provided by any EGL external platform at loadEGLExternalPlatform()
rpm-build 87357e
 * time.
rpm-build 87357e
 *
rpm-build 87357e
 * However, most of the other EGL functions can be overwritten by an EGL
rpm-build 87357e
 * external platform.
rpm-build 87357e
 *
rpm-build 87357e
 * The EGL implementation will call into getHookAddress() to retrieve any
rpm-build 87357e
 * additional EGL function that the external platform may implement. Its
rpm-build 87357e
 * behavior is comparable to eglGetProcAddress().
rpm-build 87357e
 *
rpm-build 87357e
 * Returns the hook address if the given functions is implemented; otherwise,
rpm-build 87357e
 * returns NULL.
rpm-build 87357e
 */
rpm-build 87357e
typedef void* (*PEGLEXTFNGETHOOKADDRESS) (void *platformData, const char *name);
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * isValidNativeDisplay()
rpm-build 87357e
 *
rpm-build 87357e
 * Validity check function for a native display. It will return EGL_TRUE if the
rpm-build 87357e
 * given native display is valid and belongs to the external platform
rpm-build 87357e
 * implementation; otherwise, it will return EGL_FALSE.
rpm-build 87357e
 */
rpm-build 87357e
typedef EGLBoolean (*PEGLEXTFNISVALIDNATIVEDISPLAY) (void *platformData, void *nativeDisplay);
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * getPlatformDisplay()
rpm-build 87357e
 *
rpm-build 87357e
 * Same as eglGetPlatformDisplay()
rpm-build 87357e
 */
rpm-build 87357e
typedef EGLDisplay (*PEGLEXTFNGETPLATFORMDISPLAY) (void *platformData, EGLenum platform, void *nativeDisplay, const EGLAttrib* attribs);
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * queryString()
rpm-build 87357e
 *
rpm-build 87357e
 * Similar to eglQueryString(), but takes its own enumeration as the string name
rpm-build 87357e
 * parameter.
rpm-build 87357e
 *
rpm-build 87357e
 * Returns the appropriate extension string which is supported by the external
rpm-build 87357e
 * platform. See descriptions of EGLExtPlatformString enums for more details.
rpm-build 87357e
 */
rpm-build 87357e
typedef const char * (*PEGLEXTFNQUERYSTRING) (void *platformData, EGLDisplay dpy, EGLExtPlatformString name);
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * getInternalHandle()
rpm-build 87357e
 *
rpm-build 87357e
 * Conversion function from an EGL external object handle to its corresponding
rpm-build 87357e
 * EGL internal one. It will return the internal EGL object handle if the given
rpm-build 87357e
 * external handle is valid and belongs to the given EGLDisplay; otherwise, it
rpm-build 87357e
 * will return NULL.
rpm-build 87357e
 *
rpm-build 87357e
 * Note that the object handle type must be provided by the caller. Its value
rpm-build 87357e
 * must be one of the object type enums as defined in EGL_KHR_debug.
rpm-build 87357e
 */
rpm-build 87357e
typedef void* (*PEGLEXTFNGETINTERNALHANDLE) (EGLDisplay dpy, EGLenum type, void *handle);
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * getObjectLabel()
rpm-build 87357e
 *
rpm-build 87357e
 * Returns an EGL external object label previously attached with
rpm-build 87357e
 * eglLabelObjectKHR() from EGL_KHR_debug.
rpm-build 87357e
 *
rpm-build 87357e
 * Note that the object handle type must be provided by the caller. Its value
rpm-build 87357e
 * must be one of the object type enums as defined in EGL_KHR_debug.
rpm-build 87357e
 */
rpm-build 87357e
typedef void* (*PEGLEXTFNGETOBJECTLABEL) (EGLDisplay dpy, EGLenum type, void *handle);
rpm-build 87357e
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * EGLExtPlatformExports definition. This is the exports table an external
rpm-build 87357e
 * platform must fill out and make available for the EGL implementation to use
rpm-build 87357e
 */
rpm-build 87357e
struct EGLExtPlatformExports {
rpm-build 87357e
    PEGLEXTFNUNLOADEGLEXTERNALPLATFORM unloadEGLExternalPlatform;
rpm-build 87357e
    PEGLEXTFNGETHOOKADDRESS            getHookAddress;
rpm-build 87357e
rpm-build 87357e
    PEGLEXTFNISVALIDNATIVEDISPLAY      isValidNativeDisplay;
rpm-build 87357e
    PEGLEXTFNGETPLATFORMDISPLAY        getPlatformDisplay;
rpm-build 87357e
rpm-build 87357e
    PEGLEXTFNQUERYSTRING               queryString;
rpm-build 87357e
rpm-build 87357e
    PEGLEXTFNGETINTERNALHANDLE         getInternalHandle;
rpm-build 87357e
rpm-build 87357e
    PEGLEXTFNGETOBJECTLABEL            getObjectLabel;
rpm-build 87357e
};
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * EGLExtPlatform definition. This is common to all external platforms
rpm-build 87357e
 *
rpm-build 87357e
 * Fields:
rpm-build 87357e
 *  - major/minor: External platform major/minor version number. Specify the EGL
rpm-build 87357e
 *                 external platform interface version number the given platform
rpm-build 87357e
 *                 implements. They are tied to EGL external platform interface
rpm-build 87357e
 *                 changes.
rpm-build 87357e
 *  - micro:       External platform micro version number. Similar to
rpm-build 87357e
 *                 major/minor numbers, but it is tied to specific external
rpm-build 87357e
 *                 platform implementation changes.
rpm-build 87357e
 *  - platform:    EGL platform enumeration the corresponding external platform
rpm-build 87357e
 *                 implements.
rpm-build 87357e
 *  - data:        Opaque pointer to platform specific data. At platform
rpm-build 87357e
 *                 load time, the external platform can initialize its own data
rpm-build 87357e
 *                 structure to store any information that may be required by
rpm-build 87357e
 *                 any function that does not take an EGLDisplay or the display
rpm-build 87357e
 *                 belongs to another platform.
rpm-build 87357e
 *  - exports:     External platform exports table.
rpm-build 87357e
 */
rpm-build 87357e
struct EGLExtPlatform {
rpm-build 87357e
    struct {
rpm-build 87357e
        int major;
rpm-build 87357e
        int minor;
rpm-build 87357e
        int micro;
rpm-build 87357e
    }                      version;
rpm-build 87357e
    EGLenum                platform;
rpm-build 87357e
    void                  *data;
rpm-build 87357e
    EGLExtPlatformExports  exports;
rpm-build 87357e
};
rpm-build 87357e
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * getProcAddress()
rpm-build 87357e
 *
rpm-build 87357e
 * Equivalent to eglGetProcAddress() to fetch EGL methods provided by a
rpm-build 87357e
 * specific EGL driver.
rpm-build 87357e
 */
rpm-build 87357e
typedef void* (*PEGLEXTFNGETPROCADDRESS) (const char *name);
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * setError()
rpm-build 87357e
 *
rpm-build 87357e
 * Sets the last EGL error, which can be queried with eglGetError() later on. It
rpm-build 87357e
 * also calls the EGL_KHR_debug callback if such extension is supported by the
rpm-build 87357e
 * driver.
rpm-build 87357e
 *
rpm-build 87357e
 * Takes the EGL error code and both message type and string as defined in
rpm-build 87357e
 * EGL_KHR_debug for the debug callback function.
rpm-build 87357e
 */
rpm-build 87357e
typedef void (*PEGLEXTFNSETERROR) (EGLint error, EGLint msgType, const char *msg);
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * debugMessage()
rpm-build 87357e
 *
rpm-build 87357e
 * Calls the EGL_KHR_debug callback if such extension is supported by the
rpm-build 87357e
 * driver.
rpm-build 87357e
 *
rpm-build 87357e
 * Takes both message type and string as defined in EGL_KHR_debug for the debug
rpm-build 87357e
 * callback function.
rpm-build 87357e
 */
rpm-build 87357e
typedef void* (*PEGLEXTFNDEBUGMESSAGE) (EGLint msgType, const char *msg);
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * streamSwapInterval()
rpm-build 87357e
 *
rpm-build 87357e
 * Handle swapinterval on the EGLStream consumer side. Should be a noop for
rpm-build 87357e
 * any consumer that does not present directly to a display.
rpm-build 87357e
 *
rpm-build 87357e
 * Takes the stream handle and a pointer to the interval value as parameters.
rpm-build 87357e
 *
rpm-build 87357e
 * Returns one of the following EGL error codes:
rpm-build 87357e
 *  - EGL_SUCCESS:    The interval setting operation succeeded (or noop).
rpm-build 87357e
 *  - EGL_BAD_MATCH:  A server-side interval override is in place. The override
rpm-build 87357e
 *                    value is returned in the <interval> parameter.
rpm-build 87357e
 *  - EGL_BAD_ACCESS: The interval setting operation failed.
rpm-build 87357e
 */
rpm-build 87357e
typedef EGLint (*PEGLEXTFNSTREAMSWAPINTERVAL) (EGLStreamKHR stream, int *interval);
rpm-build 87357e
rpm-build 87357e
/*
rpm-build 87357e
 * EGLExtDriver definition. The EGL external driver is the component in
rpm-build 87357e
 * charge of dispatching EGL calls to the underlying EGL implementation.
rpm-build 87357e
 */
rpm-build 87357e
struct EGLExtDriver {
rpm-build 87357e
    PEGLEXTFNGETPROCADDRESS     getProcAddress;
rpm-build 87357e
    PEGLEXTFNSETERROR           setError;
rpm-build 87357e
    PEGLEXTFNDEBUGMESSAGE       debugMessage;
rpm-build 87357e
    PEGLEXTFNSTREAMSWAPINTERVAL streamSwapInterval;
rpm-build 87357e
#if EGL_EXTERNAL_PLATFORM_HAS(DRIVER_VERSION)
rpm-build 87357e
    int major;
rpm-build 87357e
    int minor;
rpm-build 87357e
#endif
rpm-build 87357e
};
rpm-build 87357e
rpm-build 87357e
#endif // EGL_EXTERNAL_PLATFORM_H