/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/Makefile.am |
---|
0,0 → 1,98 |
# Copyright © 2012 Intel Corporation |
# |
# Permission is hereby granted, free of charge, to any person obtaining a |
# copy of this software and associated documentation files (the "Software"), |
# to deal in the Software without restriction, including without limitation |
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
# and/or sell copies of the Software, and to permit persons to whom the |
# Software is furnished to do so, subject to the following conditions: |
# |
# The above copyright notice and this permission notice (including the next |
# paragraph) shall be included in all copies or substantial portions of the |
# Software. |
# |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
# IN THE SOFTWARE. |
include Makefile.sources |
AM_CFLAGS = \ |
-I$(top_srcdir)/include \ |
-I$(top_srcdir)/src/gbm/main \ |
$(DEFINES) \ |
$(VISIBILITY_CFLAGS) \ |
$(EGL_CFLAGS) \ |
-D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) \ |
-D_EGL_DRIVER_SEARCH_DIR=\"$(libdir)/egl\" \ |
-D_EGL_OS_UNIX=1 |
lib_LTLIBRARIES = libEGL.la |
libEGL_la_SOURCES = \ |
${LIBEGL_C_FILES} |
libEGL_la_LIBADD = \ |
$(EGL_LIB_DEPS) |
libEGL_la_LDFLAGS = \ |
-no-undefined \ |
-version-number 1:0 \ |
$(BSYMBOLIC) \ |
$(GC_SECTIONS) \ |
$(LD_NO_UNDEFINED) |
if HAVE_EGL_PLATFORM_X11 |
AM_CFLAGS += -DHAVE_X11_PLATFORM |
AM_CFLAGS += $(XCB_DRI2_CFLAGS) |
libEGL_la_LIBADD += $(XCB_DRI2_LIBS) |
endif |
if HAVE_EGL_PLATFORM_WAYLAND |
AM_CFLAGS += -DHAVE_WAYLAND_PLATFORM |
AM_CFLAGS += $(WAYLAND_CFLAGS) |
libEGL_la_LIBADD += $(WAYLAND_LIBS) |
libEGL_la_LIBADD += $(LIBDRM_LIBS) |
libEGL_la_LIBADD += ../wayland/wayland-drm/libwayland-drm.la |
endif |
if HAVE_EGL_PLATFORM_DRM |
AM_CFLAGS += -DHAVE_DRM_PLATFORM |
libEGL_la_LIBADD += ../../gbm/libgbm.la |
endif |
if HAVE_EGL_PLATFORM_NULL |
AM_CFLAGS += -DHAVE_NULL_PLATFORM |
endif |
if HAVE_EGL_DRIVER_DRI2 |
AM_CFLAGS += -D_EGL_BUILT_IN_DRIVER_DRI2 |
AM_CFLAGS += -DHAVE_XCB_DRI2 |
libEGL_la_LIBADD += ../drivers/dri2/libegl_dri2.la |
libEGL_la_LIBADD += $(DLOPEN_LIBS) $(LIBDRM_LIBS) |
endif |
include $(top_srcdir)/install-lib-links.mk |
pkgconfigdir = $(libdir)/pkgconfig |
pkgconfig_DATA = egl.pc |
khrdir = $(includedir)/KHR |
khr_HEADERS = $(top_srcdir)/include/KHR/khrplatform.h |
egldir = $(includedir)/EGL |
egl_HEADERS = \ |
$(top_srcdir)/include/EGL/eglext.h \ |
$(top_srcdir)/include/EGL/egl.h \ |
$(top_srcdir)/include/EGL/eglextchromium.h \ |
$(top_srcdir)/include/EGL/eglmesaext.h \ |
$(top_srcdir)/include/EGL/eglplatform.h |
EXTRA_DIST = \ |
egl.def \ |
README.txt \ |
SConscript |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/Makefile.in |
---|
0,0 → 1,1050 |
# Makefile.in generated by automake 1.15 from Makefile.am. |
# @configure_input@ |
# Copyright (C) 1994-2014 Free Software Foundation, Inc. |
# This Makefile.in is free software; the Free Software Foundation |
# gives unlimited permission to copy and/or distribute it, |
# with or without modifications, as long as this notice is preserved. |
# This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without |
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
# PARTICULAR PURPOSE. |
@SET_MAKE@ |
# Copyright © 2012 Intel Corporation |
# |
# Permission is hereby granted, free of charge, to any person obtaining a |
# copy of this software and associated documentation files (the "Software"), |
# to deal in the Software without restriction, including without limitation |
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
# and/or sell copies of the Software, and to permit persons to whom the |
# Software is furnished to do so, subject to the following conditions: |
# |
# The above copyright notice and this permission notice (including the next |
# paragraph) shall be included in all copies or substantial portions of the |
# Software. |
# |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
# IN THE SOFTWARE. |
# Provide compatibility with scripts for the old Mesa build system for |
# a while by putting a link to the driver into /lib of the build tree. |
VPATH = @srcdir@ |
am__is_gnu_make = { \ |
if test -z '$(MAKELEVEL)'; then \ |
false; \ |
elif test -n '$(MAKE_HOST)'; then \ |
true; \ |
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ |
true; \ |
else \ |
false; \ |
fi; \ |
} |
am__make_running_with_option = \ |
case $${target_option-} in \ |
?) ;; \ |
*) echo "am__make_running_with_option: internal error: invalid" \ |
"target option '$${target_option-}' specified" >&2; \ |
exit 1;; \ |
esac; \ |
has_opt=no; \ |
sane_makeflags=$$MAKEFLAGS; \ |
if $(am__is_gnu_make); then \ |
sane_makeflags=$$MFLAGS; \ |
else \ |
case $$MAKEFLAGS in \ |
*\\[\ \ ]*) \ |
bs=\\; \ |
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ |
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ |
esac; \ |
fi; \ |
skip_next=no; \ |
strip_trailopt () \ |
{ \ |
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ |
}; \ |
for flg in $$sane_makeflags; do \ |
test $$skip_next = yes && { skip_next=no; continue; }; \ |
case $$flg in \ |
*=*|--*) continue;; \ |
-*I) strip_trailopt 'I'; skip_next=yes;; \ |
-*I?*) strip_trailopt 'I';; \ |
-*O) strip_trailopt 'O'; skip_next=yes;; \ |
-*O?*) strip_trailopt 'O';; \ |
-*l) strip_trailopt 'l'; skip_next=yes;; \ |
-*l?*) strip_trailopt 'l';; \ |
-[dEDm]) skip_next=yes;; \ |
-[JT]) skip_next=yes;; \ |
esac; \ |
case $$flg in \ |
*$$target_option*) has_opt=yes; break;; \ |
esac; \ |
done; \ |
test $$has_opt = yes |
am__make_dryrun = (target_option=n; $(am__make_running_with_option)) |
am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) |
pkgdatadir = $(datadir)/@PACKAGE@ |
pkgincludedir = $(includedir)/@PACKAGE@ |
pkglibdir = $(libdir)/@PACKAGE@ |
pkglibexecdir = $(libexecdir)/@PACKAGE@ |
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd |
install_sh_DATA = $(install_sh) -c -m 644 |
install_sh_PROGRAM = $(install_sh) -c |
install_sh_SCRIPT = $(install_sh) -c |
INSTALL_HEADER = $(INSTALL_DATA) |
transform = $(program_transform_name) |
NORMAL_INSTALL = : |
PRE_INSTALL = : |
POST_INSTALL = : |
NORMAL_UNINSTALL = : |
PRE_UNINSTALL = : |
POST_UNINSTALL = : |
build_triplet = @build@ |
host_triplet = @host@ |
target_triplet = @target@ |
@HAVE_EGL_PLATFORM_X11_TRUE@am__append_1 = -DHAVE_X11_PLATFORM \ |
@HAVE_EGL_PLATFORM_X11_TRUE@ $(XCB_DRI2_CFLAGS) |
@HAVE_EGL_PLATFORM_X11_TRUE@am__append_2 = $(XCB_DRI2_LIBS) |
@HAVE_EGL_PLATFORM_WAYLAND_TRUE@am__append_3 = \ |
@HAVE_EGL_PLATFORM_WAYLAND_TRUE@ -DHAVE_WAYLAND_PLATFORM \ |
@HAVE_EGL_PLATFORM_WAYLAND_TRUE@ $(WAYLAND_CFLAGS) |
@HAVE_EGL_PLATFORM_WAYLAND_TRUE@am__append_4 = $(WAYLAND_LIBS) \ |
@HAVE_EGL_PLATFORM_WAYLAND_TRUE@ $(LIBDRM_LIBS) \ |
@HAVE_EGL_PLATFORM_WAYLAND_TRUE@ ../wayland/wayland-drm/libwayland-drm.la |
@HAVE_EGL_PLATFORM_DRM_TRUE@am__append_5 = -DHAVE_DRM_PLATFORM |
@HAVE_EGL_PLATFORM_DRM_TRUE@am__append_6 = ../../gbm/libgbm.la |
@HAVE_EGL_PLATFORM_NULL_TRUE@am__append_7 = -DHAVE_NULL_PLATFORM |
@HAVE_EGL_DRIVER_DRI2_TRUE@am__append_8 = -D_EGL_BUILT_IN_DRIVER_DRI2 \ |
@HAVE_EGL_DRIVER_DRI2_TRUE@ -DHAVE_XCB_DRI2 |
@HAVE_EGL_DRIVER_DRI2_TRUE@am__append_9 = \ |
@HAVE_EGL_DRIVER_DRI2_TRUE@ ../drivers/dri2/libegl_dri2.la \ |
@HAVE_EGL_DRIVER_DRI2_TRUE@ $(DLOPEN_LIBS) $(LIBDRM_LIBS) |
subdir = src/egl/main |
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_gnu_make.m4 \ |
$(top_srcdir)/m4/ax_check_python_mako_module.m4 \ |
$(top_srcdir)/m4/ax_gcc_builtin.m4 \ |
$(top_srcdir)/m4/ax_gcc_func_attribute.m4 \ |
$(top_srcdir)/m4/ax_prog_bison.m4 \ |
$(top_srcdir)/m4/ax_prog_flex.m4 \ |
$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \ |
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ |
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ |
$(top_srcdir)/VERSION $(top_srcdir)/configure.ac |
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
$(ACLOCAL_M4) |
DIST_COMMON = $(srcdir)/Makefile.am $(egl_HEADERS) $(khr_HEADERS) \ |
$(am__DIST_COMMON) |
mkinstalldirs = $(install_sh) -d |
CONFIG_CLEAN_FILES = egl.pc |
CONFIG_CLEAN_VPATH_FILES = |
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; |
am__vpath_adj = case $$p in \ |
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ |
*) f=$$p;; \ |
esac; |
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; |
am__install_max = 40 |
am__nobase_strip_setup = \ |
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` |
am__nobase_strip = \ |
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" |
am__nobase_list = $(am__nobase_strip_setup); \ |
for p in $$list; do echo "$$p $$p"; done | \ |
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ |
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ |
if (++n[$$2] == $(am__install_max)) \ |
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ |
END { for (dir in files) print dir, files[dir] }' |
am__base_list = \ |
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ |
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' |
am__uninstall_files_from_dir = { \ |
test -z "$$files" \ |
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ |
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \ |
$(am__cd) "$$dir" && rm -f $$files; }; \ |
} |
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" \ |
"$(DESTDIR)$(egldir)" "$(DESTDIR)$(khrdir)" |
LTLIBRARIES = $(lib_LTLIBRARIES) |
am__DEPENDENCIES_1 = |
@HAVE_EGL_PLATFORM_X11_TRUE@am__DEPENDENCIES_2 = \ |
@HAVE_EGL_PLATFORM_X11_TRUE@ $(am__DEPENDENCIES_1) |
@HAVE_EGL_PLATFORM_WAYLAND_TRUE@am__DEPENDENCIES_3 = \ |
@HAVE_EGL_PLATFORM_WAYLAND_TRUE@ $(am__DEPENDENCIES_1) \ |
@HAVE_EGL_PLATFORM_WAYLAND_TRUE@ $(am__DEPENDENCIES_1) \ |
@HAVE_EGL_PLATFORM_WAYLAND_TRUE@ ../wayland/wayland-drm/libwayland-drm.la |
@HAVE_EGL_DRIVER_DRI2_TRUE@am__DEPENDENCIES_4 = \ |
@HAVE_EGL_DRIVER_DRI2_TRUE@ ../drivers/dri2/libegl_dri2.la \ |
@HAVE_EGL_DRIVER_DRI2_TRUE@ $(am__DEPENDENCIES_1) \ |
@HAVE_EGL_DRIVER_DRI2_TRUE@ $(am__DEPENDENCIES_1) |
libEGL_la_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ |
$(am__DEPENDENCIES_3) $(am__append_6) $(am__DEPENDENCIES_4) |
am__objects_1 = eglapi.lo eglarray.lo eglconfig.lo eglcontext.lo \ |
eglcurrent.lo egldisplay.lo egldriver.lo eglfallbacks.lo \ |
eglglobals.lo eglimage.lo egllog.lo eglstring.lo eglsurface.lo \ |
eglsync.lo |
am_libEGL_la_OBJECTS = $(am__objects_1) |
libEGL_la_OBJECTS = $(am_libEGL_la_OBJECTS) |
AM_V_lt = $(am__v_lt_@AM_V@) |
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) |
am__v_lt_0 = --silent |
am__v_lt_1 = |
libEGL_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ |
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ |
$(libEGL_la_LDFLAGS) $(LDFLAGS) -o $@ |
AM_V_P = $(am__v_P_@AM_V@) |
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) |
am__v_P_0 = false |
am__v_P_1 = : |
AM_V_GEN = $(am__v_GEN_@AM_V@) |
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) |
am__v_GEN_0 = @echo " GEN " $@; |
am__v_GEN_1 = |
AM_V_at = $(am__v_at_@AM_V@) |
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) |
am__v_at_0 = @ |
am__v_at_1 = |
DEFAULT_INCLUDES = -I.@am__isrc@ |
depcomp = $(SHELL) $(top_srcdir)/bin/depcomp |
am__depfiles_maybe = depfiles |
am__mv = mv -f |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ |
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ |
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ |
$(AM_CFLAGS) $(CFLAGS) |
AM_V_CC = $(am__v_CC_@AM_V@) |
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) |
am__v_CC_0 = @echo " CC " $@; |
am__v_CC_1 = |
CCLD = $(CC) |
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ |
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ |
$(AM_LDFLAGS) $(LDFLAGS) -o $@ |
AM_V_CCLD = $(am__v_CCLD_@AM_V@) |
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) |
am__v_CCLD_0 = @echo " CCLD " $@; |
am__v_CCLD_1 = |
SOURCES = $(libEGL_la_SOURCES) |
DIST_SOURCES = $(libEGL_la_SOURCES) |
am__can_run_installinfo = \ |
case $$AM_UPDATE_INFO_DIR in \ |
n|no|NO) false;; \ |
*) (install-info --version) >/dev/null 2>&1;; \ |
esac |
DATA = $(pkgconfig_DATA) |
HEADERS = $(egl_HEADERS) $(khr_HEADERS) |
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) |
# Read a list of newline-separated strings from the standard input, |
# and print each of them once, without duplicates. Input order is |
# *not* preserved. |
am__uniquify_input = $(AWK) '\ |
BEGIN { nonempty = 0; } \ |
{ items[$$0] = 1; nonempty = 1; } \ |
END { if (nonempty) { for (i in items) print i; }; } \ |
' |
# Make sure the list of sources is unique. This is necessary because, |
# e.g., the same source file might be shared among _SOURCES variables |
# for different programs/libraries. |
am__define_uniq_tagged_files = \ |
list='$(am__tagged_files)'; \ |
unique=`for i in $$list; do \ |
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ |
done | $(am__uniquify_input)` |
ETAGS = etags |
CTAGS = ctags |
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.sources \ |
$(srcdir)/egl.pc.in $(top_srcdir)/bin/depcomp \ |
$(top_srcdir)/install-lib-links.mk |
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
ACLOCAL = @ACLOCAL@ |
AMTAR = @AMTAR@ |
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ |
AR = @AR@ |
AUTOCONF = @AUTOCONF@ |
AUTOHEADER = @AUTOHEADER@ |
AUTOMAKE = @AUTOMAKE@ |
AWK = @AWK@ |
BSYMBOLIC = @BSYMBOLIC@ |
CC = @CC@ |
CCAS = @CCAS@ |
CCASDEPMODE = @CCASDEPMODE@ |
CCASFLAGS = @CCASFLAGS@ |
CCDEPMODE = @CCDEPMODE@ |
CFLAGS = @CFLAGS@ |
CLANG_RESOURCE_DIR = @CLANG_RESOURCE_DIR@ |
CLOCK_LIB = @CLOCK_LIB@ |
CPP = @CPP@ |
CPPFLAGS = @CPPFLAGS@ |
CXX = @CXX@ |
CXXCPP = @CXXCPP@ |
CXXDEPMODE = @CXXDEPMODE@ |
CXXFLAGS = @CXXFLAGS@ |
CYGPATH_W = @CYGPATH_W@ |
D3D_DRIVER_INSTALL_DIR = @D3D_DRIVER_INSTALL_DIR@ |
DEFINES = @DEFINES@ |
DEFS = @DEFS@ |
DEPDIR = @DEPDIR@ |
DLLTOOL = @DLLTOOL@ |
DLOPEN_LIBS = @DLOPEN_LIBS@ |
DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ |
DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ |
DRI3PROTO_CFLAGS = @DRI3PROTO_CFLAGS@ |
DRI3PROTO_LIBS = @DRI3PROTO_LIBS@ |
DRIGL_CFLAGS = @DRIGL_CFLAGS@ |
DRIGL_LIBS = @DRIGL_LIBS@ |
DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@ |
DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@ |
DRI_LIB_DEPS = @DRI_LIB_DEPS@ |
DRI_PC_REQ_PRIV = @DRI_PC_REQ_PRIV@ |
DSYMUTIL = @DSYMUTIL@ |
DUMPBIN = @DUMPBIN@ |
ECHO_C = @ECHO_C@ |
ECHO_N = @ECHO_N@ |
ECHO_T = @ECHO_T@ |
EGL_CFLAGS = @EGL_CFLAGS@ |
EGL_CLIENT_APIS = @EGL_CLIENT_APIS@ |
EGL_LIB_DEPS = @EGL_LIB_DEPS@ |
EGL_NATIVE_PLATFORM = @EGL_NATIVE_PLATFORM@ |
EGREP = @EGREP@ |
ELF_LIB = @ELF_LIB@ |
EXEEXT = @EXEEXT@ |
EXPAT_CFLAGS = @EXPAT_CFLAGS@ |
EXPAT_LIBS = @EXPAT_LIBS@ |
FGREP = @FGREP@ |
FREEDRENO_CFLAGS = @FREEDRENO_CFLAGS@ |
FREEDRENO_LIBS = @FREEDRENO_LIBS@ |
GALLIUM_PIPE_LOADER_CLIENT_DEFINES = @GALLIUM_PIPE_LOADER_CLIENT_DEFINES@ |
GALLIUM_PIPE_LOADER_CLIENT_LIBS = @GALLIUM_PIPE_LOADER_CLIENT_LIBS@ |
GALLIUM_PIPE_LOADER_DEFINES = @GALLIUM_PIPE_LOADER_DEFINES@ |
GALLIUM_PIPE_LOADER_LIBS = @GALLIUM_PIPE_LOADER_LIBS@ |
GALLIUM_PIPE_LOADER_XCB_CFLAGS = @GALLIUM_PIPE_LOADER_XCB_CFLAGS@ |
GALLIUM_PIPE_LOADER_XCB_LIBS = @GALLIUM_PIPE_LOADER_XCB_LIBS@ |
GBM_PC_LIB_PRIV = @GBM_PC_LIB_PRIV@ |
GBM_PC_REQ_PRIV = @GBM_PC_REQ_PRIV@ |
GC_SECTIONS = @GC_SECTIONS@ |
GLESv1_CM_LIB_DEPS = @GLESv1_CM_LIB_DEPS@ |
GLESv1_CM_PC_LIB_PRIV = @GLESv1_CM_PC_LIB_PRIV@ |
GLESv2_LIB_DEPS = @GLESv2_LIB_DEPS@ |
GLESv2_PC_LIB_PRIV = @GLESv2_PC_LIB_PRIV@ |
GLPROTO_CFLAGS = @GLPROTO_CFLAGS@ |
GLPROTO_LIBS = @GLPROTO_LIBS@ |
GLX_TLS = @GLX_TLS@ |
GL_LIB = @GL_LIB@ |
GL_LIB_DEPS = @GL_LIB_DEPS@ |
GL_PC_CFLAGS = @GL_PC_CFLAGS@ |
GL_PC_LIB_PRIV = @GL_PC_LIB_PRIV@ |
GL_PC_REQ_PRIV = @GL_PC_REQ_PRIV@ |
GREP = @GREP@ |
HAVE_XF86VIDMODE = @HAVE_XF86VIDMODE@ |
INDENT = @INDENT@ |
INDENT_FLAGS = @INDENT_FLAGS@ |
INSTALL = @INSTALL@ |
INSTALL_DATA = @INSTALL_DATA@ |
INSTALL_PROGRAM = @INSTALL_PROGRAM@ |
INSTALL_SCRIPT = @INSTALL_SCRIPT@ |
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ |
INTEL_CFLAGS = @INTEL_CFLAGS@ |
INTEL_LIBS = @INTEL_LIBS@ |
LD = @LD@ |
LDFLAGS = @LDFLAGS@ |
LD_NO_UNDEFINED = @LD_NO_UNDEFINED@ |
LEX = @LEX@ |
LEXLIB = @LEXLIB@ |
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ |
LIBCLC_INCLUDEDIR = @LIBCLC_INCLUDEDIR@ |
LIBCLC_LIBEXECDIR = @LIBCLC_LIBEXECDIR@ |
LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ |
LIBDRM_LIBS = @LIBDRM_LIBS@ |
LIBOBJS = @LIBOBJS@ |
LIBS = @LIBS@ |
LIBSHA1_CFLAGS = @LIBSHA1_CFLAGS@ |
LIBSHA1_LIBS = @LIBSHA1_LIBS@ |
LIBTOOL = @LIBTOOL@ |
LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ |
LIBUDEV_LIBS = @LIBUDEV_LIBS@ |
LIB_DIR = @LIB_DIR@ |
LIB_EXT = @LIB_EXT@ |
LIPO = @LIPO@ |
LLVM_BINDIR = @LLVM_BINDIR@ |
LLVM_CFLAGS = @LLVM_CFLAGS@ |
LLVM_CONFIG = @LLVM_CONFIG@ |
LLVM_CPPFLAGS = @LLVM_CPPFLAGS@ |
LLVM_CXXFLAGS = @LLVM_CXXFLAGS@ |
LLVM_INCLUDEDIR = @LLVM_INCLUDEDIR@ |
LLVM_LDFLAGS = @LLVM_LDFLAGS@ |
LLVM_LIBDIR = @LLVM_LIBDIR@ |
LLVM_LIBS = @LLVM_LIBS@ |
LLVM_VERSION = @LLVM_VERSION@ |
LN_S = @LN_S@ |
LTLIBOBJS = @LTLIBOBJS@ |
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ |
MAKEINFO = @MAKEINFO@ |
MANIFEST_TOOL = @MANIFEST_TOOL@ |
MESA_LLVM = @MESA_LLVM@ |
MKDIR_P = @MKDIR_P@ |
MSVC2008_COMPAT_CFLAGS = @MSVC2008_COMPAT_CFLAGS@ |
MSVC2008_COMPAT_CXXFLAGS = @MSVC2008_COMPAT_CXXFLAGS@ |
MSVC2013_COMPAT_CFLAGS = @MSVC2013_COMPAT_CFLAGS@ |
MSVC2013_COMPAT_CXXFLAGS = @MSVC2013_COMPAT_CXXFLAGS@ |
NINE_MAJOR = @NINE_MAJOR@ |
NINE_MINOR = @NINE_MINOR@ |
NINE_TINY = @NINE_TINY@ |
NINE_VERSION = @NINE_VERSION@ |
NM = @NM@ |
NMEDIT = @NMEDIT@ |
NOUVEAU_CFLAGS = @NOUVEAU_CFLAGS@ |
NOUVEAU_LIBS = @NOUVEAU_LIBS@ |
OBJDUMP = @OBJDUMP@ |
OBJEXT = @OBJEXT@ |
OMX_CFLAGS = @OMX_CFLAGS@ |
OMX_LIBS = @OMX_LIBS@ |
OMX_LIB_INSTALL_DIR = @OMX_LIB_INSTALL_DIR@ |
OPENCL_LIBNAME = @OPENCL_LIBNAME@ |
OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ |
OPENSSL_LIBS = @OPENSSL_LIBS@ |
OSMESA_LIB = @OSMESA_LIB@ |
OSMESA_LIB_DEPS = @OSMESA_LIB_DEPS@ |
OSMESA_PC_LIB_PRIV = @OSMESA_PC_LIB_PRIV@ |
OSMESA_PC_REQ = @OSMESA_PC_REQ@ |
OSMESA_VERSION = @OSMESA_VERSION@ |
OTOOL = @OTOOL@ |
OTOOL64 = @OTOOL64@ |
PACKAGE = @PACKAGE@ |
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ |
PACKAGE_NAME = @PACKAGE_NAME@ |
PACKAGE_STRING = @PACKAGE_STRING@ |
PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
PACKAGE_URL = @PACKAGE_URL@ |
PACKAGE_VERSION = @PACKAGE_VERSION@ |
PATH_SEPARATOR = @PATH_SEPARATOR@ |
PKG_CONFIG = @PKG_CONFIG@ |
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ |
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ |
POSIX_SHELL = @POSIX_SHELL@ |
PRESENTPROTO_CFLAGS = @PRESENTPROTO_CFLAGS@ |
PRESENTPROTO_LIBS = @PRESENTPROTO_LIBS@ |
PTHREAD_CC = @PTHREAD_CC@ |
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ |
PTHREAD_LIBS = @PTHREAD_LIBS@ |
PYTHON2 = @PYTHON2@ |
RADEON_CFLAGS = @RADEON_CFLAGS@ |
RADEON_LIBS = @RADEON_LIBS@ |
RANLIB = @RANLIB@ |
SED = @SED@ |
SELINUX_CFLAGS = @SELINUX_CFLAGS@ |
SELINUX_LIBS = @SELINUX_LIBS@ |
SET_MAKE = @SET_MAKE@ |
SHA1_CFLAGS = @SHA1_CFLAGS@ |
SHA1_LIBS = @SHA1_LIBS@ |
SHELL = @SHELL@ |
SSE41_CFLAGS = @SSE41_CFLAGS@ |
STRIP = @STRIP@ |
VA_CFLAGS = @VA_CFLAGS@ |
VA_LIBS = @VA_LIBS@ |
VA_LIB_INSTALL_DIR = @VA_LIB_INSTALL_DIR@ |
VA_MAJOR = @VA_MAJOR@ |
VA_MINOR = @VA_MINOR@ |
VDPAU_CFLAGS = @VDPAU_CFLAGS@ |
VDPAU_LIBS = @VDPAU_LIBS@ |
VDPAU_LIB_INSTALL_DIR = @VDPAU_LIB_INSTALL_DIR@ |
VDPAU_MAJOR = @VDPAU_MAJOR@ |
VDPAU_MINOR = @VDPAU_MINOR@ |
VERSION = @VERSION@ |
VG_LIB_DEPS = @VG_LIB_DEPS@ |
VISIBILITY_CFLAGS = @VISIBILITY_CFLAGS@ |
VISIBILITY_CXXFLAGS = @VISIBILITY_CXXFLAGS@ |
VL_CFLAGS = @VL_CFLAGS@ |
VL_LIBS = @VL_LIBS@ |
WAYLAND_CFLAGS = @WAYLAND_CFLAGS@ |
WAYLAND_LIBS = @WAYLAND_LIBS@ |
WAYLAND_SCANNER = @WAYLAND_SCANNER@ |
WAYLAND_SCANNER_CFLAGS = @WAYLAND_SCANNER_CFLAGS@ |
WAYLAND_SCANNER_LIBS = @WAYLAND_SCANNER_LIBS@ |
X11_INCLUDES = @X11_INCLUDES@ |
XA_MAJOR = @XA_MAJOR@ |
XA_MINOR = @XA_MINOR@ |
XA_TINY = @XA_TINY@ |
XA_VERSION = @XA_VERSION@ |
XCB_DRI2_CFLAGS = @XCB_DRI2_CFLAGS@ |
XCB_DRI2_LIBS = @XCB_DRI2_LIBS@ |
XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ |
XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ |
XLIBGL_CFLAGS = @XLIBGL_CFLAGS@ |
XLIBGL_LIBS = @XLIBGL_LIBS@ |
XVMC_CFLAGS = @XVMC_CFLAGS@ |
XVMC_LIBS = @XVMC_LIBS@ |
XVMC_LIB_INSTALL_DIR = @XVMC_LIB_INSTALL_DIR@ |
XVMC_MAJOR = @XVMC_MAJOR@ |
XVMC_MINOR = @XVMC_MINOR@ |
YACC = @YACC@ |
YFLAGS = @YFLAGS@ |
abs_builddir = @abs_builddir@ |
abs_srcdir = @abs_srcdir@ |
abs_top_builddir = @abs_top_builddir@ |
abs_top_srcdir = @abs_top_srcdir@ |
ac_ct_AR = @ac_ct_AR@ |
ac_ct_CC = @ac_ct_CC@ |
ac_ct_CXX = @ac_ct_CXX@ |
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ |
acv_mako_found = @acv_mako_found@ |
am__include = @am__include@ |
am__leading_dot = @am__leading_dot@ |
am__quote = @am__quote@ |
am__tar = @am__tar@ |
am__untar = @am__untar@ |
ax_pthread_config = @ax_pthread_config@ |
bindir = @bindir@ |
build = @build@ |
build_alias = @build_alias@ |
build_cpu = @build_cpu@ |
build_os = @build_os@ |
build_vendor = @build_vendor@ |
builddir = @builddir@ |
datadir = @datadir@ |
datarootdir = @datarootdir@ |
docdir = @docdir@ |
dvidir = @dvidir@ |
exec_prefix = @exec_prefix@ |
host = @host@ |
host_alias = @host_alias@ |
host_cpu = @host_cpu@ |
host_os = @host_os@ |
host_vendor = @host_vendor@ |
htmldir = @htmldir@ |
ifGNUmake = @ifGNUmake@ |
includedir = @includedir@ |
infodir = @infodir@ |
install_sh = @install_sh@ |
libdir = @libdir@ |
libexecdir = @libexecdir@ |
localedir = @localedir@ |
localstatedir = @localstatedir@ |
mandir = @mandir@ |
mkdir_p = @mkdir_p@ |
oldincludedir = @oldincludedir@ |
pdfdir = @pdfdir@ |
prefix = @prefix@ |
program_transform_name = @program_transform_name@ |
psdir = @psdir@ |
sbindir = @sbindir@ |
sharedstatedir = @sharedstatedir@ |
srcdir = @srcdir@ |
sysconfdir = @sysconfdir@ |
target = @target@ |
target_alias = @target_alias@ |
target_cpu = @target_cpu@ |
target_os = @target_os@ |
target_vendor = @target_vendor@ |
top_build_prefix = @top_build_prefix@ |
top_builddir = @top_builddir@ |
top_srcdir = @top_srcdir@ |
LIBEGL_C_FILES := \ |
eglapi.c \ |
eglapi.h \ |
eglarray.c \ |
eglarray.h \ |
eglcompiler.h \ |
eglconfig.c \ |
eglconfig.h \ |
eglcontext.c \ |
eglcontext.h \ |
eglcurrent.c \ |
eglcurrent.h \ |
egldefines.h \ |
egldisplay.c \ |
egldisplay.h \ |
egldriver.c \ |
egldriver.h \ |
eglfallbacks.c \ |
eglglobals.c \ |
eglglobals.h \ |
eglimage.c \ |
eglimage.h \ |
egllog.c \ |
egllog.h \ |
eglstring.c \ |
eglstring.h \ |
eglsurface.c \ |
eglsurface.h \ |
eglsync.c \ |
eglsync.h \ |
egltypedefs.h |
AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/gbm/main \ |
$(DEFINES) $(VISIBILITY_CFLAGS) $(EGL_CFLAGS) \ |
-D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) \ |
-D_EGL_DRIVER_SEARCH_DIR=\"$(libdir)/egl\" -D_EGL_OS_UNIX=1 \ |
$(am__append_1) $(am__append_3) $(am__append_5) \ |
$(am__append_7) $(am__append_8) |
lib_LTLIBRARIES = libEGL.la |
libEGL_la_SOURCES = \ |
${LIBEGL_C_FILES} |
libEGL_la_LIBADD = $(EGL_LIB_DEPS) $(am__append_2) $(am__append_4) \ |
$(am__append_6) $(am__append_9) |
libEGL_la_LDFLAGS = \ |
-no-undefined \ |
-version-number 1:0 \ |
$(BSYMBOLIC) \ |
$(GC_SECTIONS) \ |
$(LD_NO_UNDEFINED) |
pkgconfigdir = $(libdir)/pkgconfig |
pkgconfig_DATA = egl.pc |
khrdir = $(includedir)/KHR |
khr_HEADERS = $(top_srcdir)/include/KHR/khrplatform.h |
egldir = $(includedir)/EGL |
egl_HEADERS = \ |
$(top_srcdir)/include/EGL/eglext.h \ |
$(top_srcdir)/include/EGL/egl.h \ |
$(top_srcdir)/include/EGL/eglextchromium.h \ |
$(top_srcdir)/include/EGL/eglmesaext.h \ |
$(top_srcdir)/include/EGL/eglplatform.h |
EXTRA_DIST = \ |
egl.def \ |
README.txt \ |
SConscript |
all: all-am |
.SUFFIXES: |
.SUFFIXES: .c .lo .o .obj |
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/Makefile.sources $(top_srcdir)/install-lib-links.mk $(am__configure_deps) |
@for dep in $?; do \ |
case '$(am__configure_deps)' in \ |
*$$dep*) \ |
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ |
&& { if test -f $@; then exit 0; else break; fi; }; \ |
exit 1;; \ |
esac; \ |
done; \ |
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/egl/main/Makefile'; \ |
$(am__cd) $(top_srcdir) && \ |
$(AUTOMAKE) --foreign src/egl/main/Makefile |
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
@case '$?' in \ |
*config.status*) \ |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ |
*) \ |
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ |
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ |
esac; |
$(srcdir)/Makefile.sources $(top_srcdir)/install-lib-links.mk $(am__empty): |
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
$(top_srcdir)/configure: $(am__configure_deps) |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
$(ACLOCAL_M4): $(am__aclocal_m4_deps) |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
$(am__aclocal_m4_deps): |
egl.pc: $(top_builddir)/config.status $(srcdir)/egl.pc.in |
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ |
install-libLTLIBRARIES: $(lib_LTLIBRARIES) |
@$(NORMAL_INSTALL) |
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ |
list2=; for p in $$list; do \ |
if test -f $$p; then \ |
list2="$$list2 $$p"; \ |
else :; fi; \ |
done; \ |
test -z "$$list2" || { \ |
echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ |
$(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ |
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ |
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ |
} |
uninstall-libLTLIBRARIES: |
@$(NORMAL_UNINSTALL) |
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ |
for p in $$list; do \ |
$(am__strip_dir) \ |
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ |
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ |
done |
clean-libLTLIBRARIES: |
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) |
@list='$(lib_LTLIBRARIES)'; \ |
locs=`for p in $$list; do echo $$p; done | \ |
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ |
sort -u`; \ |
test -z "$$locs" || { \ |
echo rm -f $${locs}; \ |
rm -f $${locs}; \ |
} |
libEGL.la: $(libEGL_la_OBJECTS) $(libEGL_la_DEPENDENCIES) $(EXTRA_libEGL_la_DEPENDENCIES) |
$(AM_V_CCLD)$(libEGL_la_LINK) -rpath $(libdir) $(libEGL_la_OBJECTS) $(libEGL_la_LIBADD) $(LIBS) |
mostlyclean-compile: |
-rm -f *.$(OBJEXT) |
distclean-compile: |
-rm -f *.tab.c |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eglapi.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eglarray.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eglconfig.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eglcontext.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eglcurrent.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/egldisplay.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/egldriver.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eglfallbacks.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eglglobals.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eglimage.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/egllog.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eglstring.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eglsurface.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eglsync.Plo@am__quote@ |
.c.o: |
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< |
.c.obj: |
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` |
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` |
.c.lo: |
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< |
mostlyclean-libtool: |
-rm -f *.lo |
clean-libtool: |
-rm -rf .libs _libs |
install-pkgconfigDATA: $(pkgconfig_DATA) |
@$(NORMAL_INSTALL) |
@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ |
if test -n "$$list"; then \ |
echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ |
$(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ |
fi; \ |
for p in $$list; do \ |
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ |
echo "$$d$$p"; \ |
done | $(am__base_list) | \ |
while read files; do \ |
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ |
$(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ |
done |
uninstall-pkgconfigDATA: |
@$(NORMAL_UNINSTALL) |
@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ |
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ |
dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) |
install-eglHEADERS: $(egl_HEADERS) |
@$(NORMAL_INSTALL) |
@list='$(egl_HEADERS)'; test -n "$(egldir)" || list=; \ |
if test -n "$$list"; then \ |
echo " $(MKDIR_P) '$(DESTDIR)$(egldir)'"; \ |
$(MKDIR_P) "$(DESTDIR)$(egldir)" || exit 1; \ |
fi; \ |
for p in $$list; do \ |
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ |
echo "$$d$$p"; \ |
done | $(am__base_list) | \ |
while read files; do \ |
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(egldir)'"; \ |
$(INSTALL_HEADER) $$files "$(DESTDIR)$(egldir)" || exit $$?; \ |
done |
uninstall-eglHEADERS: |
@$(NORMAL_UNINSTALL) |
@list='$(egl_HEADERS)'; test -n "$(egldir)" || list=; \ |
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ |
dir='$(DESTDIR)$(egldir)'; $(am__uninstall_files_from_dir) |
install-khrHEADERS: $(khr_HEADERS) |
@$(NORMAL_INSTALL) |
@list='$(khr_HEADERS)'; test -n "$(khrdir)" || list=; \ |
if test -n "$$list"; then \ |
echo " $(MKDIR_P) '$(DESTDIR)$(khrdir)'"; \ |
$(MKDIR_P) "$(DESTDIR)$(khrdir)" || exit 1; \ |
fi; \ |
for p in $$list; do \ |
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ |
echo "$$d$$p"; \ |
done | $(am__base_list) | \ |
while read files; do \ |
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(khrdir)'"; \ |
$(INSTALL_HEADER) $$files "$(DESTDIR)$(khrdir)" || exit $$?; \ |
done |
uninstall-khrHEADERS: |
@$(NORMAL_UNINSTALL) |
@list='$(khr_HEADERS)'; test -n "$(khrdir)" || list=; \ |
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ |
dir='$(DESTDIR)$(khrdir)'; $(am__uninstall_files_from_dir) |
ID: $(am__tagged_files) |
$(am__define_uniq_tagged_files); mkid -fID $$unique |
tags: tags-am |
TAGS: tags |
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) |
set x; \ |
here=`pwd`; \ |
$(am__define_uniq_tagged_files); \ |
shift; \ |
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ |
test -n "$$unique" || unique=$$empty_fix; \ |
if test $$# -gt 0; then \ |
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ |
"$$@" $$unique; \ |
else \ |
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ |
$$unique; \ |
fi; \ |
fi |
ctags: ctags-am |
CTAGS: ctags |
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) |
$(am__define_uniq_tagged_files); \ |
test -z "$(CTAGS_ARGS)$$unique" \ |
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ |
$$unique |
GTAGS: |
here=`$(am__cd) $(top_builddir) && pwd` \ |
&& $(am__cd) $(top_srcdir) \ |
&& gtags -i $(GTAGS_ARGS) "$$here" |
cscopelist: cscopelist-am |
cscopelist-am: $(am__tagged_files) |
list='$(am__tagged_files)'; \ |
case "$(srcdir)" in \ |
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ |
*) sdir=$(subdir)/$(srcdir) ;; \ |
esac; \ |
for i in $$list; do \ |
if test -f "$$i"; then \ |
echo "$(subdir)/$$i"; \ |
else \ |
echo "$$sdir/$$i"; \ |
fi; \ |
done >> $(top_builddir)/cscope.files |
distclean-tags: |
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags |
distdir: $(DISTFILES) |
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ |
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ |
list='$(DISTFILES)'; \ |
dist_files=`for file in $$list; do echo $$file; done | \ |
sed -e "s|^$$srcdirstrip/||;t" \ |
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ |
case $$dist_files in \ |
*/*) $(MKDIR_P) `echo "$$dist_files" | \ |
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ |
sort -u` ;; \ |
esac; \ |
for file in $$dist_files; do \ |
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ |
if test -d $$d/$$file; then \ |
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ |
if test -d "$(distdir)/$$file"; then \ |
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ |
fi; \ |
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ |
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ |
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ |
fi; \ |
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ |
else \ |
test -f "$(distdir)/$$file" \ |
|| cp -p $$d/$$file "$(distdir)/$$file" \ |
|| exit 1; \ |
fi; \ |
done |
check-am: all-am |
check: check-am |
@BUILD_SHARED_FALSE@all-local: |
@HAVE_COMPAT_SYMLINKS_FALSE@all-local: |
all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) all-local |
installdirs: |
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(egldir)" "$(DESTDIR)$(khrdir)"; do \ |
test -z "$$dir" || $(MKDIR_P) "$$dir"; \ |
done |
install: install-am |
install-exec: install-exec-am |
install-data: install-data-am |
uninstall: uninstall-am |
install-am: all-am |
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am |
installcheck: installcheck-am |
install-strip: |
if test -z '$(STRIP)'; then \ |
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ |
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ |
install; \ |
else \ |
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ |
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ |
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ |
fi |
mostlyclean-generic: |
clean-generic: |
distclean-generic: |
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) |
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) |
maintainer-clean-generic: |
@echo "This command is intended for maintainers to use" |
@echo "it deletes files that may require special tools to rebuild." |
@BUILD_SHARED_FALSE@clean-local: |
@HAVE_COMPAT_SYMLINKS_FALSE@clean-local: |
clean: clean-am |
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool clean-local \ |
mostlyclean-am |
distclean: distclean-am |
-rm -rf ./$(DEPDIR) |
-rm -f Makefile |
distclean-am: clean-am distclean-compile distclean-generic \ |
distclean-tags |
dvi: dvi-am |
dvi-am: |
html: html-am |
html-am: |
info: info-am |
info-am: |
install-data-am: install-eglHEADERS install-khrHEADERS \ |
install-pkgconfigDATA |
install-dvi: install-dvi-am |
install-dvi-am: |
install-exec-am: install-libLTLIBRARIES |
install-html: install-html-am |
install-html-am: |
install-info: install-info-am |
install-info-am: |
install-man: |
install-pdf: install-pdf-am |
install-pdf-am: |
install-ps: install-ps-am |
install-ps-am: |
installcheck-am: |
maintainer-clean: maintainer-clean-am |
-rm -rf ./$(DEPDIR) |
-rm -f Makefile |
maintainer-clean-am: distclean-am maintainer-clean-generic |
mostlyclean: mostlyclean-am |
mostlyclean-am: mostlyclean-compile mostlyclean-generic \ |
mostlyclean-libtool |
pdf: pdf-am |
pdf-am: |
ps: ps-am |
ps-am: |
uninstall-am: uninstall-eglHEADERS uninstall-khrHEADERS \ |
uninstall-libLTLIBRARIES uninstall-pkgconfigDATA |
.MAKE: install-am install-strip |
.PHONY: CTAGS GTAGS TAGS all all-am all-local check check-am clean \ |
clean-generic clean-libLTLIBRARIES clean-libtool clean-local \ |
cscopelist-am ctags ctags-am distclean distclean-compile \ |
distclean-generic distclean-libtool distclean-tags distdir dvi \ |
dvi-am html html-am info info-am install install-am \ |
install-data install-data-am install-dvi install-dvi-am \ |
install-eglHEADERS install-exec install-exec-am install-html \ |
install-html-am install-info install-info-am \ |
install-khrHEADERS install-libLTLIBRARIES install-man \ |
install-pdf install-pdf-am install-pkgconfigDATA install-ps \ |
install-ps-am install-strip installcheck installcheck-am \ |
installdirs maintainer-clean maintainer-clean-generic \ |
mostlyclean mostlyclean-compile mostlyclean-generic \ |
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ |
uninstall-am uninstall-eglHEADERS uninstall-khrHEADERS \ |
uninstall-libLTLIBRARIES uninstall-pkgconfigDATA |
.PRECIOUS: Makefile |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@all-local : .install-mesa-links |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@.install-mesa-links : $(lib_LTLIBRARIES) |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ $(AM_V_GEN)$(MKDIR_P) $(top_builddir)/$(LIB_DIR); \ |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ for f in $(join $(addsuffix .libs/,$(dir $(lib_LTLIBRARIES))),$(notdir $(lib_LTLIBRARIES:%.la=%.$(LIB_EXT)*))); do \ |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ if test -h .libs/$$f; then \ |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ cp -d $$f $(top_builddir)/$(LIB_DIR); \ |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ else \ |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ ln -f $$f $(top_builddir)/$(LIB_DIR); \ |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ fi; \ |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ done && touch $@ |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@clean-local: |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ for f in $(notdir $(lib_LTLIBRARIES:%.la=.libs/%.$(LIB_EXT)*)); do \ |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ $(RM) $(top_builddir)/$(LIB_DIR)/$$f; \ |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ done; |
@BUILD_SHARED_TRUE@@HAVE_COMPAT_SYMLINKS_TRUE@ $(RM) .install-mesa-links |
# Tell versions [3.59,3.63) of GNU make to not export all variables. |
# Otherwise a system limit (for SysV at least) may be exceeded. |
.NOEXPORT: |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/Makefile.sources |
---|
0,0 → 1,31 |
LIBEGL_C_FILES := \ |
eglapi.c \ |
eglapi.h \ |
eglarray.c \ |
eglarray.h \ |
eglcompiler.h \ |
eglconfig.c \ |
eglconfig.h \ |
eglcontext.c \ |
eglcontext.h \ |
eglcurrent.c \ |
eglcurrent.h \ |
egldefines.h \ |
egldisplay.c \ |
egldisplay.h \ |
egldriver.c \ |
egldriver.h \ |
eglfallbacks.c \ |
eglglobals.c \ |
eglglobals.h \ |
eglimage.c \ |
eglimage.h \ |
egllog.c \ |
egllog.h \ |
eglstring.c \ |
eglstring.h \ |
eglsurface.c \ |
eglsurface.h \ |
eglsync.c \ |
eglsync.h \ |
egltypedefs.h |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/README.txt |
---|
0,0 → 1,70 |
Notes about the EGL library: |
The EGL code here basically consists of two things: |
1. An EGL API dispatcher. This directly routes all the eglFooBar() API |
calls into driver-specific functions. |
2. Fallbacks for EGL API functions. A driver _could_ implement all the |
EGL API calls from scratch. But in many cases, the fallbacks provided |
in libEGL (such as eglChooseConfig()) will do the job. |
Bootstrapping: |
When the apps calls eglInitialize() a device driver is selected and loaded |
(look for _eglAddDrivers() and _eglLoadModule() in egldriver.c). |
The built-in driver's entry point function is then called. This driver function |
allocates, initializes and returns a new _EGLDriver object (usually a |
subclass of that type). |
As part of initialization, the dispatch table in _EGLDriver->API must be |
populated with all the EGL entrypoints. Typically, _eglInitDriverFallbacks() |
can be used to plug in default/fallback functions. Some functions like |
driver->API.Initialize and driver->API.Terminate _must_ be implemented |
with driver-specific code (no default/fallback function is possible). |
Shortly after, the driver->API.Initialize() function is executed. Any additional |
driver initialization that wasn't done in the driver entry point should be |
done at this point. Typically, this will involve setting up visual configs, etc. |
Special Functions: |
Certain EGL functions _must_ be implemented by the driver. This includes: |
eglCreateContext |
eglCreateWindowSurface |
eglCreatePixmapSurface |
eglCreatePBufferSurface |
eglMakeCurrent |
eglSwapBuffers |
Most of the EGLConfig-related functions can be implemented with the |
defaults/fallbacks. Same thing for the eglGet/Query functions. |
Teardown: |
When eglTerminate() is called, the driver->API.Terminate() function is |
called. The driver should clean up after itself. eglTerminate() will |
then close/unload the driver (shared library). |
Subclassing: |
The internal libEGL data structures such as _EGLDisplay, _EGLContext, |
_EGLSurface, etc should be considered base classes from which drivers |
will derive subclasses. |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/SConscript |
---|
0,0 → 1,52 |
####################################################################### |
# SConscript for EGL |
Import('*') |
env = env.Clone() |
env.Append(CPPDEFINES = [ |
'_EGL_DRIVER_SEARCH_DIR=\\"\\"', |
]) |
if env['platform'] == 'haiku': |
env.Append(CPPDEFINES = [ |
'_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_HAIKU', |
'_EGL_OS_UNIX', |
'_EGL_BUILT_IN_DRIVER_HAIKU', |
]) |
env.Prepend(LIBS = [ |
egl_haiku, |
libloader, |
]) |
else: |
env.Append(CPPDEFINES = [ |
'_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_X11', |
'_EGL_OS_UNIX', |
]) |
if env['dri']: |
env.Prepend(LIBS = [ |
egl_dri2, |
libloader, |
]) |
# Disallow undefined symbols |
if env['platform'] != 'darwin': |
env.Append(SHLINKFLAGS = ['-Wl,-z,defs']) |
env.Append(CPPPATH = [ |
'#/include', |
]) |
# parse Makefile.sources |
egl_sources = env.ParseSourceList('Makefile.sources', 'LIBEGL_C_FILES') |
egl = env.SharedLibrary( |
target = 'EGL', |
source = egl_sources, |
) |
egl = env.InstallSharedLibrary(egl, version=(1, 0, 0)) |
env.Alias('egl', egl) |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/egl.def |
---|
0,0 → 1,35 |
EXPORTS |
eglBindAPI |
eglBindTexImage |
eglChooseConfig |
eglCopyBuffers |
eglCreateContext |
eglCreatePbufferFromClientBuffer |
eglCreatePbufferSurface |
eglCreatePixmapSurface |
eglCreateWindowSurface |
eglDestroyContext |
eglDestroySurface |
eglGetConfigAttrib |
eglGetConfigs |
eglGetCurrentContext |
eglGetCurrentDisplay |
eglGetCurrentSurface |
eglGetDisplay |
eglGetError |
eglGetProcAddress |
eglInitialize |
eglMakeCurrent |
eglQueryAPI |
eglQueryContext |
eglQueryString |
eglQuerySurface |
eglReleaseTexImage |
eglReleaseThread |
eglSurfaceAttrib |
eglSwapBuffers |
eglSwapInterval |
eglTerminate |
eglWaitClient |
eglWaitGL |
eglWaitNative |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/egl.pc.in |
---|
0,0 → 1,12 |
prefix=@prefix@ |
exec_prefix=${prefix} |
libdir=@libdir@ |
includedir=@includedir@ |
Name: egl |
Description: Mesa EGL library |
Requires.private: @GL_PC_REQ_PRIV@ |
Version: @PACKAGE_VERSION@ |
Libs: -L${libdir} -lEGL |
Libs.private: @GL_PC_LIB_PRIV@ |
Cflags: -I${includedir} @GL_PC_CFLAGS@ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglapi.c |
---|
0,0 → 1,1774 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
/** |
* Public EGL API entrypoints |
* |
* Generally, we use the EGLDisplay parameter as a key to lookup the |
* appropriate device driver handle, then jump though the driver's |
* dispatch table to handle the function. |
* |
* That allows us the option of supporting multiple, simultaneous, |
* heterogeneous hardware devices in the future. |
* |
* The EGLDisplay, EGLConfig, EGLContext and EGLSurface types are |
* opaque handles. Internal objects are linked to a display to |
* create the handles. |
* |
* For each public API entry point, the opaque handles are looked up |
* before being dispatched to the drivers. When it fails to look up |
* a handle, one of |
* |
* EGL_BAD_DISPLAY |
* EGL_BAD_CONFIG |
* EGL_BAD_CONTEXT |
* EGL_BAD_SURFACE |
* EGL_BAD_SCREEN_MESA |
* EGL_BAD_MODE_MESA |
* |
* is generated and the driver function is not called. An |
* uninitialized EGLDisplay has no driver associated with it. When |
* such display is detected, |
* |
* EGL_NOT_INITIALIZED |
* |
* is generated. |
* |
* Some of the entry points use current display, context, or surface |
* implicitly. For such entry points, the implicit objects are also |
* checked before calling the driver function. Other than the |
* errors listed above, |
* |
* EGL_BAD_CURRENT_SURFACE |
* |
* may also be generated. |
* |
* Notes on naming conventions: |
* |
* eglFooBar - public EGL function |
* EGL_FOO_BAR - public EGL token |
* EGLDatatype - public EGL datatype |
* |
* _eglFooBar - private EGL function |
* _EGLDatatype - private EGL datatype, typedef'd struct |
* _egl_struct - private EGL struct, non-typedef'd |
* |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
#include "c99_compat.h" |
#include "c11/threads.h" |
#include "eglcompiler.h" |
#include "eglglobals.h" |
#include "eglcontext.h" |
#include "egldisplay.h" |
#include "egltypedefs.h" |
#include "eglcurrent.h" |
#include "egldriver.h" |
#include "eglsurface.h" |
#include "eglconfig.h" |
#include "eglimage.h" |
#include "eglsync.h" |
#include "eglstring.h" |
/** |
* Macros to help return an API entrypoint. |
* |
* These macros will unlock the display and record the error code. |
*/ |
#define RETURN_EGL_ERROR(disp, err, ret) \ |
do { \ |
if (disp) \ |
_eglUnlockDisplay(disp); \ |
/* EGL error codes are non-zero */ \ |
if (err) \ |
_eglError(err, __func__); \ |
return ret; \ |
} while (0) |
#define RETURN_EGL_SUCCESS(disp, ret) \ |
RETURN_EGL_ERROR(disp, EGL_SUCCESS, ret) |
/* record EGL_SUCCESS only when ret evaluates to true */ |
#define RETURN_EGL_EVAL(disp, ret) \ |
RETURN_EGL_ERROR(disp, (ret) ? EGL_SUCCESS : 0, ret) |
/* |
* A bunch of macros and checks to simplify error checking. |
*/ |
#define _EGL_CHECK_DISPLAY(disp, ret, drv) \ |
do { \ |
drv = _eglCheckDisplay(disp, __func__); \ |
if (!drv) \ |
RETURN_EGL_ERROR(disp, 0, ret); \ |
} while (0) |
#define _EGL_CHECK_OBJECT(disp, type, obj, ret, drv) \ |
do { \ |
drv = _eglCheck ## type(disp, obj, __func__); \ |
if (!drv) \ |
RETURN_EGL_ERROR(disp, 0, ret); \ |
} while (0) |
#define _EGL_CHECK_SURFACE(disp, surf, ret, drv) \ |
_EGL_CHECK_OBJECT(disp, Surface, surf, ret, drv) |
#define _EGL_CHECK_CONTEXT(disp, context, ret, drv) \ |
_EGL_CHECK_OBJECT(disp, Context, context, ret, drv) |
#define _EGL_CHECK_CONFIG(disp, conf, ret, drv) \ |
_EGL_CHECK_OBJECT(disp, Config, conf, ret, drv) |
#define _EGL_CHECK_SYNC(disp, s, ret, drv) \ |
_EGL_CHECK_OBJECT(disp, Sync, s, ret, drv) |
static inline _EGLDriver * |
_eglCheckDisplay(_EGLDisplay *disp, const char *msg) |
{ |
if (!disp) { |
_eglError(EGL_BAD_DISPLAY, msg); |
return NULL; |
} |
if (!disp->Initialized) { |
_eglError(EGL_NOT_INITIALIZED, msg); |
return NULL; |
} |
return disp->Driver; |
} |
static inline _EGLDriver * |
_eglCheckSurface(_EGLDisplay *disp, _EGLSurface *surf, const char *msg) |
{ |
_EGLDriver *drv = _eglCheckDisplay(disp, msg); |
if (!drv) |
return NULL; |
if (!surf) { |
_eglError(EGL_BAD_SURFACE, msg); |
return NULL; |
} |
return drv; |
} |
static inline _EGLDriver * |
_eglCheckContext(_EGLDisplay *disp, _EGLContext *context, const char *msg) |
{ |
_EGLDriver *drv = _eglCheckDisplay(disp, msg); |
if (!drv) |
return NULL; |
if (!context) { |
_eglError(EGL_BAD_CONTEXT, msg); |
return NULL; |
} |
return drv; |
} |
static inline _EGLDriver * |
_eglCheckConfig(_EGLDisplay *disp, _EGLConfig *conf, const char *msg) |
{ |
_EGLDriver *drv = _eglCheckDisplay(disp, msg); |
if (!drv) |
return NULL; |
if (!conf) { |
_eglError(EGL_BAD_CONFIG, msg); |
return NULL; |
} |
return drv; |
} |
static inline _EGLDriver * |
_eglCheckSync(_EGLDisplay *disp, _EGLSync *s, const char *msg) |
{ |
_EGLDriver *drv = _eglCheckDisplay(disp, msg); |
if (!drv) |
return NULL; |
if (!s) { |
_eglError(EGL_BAD_PARAMETER, msg); |
return NULL; |
} |
return drv; |
} |
/** |
* Lookup and lock a display. |
*/ |
static inline _EGLDisplay * |
_eglLockDisplay(EGLDisplay display) |
{ |
_EGLDisplay *dpy = _eglLookupDisplay(display); |
if (dpy) |
mtx_lock(&dpy->Mutex); |
return dpy; |
} |
/** |
* Unlock a display. |
*/ |
static inline void |
_eglUnlockDisplay(_EGLDisplay *dpy) |
{ |
mtx_unlock(&dpy->Mutex); |
} |
/** |
* This is typically the first EGL function that an application calls. |
* It associates a private _EGLDisplay object to the native display. |
*/ |
EGLDisplay EGLAPIENTRY |
eglGetDisplay(EGLNativeDisplayType nativeDisplay) |
{ |
_EGLPlatformType plat; |
_EGLDisplay *dpy; |
void *native_display_ptr; |
STATIC_ASSERT(sizeof(void*) == sizeof(nativeDisplay)); |
native_display_ptr = (void*) nativeDisplay; |
plat = _eglGetNativePlatform(native_display_ptr); |
dpy = _eglFindDisplay(plat, native_display_ptr); |
return _eglGetDisplayHandle(dpy); |
} |
static EGLDisplay EGLAPIENTRY |
eglGetPlatformDisplayEXT(EGLenum platform, void *native_display, |
const EGLint *attrib_list) |
{ |
_EGLDisplay *dpy; |
switch (platform) { |
#ifdef HAVE_X11_PLATFORM |
case EGL_PLATFORM_X11_EXT: |
dpy = _eglGetX11Display((Display*) native_display, attrib_list); |
break; |
#endif |
#ifdef HAVE_DRM_PLATFORM |
case EGL_PLATFORM_GBM_MESA: |
dpy = _eglGetGbmDisplay((struct gbm_device*) native_display, |
attrib_list); |
break; |
#endif |
#ifdef HAVE_WAYLAND_PLATFORM |
case EGL_PLATFORM_WAYLAND_EXT: |
dpy = _eglGetWaylandDisplay((struct wl_display*) native_display, |
attrib_list); |
break; |
#endif |
default: |
RETURN_EGL_ERROR(NULL, EGL_BAD_PARAMETER, NULL); |
} |
return _eglGetDisplayHandle(dpy); |
} |
/** |
* Copy the extension into the string and update the string pointer. |
*/ |
static EGLint |
_eglAppendExtension(char **str, const char *ext) |
{ |
char *s = *str; |
size_t len = strlen(ext); |
if (s) { |
memcpy(s, ext, len); |
s[len++] = ' '; |
s[len] = '\0'; |
*str += len; |
} |
else { |
len++; |
} |
return (EGLint) len; |
} |
/** |
* Examine the individual extension enable/disable flags and recompute |
* the driver's Extensions string. |
*/ |
static void |
_eglCreateExtensionsString(_EGLDisplay *dpy) |
{ |
#define _EGL_CHECK_EXTENSION(ext) \ |
do { \ |
if (dpy->Extensions.ext) { \ |
_eglAppendExtension(&exts, "EGL_" #ext); \ |
assert(exts <= dpy->ExtensionsString + _EGL_MAX_EXTENSIONS_LEN); \ |
} \ |
} while (0) |
char *exts = dpy->ExtensionsString; |
_EGL_CHECK_EXTENSION(MESA_drm_display); |
_EGL_CHECK_EXTENSION(MESA_drm_image); |
_EGL_CHECK_EXTENSION(MESA_configless_context); |
_EGL_CHECK_EXTENSION(WL_bind_wayland_display); |
_EGL_CHECK_EXTENSION(WL_create_wayland_buffer_from_image); |
_EGL_CHECK_EXTENSION(KHR_image_base); |
_EGL_CHECK_EXTENSION(KHR_image_pixmap); |
if (dpy->Extensions.KHR_image_base && dpy->Extensions.KHR_image_pixmap) |
_eglAppendExtension(&exts, "EGL_KHR_image"); |
_EGL_CHECK_EXTENSION(KHR_vg_parent_image); |
_EGL_CHECK_EXTENSION(KHR_get_all_proc_addresses); |
_EGL_CHECK_EXTENSION(KHR_gl_texture_2D_image); |
_EGL_CHECK_EXTENSION(KHR_gl_texture_cubemap_image); |
_EGL_CHECK_EXTENSION(KHR_gl_texture_3D_image); |
_EGL_CHECK_EXTENSION(KHR_gl_renderbuffer_image); |
_EGL_CHECK_EXTENSION(KHR_reusable_sync); |
_EGL_CHECK_EXTENSION(KHR_fence_sync); |
_EGL_CHECK_EXTENSION(KHR_wait_sync); |
_EGL_CHECK_EXTENSION(KHR_cl_event2); |
_EGL_CHECK_EXTENSION(KHR_surfaceless_context); |
_EGL_CHECK_EXTENSION(KHR_create_context); |
_EGL_CHECK_EXTENSION(NOK_swap_region); |
_EGL_CHECK_EXTENSION(NOK_texture_from_pixmap); |
_EGL_CHECK_EXTENSION(ANDROID_image_native_buffer); |
_EGL_CHECK_EXTENSION(CHROMIUM_sync_control); |
_EGL_CHECK_EXTENSION(EXT_create_context_robustness); |
_EGL_CHECK_EXTENSION(EXT_buffer_age); |
_EGL_CHECK_EXTENSION(EXT_swap_buffers_with_damage); |
_EGL_CHECK_EXTENSION(EXT_image_dma_buf_import); |
_EGL_CHECK_EXTENSION(NV_post_sub_buffer); |
_EGL_CHECK_EXTENSION(MESA_image_dma_buf_export); |
#undef _EGL_CHECK_EXTENSION |
} |
static void |
_eglCreateAPIsString(_EGLDisplay *dpy) |
{ |
if (dpy->ClientAPIs & EGL_OPENGL_BIT) |
strcat(dpy->ClientAPIsString, "OpenGL "); |
if (dpy->ClientAPIs & EGL_OPENGL_ES_BIT) |
strcat(dpy->ClientAPIsString, "OpenGL_ES "); |
if (dpy->ClientAPIs & EGL_OPENGL_ES2_BIT) |
strcat(dpy->ClientAPIsString, "OpenGL_ES2 "); |
if (dpy->ClientAPIs & EGL_OPENGL_ES3_BIT_KHR) |
strcat(dpy->ClientAPIsString, "OpenGL_ES3 "); |
if (dpy->ClientAPIs & EGL_OPENVG_BIT) |
strcat(dpy->ClientAPIsString, "OpenVG "); |
assert(strlen(dpy->ClientAPIsString) < sizeof(dpy->ClientAPIsString)); |
} |
/** |
* This is typically the second EGL function that an application calls. |
* Here we load/initialize the actual hardware driver. |
*/ |
EGLBoolean EGLAPIENTRY |
eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
if (!disp) |
RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE); |
if (!disp->Initialized) { |
if (!_eglMatchDriver(disp, EGL_FALSE)) |
RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE); |
/* limit to APIs supported by core */ |
disp->ClientAPIs &= _EGL_API_ALL_BITS; |
/* EGL_KHR_get_all_proc_addresses is a corner-case extension. The spec |
* classifies it as an EGL display extension, though conceptually it's an |
* EGL client extension. |
* |
* From the EGL_KHR_get_all_proc_addresses spec: |
* |
* The EGL implementation must expose the name |
* EGL_KHR_client_get_all_proc_addresses if and only if it exposes |
* EGL_KHR_get_all_proc_addresses and supports |
* EGL_EXT_client_extensions. |
* |
* Mesa unconditionally exposes both client extensions mentioned above, |
* so the spec requires that each EGLDisplay unconditionally expose |
* EGL_KHR_get_all_proc_addresses also. |
*/ |
disp->Extensions.KHR_get_all_proc_addresses = EGL_TRUE; |
_eglCreateExtensionsString(disp); |
_eglCreateAPIsString(disp); |
_eglsnprintf(disp->VersionString, sizeof(disp->VersionString), |
"%d.%d (%s)", disp->VersionMajor, disp->VersionMinor, |
disp->Driver->Name); |
} |
/* Update applications version of major and minor if not NULL */ |
if ((major != NULL) && (minor != NULL)) { |
*major = disp->VersionMajor; |
*minor = disp->VersionMinor; |
} |
RETURN_EGL_SUCCESS(disp, EGL_TRUE); |
} |
EGLBoolean EGLAPIENTRY |
eglTerminate(EGLDisplay dpy) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
if (!disp) |
RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE); |
if (disp->Initialized) { |
_EGLDriver *drv = disp->Driver; |
drv->API.Terminate(drv, disp); |
/* do not reset disp->Driver */ |
disp->ClientAPIsString[0] = 0; |
disp->Initialized = EGL_FALSE; |
} |
RETURN_EGL_SUCCESS(disp, EGL_TRUE); |
} |
const char * EGLAPIENTRY |
eglQueryString(EGLDisplay dpy, EGLint name) |
{ |
_EGLDisplay *disp; |
_EGLDriver *drv; |
if (dpy == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) { |
RETURN_EGL_SUCCESS(NULL, _eglGlobal.ClientExtensionString); |
} |
disp = _eglLockDisplay(dpy); |
_EGL_CHECK_DISPLAY(disp, NULL, drv); |
switch (name) { |
case EGL_VENDOR: |
RETURN_EGL_SUCCESS(disp, _EGL_VENDOR_STRING); |
case EGL_VERSION: |
RETURN_EGL_SUCCESS(disp, disp->VersionString); |
case EGL_EXTENSIONS: |
RETURN_EGL_SUCCESS(disp, disp->ExtensionsString); |
case EGL_CLIENT_APIS: |
RETURN_EGL_SUCCESS(disp, disp->ClientAPIsString); |
default: |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, NULL); |
} |
} |
EGLBoolean EGLAPIENTRY |
eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, |
EGLint config_size, EGLint *num_config) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
ret = drv->API.GetConfigs(drv, disp, configs, config_size, num_config); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, |
EGLint config_size, EGLint *num_config) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
ret = drv->API.ChooseConfig(drv, disp, attrib_list, configs, |
config_size, num_config); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, |
EGLint attribute, EGLint *value) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLConfig *conf = _eglLookupConfig(config, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_CONFIG(disp, conf, EGL_FALSE, drv); |
ret = drv->API.GetConfigAttrib(drv, disp, conf, attribute, value); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLContext EGLAPIENTRY |
eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list, |
const EGLint *attrib_list) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLConfig *conf = _eglLookupConfig(config, disp); |
_EGLContext *share = _eglLookupContext(share_list, disp); |
_EGLDriver *drv; |
_EGLContext *context; |
EGLContext ret; |
_EGL_CHECK_DISPLAY(disp, EGL_NO_CONTEXT, drv); |
if (!config && !disp->Extensions.MESA_configless_context) |
RETURN_EGL_ERROR(disp, EGL_BAD_CONFIG, EGL_NO_CONTEXT); |
if (!share && share_list != EGL_NO_CONTEXT) |
RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_CONTEXT); |
context = drv->API.CreateContext(drv, disp, conf, share, attrib_list); |
ret = (context) ? _eglLinkContext(context) : EGL_NO_CONTEXT; |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglDestroyContext(EGLDisplay dpy, EGLContext ctx) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLContext *context = _eglLookupContext(ctx, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_CONTEXT(disp, context, EGL_FALSE, drv); |
_eglUnlinkContext(context); |
ret = drv->API.DestroyContext(drv, disp, context); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, |
EGLContext ctx) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLContext *context = _eglLookupContext(ctx, disp); |
_EGLSurface *draw_surf = _eglLookupSurface(draw, disp); |
_EGLSurface *read_surf = _eglLookupSurface(read, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
if (!disp) |
RETURN_EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE); |
drv = disp->Driver; |
/* display is allowed to be uninitialized under certain condition */ |
if (!disp->Initialized) { |
if (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE || |
ctx != EGL_NO_CONTEXT) |
RETURN_EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE); |
} |
if (!drv) |
RETURN_EGL_SUCCESS(disp, EGL_TRUE); |
if (!context && ctx != EGL_NO_CONTEXT) |
RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE); |
if (!draw_surf || !read_surf) { |
/* From the EGL 1.4 (20130211) spec: |
* |
* To release the current context without assigning a new one, set ctx |
* to EGL_NO_CONTEXT and set draw and read to EGL_NO_SURFACE. |
*/ |
if (!disp->Extensions.KHR_surfaceless_context && ctx != EGL_NO_CONTEXT) |
RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
if ((!draw_surf && draw != EGL_NO_SURFACE) || |
(!read_surf && read != EGL_NO_SURFACE)) |
RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
if (draw_surf || read_surf) |
RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_FALSE); |
} |
ret = drv->API.MakeCurrent(drv, disp, draw_surf, read_surf, context); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglQueryContext(EGLDisplay dpy, EGLContext ctx, |
EGLint attribute, EGLint *value) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLContext *context = _eglLookupContext(ctx, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_CONTEXT(disp, context, EGL_FALSE, drv); |
ret = drv->API.QueryContext(drv, disp, context, attribute, value); |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLSurface |
_eglCreateWindowSurfaceCommon(_EGLDisplay *disp, EGLConfig config, |
void *native_window, const EGLint *attrib_list) |
{ |
_EGLConfig *conf = _eglLookupConfig(config, disp); |
_EGLDriver *drv; |
_EGLSurface *surf; |
EGLSurface ret; |
_EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); |
if (native_window == NULL) |
RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); |
surf = drv->API.CreateWindowSurface(drv, disp, conf, native_window, |
attrib_list); |
ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLSurface EGLAPIENTRY |
eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, |
EGLNativeWindowType window, const EGLint *attrib_list) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
STATIC_ASSERT(sizeof(void*) == sizeof(window)); |
return _eglCreateWindowSurfaceCommon(disp, config, (void*) window, |
attrib_list); |
} |
static EGLSurface EGLAPIENTRY |
eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config, |
void *native_window, |
const EGLint *attrib_list) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
#ifdef HAVE_X11_PLATFORM |
if (disp->Platform == _EGL_PLATFORM_X11 && native_window != NULL) { |
/* The `native_window` parameter for the X11 platform differs between |
* eglCreateWindowSurface() and eglCreatePlatformPixmapSurfaceEXT(). In |
* eglCreateWindowSurface(), the type of `native_window` is an Xlib |
* `Window`. In eglCreatePlatformWindowSurfaceEXT(), the type is |
* `Window*`. Convert `Window*` to `Window` because that's what |
* dri2_x11_create_window_surface() expects. |
*/ |
native_window = (void*) (* (Window*) native_window); |
} |
#endif |
return _eglCreateWindowSurfaceCommon(disp, config, native_window, |
attrib_list); |
} |
static EGLSurface |
_eglCreatePixmapSurfaceCommon(_EGLDisplay *disp, EGLConfig config, |
void *native_pixmap, const EGLint *attrib_list) |
{ |
_EGLConfig *conf = _eglLookupConfig(config, disp); |
_EGLDriver *drv; |
_EGLSurface *surf; |
EGLSurface ret; |
_EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); |
surf = drv->API.CreatePixmapSurface(drv, disp, conf, native_pixmap, |
attrib_list); |
ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLSurface EGLAPIENTRY |
eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, |
EGLNativePixmapType pixmap, const EGLint *attrib_list) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
STATIC_ASSERT(sizeof(void*) == sizeof(pixmap)); |
return _eglCreatePixmapSurfaceCommon(disp, config, (void*) pixmap, |
attrib_list); |
} |
static EGLSurface EGLAPIENTRY |
eglCreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, EGLConfig config, |
void *native_pixmap, |
const EGLint *attrib_list) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
#ifdef HAVE_X11_PLATFORM |
/* The `native_pixmap` parameter for the X11 platform differs between |
* eglCreatePixmapSurface() and eglCreatePlatformPixmapSurfaceEXT(). In |
* eglCreatePixmapSurface(), the type of `native_pixmap` is an Xlib |
* `Pixmap`. In eglCreatePlatformPixmapSurfaceEXT(), the type is |
* `Pixmap*`. Convert `Pixmap*` to `Pixmap` because that's what |
* dri2_x11_create_pixmap_surface() expects. |
*/ |
if (disp->Platform == _EGL_PLATFORM_X11 && native_pixmap != NULL) { |
native_pixmap = (void*) (* (Pixmap*) native_pixmap); |
} |
#endif |
return _eglCreatePixmapSurfaceCommon(disp, config, native_pixmap, |
attrib_list); |
} |
EGLSurface EGLAPIENTRY |
eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, |
const EGLint *attrib_list) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLConfig *conf = _eglLookupConfig(config, disp); |
_EGLDriver *drv; |
_EGLSurface *surf; |
EGLSurface ret; |
_EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); |
surf = drv->API.CreatePbufferSurface(drv, disp, conf, attrib_list); |
ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglDestroySurface(EGLDisplay dpy, EGLSurface surface) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSurface *surf = _eglLookupSurface(surface, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
_eglUnlinkSurface(surf); |
ret = drv->API.DestroySurface(drv, disp, surf); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglQuerySurface(EGLDisplay dpy, EGLSurface surface, |
EGLint attribute, EGLint *value) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSurface *surf = _eglLookupSurface(surface, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
ret = drv->API.QuerySurface(drv, disp, surf, attribute, value); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, |
EGLint attribute, EGLint value) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSurface *surf = _eglLookupSurface(surface, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
ret = drv->API.SurfaceAttrib(drv, disp, surf, attribute, value); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSurface *surf = _eglLookupSurface(surface, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
ret = drv->API.BindTexImage(drv, disp, surf, buffer); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSurface *surf = _eglLookupSurface(surface, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
ret = drv->API.ReleaseTexImage(drv, disp, surf, buffer); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglSwapInterval(EGLDisplay dpy, EGLint interval) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLContext *ctx = _eglGetCurrentContext(); |
_EGLSurface *surf; |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
ctx->Resource.Display != disp) |
RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE); |
surf = ctx->DrawSurface; |
if (_eglGetSurfaceHandle(surf) == EGL_NO_SURFACE) |
RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
ret = drv->API.SwapInterval(drv, disp, surf, interval); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) |
{ |
_EGLContext *ctx = _eglGetCurrentContext(); |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSurface *surf = _eglLookupSurface(surface, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
/* surface must be bound to current context in EGL 1.4 */ |
#ifndef _EGL_BUILT_IN_DRIVER_HAIKU |
if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
surf != ctx->DrawSurface) |
RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
#endif |
ret = drv->API.SwapBuffers(drv, disp, surf); |
RETURN_EGL_EVAL(disp, ret); |
} |
#ifdef EGL_EXT_swap_buffers_with_damage |
static EGLBoolean EGLAPIENTRY |
eglSwapBuffersWithDamageEXT(EGLDisplay dpy, EGLSurface surface, |
EGLint *rects, EGLint n_rects) |
{ |
_EGLContext *ctx = _eglGetCurrentContext(); |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSurface *surf = _eglLookupSurface(surface, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
/* surface must be bound to current context in EGL 1.4 */ |
if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
surf != ctx->DrawSurface) |
RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
if ((n_rects > 0 && rects == NULL) || n_rects < 0) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
ret = drv->API.SwapBuffersWithDamageEXT(drv, disp, surf, rects, n_rects); |
RETURN_EGL_EVAL(disp, ret); |
} |
#endif /* EGL_EXT_swap_buffers_with_damage */ |
EGLBoolean EGLAPIENTRY |
eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSurface *surf = _eglLookupSurface(surface, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
void *native_pixmap_ptr; |
STATIC_ASSERT(sizeof(void*) == sizeof(target)); |
native_pixmap_ptr = (void*) target; |
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay)) |
RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_FALSE); |
ret = drv->API.CopyBuffers(drv, disp, surf, native_pixmap_ptr); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglWaitClient(void) |
{ |
_EGLContext *ctx = _eglGetCurrentContext(); |
_EGLDisplay *disp; |
_EGLDriver *drv; |
EGLBoolean ret; |
if (!ctx) |
RETURN_EGL_SUCCESS(NULL, EGL_TRUE); |
disp = ctx->Resource.Display; |
mtx_lock(&disp->Mutex); |
/* let bad current context imply bad current surface */ |
if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
_eglGetSurfaceHandle(ctx->DrawSurface) == EGL_NO_SURFACE) |
RETURN_EGL_ERROR(disp, EGL_BAD_CURRENT_SURFACE, EGL_FALSE); |
/* a valid current context implies an initialized current display */ |
assert(disp->Initialized); |
drv = disp->Driver; |
ret = drv->API.WaitClient(drv, disp, ctx); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglWaitGL(void) |
{ |
_EGLThreadInfo *t = _eglGetCurrentThread(); |
EGLint api_index = t->CurrentAPIIndex; |
EGLint es_index = _eglConvertApiToIndex(EGL_OPENGL_ES_API); |
EGLBoolean ret; |
if (api_index != es_index && _eglIsCurrentThreadDummy()) |
RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_FALSE); |
t->CurrentAPIIndex = es_index; |
ret = eglWaitClient(); |
t->CurrentAPIIndex = api_index; |
return ret; |
} |
EGLBoolean EGLAPIENTRY |
eglWaitNative(EGLint engine) |
{ |
_EGLContext *ctx = _eglGetCurrentContext(); |
_EGLDisplay *disp; |
_EGLDriver *drv; |
EGLBoolean ret; |
if (!ctx) |
RETURN_EGL_SUCCESS(NULL, EGL_TRUE); |
disp = ctx->Resource.Display; |
mtx_lock(&disp->Mutex); |
/* let bad current context imply bad current surface */ |
if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
_eglGetSurfaceHandle(ctx->DrawSurface) == EGL_NO_SURFACE) |
RETURN_EGL_ERROR(disp, EGL_BAD_CURRENT_SURFACE, EGL_FALSE); |
/* a valid current context implies an initialized current display */ |
assert(disp->Initialized); |
drv = disp->Driver; |
ret = drv->API.WaitNative(drv, disp, engine); |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLDisplay EGLAPIENTRY |
eglGetCurrentDisplay(void) |
{ |
_EGLContext *ctx = _eglGetCurrentContext(); |
EGLDisplay ret; |
ret = (ctx) ? _eglGetDisplayHandle(ctx->Resource.Display) : EGL_NO_DISPLAY; |
RETURN_EGL_SUCCESS(NULL, ret); |
} |
EGLContext EGLAPIENTRY |
eglGetCurrentContext(void) |
{ |
_EGLContext *ctx = _eglGetCurrentContext(); |
EGLContext ret; |
ret = _eglGetContextHandle(ctx); |
RETURN_EGL_SUCCESS(NULL, ret); |
} |
EGLSurface EGLAPIENTRY |
eglGetCurrentSurface(EGLint readdraw) |
{ |
_EGLContext *ctx = _eglGetCurrentContext(); |
EGLint err = EGL_SUCCESS; |
_EGLSurface *surf; |
EGLSurface ret; |
if (!ctx) |
RETURN_EGL_SUCCESS(NULL, EGL_NO_SURFACE); |
switch (readdraw) { |
case EGL_DRAW: |
surf = ctx->DrawSurface; |
break; |
case EGL_READ: |
surf = ctx->ReadSurface; |
break; |
default: |
surf = NULL; |
err = EGL_BAD_PARAMETER; |
break; |
} |
ret = _eglGetSurfaceHandle(surf); |
RETURN_EGL_ERROR(NULL, err, ret); |
} |
EGLint EGLAPIENTRY |
eglGetError(void) |
{ |
_EGLThreadInfo *t = _eglGetCurrentThread(); |
EGLint e = t->LastError; |
if (!_eglIsCurrentThreadDummy()) |
t->LastError = EGL_SUCCESS; |
return e; |
} |
#ifdef EGL_MESA_drm_display |
static EGLDisplay EGLAPIENTRY |
eglGetDRMDisplayMESA(int fd) |
{ |
_EGLDisplay *dpy = _eglFindDisplay(_EGL_PLATFORM_DRM, (void *) (intptr_t) fd); |
return _eglGetDisplayHandle(dpy); |
} |
#endif /* EGL_MESA_drm_display */ |
/** |
** EGL 1.2 |
**/ |
/** |
* Specify the client API to use for subsequent calls including: |
* eglCreateContext() |
* eglGetCurrentContext() |
* eglGetCurrentDisplay() |
* eglGetCurrentSurface() |
* eglMakeCurrent(when the ctx parameter is EGL NO CONTEXT) |
* eglWaitClient() |
* eglWaitNative() |
* See section 3.7 "Rendering Context" in the EGL specification for details. |
*/ |
EGLBoolean EGLAPIENTRY |
eglBindAPI(EGLenum api) |
{ |
_EGLThreadInfo *t = _eglGetCurrentThread(); |
if (_eglIsCurrentThreadDummy()) |
RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_FALSE); |
if (!_eglIsApiValid(api)) |
RETURN_EGL_ERROR(NULL, EGL_BAD_PARAMETER, EGL_FALSE); |
t->CurrentAPIIndex = _eglConvertApiToIndex(api); |
RETURN_EGL_SUCCESS(NULL, EGL_TRUE); |
} |
/** |
* Return the last value set with eglBindAPI(). |
*/ |
EGLenum EGLAPIENTRY |
eglQueryAPI(void) |
{ |
_EGLThreadInfo *t = _eglGetCurrentThread(); |
EGLenum ret; |
/* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */ |
ret = _eglConvertApiFromIndex(t->CurrentAPIIndex); |
RETURN_EGL_SUCCESS(NULL, ret); |
} |
EGLSurface EGLAPIENTRY |
eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, |
EGLClientBuffer buffer, EGLConfig config, |
const EGLint *attrib_list) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLConfig *conf = _eglLookupConfig(config, disp); |
_EGLDriver *drv; |
_EGLSurface *surf; |
EGLSurface ret; |
_EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); |
surf = drv->API.CreatePbufferFromClientBuffer(drv, disp, buftype, buffer, |
conf, attrib_list); |
ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; |
RETURN_EGL_EVAL(disp, ret); |
} |
EGLBoolean EGLAPIENTRY |
eglReleaseThread(void) |
{ |
/* unbind current contexts */ |
if (!_eglIsCurrentThreadDummy()) { |
_EGLThreadInfo *t = _eglGetCurrentThread(); |
EGLint api_index = t->CurrentAPIIndex; |
EGLint i; |
for (i = 0; i < _EGL_API_NUM_APIS; i++) { |
_EGLContext *ctx = t->CurrentContexts[i]; |
if (ctx) { |
_EGLDisplay *disp = ctx->Resource.Display; |
_EGLDriver *drv; |
t->CurrentAPIIndex = i; |
mtx_lock(&disp->Mutex); |
drv = disp->Driver; |
(void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); |
mtx_unlock(&disp->Mutex); |
} |
} |
t->CurrentAPIIndex = api_index; |
} |
_eglDestroyCurrentThread(); |
RETURN_EGL_SUCCESS(NULL, EGL_TRUE); |
} |
static EGLImageKHR EGLAPIENTRY |
eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, |
EGLClientBuffer buffer, const EGLint *attr_list) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLContext *context = _eglLookupContext(ctx, disp); |
_EGLDriver *drv; |
_EGLImage *img; |
EGLImageKHR ret; |
_EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv); |
if (!disp->Extensions.KHR_image_base) |
RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR); |
if (!context && ctx != EGL_NO_CONTEXT) |
RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR); |
/* "If <target> is EGL_LINUX_DMA_BUF_EXT, <dpy> must be a valid display, |
* <ctx> must be EGL_NO_CONTEXT..." |
*/ |
if (ctx != EGL_NO_CONTEXT && target == EGL_LINUX_DMA_BUF_EXT) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR); |
img = drv->API.CreateImageKHR(drv, |
disp, context, target, buffer, attr_list); |
ret = (img) ? _eglLinkImage(img) : EGL_NO_IMAGE_KHR; |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLBoolean EGLAPIENTRY |
eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLImage *img = _eglLookupImage(image, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
if (!disp->Extensions.KHR_image_base) |
RETURN_EGL_EVAL(disp, EGL_FALSE); |
if (!img) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
_eglUnlinkImage(img); |
ret = drv->API.DestroyImageKHR(drv, disp, img); |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLSyncKHR |
_eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list, |
const EGLAttribKHR *attrib_list64, EGLBoolean is64) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLContext *ctx = _eglGetCurrentContext(); |
_EGLDriver *drv; |
_EGLSync *sync; |
EGLSyncKHR ret; |
_EGL_CHECK_DISPLAY(disp, EGL_NO_SYNC_KHR, drv); |
if (!disp->Extensions.KHR_cl_event2 && is64) |
RETURN_EGL_EVAL(disp, EGL_NO_SYNC_KHR); |
/* return an error if the client API doesn't support GL_OES_EGL_sync */ |
if (!ctx || ctx->Resource.Display != dpy || |
ctx->ClientAPI != EGL_OPENGL_ES_API) |
RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_NO_SYNC_KHR); |
switch (type) { |
case EGL_SYNC_FENCE_KHR: |
if (!disp->Extensions.KHR_fence_sync) |
RETURN_EGL_ERROR(disp, EGL_BAD_ATTRIBUTE, EGL_NO_SYNC_KHR); |
break; |
case EGL_SYNC_REUSABLE_KHR: |
if (!disp->Extensions.KHR_reusable_sync) |
RETURN_EGL_ERROR(disp, EGL_BAD_ATTRIBUTE, EGL_NO_SYNC_KHR); |
break; |
case EGL_SYNC_CL_EVENT_KHR: |
if (!disp->Extensions.KHR_cl_event2) |
RETURN_EGL_ERROR(disp, EGL_BAD_ATTRIBUTE, EGL_NO_SYNC_KHR); |
break; |
default: |
RETURN_EGL_ERROR(disp, EGL_BAD_ATTRIBUTE, EGL_NO_SYNC_KHR); |
} |
sync = drv->API.CreateSyncKHR(drv, disp, type, attrib_list, attrib_list64); |
ret = (sync) ? _eglLinkSync(sync) : EGL_NO_SYNC_KHR; |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLSyncKHR EGLAPIENTRY |
eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) |
{ |
return _eglCreateSync(dpy, type, attrib_list, NULL, EGL_FALSE); |
} |
static EGLSyncKHR EGLAPIENTRY |
eglCreateSync64KHR(EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list) |
{ |
return _eglCreateSync(dpy, type, NULL, attrib_list, EGL_TRUE); |
} |
static EGLBoolean EGLAPIENTRY |
eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSync *s = _eglLookupSync(sync, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); |
assert(disp->Extensions.KHR_reusable_sync || |
disp->Extensions.KHR_fence_sync); |
_eglUnlinkSync(s); |
ret = drv->API.DestroySyncKHR(drv, disp, s); |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLint EGLAPIENTRY |
eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSync *s = _eglLookupSync(sync, disp); |
_EGLDriver *drv; |
EGLint ret; |
_EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); |
assert(disp->Extensions.KHR_reusable_sync || |
disp->Extensions.KHR_fence_sync); |
if (s->SyncStatus == EGL_SIGNALED_KHR) |
RETURN_EGL_EVAL(disp, EGL_CONDITION_SATISFIED_KHR); |
ret = drv->API.ClientWaitSyncKHR(drv, disp, s, flags, timeout); |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLint EGLAPIENTRY |
eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSync *s = _eglLookupSync(sync, disp); |
_EGLContext *ctx = _eglGetCurrentContext(); |
_EGLDriver *drv; |
EGLint ret; |
_EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); |
assert(disp->Extensions.KHR_wait_sync); |
/* return an error if the client API doesn't support GL_OES_EGL_sync */ |
if (ctx == EGL_NO_CONTEXT || ctx->ClientAPI != EGL_OPENGL_ES_API) |
RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_FALSE); |
/* the API doesn't allow any flags yet */ |
if (flags != 0) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
ret = drv->API.WaitSyncKHR(drv, disp, s); |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLBoolean EGLAPIENTRY |
eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSync *s = _eglLookupSync(sync, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); |
assert(disp->Extensions.KHR_reusable_sync); |
ret = drv->API.SignalSyncKHR(drv, disp, s, mode); |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLBoolean EGLAPIENTRY |
eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSync *s = _eglLookupSync(sync, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); |
assert(disp->Extensions.KHR_reusable_sync || |
disp->Extensions.KHR_fence_sync); |
ret = drv->API.GetSyncAttribKHR(drv, disp, s, attribute, value); |
RETURN_EGL_EVAL(disp, ret); |
} |
#ifdef EGL_NOK_swap_region |
static EGLBoolean EGLAPIENTRY |
eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface, |
EGLint numRects, const EGLint *rects) |
{ |
_EGLContext *ctx = _eglGetCurrentContext(); |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSurface *surf = _eglLookupSurface(surface, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
if (!disp->Extensions.NOK_swap_region) |
RETURN_EGL_EVAL(disp, EGL_FALSE); |
/* surface must be bound to current context in EGL 1.4 */ |
if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
surf != ctx->DrawSurface) |
RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
ret = drv->API.SwapBuffersRegionNOK(drv, disp, surf, numRects, rects); |
RETURN_EGL_EVAL(disp, ret); |
} |
#endif /* EGL_NOK_swap_region */ |
#ifdef EGL_MESA_drm_image |
static EGLImageKHR EGLAPIENTRY |
eglCreateDRMImageMESA(EGLDisplay dpy, const EGLint *attr_list) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLDriver *drv; |
_EGLImage *img; |
EGLImageKHR ret; |
_EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv); |
if (!disp->Extensions.MESA_drm_image) |
RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR); |
img = drv->API.CreateDRMImageMESA(drv, disp, attr_list); |
ret = (img) ? _eglLinkImage(img) : EGL_NO_IMAGE_KHR; |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLBoolean EGLAPIENTRY |
eglExportDRMImageMESA(EGLDisplay dpy, EGLImageKHR image, |
EGLint *name, EGLint *handle, EGLint *stride) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLImage *img = _eglLookupImage(image, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
assert(disp->Extensions.MESA_drm_image); |
if (!img) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
ret = drv->API.ExportDRMImageMESA(drv, disp, img, name, handle, stride); |
RETURN_EGL_EVAL(disp, ret); |
} |
#endif |
#ifdef EGL_WL_bind_wayland_display |
struct wl_display; |
static EGLBoolean EGLAPIENTRY |
eglBindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
assert(disp->Extensions.WL_bind_wayland_display); |
if (!display) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
ret = drv->API.BindWaylandDisplayWL(drv, disp, display); |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLBoolean EGLAPIENTRY |
eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
assert(disp->Extensions.WL_bind_wayland_display); |
if (!display) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
ret = drv->API.UnbindWaylandDisplayWL(drv, disp, display); |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLBoolean EGLAPIENTRY |
eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_resource *buffer, |
EGLint attribute, EGLint *value) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
assert(disp->Extensions.WL_bind_wayland_display); |
if (!buffer) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
ret = drv->API.QueryWaylandBufferWL(drv, disp, buffer, attribute, value); |
RETURN_EGL_EVAL(disp, ret); |
} |
#endif |
#ifdef EGL_WL_create_wayland_buffer_from_image |
static struct wl_buffer * EGLAPIENTRY |
eglCreateWaylandBufferFromImageWL(EGLDisplay dpy, EGLImageKHR image) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLImage *img; |
_EGLDriver *drv; |
struct wl_buffer *ret; |
_EGL_CHECK_DISPLAY(disp, NULL, drv); |
assert(disp->Extensions.WL_create_wayland_buffer_from_image); |
img = _eglLookupImage(image, disp); |
if (!img) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, NULL); |
ret = drv->API.CreateWaylandBufferFromImageWL(drv, disp, img); |
RETURN_EGL_EVAL(disp, ret); |
} |
#endif |
static EGLBoolean EGLAPIENTRY |
eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, |
EGLint x, EGLint y, EGLint width, EGLint height) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLSurface *surf = _eglLookupSurface(surface, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
if (!disp->Extensions.NV_post_sub_buffer) |
RETURN_EGL_EVAL(disp, EGL_FALSE); |
ret = drv->API.PostSubBufferNV(drv, disp, surf, x, y, width, height); |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLBoolean EGLAPIENTRY |
eglGetSyncValuesCHROMIUM(EGLDisplay display, EGLSurface surface, |
EGLuint64KHR *ust, EGLuint64KHR *msc, |
EGLuint64KHR *sbc) |
{ |
_EGLDisplay *disp = _eglLockDisplay(display); |
_EGLSurface *surf = _eglLookupSurface(surface, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
if (!disp->Extensions.CHROMIUM_sync_control) |
RETURN_EGL_EVAL(disp, EGL_FALSE); |
if (!ust || !msc || !sbc) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
ret = drv->API.GetSyncValuesCHROMIUM(disp, surf, ust, msc, sbc); |
RETURN_EGL_EVAL(disp, ret); |
} |
#ifdef EGL_MESA_image_dma_buf_export |
static EGLBoolean EGLAPIENTRY |
eglExportDMABUFImageQueryMESA(EGLDisplay dpy, EGLImageKHR image, |
EGLint *fourcc, EGLint *nplanes, |
EGLuint64KHR *modifiers) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLImage *img = _eglLookupImage(image, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
assert(disp->Extensions.MESA_image_dma_buf_export); |
if (!img) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
ret = drv->API.ExportDMABUFImageQueryMESA(drv, disp, img, fourcc, nplanes, |
modifiers); |
RETURN_EGL_EVAL(disp, ret); |
} |
static EGLBoolean EGLAPIENTRY |
eglExportDMABUFImageMESA(EGLDisplay dpy, EGLImageKHR image, |
int *fds, EGLint *strides, EGLint *offsets) |
{ |
_EGLDisplay *disp = _eglLockDisplay(dpy); |
_EGLImage *img = _eglLookupImage(image, disp); |
_EGLDriver *drv; |
EGLBoolean ret; |
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
assert(disp->Extensions.MESA_image_dma_buf_export); |
if (!img) |
RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
ret = drv->API.ExportDMABUFImageMESA(drv, disp, img, fds, strides, offsets); |
RETURN_EGL_EVAL(disp, ret); |
} |
#endif |
__eglMustCastToProperFunctionPointerType EGLAPIENTRY |
eglGetProcAddress(const char *procname) |
{ |
static const struct { |
const char *name; |
_EGLProc function; |
} egl_functions[] = { |
/* core functions queryable in the presence of |
* EGL_KHR_get_all_proc_addresses or EGL 1.5 |
*/ |
/* alphabetical order */ |
{ "eglBindAPI", (_EGLProc) eglBindAPI }, |
{ "eglBindTexImage", (_EGLProc) eglBindTexImage }, |
{ "eglChooseConfig", (_EGLProc) eglChooseConfig }, |
{ "eglCopyBuffers", (_EGLProc) eglCopyBuffers }, |
{ "eglCreateContext", (_EGLProc) eglCreateContext }, |
{ "eglCreatePbufferFromClientBuffer", (_EGLProc) eglCreatePbufferFromClientBuffer }, |
{ "eglCreatePbufferSurface", (_EGLProc) eglCreatePbufferSurface }, |
{ "eglCreatePixmapSurface", (_EGLProc) eglCreatePixmapSurface }, |
{ "eglCreateWindowSurface", (_EGLProc) eglCreateWindowSurface }, |
{ "eglDestroyContext", (_EGLProc) eglDestroyContext }, |
{ "eglDestroySurface", (_EGLProc) eglDestroySurface }, |
{ "eglGetConfigAttrib", (_EGLProc) eglGetConfigAttrib }, |
{ "eglGetConfigs", (_EGLProc) eglGetConfigs }, |
{ "eglGetCurrentContext", (_EGLProc) eglGetCurrentContext }, |
{ "eglGetCurrentDisplay", (_EGLProc) eglGetCurrentDisplay }, |
{ "eglGetCurrentSurface", (_EGLProc) eglGetCurrentSurface }, |
{ "eglGetDisplay", (_EGLProc) eglGetDisplay }, |
{ "eglGetError", (_EGLProc) eglGetError }, |
{ "eglGetProcAddress", (_EGLProc) eglGetProcAddress }, |
{ "eglInitialize", (_EGLProc) eglInitialize }, |
{ "eglMakeCurrent", (_EGLProc) eglMakeCurrent }, |
{ "eglQueryAPI", (_EGLProc) eglQueryAPI }, |
{ "eglQueryContext", (_EGLProc) eglQueryContext }, |
{ "eglQueryString", (_EGLProc) eglQueryString }, |
{ "eglQuerySurface", (_EGLProc) eglQuerySurface }, |
{ "eglReleaseTexImage", (_EGLProc) eglReleaseTexImage }, |
{ "eglReleaseThread", (_EGLProc) eglReleaseThread }, |
{ "eglSurfaceAttrib", (_EGLProc) eglSurfaceAttrib }, |
{ "eglSwapBuffers", (_EGLProc) eglSwapBuffers }, |
{ "eglSwapInterval", (_EGLProc) eglSwapInterval }, |
{ "eglTerminate", (_EGLProc) eglTerminate }, |
{ "eglWaitClient", (_EGLProc) eglWaitClient }, |
{ "eglWaitGL", (_EGLProc) eglWaitGL }, |
{ "eglWaitNative", (_EGLProc) eglWaitNative }, |
#ifdef EGL_MESA_drm_display |
{ "eglGetDRMDisplayMESA", (_EGLProc) eglGetDRMDisplayMESA }, |
#endif |
{ "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR }, |
{ "eglDestroyImageKHR", (_EGLProc) eglDestroyImageKHR }, |
{ "eglCreateSyncKHR", (_EGLProc) eglCreateSyncKHR }, |
{ "eglCreateSync64KHR", (_EGLProc) eglCreateSync64KHR }, |
{ "eglDestroySyncKHR", (_EGLProc) eglDestroySyncKHR }, |
{ "eglClientWaitSyncKHR", (_EGLProc) eglClientWaitSyncKHR }, |
{ "eglWaitSyncKHR", (_EGLProc) eglWaitSyncKHR }, |
{ "eglSignalSyncKHR", (_EGLProc) eglSignalSyncKHR }, |
{ "eglGetSyncAttribKHR", (_EGLProc) eglGetSyncAttribKHR }, |
#ifdef EGL_NOK_swap_region |
{ "eglSwapBuffersRegionNOK", (_EGLProc) eglSwapBuffersRegionNOK }, |
#endif |
#ifdef EGL_MESA_drm_image |
{ "eglCreateDRMImageMESA", (_EGLProc) eglCreateDRMImageMESA }, |
{ "eglExportDRMImageMESA", (_EGLProc) eglExportDRMImageMESA }, |
#endif |
#ifdef EGL_WL_bind_wayland_display |
{ "eglBindWaylandDisplayWL", (_EGLProc) eglBindWaylandDisplayWL }, |
{ "eglUnbindWaylandDisplayWL", (_EGLProc) eglUnbindWaylandDisplayWL }, |
{ "eglQueryWaylandBufferWL", (_EGLProc) eglQueryWaylandBufferWL }, |
#endif |
#ifdef EGL_WL_create_wayland_buffer_from_image |
{ "eglCreateWaylandBufferFromImageWL", (_EGLProc) eglCreateWaylandBufferFromImageWL }, |
#endif |
{ "eglPostSubBufferNV", (_EGLProc) eglPostSubBufferNV }, |
#ifdef EGL_EXT_swap_buffers_with_damage |
{ "eglSwapBuffersWithDamageEXT", (_EGLProc) eglSwapBuffersWithDamageEXT }, |
#endif |
{ "eglGetPlatformDisplayEXT", (_EGLProc) eglGetPlatformDisplayEXT }, |
{ "eglCreatePlatformWindowSurfaceEXT", (_EGLProc) eglCreatePlatformWindowSurfaceEXT }, |
{ "eglCreatePlatformPixmapSurfaceEXT", (_EGLProc) eglCreatePlatformPixmapSurfaceEXT }, |
{ "eglGetSyncValuesCHROMIUM", (_EGLProc) eglGetSyncValuesCHROMIUM }, |
#ifdef EGL_MESA_image_dma_buf_export |
{ "eglExportDMABUFImageQueryMESA", (_EGLProc) eglExportDMABUFImageQueryMESA }, |
{ "eglExportDMABUFImageMESA", (_EGLProc) eglExportDMABUFImageMESA }, |
#endif |
{ NULL, NULL } |
}; |
EGLint i; |
_EGLProc ret; |
if (!procname) |
RETURN_EGL_SUCCESS(NULL, NULL); |
ret = NULL; |
if (strncmp(procname, "egl", 3) == 0) { |
for (i = 0; egl_functions[i].name; i++) { |
if (strcmp(egl_functions[i].name, procname) == 0) { |
ret = egl_functions[i].function; |
break; |
} |
} |
} |
if (!ret) |
ret = _eglGetDriverProc(procname); |
RETURN_EGL_SUCCESS(NULL, ret); |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglapi.h |
---|
0,0 → 1,222 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLAPI_INCLUDED |
#define EGLAPI_INCLUDED |
#ifdef __cplusplus |
extern "C" { |
#endif |
/** |
* A generic function ptr type |
*/ |
typedef void (*_EGLProc)(void); |
/** |
* Typedefs for all EGL API entrypoint functions. |
*/ |
/* driver funcs */ |
typedef EGLBoolean (*Initialize_t)(_EGLDriver *, _EGLDisplay *dpy); |
typedef EGLBoolean (*Terminate_t)(_EGLDriver *, _EGLDisplay *dpy); |
/* config funcs */ |
typedef EGLBoolean (*GetConfigs_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); |
typedef EGLBoolean (*ChooseConfig_t)(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); |
typedef EGLBoolean (*GetConfigAttrib_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, EGLint attribute, EGLint *value); |
/* context funcs */ |
typedef _EGLContext *(*CreateContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, _EGLContext *share_list, const EGLint *attrib_list); |
typedef EGLBoolean (*DestroyContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx); |
/* this is the only function (other than Initialize) that may be called with an uninitialized display */ |
typedef EGLBoolean (*MakeCurrent_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx); |
typedef EGLBoolean (*QueryContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value); |
/* surface funcs */ |
typedef _EGLSurface *(*CreateWindowSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, void *native_window, const EGLint *attrib_list); |
typedef _EGLSurface *(*CreatePixmapSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, void *native_pixmap, const EGLint *attrib_list); |
typedef _EGLSurface *(*CreatePbufferSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, const EGLint *attrib_list); |
typedef EGLBoolean (*DestroySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface); |
typedef EGLBoolean (*QuerySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint *value); |
typedef EGLBoolean (*SurfaceAttrib_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint value); |
typedef EGLBoolean (*BindTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer); |
typedef EGLBoolean (*ReleaseTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer); |
typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval); |
typedef EGLBoolean (*SwapBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw); |
typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, void *native_pixmap_target); |
/* misc funcs */ |
typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx); |
typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine); |
/* this function may be called from multiple threads at the same time */ |
typedef _EGLProc (*GetProcAddress_t)(_EGLDriver *drv, const char *procname); |
typedef _EGLSurface *(*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum buftype, EGLClientBuffer buffer, _EGLConfig *config, const EGLint *attrib_list); |
typedef _EGLImage *(*CreateImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list); |
typedef EGLBoolean (*DestroyImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image); |
typedef _EGLSync *(*CreateSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum type, const EGLint *attrib_list, const EGLAttribKHR *attrib_list64); |
typedef EGLBoolean (*DestroySyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync); |
typedef EGLint (*ClientWaitSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, EGLint flags, EGLTimeKHR timeout); |
typedef EGLint (*WaitSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync); |
typedef EGLBoolean (*SignalSyncKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, EGLenum mode); |
typedef EGLBoolean (*GetSyncAttribKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, EGLint attribute, EGLint *value); |
#ifdef EGL_NOK_swap_region |
typedef EGLBoolean (*SwapBuffersRegionNOK_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint numRects, const EGLint *rects); |
#endif |
#ifdef EGL_MESA_drm_image |
typedef _EGLImage *(*CreateDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attr_list); |
typedef EGLBoolean (*ExportDRMImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *name, EGLint *handle, EGLint *stride); |
#endif |
#ifdef EGL_WL_bind_wayland_display |
struct wl_display; |
typedef EGLBoolean (*BindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *display); |
typedef EGLBoolean (*UnbindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *display); |
typedef EGLBoolean (*QueryWaylandBufferWL_t)(_EGLDriver *drv, _EGLDisplay *displ, struct wl_resource *buffer, EGLint attribute, EGLint *value); |
#endif |
#ifdef EGL_WL_create_wayland_buffer_from_image |
typedef struct wl_buffer * (*CreateWaylandBufferFromImageWL_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img); |
#endif |
typedef EGLBoolean (*PostSubBufferNV_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surface, EGLint x, EGLint y, EGLint width, EGLint height); |
typedef EGLint (*QueryBufferAge_t)(_EGLDriver *drv, |
_EGLDisplay *dpy, _EGLSurface *surface); |
#ifdef EGL_EXT_swap_buffers_with_damage |
typedef EGLBoolean (*SwapBuffersWithDamageEXT_t) (_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, const EGLint *rects, EGLint n_rects); |
#endif |
typedef EGLBoolean (*GetSyncValuesCHROMIUM_t) (_EGLDisplay *dpy, _EGLSurface *surface, EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc); |
#ifdef EGL_MESA_image_dma_buf_export |
typedef EGLBoolean (*ExportDMABUFImageQueryMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *fourcc, EGLint *nplanes, EGLuint64KHR *modifiers); |
typedef EGLBoolean (*ExportDMABUFImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *fds, EGLint *strides, EGLint *offsets); |
#endif |
/** |
* The API dispatcher jumps through these functions |
*/ |
struct _egl_api |
{ |
Initialize_t Initialize; |
Terminate_t Terminate; |
GetConfigs_t GetConfigs; |
ChooseConfig_t ChooseConfig; |
GetConfigAttrib_t GetConfigAttrib; |
CreateContext_t CreateContext; |
DestroyContext_t DestroyContext; |
MakeCurrent_t MakeCurrent; |
QueryContext_t QueryContext; |
CreateWindowSurface_t CreateWindowSurface; |
CreatePixmapSurface_t CreatePixmapSurface; |
CreatePbufferSurface_t CreatePbufferSurface; |
DestroySurface_t DestroySurface; |
QuerySurface_t QuerySurface; |
SurfaceAttrib_t SurfaceAttrib; |
BindTexImage_t BindTexImage; |
ReleaseTexImage_t ReleaseTexImage; |
SwapInterval_t SwapInterval; |
SwapBuffers_t SwapBuffers; |
CopyBuffers_t CopyBuffers; |
WaitClient_t WaitClient; |
WaitNative_t WaitNative; |
GetProcAddress_t GetProcAddress; |
CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer; |
CreateImageKHR_t CreateImageKHR; |
DestroyImageKHR_t DestroyImageKHR; |
CreateSyncKHR_t CreateSyncKHR; |
DestroySyncKHR_t DestroySyncKHR; |
ClientWaitSyncKHR_t ClientWaitSyncKHR; |
WaitSyncKHR_t WaitSyncKHR; |
SignalSyncKHR_t SignalSyncKHR; |
GetSyncAttribKHR_t GetSyncAttribKHR; |
#ifdef EGL_NOK_swap_region |
SwapBuffersRegionNOK_t SwapBuffersRegionNOK; |
#endif |
#ifdef EGL_MESA_drm_image |
CreateDRMImageMESA_t CreateDRMImageMESA; |
ExportDRMImageMESA_t ExportDRMImageMESA; |
#endif |
#ifdef EGL_WL_bind_wayland_display |
BindWaylandDisplayWL_t BindWaylandDisplayWL; |
UnbindWaylandDisplayWL_t UnbindWaylandDisplayWL; |
QueryWaylandBufferWL_t QueryWaylandBufferWL; |
#endif |
#ifdef EGL_WL_create_wayland_buffer_from_image |
CreateWaylandBufferFromImageWL_t CreateWaylandBufferFromImageWL; |
#endif |
#ifdef EGL_EXT_swap_buffers_with_damage |
SwapBuffersWithDamageEXT_t SwapBuffersWithDamageEXT; |
#endif /* EGL_EXT_swap_buffers_with_damage */ |
PostSubBufferNV_t PostSubBufferNV; |
QueryBufferAge_t QueryBufferAge; |
GetSyncValuesCHROMIUM_t GetSyncValuesCHROMIUM; |
#ifdef EGL_MESA_image_dma_buf_export |
ExportDMABUFImageQueryMESA_t ExportDMABUFImageQueryMESA; |
ExportDMABUFImageMESA_t ExportDMABUFImageMESA; |
#endif |
}; |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLAPI_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglarray.c |
---|
0,0 → 1,209 |
/************************************************************************** |
* |
* Copyright 2010 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#include <stdlib.h> |
#include <string.h> |
#include "egllog.h" |
#include "eglarray.h" |
/** |
* Grow the size of the array. |
*/ |
static EGLBoolean |
_eglGrowArray(_EGLArray *array) |
{ |
EGLint new_size; |
void **elems; |
new_size = array->MaxSize; |
while (new_size <= array->Size) |
new_size *= 2; |
elems = realloc(array->Elements, new_size * sizeof(array->Elements[0])); |
if (!elems) { |
_eglLog(_EGL_DEBUG, "failed to grow %s array to %d", |
array->Name, new_size); |
return EGL_FALSE; |
} |
array->Elements = elems; |
array->MaxSize = new_size; |
return EGL_TRUE; |
} |
/** |
* Create an array. |
*/ |
_EGLArray * |
_eglCreateArray(const char *name, EGLint init_size) |
{ |
_EGLArray *array; |
array = calloc(1, sizeof(*array)); |
if (array) { |
array->Name = name; |
array->MaxSize = (init_size > 0) ? init_size : 1; |
if (!_eglGrowArray(array)) { |
free(array); |
array = NULL; |
} |
} |
return array; |
} |
/** |
* Destroy an array, optionally free the data. |
*/ |
void |
_eglDestroyArray(_EGLArray *array, void (*free_cb)(void *)) |
{ |
if (free_cb) { |
EGLint i; |
for (i = 0; i < array->Size; i++) |
free_cb(array->Elements[i]); |
} |
free(array->Elements); |
free(array); |
} |
/** |
* Append a element to an array. |
*/ |
void |
_eglAppendArray(_EGLArray *array, void *elem) |
{ |
if (array->Size >= array->MaxSize && !_eglGrowArray(array)) |
return; |
array->Elements[array->Size++] = elem; |
} |
/** |
* Erase an element from an array. |
*/ |
void |
_eglEraseArray(_EGLArray *array, EGLint i, void (*free_cb)(void *)) |
{ |
if (free_cb) |
free_cb(array->Elements[i]); |
if (i < array->Size - 1) { |
memmove(&array->Elements[i], &array->Elements[i + 1], |
(array->Size - i - 1) * sizeof(array->Elements[0])); |
} |
array->Size--; |
} |
/** |
* Find in an array for the given element. |
*/ |
void * |
_eglFindArray(_EGLArray *array, void *elem) |
{ |
EGLint i; |
if (!array) |
return NULL; |
for (i = 0; i < array->Size; i++) |
if (array->Elements[i] == elem) |
return elem; |
return NULL; |
} |
/** |
* Filter an array and return the number of filtered elements. |
*/ |
EGLint |
_eglFilterArray(_EGLArray *array, void **data, EGLint size, |
_EGLArrayForEach filter, void *filter_data) |
{ |
EGLint count = 0, i; |
if (!array) |
return 0; |
if (filter) { |
for (i = 0; i < array->Size; i++) { |
if (filter(array->Elements[i], filter_data)) { |
if (data && count < size) |
data[count] = array->Elements[i]; |
count++; |
} |
if (data && count >= size) |
break; |
} |
} |
else { |
if (data) { |
count = (size < array->Size) ? size : array->Size; |
memcpy(data, array->Elements, count * sizeof(array->Elements[0])); |
} |
else { |
count = array->Size; |
} |
} |
return count; |
} |
/** |
* Flatten an array by converting array elements into another form and store |
* them in a buffer. |
*/ |
EGLint |
_eglFlattenArray(_EGLArray *array, void *buffer, EGLint elem_size, EGLint size, |
_EGLArrayForEach flatten) |
{ |
EGLint i, count; |
if (!array) |
return 0; |
count = array->Size; |
if (buffer) { |
/* do not exceed buffer size */ |
if (count > size) |
count = size; |
for (i = 0; i < count; i++) |
flatten(array->Elements[i], |
(void *) ((char *) buffer + elem_size * i)); |
} |
return count; |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglarray.h |
---|
0,0 → 1,94 |
/************************************************************************** |
* |
* Copyright 2010 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLARRAY_INCLUDED |
#define EGLARRAY_INCLUDED |
#include "c99_compat.h" |
#include "egltypedefs.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
typedef EGLBoolean (*_EGLArrayForEach)(void *elem, void *foreach_data); |
struct _egl_array { |
const char *Name; |
EGLint MaxSize; |
void **Elements; |
EGLint Size; |
}; |
extern _EGLArray * |
_eglCreateArray(const char *name, EGLint init_size); |
extern void |
_eglDestroyArray(_EGLArray *array, void (*free_cb)(void *)); |
extern void |
_eglAppendArray(_EGLArray *array, void *elem); |
extern void |
_eglEraseArray(_EGLArray *array, EGLint i, void (*free_cb)(void *)); |
void * |
_eglFindArray(_EGLArray *array, void *elem); |
extern EGLint |
_eglFilterArray(_EGLArray *array, void **data, EGLint size, |
_EGLArrayForEach filter, void *filter_data); |
EGLint |
_eglFlattenArray(_EGLArray *array, void *buffer, EGLint elem_size, EGLint size, |
_EGLArrayForEach flatten); |
static inline EGLint |
_eglGetArraySize(_EGLArray *array) |
{ |
return (array) ? array->Size : 0; |
} |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLARRAY_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglcompiler.h |
---|
0,0 → 1,46 |
/************************************************************************** |
* |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLCOMPILER_INCLUDED |
#define EGLCOMPILER_INCLUDED |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define STATIC_ASSERT(COND) \ |
do { \ |
(void) sizeof(char [1 - 2*!(COND)]); \ |
} while (0) |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLCOMPILER_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglconfig.c |
---|
0,0 → 1,840 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
/** |
* EGL Configuration (pixel format) functions. |
*/ |
#include <stdlib.h> |
#include <string.h> |
#include <assert.h> |
#include "c99_compat.h" |
#include "eglconfig.h" |
#include "egldisplay.h" |
#include "eglcurrent.h" |
#include "egllog.h" |
#define MIN2(A, B) (((A) < (B)) ? (A) : (B)) |
/** |
* Init the given _EGLconfig to default values. |
* \param id the configuration's ID. |
* |
* Note that id must be positive for the config to be valid. |
* It is also recommended that when there are N configs, their |
* IDs are from 1 to N respectively. |
*/ |
void |
_eglInitConfig(_EGLConfig *conf, _EGLDisplay *dpy, EGLint id) |
{ |
memset(conf, 0, sizeof(*conf)); |
conf->Display = dpy; |
/* some attributes take non-zero default values */ |
conf->ConfigID = id; |
conf->ConfigCaveat = EGL_NONE; |
conf->TransparentType = EGL_NONE; |
conf->NativeVisualType = EGL_NONE; |
conf->ColorBufferType = EGL_RGB_BUFFER; |
} |
/** |
* Link a config to its display and return the handle of the link. |
* The handle can be passed to client directly. |
* |
* Note that we just save the ptr to the config (we don't copy the config). |
*/ |
EGLConfig |
_eglLinkConfig(_EGLConfig *conf) |
{ |
_EGLDisplay *dpy = conf->Display; |
/* sanity check */ |
assert(dpy && conf->ConfigID > 0); |
if (!dpy->Configs) { |
dpy->Configs = _eglCreateArray("Config", 16); |
if (!dpy->Configs) |
return (EGLConfig) NULL; |
} |
_eglAppendArray(dpy->Configs, (void *) conf); |
return (EGLConfig) conf; |
} |
/** |
* Lookup a handle to find the linked config. |
* Return NULL if the handle has no corresponding linked config. |
*/ |
_EGLConfig * |
_eglLookupConfig(EGLConfig config, _EGLDisplay *dpy) |
{ |
_EGLConfig *conf; |
if (!dpy) |
return NULL; |
conf = (_EGLConfig *) _eglFindArray(dpy->Configs, (void *) config); |
if (conf) |
assert(conf->Display == dpy); |
return conf; |
} |
enum { |
/* types */ |
ATTRIB_TYPE_INTEGER, |
ATTRIB_TYPE_BOOLEAN, |
ATTRIB_TYPE_BITMASK, |
ATTRIB_TYPE_ENUM, |
ATTRIB_TYPE_PSEUDO, /* non-queryable */ |
ATTRIB_TYPE_PLATFORM, /* platform-dependent */ |
/* criteria */ |
ATTRIB_CRITERION_EXACT, |
ATTRIB_CRITERION_ATLEAST, |
ATTRIB_CRITERION_MASK, |
ATTRIB_CRITERION_SPECIAL, |
ATTRIB_CRITERION_IGNORE |
}; |
/* EGL spec Table 3.1 and 3.4 */ |
static const struct { |
EGLint attr; |
EGLint type; |
EGLint criterion; |
EGLint default_value; |
} _eglValidationTable[] = |
{ |
/* core */ |
{ EGL_BUFFER_SIZE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_ATLEAST, |
0 }, |
{ EGL_RED_SIZE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_ATLEAST, |
0 }, |
{ EGL_GREEN_SIZE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_ATLEAST, |
0 }, |
{ EGL_BLUE_SIZE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_ATLEAST, |
0 }, |
{ EGL_LUMINANCE_SIZE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_ATLEAST, |
0 }, |
{ EGL_ALPHA_SIZE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_ATLEAST, |
0 }, |
{ EGL_ALPHA_MASK_SIZE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_ATLEAST, |
0 }, |
{ EGL_BIND_TO_TEXTURE_RGB, ATTRIB_TYPE_BOOLEAN, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE }, |
{ EGL_BIND_TO_TEXTURE_RGBA, ATTRIB_TYPE_BOOLEAN, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE }, |
{ EGL_COLOR_BUFFER_TYPE, ATTRIB_TYPE_ENUM, |
ATTRIB_CRITERION_EXACT, |
EGL_RGB_BUFFER }, |
{ EGL_CONFIG_CAVEAT, ATTRIB_TYPE_ENUM, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE }, |
{ EGL_CONFIG_ID, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE }, |
{ EGL_CONFORMANT, ATTRIB_TYPE_BITMASK, |
ATTRIB_CRITERION_MASK, |
0 }, |
{ EGL_DEPTH_SIZE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_ATLEAST, |
0 }, |
{ EGL_LEVEL, ATTRIB_TYPE_PLATFORM, |
ATTRIB_CRITERION_EXACT, |
0 }, |
{ EGL_MAX_PBUFFER_WIDTH, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_IGNORE, |
0 }, |
{ EGL_MAX_PBUFFER_HEIGHT, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_IGNORE, |
0 }, |
{ EGL_MAX_PBUFFER_PIXELS, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_IGNORE, |
0 }, |
{ EGL_MAX_SWAP_INTERVAL, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE }, |
{ EGL_MIN_SWAP_INTERVAL, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE }, |
{ EGL_NATIVE_RENDERABLE, ATTRIB_TYPE_BOOLEAN, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE }, |
{ EGL_NATIVE_VISUAL_ID, ATTRIB_TYPE_PLATFORM, |
ATTRIB_CRITERION_IGNORE, |
0 }, |
{ EGL_NATIVE_VISUAL_TYPE, ATTRIB_TYPE_PLATFORM, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE }, |
{ EGL_RENDERABLE_TYPE, ATTRIB_TYPE_BITMASK, |
ATTRIB_CRITERION_MASK, |
EGL_OPENGL_ES_BIT }, |
{ EGL_SAMPLE_BUFFERS, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_ATLEAST, |
0 }, |
{ EGL_SAMPLES, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_ATLEAST, |
0 }, |
{ EGL_STENCIL_SIZE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_ATLEAST, |
0 }, |
{ EGL_SURFACE_TYPE, ATTRIB_TYPE_BITMASK, |
ATTRIB_CRITERION_MASK, |
EGL_WINDOW_BIT }, |
{ EGL_TRANSPARENT_TYPE, ATTRIB_TYPE_ENUM, |
ATTRIB_CRITERION_EXACT, |
EGL_NONE }, |
{ EGL_TRANSPARENT_RED_VALUE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE }, |
{ EGL_TRANSPARENT_GREEN_VALUE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE }, |
{ EGL_TRANSPARENT_BLUE_VALUE, ATTRIB_TYPE_INTEGER, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE }, |
{ EGL_MATCH_NATIVE_PIXMAP, ATTRIB_TYPE_PSEUDO, |
ATTRIB_CRITERION_SPECIAL, |
EGL_NONE }, |
/* extensions */ |
{ EGL_Y_INVERTED_NOK, ATTRIB_TYPE_BOOLEAN, |
ATTRIB_CRITERION_EXACT, |
EGL_DONT_CARE } |
}; |
/** |
* Return true if a config is valid. When for_matching is true, |
* EGL_DONT_CARE is accepted as a valid attribute value, and checks |
* for conflicting attribute values are skipped. |
* |
* Note that some attributes are platform-dependent and are not |
* checked. |
*/ |
EGLBoolean |
_eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching) |
{ |
EGLint i, attr, val; |
EGLBoolean valid = EGL_TRUE; |
/* check attributes by their types */ |
for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) { |
EGLint mask; |
attr = _eglValidationTable[i].attr; |
val = _eglGetConfigKey(conf, attr); |
switch (_eglValidationTable[i].type) { |
case ATTRIB_TYPE_INTEGER: |
switch (attr) { |
case EGL_CONFIG_ID: |
/* config id must be positive */ |
if (val <= 0) |
valid = EGL_FALSE; |
break; |
case EGL_SAMPLE_BUFFERS: |
/* there can be at most 1 sample buffer */ |
if (val > 1 || val < 0) |
valid = EGL_FALSE; |
break; |
default: |
if (val < 0) |
valid = EGL_FALSE; |
break; |
} |
break; |
case ATTRIB_TYPE_BOOLEAN: |
if (val != EGL_TRUE && val != EGL_FALSE) |
valid = EGL_FALSE; |
break; |
case ATTRIB_TYPE_ENUM: |
switch (attr) { |
case EGL_CONFIG_CAVEAT: |
if (val != EGL_NONE && val != EGL_SLOW_CONFIG && |
val != EGL_NON_CONFORMANT_CONFIG) |
valid = EGL_FALSE; |
break; |
case EGL_TRANSPARENT_TYPE: |
if (val != EGL_NONE && val != EGL_TRANSPARENT_RGB) |
valid = EGL_FALSE; |
break; |
case EGL_COLOR_BUFFER_TYPE: |
if (val != EGL_RGB_BUFFER && val != EGL_LUMINANCE_BUFFER) |
valid = EGL_FALSE; |
break; |
default: |
assert(0); |
break; |
} |
break; |
case ATTRIB_TYPE_BITMASK: |
switch (attr) { |
case EGL_SURFACE_TYPE: |
mask = EGL_PBUFFER_BIT | |
EGL_PIXMAP_BIT | |
EGL_WINDOW_BIT | |
EGL_VG_COLORSPACE_LINEAR_BIT | |
EGL_VG_ALPHA_FORMAT_PRE_BIT | |
EGL_MULTISAMPLE_RESOLVE_BOX_BIT | |
EGL_SWAP_BEHAVIOR_PRESERVED_BIT; |
break; |
case EGL_RENDERABLE_TYPE: |
case EGL_CONFORMANT: |
mask = EGL_OPENGL_ES_BIT | |
EGL_OPENVG_BIT | |
EGL_OPENGL_ES2_BIT | |
EGL_OPENGL_ES3_BIT_KHR | |
EGL_OPENGL_BIT; |
break; |
default: |
assert(0); |
mask = 0; |
break; |
} |
if (val & ~mask) |
valid = EGL_FALSE; |
break; |
case ATTRIB_TYPE_PLATFORM: |
/* unable to check platform-dependent attributes here */ |
break; |
case ATTRIB_TYPE_PSEUDO: |
/* pseudo attributes should not be set */ |
if (val != 0) |
valid = EGL_FALSE; |
break; |
default: |
assert(0); |
break; |
} |
if (!valid && for_matching) { |
/* accept EGL_DONT_CARE as a valid value */ |
if (val == EGL_DONT_CARE) |
valid = EGL_TRUE; |
if (_eglValidationTable[i].criterion == ATTRIB_CRITERION_SPECIAL) |
valid = EGL_TRUE; |
} |
if (!valid) { |
_eglLog(_EGL_DEBUG, |
"attribute 0x%04x has an invalid value 0x%x", attr, val); |
break; |
} |
} |
/* any invalid attribute value should have been catched */ |
if (!valid || for_matching) |
return valid; |
/* now check for conflicting attribute values */ |
switch (conf->ColorBufferType) { |
case EGL_RGB_BUFFER: |
if (conf->LuminanceSize) |
valid = EGL_FALSE; |
if (conf->RedSize + conf->GreenSize + |
conf->BlueSize + conf->AlphaSize != conf->BufferSize) |
valid = EGL_FALSE; |
break; |
case EGL_LUMINANCE_BUFFER: |
if (conf->RedSize || conf->GreenSize || conf->BlueSize) |
valid = EGL_FALSE; |
if (conf->LuminanceSize + conf->AlphaSize != conf->BufferSize) |
valid = EGL_FALSE; |
break; |
} |
if (!valid) { |
_eglLog(_EGL_DEBUG, "conflicting color buffer type and channel sizes"); |
return EGL_FALSE; |
} |
if (!conf->SampleBuffers && conf->Samples) |
valid = EGL_FALSE; |
if (!valid) { |
_eglLog(_EGL_DEBUG, "conflicting samples and sample buffers"); |
return EGL_FALSE; |
} |
if (!(conf->SurfaceType & EGL_WINDOW_BIT)) { |
if (conf->NativeVisualID != 0 || conf->NativeVisualType != EGL_NONE) |
valid = EGL_FALSE; |
} |
if (!(conf->SurfaceType & EGL_PBUFFER_BIT)) { |
if (conf->BindToTextureRGB || conf->BindToTextureRGBA) |
valid = EGL_FALSE; |
} |
if (!valid) { |
_eglLog(_EGL_DEBUG, "conflicting surface type and native visual/texture binding"); |
return EGL_FALSE; |
} |
return valid; |
} |
/** |
* Return true if a config matches the criteria. This and |
* _eglParseConfigAttribList together implement the algorithm |
* described in "Selection of EGLConfigs". |
* |
* Note that attributes that are special (currently, only |
* EGL_MATCH_NATIVE_PIXMAP) are ignored. |
*/ |
EGLBoolean |
_eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria) |
{ |
EGLint attr, val, i; |
EGLBoolean matched = EGL_TRUE; |
for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) { |
EGLint cmp; |
if (_eglValidationTable[i].criterion == ATTRIB_CRITERION_IGNORE) |
continue; |
attr = _eglValidationTable[i].attr; |
cmp = _eglGetConfigKey(criteria, attr); |
if (cmp == EGL_DONT_CARE) |
continue; |
val = _eglGetConfigKey(conf, attr); |
switch (_eglValidationTable[i].criterion) { |
case ATTRIB_CRITERION_EXACT: |
if (val != cmp) |
matched = EGL_FALSE; |
break; |
case ATTRIB_CRITERION_ATLEAST: |
if (val < cmp) |
matched = EGL_FALSE; |
break; |
case ATTRIB_CRITERION_MASK: |
if ((val & cmp) != cmp) |
matched = EGL_FALSE; |
break; |
case ATTRIB_CRITERION_SPECIAL: |
/* ignored here */ |
break; |
default: |
assert(0); |
break; |
} |
if (!matched) { |
#ifndef DEBUG |
/* only print the common errors when DEBUG is not defined */ |
if (attr != EGL_RENDERABLE_TYPE) |
break; |
#endif |
_eglLog(_EGL_DEBUG, |
"the value (0x%x) of attribute 0x%04x did not meet the criteria (0x%x)", |
val, attr, cmp); |
break; |
} |
} |
return matched; |
} |
static inline EGLBoolean |
_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr) |
{ |
if (_eglOffsetOfConfig(attr) < 0) |
return EGL_FALSE; |
switch (attr) { |
case EGL_Y_INVERTED_NOK: |
return conf->Display->Extensions.NOK_texture_from_pixmap; |
default: |
break; |
} |
return EGL_TRUE; |
} |
/** |
* Initialize a criteria config from the given attribute list. |
* Return EGL_FALSE if any of the attribute is invalid. |
*/ |
EGLBoolean |
_eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy, |
const EGLint *attrib_list) |
{ |
EGLint attr, val, i; |
_eglInitConfig(conf, dpy, EGL_DONT_CARE); |
/* reset to default values */ |
for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) { |
attr = _eglValidationTable[i].attr; |
val = _eglValidationTable[i].default_value; |
_eglSetConfigKey(conf, attr, val); |
} |
/* parse the list */ |
for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i += 2) { |
attr = attrib_list[i]; |
val = attrib_list[i + 1]; |
if (!_eglIsConfigAttribValid(conf, attr)) |
return EGL_FALSE; |
_eglSetConfigKey(conf, attr, val); |
} |
if (!_eglValidateConfig(conf, EGL_TRUE)) |
return EGL_FALSE; |
/* EGL_LEVEL and EGL_MATCH_NATIVE_PIXMAP cannot be EGL_DONT_CARE */ |
if (conf->Level == EGL_DONT_CARE || |
conf->MatchNativePixmap == EGL_DONT_CARE) |
return EGL_FALSE; |
/* ignore other attributes when EGL_CONFIG_ID is given */ |
if (conf->ConfigID != EGL_DONT_CARE) { |
for (i = 0; i < ARRAY_SIZE(_eglValidationTable); i++) { |
attr = _eglValidationTable[i].attr; |
if (attr != EGL_CONFIG_ID) |
_eglSetConfigKey(conf, attr, EGL_DONT_CARE); |
} |
} |
else { |
if (!(conf->SurfaceType & EGL_WINDOW_BIT)) |
conf->NativeVisualType = EGL_DONT_CARE; |
if (conf->TransparentType == EGL_NONE) { |
conf->TransparentRedValue = EGL_DONT_CARE; |
conf->TransparentGreenValue = EGL_DONT_CARE; |
conf->TransparentBlueValue = EGL_DONT_CARE; |
} |
} |
return EGL_TRUE; |
} |
/** |
* Decide the ordering of conf1 and conf2, under the given criteria. |
* When compare_id is true, this implements the algorithm described |
* in "Sorting of EGLConfigs". When compare_id is false, |
* EGL_CONFIG_ID is not compared. |
* |
* It returns a negative integer if conf1 is considered to come |
* before conf2; a positive integer if conf2 is considered to come |
* before conf1; zero if the ordering cannot be decided. |
* |
* Note that EGL_NATIVE_VISUAL_TYPE is platform-dependent and is |
* ignored here. |
*/ |
EGLint |
_eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2, |
const _EGLConfig *criteria, EGLBoolean compare_id) |
{ |
const EGLint compare_attribs[] = { |
EGL_BUFFER_SIZE, |
EGL_SAMPLE_BUFFERS, |
EGL_SAMPLES, |
EGL_DEPTH_SIZE, |
EGL_STENCIL_SIZE, |
EGL_ALPHA_MASK_SIZE, |
}; |
EGLint val1, val2; |
EGLint i; |
if (conf1 == conf2) |
return 0; |
/* the enum values have the desired ordering */ |
assert(EGL_NONE < EGL_SLOW_CONFIG); |
assert(EGL_SLOW_CONFIG < EGL_NON_CONFORMANT_CONFIG); |
val1 = conf1->ConfigCaveat - conf2->ConfigCaveat; |
if (val1) |
return val1; |
/* the enum values have the desired ordering */ |
assert(EGL_RGB_BUFFER < EGL_LUMINANCE_BUFFER); |
val1 = conf1->ColorBufferType - conf2->ColorBufferType; |
if (val1) |
return val1; |
if (criteria) { |
val1 = val2 = 0; |
if (conf1->ColorBufferType == EGL_RGB_BUFFER) { |
if (criteria->RedSize > 0) { |
val1 += conf1->RedSize; |
val2 += conf2->RedSize; |
} |
if (criteria->GreenSize > 0) { |
val1 += conf1->GreenSize; |
val2 += conf2->GreenSize; |
} |
if (criteria->BlueSize > 0) { |
val1 += conf1->BlueSize; |
val2 += conf2->BlueSize; |
} |
} |
else { |
if (criteria->LuminanceSize > 0) { |
val1 += conf1->LuminanceSize; |
val2 += conf2->LuminanceSize; |
} |
} |
if (criteria->AlphaSize > 0) { |
val1 += conf1->AlphaSize; |
val2 += conf2->AlphaSize; |
} |
} |
else { |
/* assume the default criteria, which gives no specific ordering */ |
val1 = val2 = 0; |
} |
/* for color bits, larger one is preferred */ |
if (val1 != val2) |
return (val2 - val1); |
for (i = 0; i < ARRAY_SIZE(compare_attribs); i++) { |
val1 = _eglGetConfigKey(conf1, compare_attribs[i]); |
val2 = _eglGetConfigKey(conf2, compare_attribs[i]); |
if (val1 != val2) |
return (val1 - val2); |
} |
/* EGL_NATIVE_VISUAL_TYPE cannot be compared here */ |
return (compare_id) ? (conf1->ConfigID - conf2->ConfigID) : 0; |
} |
static inline |
void _eglSwapConfigs(const _EGLConfig **conf1, const _EGLConfig **conf2) |
{ |
const _EGLConfig *tmp = *conf1; |
*conf1 = *conf2; |
*conf2 = tmp; |
} |
/** |
* Quick sort an array of configs. This differs from the standard |
* qsort() in that the compare function accepts an additional |
* argument. |
*/ |
static void |
_eglSortConfigs(const _EGLConfig **configs, EGLint count, |
EGLint (*compare)(const _EGLConfig *, const _EGLConfig *, |
void *), |
void *priv_data) |
{ |
const EGLint pivot = 0; |
EGLint i, j; |
if (count <= 1) |
return; |
_eglSwapConfigs(&configs[pivot], &configs[count / 2]); |
i = 1; |
j = count - 1; |
do { |
while (i < count && compare(configs[i], configs[pivot], priv_data) < 0) |
i++; |
while (compare(configs[j], configs[pivot], priv_data) > 0) |
j--; |
if (i < j) { |
_eglSwapConfigs(&configs[i], &configs[j]); |
i++; |
j--; |
} |
else if (i == j) { |
i++; |
j--; |
break; |
} |
} while (i <= j); |
_eglSwapConfigs(&configs[pivot], &configs[j]); |
_eglSortConfigs(configs, j, compare, priv_data); |
_eglSortConfigs(configs + i, count - i, compare, priv_data); |
} |
/** |
* A helper function for implementing eglChooseConfig. See _eglFilterArray and |
* _eglSortConfigs for the meanings of match and compare. |
*/ |
EGLBoolean |
_eglFilterConfigArray(_EGLArray *array, EGLConfig *configs, |
EGLint config_size, EGLint *num_configs, |
EGLBoolean (*match)(const _EGLConfig *, void *), |
EGLint (*compare)(const _EGLConfig *, const _EGLConfig *, |
void *), |
void *priv_data) |
{ |
_EGLConfig **configList; |
EGLint i, count; |
if (!num_configs) |
return _eglError(EGL_BAD_PARAMETER, "eglChooseConfigs"); |
/* get the number of matched configs */ |
count = _eglFilterArray(array, NULL, 0, |
(_EGLArrayForEach) match, priv_data); |
if (!count) { |
*num_configs = count; |
return EGL_TRUE; |
} |
configList = malloc(sizeof(*configList) * count); |
if (!configList) |
return _eglError(EGL_BAD_ALLOC, "eglChooseConfig(out of memory)"); |
/* get the matched configs */ |
_eglFilterArray(array, (void **) configList, count, |
(_EGLArrayForEach) match, priv_data); |
/* perform sorting of configs */ |
if (configs && count) { |
_eglSortConfigs((const _EGLConfig **) configList, count, |
compare, priv_data); |
count = MIN2(count, config_size); |
for (i = 0; i < count; i++) |
configs[i] = _eglGetConfigHandle(configList[i]); |
} |
free(configList); |
*num_configs = count; |
return EGL_TRUE; |
} |
static EGLBoolean |
_eglFallbackMatch(const _EGLConfig *conf, void *priv_data) |
{ |
return _eglMatchConfig(conf, (const _EGLConfig *) priv_data); |
} |
static EGLint |
_eglFallbackCompare(const _EGLConfig *conf1, const _EGLConfig *conf2, |
void *priv_data) |
{ |
return _eglCompareConfigs(conf1, conf2, |
(const _EGLConfig *) priv_data, EGL_TRUE); |
} |
/** |
* Typical fallback routine for eglChooseConfig |
*/ |
EGLBoolean |
_eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list, |
EGLConfig *configs, EGLint config_size, EGLint *num_configs) |
{ |
_EGLConfig criteria; |
if (!_eglParseConfigAttribList(&criteria, disp, attrib_list)) |
return _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig"); |
return _eglFilterConfigArray(disp->Configs, |
configs, config_size, num_configs, |
_eglFallbackMatch, _eglFallbackCompare, |
(void *) &criteria); |
} |
/** |
* Fallback for eglGetConfigAttrib. |
*/ |
EGLBoolean |
_eglGetConfigAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, |
EGLint attribute, EGLint *value) |
{ |
if (!_eglIsConfigAttribValid(conf, attribute)) |
return _eglError(EGL_BAD_ATTRIBUTE, "eglGetConfigAttrib"); |
/* nonqueryable attributes */ |
switch (attribute) { |
case EGL_MATCH_NATIVE_PIXMAP: |
return _eglError(EGL_BAD_ATTRIBUTE, "eglGetConfigAttrib"); |
break; |
default: |
break; |
} |
if (!value) |
return _eglError(EGL_BAD_PARAMETER, "eglGetConfigAttrib"); |
*value = _eglGetConfigKey(conf, attribute); |
return EGL_TRUE; |
} |
static EGLBoolean |
_eglFlattenConfig(void *elem, void *buffer) |
{ |
_EGLConfig *conf = (_EGLConfig *) elem; |
EGLConfig *handle = (EGLConfig *) buffer; |
*handle = _eglGetConfigHandle(conf); |
return EGL_TRUE; |
} |
/** |
* Fallback for eglGetConfigs. |
*/ |
EGLBoolean |
_eglGetConfigs(_EGLDriver *drv, _EGLDisplay *disp, EGLConfig *configs, |
EGLint config_size, EGLint *num_config) |
{ |
if (!num_config) |
return _eglError(EGL_BAD_PARAMETER, "eglGetConfigs"); |
*num_config = _eglFlattenArray(disp->Configs, (void *) configs, |
sizeof(configs[0]), config_size, _eglFlattenConfig); |
return EGL_TRUE; |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglconfig.h |
---|
0,0 → 1,236 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLCONFIG_INCLUDED |
#define EGLCONFIG_INCLUDED |
#include <assert.h> |
#include <stddef.h> |
#include "c99_compat.h" |
#include "egltypedefs.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* update _eglValidationTable and _eglOffsetOfConfig before updating this |
* struct */ |
struct _egl_config |
{ |
_EGLDisplay *Display; |
/* core */ |
EGLint BufferSize; |
EGLint AlphaSize; |
EGLint BlueSize; |
EGLint GreenSize; |
EGLint RedSize; |
EGLint DepthSize; |
EGLint StencilSize; |
EGLint ConfigCaveat; |
EGLint ConfigID; |
EGLint Level; |
EGLint MaxPbufferHeight; |
EGLint MaxPbufferPixels; |
EGLint MaxPbufferWidth; |
EGLint NativeRenderable; |
EGLint NativeVisualID; |
EGLint NativeVisualType; |
EGLint Samples; |
EGLint SampleBuffers; |
EGLint SurfaceType; |
EGLint TransparentType; |
EGLint TransparentBlueValue; |
EGLint TransparentGreenValue; |
EGLint TransparentRedValue; |
EGLint BindToTextureRGB; |
EGLint BindToTextureRGBA; |
EGLint MinSwapInterval; |
EGLint MaxSwapInterval; |
EGLint LuminanceSize; |
EGLint AlphaMaskSize; |
EGLint ColorBufferType; |
EGLint RenderableType; |
EGLint MatchNativePixmap; |
EGLint Conformant; |
/* extensions */ |
EGLint YInvertedNOK; |
}; |
/** |
* Map an EGL attribute enum to the offset of the member in _EGLConfig. |
*/ |
static inline EGLint |
_eglOffsetOfConfig(EGLint attr) |
{ |
switch (attr) { |
#define ATTRIB_MAP(attr, memb) case attr: return offsetof(_EGLConfig, memb) |
/* core */ |
ATTRIB_MAP(EGL_BUFFER_SIZE, BufferSize); |
ATTRIB_MAP(EGL_ALPHA_SIZE, AlphaSize); |
ATTRIB_MAP(EGL_BLUE_SIZE, BlueSize); |
ATTRIB_MAP(EGL_GREEN_SIZE, GreenSize); |
ATTRIB_MAP(EGL_RED_SIZE, RedSize); |
ATTRIB_MAP(EGL_DEPTH_SIZE, DepthSize); |
ATTRIB_MAP(EGL_STENCIL_SIZE, StencilSize); |
ATTRIB_MAP(EGL_CONFIG_CAVEAT, ConfigCaveat); |
ATTRIB_MAP(EGL_CONFIG_ID, ConfigID); |
ATTRIB_MAP(EGL_LEVEL, Level); |
ATTRIB_MAP(EGL_MAX_PBUFFER_HEIGHT, MaxPbufferHeight); |
ATTRIB_MAP(EGL_MAX_PBUFFER_PIXELS, MaxPbufferPixels); |
ATTRIB_MAP(EGL_MAX_PBUFFER_WIDTH, MaxPbufferWidth); |
ATTRIB_MAP(EGL_NATIVE_RENDERABLE, NativeRenderable); |
ATTRIB_MAP(EGL_NATIVE_VISUAL_ID, NativeVisualID); |
ATTRIB_MAP(EGL_NATIVE_VISUAL_TYPE, NativeVisualType); |
ATTRIB_MAP(EGL_SAMPLES, Samples); |
ATTRIB_MAP(EGL_SAMPLE_BUFFERS, SampleBuffers); |
ATTRIB_MAP(EGL_SURFACE_TYPE, SurfaceType); |
ATTRIB_MAP(EGL_TRANSPARENT_TYPE, TransparentType); |
ATTRIB_MAP(EGL_TRANSPARENT_BLUE_VALUE, TransparentBlueValue); |
ATTRIB_MAP(EGL_TRANSPARENT_GREEN_VALUE, TransparentGreenValue); |
ATTRIB_MAP(EGL_TRANSPARENT_RED_VALUE, TransparentRedValue); |
ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGB, BindToTextureRGB); |
ATTRIB_MAP(EGL_BIND_TO_TEXTURE_RGBA, BindToTextureRGBA); |
ATTRIB_MAP(EGL_MIN_SWAP_INTERVAL, MinSwapInterval); |
ATTRIB_MAP(EGL_MAX_SWAP_INTERVAL, MaxSwapInterval); |
ATTRIB_MAP(EGL_LUMINANCE_SIZE, LuminanceSize); |
ATTRIB_MAP(EGL_ALPHA_MASK_SIZE, AlphaMaskSize); |
ATTRIB_MAP(EGL_COLOR_BUFFER_TYPE, ColorBufferType); |
ATTRIB_MAP(EGL_RENDERABLE_TYPE, RenderableType); |
ATTRIB_MAP(EGL_MATCH_NATIVE_PIXMAP, MatchNativePixmap); |
ATTRIB_MAP(EGL_CONFORMANT, Conformant); |
/* extensions */ |
ATTRIB_MAP(EGL_Y_INVERTED_NOK, YInvertedNOK); |
#undef ATTRIB_MAP |
default: |
return -1; |
} |
} |
/** |
* Update a config for a given key. |
* |
* Note that a valid key is not necessarily a valid attribute. There are gaps |
* in the attribute enums. The separation is to catch application errors. |
* Drivers should never set a key that is an invalid attribute. |
*/ |
static inline void |
_eglSetConfigKey(_EGLConfig *conf, EGLint key, EGLint val) |
{ |
EGLint offset = _eglOffsetOfConfig(key); |
assert(offset >= 0); |
*((EGLint *) ((char *) conf + offset)) = val; |
} |
/** |
* Return the value for a given key. |
*/ |
static inline EGLint |
_eglGetConfigKey(const _EGLConfig *conf, EGLint key) |
{ |
EGLint offset = _eglOffsetOfConfig(key); |
assert(offset >= 0); |
return *((EGLint *) ((char *) conf + offset)); |
} |
extern void |
_eglInitConfig(_EGLConfig *config, _EGLDisplay *dpy, EGLint id); |
extern EGLConfig |
_eglLinkConfig(_EGLConfig *conf); |
extern _EGLConfig * |
_eglLookupConfig(EGLConfig config, _EGLDisplay *dpy); |
/** |
* Return the handle of a linked config. |
*/ |
static inline EGLConfig |
_eglGetConfigHandle(_EGLConfig *conf) |
{ |
return (EGLConfig) conf; |
} |
extern EGLBoolean |
_eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching); |
extern EGLBoolean |
_eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria); |
extern EGLBoolean |
_eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy, |
const EGLint *attrib_list); |
extern EGLint |
_eglCompareConfigs(const _EGLConfig *conf1, const _EGLConfig *conf2, |
const _EGLConfig *criteria, EGLBoolean compare_id); |
extern EGLBoolean |
_eglFilterConfigArray(_EGLArray *array, EGLConfig *configs, |
EGLint config_size, EGLint *num_configs, |
EGLBoolean (*match)(const _EGLConfig *, void *), |
EGLint (*compare)(const _EGLConfig *, const _EGLConfig *, |
void *), |
void *filter_data); |
extern EGLBoolean |
_eglChooseConfig(_EGLDriver *drv, _EGLDisplay *dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); |
extern EGLBoolean |
_eglGetConfigAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLint attribute, EGLint *value); |
extern EGLBoolean |
_eglGetConfigs(_EGLDriver *drv, _EGLDisplay *dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLCONFIG_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglcontext.c |
---|
0,0 → 1,629 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#include <assert.h> |
#include <stdlib.h> |
#include <string.h> |
#include "eglconfig.h" |
#include "eglcontext.h" |
#include "egldisplay.h" |
#include "eglcurrent.h" |
#include "eglsurface.h" |
#include "egllog.h" |
/** |
* Return the API bit (one of EGL_xxx_BIT) of the context. |
*/ |
static EGLint |
_eglGetContextAPIBit(_EGLContext *ctx) |
{ |
EGLint bit = 0; |
switch (ctx->ClientAPI) { |
case EGL_OPENGL_ES_API: |
switch (ctx->ClientMajorVersion) { |
case 1: |
bit = EGL_OPENGL_ES_BIT; |
break; |
case 2: |
bit = EGL_OPENGL_ES2_BIT; |
break; |
case 3: |
bit = EGL_OPENGL_ES3_BIT_KHR; |
break; |
default: |
break; |
} |
break; |
case EGL_OPENVG_API: |
bit = EGL_OPENVG_BIT; |
break; |
case EGL_OPENGL_API: |
bit = EGL_OPENGL_BIT; |
break; |
default: |
break; |
} |
return bit; |
} |
/** |
* Parse the list of context attributes and return the proper error code. |
*/ |
static EGLint |
_eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy, |
const EGLint *attrib_list) |
{ |
EGLenum api = ctx->ClientAPI; |
EGLint i, err = EGL_SUCCESS; |
if (!attrib_list) |
return EGL_SUCCESS; |
if (api == EGL_OPENVG_API && attrib_list[0] != EGL_NONE) { |
_eglLog(_EGL_DEBUG, "bad context attribute 0x%04x", attrib_list[0]); |
return EGL_BAD_ATTRIBUTE; |
} |
for (i = 0; attrib_list[i] != EGL_NONE; i++) { |
EGLint attr = attrib_list[i++]; |
EGLint val = attrib_list[i]; |
switch (attr) { |
case EGL_CONTEXT_CLIENT_VERSION: |
ctx->ClientMajorVersion = val; |
break; |
case EGL_CONTEXT_MINOR_VERSION_KHR: |
if (!dpy->Extensions.KHR_create_context) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
ctx->ClientMinorVersion = val; |
break; |
case EGL_CONTEXT_FLAGS_KHR: |
if (!dpy->Extensions.KHR_create_context) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
/* The EGL_KHR_create_context spec says: |
* |
* "Flags are only defined for OpenGL context creation, and |
* specifying a flags value other than zero for other types of |
* contexts, including OpenGL ES contexts, will generate an |
* error." |
*/ |
if (api != EGL_OPENGL_API && val != 0) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
ctx->Flags = val; |
break; |
case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR: |
if (!dpy->Extensions.KHR_create_context) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
/* The EGL_KHR_create_context spec says: |
* |
* "[EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR] is only meaningful for |
* OpenGL contexts, and specifying it for other types of |
* contexts, including OpenGL ES contexts, will generate an |
* error." |
*/ |
if (api != EGL_OPENGL_API) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
ctx->Profile = val; |
break; |
case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR: |
/* The EGL_KHR_create_context spec says: |
* |
* "[EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR] is only |
* meaningful for OpenGL contexts, and specifying it for other |
* types of contexts, including OpenGL ES contexts, will generate |
* an error." |
*/ |
if (!dpy->Extensions.KHR_create_context |
|| api != EGL_OPENGL_API) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
ctx->ResetNotificationStrategy = val; |
break; |
case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT: |
/* The EGL_EXT_create_context_robustness spec says: |
* |
* "[EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT] is only |
* meaningful for OpenGL ES contexts, and specifying it for other |
* types of contexts will generate an EGL_BAD_ATTRIBUTE error." |
*/ |
if (!dpy->Extensions.EXT_create_context_robustness |
|| api != EGL_OPENGL_ES_API) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
ctx->ResetNotificationStrategy = val; |
break; |
case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT: |
if (!dpy->Extensions.EXT_create_context_robustness) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
ctx->Flags = EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR; |
break; |
default: |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (err != EGL_SUCCESS) { |
_eglLog(_EGL_DEBUG, "bad context attribute 0x%04x", attr); |
break; |
} |
} |
if (api == EGL_OPENGL_API) { |
/* The EGL_KHR_create_context spec says: |
* |
* "If the requested OpenGL version is less than 3.2, |
* EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR is ignored and the |
* functionality of the context is determined solely by the |
* requested version." |
* |
* Since the value is ignored, only validate the setting if the version |
* is >= 3.2. |
*/ |
if (ctx->ClientMajorVersion >= 4 |
|| (ctx->ClientMajorVersion == 3 && ctx->ClientMinorVersion >= 2)) { |
switch (ctx->Profile) { |
case EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR: |
case EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR: |
break; |
default: |
/* The EGL_KHR_create_context spec says: |
* |
* "* If an OpenGL context is requested, the requested version |
* is greater than 3.2, and the value for attribute |
* EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR has no bits set; has |
* any bits set other than EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR |
* and EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR; has |
* more than one of these bits set; or if the implementation does |
* not support the requested profile, then an EGL_BAD_MATCH error |
* is generated." |
*/ |
err = EGL_BAD_MATCH; |
break; |
} |
} |
/* The EGL_KHR_create_context spec says: |
* |
* "* If an OpenGL context is requested and the values for |
* attributes EGL_CONTEXT_MAJOR_VERSION_KHR and |
* EGL_CONTEXT_MINOR_VERSION_KHR, when considered together with |
* the value for attribute |
* EGL_CONTEXT_FORWARD_COMPATIBLE_BIT_KHR, specify an OpenGL |
* version and feature set that are not defined, than an |
* EGL_BAD_MATCH error is generated. |
* |
* ... Thus, examples of invalid combinations of attributes |
* include: |
* |
* - Major version < 1 or > 4 |
* - Major version == 1 and minor version < 0 or > 5 |
* - Major version == 2 and minor version < 0 or > 1 |
* - Major version == 3 and minor version < 0 or > 2 |
* - Major version == 4 and minor version < 0 or > 2 |
* - Forward-compatible flag set and major version < 3" |
*/ |
if (ctx->ClientMajorVersion < 1 || ctx->ClientMinorVersion < 0) |
err = EGL_BAD_MATCH; |
switch (ctx->ClientMajorVersion) { |
case 1: |
if (ctx->ClientMinorVersion > 5 |
|| (ctx->Flags & EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR) != 0) |
err = EGL_BAD_MATCH; |
break; |
case 2: |
if (ctx->ClientMinorVersion > 1 |
|| (ctx->Flags & EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR) != 0) |
err = EGL_BAD_MATCH; |
break; |
case 3: |
/* Note: The text above is incorrect. There *is* an OpenGL 3.3! |
*/ |
if (ctx->ClientMinorVersion > 3) |
err = EGL_BAD_MATCH; |
break; |
case 4: |
default: |
/* Don't put additional version checks here. We don't know that |
* there won't be versions > 4.2. |
*/ |
break; |
} |
} else if (api == EGL_OPENGL_ES_API) { |
/* The EGL_KHR_create_context spec says: |
* |
* "* If an OpenGL ES context is requested and the values for |
* attributes EGL_CONTEXT_MAJOR_VERSION_KHR and |
* EGL_CONTEXT_MINOR_VERSION_KHR specify an OpenGL ES version that |
* is not defined, than an EGL_BAD_MATCH error is generated. |
* |
* ... Examples of invalid combinations of attributes include: |
* |
* - Major version < 1 or > 2 |
* - Major version == 1 and minor version < 0 or > 1 |
* - Major version == 2 and minor version != 0 |
*/ |
if (ctx->ClientMajorVersion < 1 || ctx->ClientMinorVersion < 0) |
err = EGL_BAD_MATCH; |
switch (ctx->ClientMajorVersion) { |
case 1: |
if (ctx->ClientMinorVersion > 1) |
err = EGL_BAD_MATCH; |
break; |
case 2: |
if (ctx->ClientMinorVersion > 0) |
err = EGL_BAD_MATCH; |
break; |
case 3: |
/* Don't put additional version checks here. We don't know that |
* there won't be versions > 3.0. |
*/ |
break; |
default: |
err = EGL_BAD_MATCH; |
break; |
} |
} |
switch (ctx->ResetNotificationStrategy) { |
case EGL_NO_RESET_NOTIFICATION_KHR: |
case EGL_LOSE_CONTEXT_ON_RESET_KHR: |
break; |
default: |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if ((ctx->Flags & ~(EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR |
| EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR |
| EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR)) != 0) { |
err = EGL_BAD_ATTRIBUTE; |
} |
return err; |
} |
/** |
* Initialize the given _EGLContext object to defaults and/or the values |
* in the attrib_list. |
*/ |
EGLBoolean |
_eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, _EGLConfig *conf, |
const EGLint *attrib_list) |
{ |
const EGLenum api = eglQueryAPI(); |
EGLint err; |
if (api == EGL_NONE) { |
_eglError(EGL_BAD_MATCH, "eglCreateContext(no client API)"); |
return EGL_FALSE; |
} |
_eglInitResource(&ctx->Resource, sizeof(*ctx), dpy); |
ctx->ClientAPI = api; |
ctx->Config = conf; |
ctx->WindowRenderBuffer = EGL_NONE; |
ctx->Profile = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR; |
ctx->ClientMajorVersion = 1; /* the default, per EGL spec */ |
ctx->ClientMinorVersion = 0; |
ctx->Flags = 0; |
ctx->Profile = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR; |
ctx->ResetNotificationStrategy = EGL_NO_RESET_NOTIFICATION_KHR; |
err = _eglParseContextAttribList(ctx, dpy, attrib_list); |
if (err == EGL_SUCCESS && ctx->Config) { |
EGLint api_bit; |
api_bit = _eglGetContextAPIBit(ctx); |
if (!(ctx->Config->RenderableType & api_bit)) { |
_eglLog(_EGL_DEBUG, "context api is 0x%x while config supports 0x%x", |
api_bit, ctx->Config->RenderableType); |
err = EGL_BAD_CONFIG; |
} |
} |
if (err != EGL_SUCCESS) |
return _eglError(err, "eglCreateContext"); |
return EGL_TRUE; |
} |
static EGLint |
_eglQueryContextRenderBuffer(_EGLContext *ctx) |
{ |
_EGLSurface *surf = ctx->DrawSurface; |
EGLint rb; |
if (!surf) |
return EGL_NONE; |
if (surf->Type == EGL_WINDOW_BIT && ctx->WindowRenderBuffer != EGL_NONE) |
rb = ctx->WindowRenderBuffer; |
else |
rb = surf->RenderBuffer; |
return rb; |
} |
EGLBoolean |
_eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *c, |
EGLint attribute, EGLint *value) |
{ |
(void) drv; |
(void) dpy; |
if (!value) |
return _eglError(EGL_BAD_PARAMETER, "eglQueryContext"); |
switch (attribute) { |
case EGL_CONFIG_ID: |
if (!c->Config) |
return _eglError(EGL_BAD_ATTRIBUTE, "eglQueryContext"); |
*value = c->Config->ConfigID; |
break; |
case EGL_CONTEXT_CLIENT_VERSION: |
*value = c->ClientMajorVersion; |
break; |
case EGL_CONTEXT_CLIENT_TYPE: |
*value = c->ClientAPI; |
break; |
case EGL_RENDER_BUFFER: |
*value = _eglQueryContextRenderBuffer(c); |
break; |
default: |
return _eglError(EGL_BAD_ATTRIBUTE, "eglQueryContext"); |
} |
return EGL_TRUE; |
} |
/** |
* Bind the context to the thread and return the previous context. |
* |
* Note that the context may be NULL. |
*/ |
static _EGLContext * |
_eglBindContextToThread(_EGLContext *ctx, _EGLThreadInfo *t) |
{ |
EGLint apiIndex; |
_EGLContext *oldCtx; |
apiIndex = (ctx) ? |
_eglConvertApiToIndex(ctx->ClientAPI) : t->CurrentAPIIndex; |
oldCtx = t->CurrentContexts[apiIndex]; |
if (ctx != oldCtx) { |
if (oldCtx) |
oldCtx->Binding = NULL; |
if (ctx) |
ctx->Binding = t; |
t->CurrentContexts[apiIndex] = ctx; |
} |
return oldCtx; |
} |
/** |
* Return true if the given context and surfaces can be made current. |
*/ |
static EGLBoolean |
_eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read) |
{ |
_EGLThreadInfo *t = _eglGetCurrentThread(); |
_EGLDisplay *dpy; |
EGLint conflict_api; |
if (_eglIsCurrentThreadDummy()) |
return _eglError(EGL_BAD_ALLOC, "eglMakeCurrent"); |
/* this is easy */ |
if (!ctx) { |
if (draw || read) |
return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); |
return EGL_TRUE; |
} |
dpy = ctx->Resource.Display; |
if (!dpy->Extensions.KHR_surfaceless_context |
&& (draw == NULL || read == NULL)) |
return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); |
/* |
* The spec says |
* |
* "If ctx is current to some other thread, or if either draw or read are |
* bound to contexts in another thread, an EGL_BAD_ACCESS error is |
* generated." |
* |
* and |
* |
* "at most one context may be bound to a particular surface at a given |
* time" |
*/ |
if (ctx->Binding && ctx->Binding != t) |
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); |
if (draw && draw->CurrentContext && draw->CurrentContext != ctx) { |
if (draw->CurrentContext->Binding != t || |
draw->CurrentContext->ClientAPI != ctx->ClientAPI) |
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); |
} |
if (read && read->CurrentContext && read->CurrentContext != ctx) { |
if (read->CurrentContext->Binding != t || |
read->CurrentContext->ClientAPI != ctx->ClientAPI) |
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); |
} |
/* If the context has a config then it must match that of the two |
* surfaces */ |
if (ctx->Config) { |
if ((draw && draw->Config != ctx->Config) || |
(read && read->Config != ctx->Config)) |
return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); |
} else { |
/* Otherwise we must be using the EGL_MESA_configless_context |
* extension */ |
assert(dpy->Extensions.MESA_configless_context); |
/* The extension doesn't permit binding draw and read buffers with |
* differing contexts */ |
if (draw && read && draw->Config != read->Config) |
return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); |
} |
switch (ctx->ClientAPI) { |
/* OpenGL and OpenGL ES are conflicting */ |
case EGL_OPENGL_ES_API: |
conflict_api = EGL_OPENGL_API; |
break; |
case EGL_OPENGL_API: |
conflict_api = EGL_OPENGL_ES_API; |
break; |
default: |
conflict_api = -1; |
break; |
} |
if (conflict_api >= 0 && _eglGetAPIContext(conflict_api)) |
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); |
return EGL_TRUE; |
} |
/** |
* Bind the context to the current thread and given surfaces. Return the |
* previous bound context and surfaces. The caller should unreference the |
* returned context and surfaces. |
* |
* Making a second call with the resources returned by the first call |
* unsurprisingly undoes the first call, except for the resouce reference |
* counts. |
*/ |
EGLBoolean |
_eglBindContext(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read, |
_EGLContext **old_ctx, |
_EGLSurface **old_draw, _EGLSurface **old_read) |
{ |
_EGLThreadInfo *t = _eglGetCurrentThread(); |
_EGLContext *prev_ctx; |
_EGLSurface *prev_draw, *prev_read; |
if (!_eglCheckMakeCurrent(ctx, draw, read)) |
return EGL_FALSE; |
/* increment refcounts before binding */ |
_eglGetContext(ctx); |
_eglGetSurface(draw); |
_eglGetSurface(read); |
/* bind the new context */ |
prev_ctx = _eglBindContextToThread(ctx, t); |
/* break previous bindings */ |
if (prev_ctx) { |
prev_draw = prev_ctx->DrawSurface; |
prev_read = prev_ctx->ReadSurface; |
if (prev_draw) |
prev_draw->CurrentContext = NULL; |
if (prev_read) |
prev_read->CurrentContext = NULL; |
prev_ctx->DrawSurface = NULL; |
prev_ctx->ReadSurface = NULL; |
} |
else { |
prev_draw = prev_read = NULL; |
} |
/* establish new bindings */ |
if (ctx) { |
if (draw) |
draw->CurrentContext = ctx; |
if (read) |
read->CurrentContext = ctx; |
ctx->DrawSurface = draw; |
ctx->ReadSurface = read; |
} |
assert(old_ctx && old_draw && old_read); |
*old_ctx = prev_ctx; |
*old_draw = prev_draw; |
*old_read = prev_read; |
return EGL_TRUE; |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglcontext.h |
---|
0,0 → 1,161 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLCONTEXT_INCLUDED |
#define EGLCONTEXT_INCLUDED |
#include "c99_compat.h" |
#include "egltypedefs.h" |
#include "egldisplay.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
/** |
* "Base" class for device driver contexts. |
*/ |
struct _egl_context |
{ |
/* A context is a display resource */ |
_EGLResource Resource; |
/* The bound status of the context */ |
_EGLThreadInfo *Binding; |
_EGLSurface *DrawSurface; |
_EGLSurface *ReadSurface; |
_EGLConfig *Config; |
EGLint ClientAPI; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API */ |
EGLint ClientMajorVersion; |
EGLint ClientMinorVersion; |
EGLint Flags; |
EGLint Profile; |
EGLint ResetNotificationStrategy; |
/* The real render buffer when a window surface is bound */ |
EGLint WindowRenderBuffer; |
}; |
extern EGLBoolean |
_eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, |
_EGLConfig *config, const EGLint *attrib_list); |
extern EGLBoolean |
_eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value); |
extern EGLBoolean |
_eglBindContext(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read, |
_EGLContext **old_ctx, |
_EGLSurface **old_draw, _EGLSurface **old_read); |
/** |
* Increment reference count for the context. |
*/ |
static inline _EGLContext * |
_eglGetContext(_EGLContext *ctx) |
{ |
if (ctx) |
_eglGetResource(&ctx->Resource); |
return ctx; |
} |
/** |
* Decrement reference count for the context. |
*/ |
static inline EGLBoolean |
_eglPutContext(_EGLContext *ctx) |
{ |
return (ctx) ? _eglPutResource(&ctx->Resource) : EGL_FALSE; |
} |
/** |
* Link a context to its display and return the handle of the link. |
* The handle can be passed to client directly. |
*/ |
static inline EGLContext |
_eglLinkContext(_EGLContext *ctx) |
{ |
_eglLinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT); |
return (EGLContext) ctx; |
} |
/** |
* Unlink a linked context from its display. |
* Accessing an unlinked context should generate EGL_BAD_CONTEXT error. |
*/ |
static inline void |
_eglUnlinkContext(_EGLContext *ctx) |
{ |
_eglUnlinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT); |
} |
/** |
* Lookup a handle to find the linked context. |
* Return NULL if the handle has no corresponding linked context. |
*/ |
static inline _EGLContext * |
_eglLookupContext(EGLContext context, _EGLDisplay *dpy) |
{ |
_EGLContext *ctx = (_EGLContext *) context; |
if (!dpy || !_eglCheckResource((void *) ctx, _EGL_RESOURCE_CONTEXT, dpy)) |
ctx = NULL; |
return ctx; |
} |
/** |
* Return the handle of a linked context, or EGL_NO_CONTEXT. |
*/ |
static inline EGLContext |
_eglGetContextHandle(_EGLContext *ctx) |
{ |
_EGLResource *res = (_EGLResource *) ctx; |
return (res && _eglIsResourceLinked(res)) ? |
(EGLContext) ctx : EGL_NO_CONTEXT; |
} |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLCONTEXT_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglcurrent.c |
---|
0,0 → 1,292 |
/************************************************************************** |
* |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#include <stdlib.h> |
#include <string.h> |
#include "c99_compat.h" |
#include "c11/threads.h" |
#include "egllog.h" |
#include "eglcurrent.h" |
#include "eglglobals.h" |
/* This should be kept in sync with _eglInitThreadInfo() */ |
#define _EGL_THREAD_INFO_INITIALIZER \ |
{ EGL_SUCCESS, { NULL }, 0 } |
/* a fallback thread info to guarantee that every thread always has one */ |
static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER; |
static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP; |
static EGLBoolean _egl_TSDInitialized; |
static tss_t _egl_TSD; |
static void (*_egl_FreeTSD)(_EGLThreadInfo *); |
#ifdef GLX_USE_TLS |
static __thread const _EGLThreadInfo *_egl_TLS |
__attribute__ ((tls_model("initial-exec"))); |
#endif |
static inline void _eglSetTSD(const _EGLThreadInfo *t) |
{ |
tss_set(_egl_TSD, (void *) t); |
#ifdef GLX_USE_TLS |
_egl_TLS = t; |
#endif |
} |
static inline _EGLThreadInfo *_eglGetTSD(void) |
{ |
#ifdef GLX_USE_TLS |
return (_EGLThreadInfo *) _egl_TLS; |
#else |
return (_EGLThreadInfo *) tss_get(_egl_TSD); |
#endif |
} |
static inline void _eglFiniTSD(void) |
{ |
mtx_lock(&_egl_TSDMutex); |
if (_egl_TSDInitialized) { |
_EGLThreadInfo *t = _eglGetTSD(); |
_egl_TSDInitialized = EGL_FALSE; |
if (t && _egl_FreeTSD) |
_egl_FreeTSD((void *) t); |
tss_delete(_egl_TSD); |
} |
mtx_unlock(&_egl_TSDMutex); |
} |
static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *)) |
{ |
if (!_egl_TSDInitialized) { |
mtx_lock(&_egl_TSDMutex); |
/* check again after acquiring lock */ |
if (!_egl_TSDInitialized) { |
if (tss_create(&_egl_TSD, (void (*)(void *)) dtor) != thrd_success) { |
mtx_unlock(&_egl_TSDMutex); |
return EGL_FALSE; |
} |
_egl_FreeTSD = dtor; |
_eglAddAtExitCall(_eglFiniTSD); |
_egl_TSDInitialized = EGL_TRUE; |
} |
mtx_unlock(&_egl_TSDMutex); |
} |
return EGL_TRUE; |
} |
static void |
_eglInitThreadInfo(_EGLThreadInfo *t) |
{ |
memset(t, 0, sizeof(*t)); |
t->LastError = EGL_SUCCESS; |
/* default, per EGL spec */ |
t->CurrentAPIIndex = _eglConvertApiToIndex(EGL_OPENGL_ES_API); |
} |
/** |
* Allocate and init a new _EGLThreadInfo object. |
*/ |
static _EGLThreadInfo * |
_eglCreateThreadInfo(void) |
{ |
_EGLThreadInfo *t = calloc(1, sizeof(_EGLThreadInfo)); |
if (t) |
_eglInitThreadInfo(t); |
else |
t = &dummy_thread; |
return t; |
} |
/** |
* Delete/free a _EGLThreadInfo object. |
*/ |
static void |
_eglDestroyThreadInfo(_EGLThreadInfo *t) |
{ |
if (t != &dummy_thread) |
free(t); |
} |
/** |
* Make sure TSD is initialized and return current value. |
*/ |
static inline _EGLThreadInfo * |
_eglCheckedGetTSD(void) |
{ |
if (_eglInitTSD(&_eglDestroyThreadInfo) != EGL_TRUE) { |
_eglLog(_EGL_FATAL, "failed to initialize \"current\" system"); |
return NULL; |
} |
return _eglGetTSD(); |
} |
/** |
* Return the calling thread's thread info. |
* If the calling thread nevers calls this function before, or if its thread |
* info was destroyed, a new one is created. This function never returns NULL. |
* In the case allocation fails, a dummy one is returned. See also |
* _eglIsCurrentThreadDummy. |
*/ |
_EGLThreadInfo * |
_eglGetCurrentThread(void) |
{ |
_EGLThreadInfo *t = _eglCheckedGetTSD(); |
if (!t) { |
t = _eglCreateThreadInfo(); |
_eglSetTSD(t); |
} |
return t; |
} |
/** |
* Destroy the calling thread's thread info. |
*/ |
void |
_eglDestroyCurrentThread(void) |
{ |
_EGLThreadInfo *t = _eglCheckedGetTSD(); |
if (t) { |
_eglDestroyThreadInfo(t); |
_eglSetTSD(NULL); |
} |
} |
/** |
* Return true if the calling thread's thread info is dummy. |
* A dummy thread info is shared by all threads and should not be modified. |
* Functions like eglBindAPI or eglMakeCurrent should check for dummy-ness |
* before updating the thread info. |
*/ |
EGLBoolean |
_eglIsCurrentThreadDummy(void) |
{ |
_EGLThreadInfo *t = _eglCheckedGetTSD(); |
return (!t || t == &dummy_thread); |
} |
/** |
* Return the currently bound context of the given API, or NULL. |
*/ |
_EGLContext * |
_eglGetAPIContext(EGLenum api) |
{ |
_EGLThreadInfo *t = _eglGetCurrentThread(); |
return t->CurrentContexts[_eglConvertApiToIndex(api)]; |
} |
/** |
* Return the currently bound context of the current API, or NULL. |
*/ |
_EGLContext * |
_eglGetCurrentContext(void) |
{ |
_EGLThreadInfo *t = _eglGetCurrentThread(); |
return t->CurrentContexts[t->CurrentAPIIndex]; |
} |
/** |
* Record EGL error code and return EGL_FALSE. |
*/ |
EGLBoolean |
_eglError(EGLint errCode, const char *msg) |
{ |
_EGLThreadInfo *t = _eglGetCurrentThread(); |
if (t == &dummy_thread) |
return EGL_FALSE; |
t->LastError = errCode; |
if (errCode != EGL_SUCCESS) { |
const char *s; |
switch (errCode) { |
case EGL_BAD_ACCESS: |
s = "EGL_BAD_ACCESS"; |
break; |
case EGL_BAD_ALLOC: |
s = "EGL_BAD_ALLOC"; |
break; |
case EGL_BAD_ATTRIBUTE: |
s = "EGL_BAD_ATTRIBUTE"; |
break; |
case EGL_BAD_CONFIG: |
s = "EGL_BAD_CONFIG"; |
break; |
case EGL_BAD_CONTEXT: |
s = "EGL_BAD_CONTEXT"; |
break; |
case EGL_BAD_CURRENT_SURFACE: |
s = "EGL_BAD_CURRENT_SURFACE"; |
break; |
case EGL_BAD_DISPLAY: |
s = "EGL_BAD_DISPLAY"; |
break; |
case EGL_BAD_MATCH: |
s = "EGL_BAD_MATCH"; |
break; |
case EGL_BAD_NATIVE_PIXMAP: |
s = "EGL_BAD_NATIVE_PIXMAP"; |
break; |
case EGL_BAD_NATIVE_WINDOW: |
s = "EGL_BAD_NATIVE_WINDOW"; |
break; |
case EGL_BAD_PARAMETER: |
s = "EGL_BAD_PARAMETER"; |
break; |
case EGL_BAD_SURFACE: |
s = "EGL_BAD_SURFACE"; |
break; |
case EGL_NOT_INITIALIZED: |
s = "EGL_NOT_INITIALIZED"; |
break; |
default: |
s = "other EGL error"; |
} |
_eglLog(_EGL_DEBUG, "EGL user error 0x%x (%s) in %s\n", errCode, s, msg); |
} |
return EGL_FALSE; |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglcurrent.h |
---|
0,0 → 1,126 |
/************************************************************************** |
* |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLCURRENT_INCLUDED |
#define EGLCURRENT_INCLUDED |
#include "c99_compat.h" |
#include "egltypedefs.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _EGL_API_ALL_BITS \ |
(EGL_OPENGL_ES_BIT | \ |
EGL_OPENVG_BIT | \ |
EGL_OPENGL_ES2_BIT | \ |
EGL_OPENGL_ES3_BIT_KHR | \ |
EGL_OPENGL_BIT) |
#define _EGL_API_FIRST_API EGL_OPENGL_ES_API |
#define _EGL_API_LAST_API EGL_OPENGL_API |
#define _EGL_API_NUM_APIS (_EGL_API_LAST_API - _EGL_API_FIRST_API + 1) |
/** |
* Per-thread info |
*/ |
struct _egl_thread_info |
{ |
EGLint LastError; |
_EGLContext *CurrentContexts[_EGL_API_NUM_APIS]; |
/* use index for fast access to current context */ |
EGLint CurrentAPIIndex; |
}; |
/** |
* Return true if a client API enum is recognized. |
*/ |
static inline EGLBoolean |
_eglIsApiValid(EGLenum api) |
{ |
return (api >= _EGL_API_FIRST_API && api <= _EGL_API_LAST_API); |
} |
/** |
* Convert a client API enum to an index, for use by thread info. |
* The client API enum is assumed to be valid. |
*/ |
static inline EGLint |
_eglConvertApiToIndex(EGLenum api) |
{ |
return api - _EGL_API_FIRST_API; |
} |
/** |
* Convert an index, used by thread info, to a client API enum. |
* The index is assumed to be valid. |
*/ |
static inline EGLenum |
_eglConvertApiFromIndex(EGLint idx) |
{ |
return _EGL_API_FIRST_API + idx; |
} |
extern _EGLThreadInfo * |
_eglGetCurrentThread(void); |
extern void |
_eglDestroyCurrentThread(void); |
extern EGLBoolean |
_eglIsCurrentThreadDummy(void); |
extern _EGLContext * |
_eglGetAPIContext(EGLenum api); |
extern _EGLContext * |
_eglGetCurrentContext(void); |
extern EGLBoolean |
_eglError(EGLint errCode, const char *msg); |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLCURRENT_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/egldefines.h |
---|
0,0 → 1,51 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
/** |
* Internal EGL defines |
*/ |
#ifndef EGLDEFINES_INCLUDED |
#define EGLDEFINES_INCLUDED |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _EGL_MAX_EXTENSIONS_LEN 1000 |
#define _EGL_VENDOR_STRING "Mesa Project" |
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLDEFINES_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/egldisplay.c |
---|
0,0 → 1,522 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
/** |
* Functions related to EGLDisplay. |
*/ |
#include <assert.h> |
#include <stdlib.h> |
#include <string.h> |
#include "c11/threads.h" |
#include "eglcontext.h" |
#include "eglcurrent.h" |
#include "eglsurface.h" |
#include "egldisplay.h" |
#include "egldriver.h" |
#include "eglglobals.h" |
#include "egllog.h" |
/* Includes for _eglNativePlatformDetectNativeDisplay */ |
#ifdef HAVE_MINCORE |
#include <unistd.h> |
#include <sys/mman.h> |
#endif |
#ifdef HAVE_WAYLAND_PLATFORM |
#include <wayland-client.h> |
#endif |
#ifdef HAVE_DRM_PLATFORM |
#include <gbm.h> |
#endif |
/** |
* Map --with-egl-platforms names to platform types. |
*/ |
static const struct { |
_EGLPlatformType platform; |
const char *name; |
} egl_platforms[_EGL_NUM_PLATFORMS] = { |
{ _EGL_PLATFORM_WINDOWS, "gdi" }, |
{ _EGL_PLATFORM_X11, "x11" }, |
{ _EGL_PLATFORM_WAYLAND, "wayland" }, |
{ _EGL_PLATFORM_DRM, "drm" }, |
{ _EGL_PLATFORM_NULL, "null" }, |
{ _EGL_PLATFORM_ANDROID, "android" }, |
{ _EGL_PLATFORM_HAIKU, "haiku" } |
}; |
/** |
* Return the native platform by parsing EGL_PLATFORM. |
*/ |
static _EGLPlatformType |
_eglGetNativePlatformFromEnv(void) |
{ |
_EGLPlatformType plat = _EGL_INVALID_PLATFORM; |
const char *plat_name; |
EGLint i; |
plat_name = getenv("EGL_PLATFORM"); |
/* try deprecated env variable */ |
if (!plat_name || !plat_name[0]) |
plat_name = getenv("EGL_DISPLAY"); |
if (!plat_name || !plat_name[0]) |
return _EGL_INVALID_PLATFORM; |
for (i = 0; i < _EGL_NUM_PLATFORMS; i++) { |
if (strcmp(egl_platforms[i].name, plat_name) == 0) { |
plat = egl_platforms[i].platform; |
break; |
} |
} |
return plat; |
} |
/** |
* Perform validity checks on a generic pointer. |
*/ |
static EGLBoolean |
_eglPointerIsDereferencable(void *p) |
{ |
#ifdef HAVE_MINCORE |
uintptr_t addr = (uintptr_t) p; |
unsigned char valid = 0; |
const long page_size = getpagesize(); |
if (p == NULL) |
return EGL_FALSE; |
/* align addr to page_size */ |
addr &= ~(page_size - 1); |
if (mincore((void *) addr, page_size, &valid) < 0) { |
_eglLog(_EGL_DEBUG, "mincore failed: %m"); |
return EGL_FALSE; |
} |
return (valid & 0x01) == 0x01; |
#else |
return p != NULL; |
#endif |
} |
/** |
* Try detecting native platform with the help of native display characteristcs. |
*/ |
static _EGLPlatformType |
_eglNativePlatformDetectNativeDisplay(void *nativeDisplay) |
{ |
if (nativeDisplay == EGL_DEFAULT_DISPLAY) |
return _EGL_INVALID_PLATFORM; |
if (_eglPointerIsDereferencable(nativeDisplay)) { |
void *first_pointer = *(void **) nativeDisplay; |
(void) first_pointer; /* silence unused var warning */ |
#ifdef HAVE_WAYLAND_PLATFORM |
/* wl_display is a wl_proxy, which is a wl_object. |
* wl_object's first element points to the interfacetype. */ |
if (first_pointer == &wl_display_interface) |
return _EGL_PLATFORM_WAYLAND; |
#endif |
#ifdef HAVE_DRM_PLATFORM |
/* gbm has a pointer to its constructor as first element. */ |
if (first_pointer == gbm_create_device) |
return _EGL_PLATFORM_DRM; |
#endif |
#ifdef HAVE_X11_PLATFORM |
/* If not matched to any other platform, fallback to x11. */ |
return _EGL_PLATFORM_X11; |
#endif |
#ifdef HAVE_HAIKU_PLATFORM |
return _EGL_PLATFORM_HAIKU; |
#endif |
} |
return _EGL_INVALID_PLATFORM; |
} |
/** |
* Return the native platform. It is the platform of the EGL native types. |
*/ |
_EGLPlatformType |
_eglGetNativePlatform(void *nativeDisplay) |
{ |
static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM; |
char *detection_method = NULL; |
if (native_platform == _EGL_INVALID_PLATFORM) { |
native_platform = _eglGetNativePlatformFromEnv(); |
detection_method = "environment overwrite"; |
if (native_platform == _EGL_INVALID_PLATFORM) { |
native_platform = _eglNativePlatformDetectNativeDisplay(nativeDisplay); |
detection_method = "autodetected"; |
if (native_platform == _EGL_INVALID_PLATFORM) { |
native_platform = _EGL_NATIVE_PLATFORM; |
detection_method = "build-time configuration"; |
} |
} |
} |
if (detection_method != NULL) |
_eglLog(_EGL_DEBUG, "Native platform type: %s (%s)", |
egl_platforms[native_platform].name, detection_method); |
return native_platform; |
} |
/** |
* Finish display management. |
*/ |
void |
_eglFiniDisplay(void) |
{ |
_EGLDisplay *dpyList, *dpy; |
/* atexit function is called with global mutex locked */ |
dpyList = _eglGlobal.DisplayList; |
while (dpyList) { |
EGLint i; |
/* pop list head */ |
dpy = dpyList; |
dpyList = dpyList->Next; |
for (i = 0; i < _EGL_NUM_RESOURCES; i++) { |
if (dpy->ResourceLists[i]) { |
_eglLog(_EGL_DEBUG, "Display %p is destroyed with resources", dpy); |
break; |
} |
} |
free(dpy); |
} |
_eglGlobal.DisplayList = NULL; |
} |
/** |
* Find the display corresponding to the specified native display, or create a |
* new one. |
*/ |
_EGLDisplay * |
_eglFindDisplay(_EGLPlatformType plat, void *plat_dpy) |
{ |
_EGLDisplay *dpy; |
if (plat == _EGL_INVALID_PLATFORM) |
return NULL; |
mtx_lock(_eglGlobal.Mutex); |
/* search the display list first */ |
dpy = _eglGlobal.DisplayList; |
while (dpy) { |
if (dpy->Platform == plat && dpy->PlatformDisplay == plat_dpy) |
break; |
dpy = dpy->Next; |
} |
/* create a new display */ |
if (!dpy) { |
dpy = calloc(1, sizeof(_EGLDisplay)); |
if (dpy) { |
mtx_init(&dpy->Mutex, mtx_plain); |
dpy->Platform = plat; |
dpy->PlatformDisplay = plat_dpy; |
/* add to the display list */ |
dpy->Next = _eglGlobal.DisplayList; |
_eglGlobal.DisplayList = dpy; |
} |
} |
mtx_unlock(_eglGlobal.Mutex); |
return dpy; |
} |
/** |
* Destroy the contexts and surfaces that are linked to the display. |
*/ |
void |
_eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *display) |
{ |
_EGLResource *list; |
list = display->ResourceLists[_EGL_RESOURCE_CONTEXT]; |
while (list) { |
_EGLContext *ctx = (_EGLContext *) list; |
list = list->Next; |
_eglUnlinkContext(ctx); |
drv->API.DestroyContext(drv, display, ctx); |
} |
assert(!display->ResourceLists[_EGL_RESOURCE_CONTEXT]); |
list = display->ResourceLists[_EGL_RESOURCE_SURFACE]; |
while (list) { |
_EGLSurface *surf = (_EGLSurface *) list; |
list = list->Next; |
_eglUnlinkSurface(surf); |
drv->API.DestroySurface(drv, display, surf); |
} |
assert(!display->ResourceLists[_EGL_RESOURCE_SURFACE]); |
} |
/** |
* Free all the data hanging of an _EGLDisplay object, but not |
* the object itself. |
*/ |
void |
_eglCleanupDisplay(_EGLDisplay *disp) |
{ |
if (disp->Configs) { |
_eglDestroyArray(disp->Configs, free); |
disp->Configs = NULL; |
} |
/* XXX incomplete */ |
} |
/** |
* Return EGL_TRUE if the given handle is a valid handle to a display. |
*/ |
EGLBoolean |
_eglCheckDisplayHandle(EGLDisplay dpy) |
{ |
_EGLDisplay *cur; |
mtx_lock(_eglGlobal.Mutex); |
cur = _eglGlobal.DisplayList; |
while (cur) { |
if (cur == (_EGLDisplay *) dpy) |
break; |
cur = cur->Next; |
} |
mtx_unlock(_eglGlobal.Mutex); |
return (cur != NULL); |
} |
/** |
* Return EGL_TRUE if the given resource is valid. That is, the display does |
* own the resource. |
*/ |
EGLBoolean |
_eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy) |
{ |
_EGLResource *list = dpy->ResourceLists[type]; |
if (!res) |
return EGL_FALSE; |
while (list) { |
if (res == (void *) list) { |
assert(list->Display == dpy); |
break; |
} |
list = list->Next; |
} |
return (list != NULL); |
} |
/** |
* Initialize a display resource. The size of the subclass object is |
* specified. |
* |
* This is supposed to be called from the initializers of subclasses, such as |
* _eglInitContext or _eglInitSurface. |
*/ |
void |
_eglInitResource(_EGLResource *res, EGLint size, _EGLDisplay *dpy) |
{ |
memset(res, 0, size); |
res->Display = dpy; |
res->RefCount = 1; |
} |
/** |
* Increment reference count for the resource. |
*/ |
void |
_eglGetResource(_EGLResource *res) |
{ |
assert(res && res->RefCount > 0); |
/* hopefully a resource is always manipulated with its display locked */ |
res->RefCount++; |
} |
/** |
* Decrement reference count for the resource. |
*/ |
EGLBoolean |
_eglPutResource(_EGLResource *res) |
{ |
assert(res && res->RefCount > 0); |
res->RefCount--; |
return (!res->RefCount); |
} |
/** |
* Link a resource to its display. |
*/ |
void |
_eglLinkResource(_EGLResource *res, _EGLResourceType type) |
{ |
assert(res->Display); |
res->IsLinked = EGL_TRUE; |
res->Next = res->Display->ResourceLists[type]; |
res->Display->ResourceLists[type] = res; |
_eglGetResource(res); |
} |
/** |
* Unlink a linked resource from its display. |
*/ |
void |
_eglUnlinkResource(_EGLResource *res, _EGLResourceType type) |
{ |
_EGLResource *prev; |
prev = res->Display->ResourceLists[type]; |
if (prev != res) { |
while (prev) { |
if (prev->Next == res) |
break; |
prev = prev->Next; |
} |
assert(prev); |
prev->Next = res->Next; |
} |
else { |
res->Display->ResourceLists[type] = res->Next; |
} |
res->Next = NULL; |
res->IsLinked = EGL_FALSE; |
_eglPutResource(res); |
/* We always unlink before destroy. The driver still owns a reference */ |
assert(res->RefCount); |
} |
#ifdef HAVE_X11_PLATFORM |
static EGLBoolean |
_eglParseX11DisplayAttribList(const EGLint *attrib_list) |
{ |
int i; |
if (attrib_list == NULL) { |
return EGL_TRUE; |
} |
for (i = 0; attrib_list[i] != EGL_NONE; i += 2) { |
EGLint attrib = attrib_list[i]; |
EGLint value = attrib_list[i + 1]; |
/* EGL_EXT_platform_x11 recognizes exactly one attribute, |
* EGL_PLATFORM_X11_SCREEN_EXT, which is optional. |
* |
* Mesa supports connecting to only the default screen, so we reject |
* screen != 0. |
*/ |
if (attrib != EGL_PLATFORM_X11_SCREEN_EXT || value != 0) { |
_eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay"); |
return EGL_FALSE; |
} |
} |
return EGL_TRUE; |
} |
_EGLDisplay* |
_eglGetX11Display(Display *native_display, |
const EGLint *attrib_list) |
{ |
if (!_eglParseX11DisplayAttribList(attrib_list)) { |
return NULL; |
} |
return _eglFindDisplay(_EGL_PLATFORM_X11, native_display); |
} |
#endif /* HAVE_X11_PLATFORM */ |
#ifdef HAVE_DRM_PLATFORM |
_EGLDisplay* |
_eglGetGbmDisplay(struct gbm_device *native_display, |
const EGLint *attrib_list) |
{ |
/* EGL_MESA_platform_gbm recognizes no attributes. */ |
if (attrib_list != NULL && attrib_list[0] != EGL_NONE) { |
_eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay"); |
return NULL; |
} |
return _eglFindDisplay(_EGL_PLATFORM_DRM, native_display); |
} |
#endif /* HAVE_DRM_PLATFORM */ |
#ifdef HAVE_WAYLAND_PLATFORM |
_EGLDisplay* |
_eglGetWaylandDisplay(struct wl_display *native_display, |
const EGLint *attrib_list) |
{ |
/* EGL_EXT_platform_wayland recognizes no attributes. */ |
if (attrib_list != NULL && attrib_list[0] != EGL_NONE) { |
_eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay"); |
return NULL; |
} |
return _eglFindDisplay(_EGL_PLATFORM_WAYLAND, native_display); |
} |
#endif /* HAVE_WAYLAND_PLATFORM */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/egldisplay.h |
---|
0,0 → 1,281 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLDISPLAY_INCLUDED |
#define EGLDISPLAY_INCLUDED |
#include "c99_compat.h" |
#include "c11/threads.h" |
#include "egltypedefs.h" |
#include "egldefines.h" |
#include "eglarray.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
enum _egl_platform_type { |
_EGL_PLATFORM_WINDOWS, |
_EGL_PLATFORM_X11, |
_EGL_PLATFORM_WAYLAND, |
_EGL_PLATFORM_DRM, |
_EGL_PLATFORM_NULL, |
_EGL_PLATFORM_ANDROID, |
_EGL_PLATFORM_HAIKU, |
_EGL_NUM_PLATFORMS, |
_EGL_INVALID_PLATFORM = -1 |
}; |
typedef enum _egl_platform_type _EGLPlatformType; |
enum _egl_resource_type { |
_EGL_RESOURCE_CONTEXT, |
_EGL_RESOURCE_SURFACE, |
_EGL_RESOURCE_IMAGE, |
_EGL_RESOURCE_SYNC, |
_EGL_NUM_RESOURCES |
}; |
/* this cannot and need not go into egltypedefs.h */ |
typedef enum _egl_resource_type _EGLResourceType; |
/** |
* A resource of a display. |
*/ |
struct _egl_resource |
{ |
/* which display the resource belongs to */ |
_EGLDisplay *Display; |
EGLBoolean IsLinked; |
EGLint RefCount; |
/* used to link resources of the same type */ |
_EGLResource *Next; |
}; |
/** |
* Optional EGL extensions info. |
*/ |
struct _egl_extensions |
{ |
EGLBoolean MESA_drm_display; |
EGLBoolean MESA_drm_image; |
EGLBoolean MESA_configless_context; |
EGLBoolean WL_bind_wayland_display; |
EGLBoolean WL_create_wayland_buffer_from_image; |
EGLBoolean KHR_image_base; |
EGLBoolean KHR_image_pixmap; |
EGLBoolean KHR_vg_parent_image; |
EGLBoolean KHR_get_all_proc_addresses; |
EGLBoolean KHR_gl_texture_2D_image; |
EGLBoolean KHR_gl_texture_cubemap_image; |
EGLBoolean KHR_gl_texture_3D_image; |
EGLBoolean KHR_gl_renderbuffer_image; |
EGLBoolean KHR_reusable_sync; |
EGLBoolean KHR_fence_sync; |
EGLBoolean KHR_wait_sync; |
EGLBoolean KHR_cl_event2; |
EGLBoolean KHR_surfaceless_context; |
EGLBoolean KHR_create_context; |
EGLBoolean NOK_swap_region; |
EGLBoolean NOK_texture_from_pixmap; |
EGLBoolean ANDROID_image_native_buffer; |
EGLBoolean CHROMIUM_sync_control; |
EGLBoolean NV_post_sub_buffer; |
EGLBoolean EXT_create_context_robustness; |
EGLBoolean EXT_buffer_age; |
EGLBoolean EXT_swap_buffers_with_damage; |
EGLBoolean EXT_image_dma_buf_import; |
EGLBoolean MESA_image_dma_buf_export; |
}; |
struct _egl_display |
{ |
/* used to link displays */ |
_EGLDisplay *Next; |
mtx_t Mutex; |
_EGLPlatformType Platform; /**< The type of the platform display */ |
void *PlatformDisplay; /**< A pointer to the platform display */ |
_EGLDriver *Driver; /**< Matched driver of the display */ |
EGLBoolean Initialized; /**< True if the display is initialized */ |
/* options that affect how the driver initializes the display */ |
struct { |
EGLBoolean TestOnly; /**< Driver should not set fields when true */ |
EGLBoolean UseFallback; /**< Use fallback driver (sw or less features) */ |
} Options; |
/* these fields are set by the driver during init */ |
void *DriverData; /**< Driver private data */ |
EGLint VersionMajor; /**< EGL major version */ |
EGLint VersionMinor; /**< EGL minor version */ |
EGLint ClientAPIs; /**< Bitmask of APIs supported (EGL_xxx_BIT) */ |
_EGLExtensions Extensions; /**< Extensions supported */ |
/* these fields are derived from above */ |
char VersionString[100]; /**< EGL_VERSION */ |
char ClientAPIsString[100]; /**< EGL_CLIENT_APIS */ |
char ExtensionsString[_EGL_MAX_EXTENSIONS_LEN]; /**< EGL_EXTENSIONS */ |
_EGLArray *Screens; |
_EGLArray *Configs; |
/* lists of resources */ |
_EGLResource *ResourceLists[_EGL_NUM_RESOURCES]; |
}; |
extern _EGLPlatformType |
_eglGetNativePlatform(void *nativeDisplay); |
extern void |
_eglFiniDisplay(void); |
extern _EGLDisplay * |
_eglFindDisplay(_EGLPlatformType plat, void *plat_dpy); |
extern void |
_eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy); |
extern void |
_eglCleanupDisplay(_EGLDisplay *disp); |
extern EGLBoolean |
_eglCheckDisplayHandle(EGLDisplay dpy); |
extern EGLBoolean |
_eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy); |
/** |
* Lookup a handle to find the linked display. |
* Return NULL if the handle has no corresponding linked display. |
*/ |
static inline _EGLDisplay * |
_eglLookupDisplay(EGLDisplay display) |
{ |
_EGLDisplay *dpy = (_EGLDisplay *) display; |
if (!_eglCheckDisplayHandle(display)) |
dpy = NULL; |
return dpy; |
} |
/** |
* Return the handle of a linked display, or EGL_NO_DISPLAY. |
*/ |
static inline EGLDisplay |
_eglGetDisplayHandle(_EGLDisplay *dpy) |
{ |
return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY); |
} |
extern void |
_eglInitResource(_EGLResource *res, EGLint size, _EGLDisplay *dpy); |
extern void |
_eglGetResource(_EGLResource *res); |
extern EGLBoolean |
_eglPutResource(_EGLResource *res); |
extern void |
_eglLinkResource(_EGLResource *res, _EGLResourceType type); |
extern void |
_eglUnlinkResource(_EGLResource *res, _EGLResourceType type); |
/** |
* Return true if the resource is linked. |
*/ |
static inline EGLBoolean |
_eglIsResourceLinked(_EGLResource *res) |
{ |
return res->IsLinked; |
} |
#ifdef HAVE_X11_PLATFORM |
_EGLDisplay* |
_eglGetX11Display(Display *native_display, const EGLint *attrib_list); |
#endif |
#ifdef HAVE_DRM_PLATFORM |
struct gbm_device; |
_EGLDisplay* |
_eglGetGbmDisplay(struct gbm_device *native_display, |
const EGLint *attrib_list); |
#endif |
#ifdef HAVE_WAYLAND_PLATFORM |
struct wl_display; |
_EGLDisplay* |
_eglGetWaylandDisplay(struct wl_display *native_display, |
const EGLint *attrib_list); |
#endif |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLDISPLAY_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/egldriver.c |
---|
0,0 → 1,358 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
/** |
* Functions for choosing and opening/loading device drivers. |
*/ |
#include <assert.h> |
#include <string.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include "c11/threads.h" |
#include "eglstring.h" |
#include "egldefines.h" |
#include "egldisplay.h" |
#include "egldriver.h" |
#include "egllog.h" |
typedef struct _egl_module { |
char *Name; |
_EGLMain_t BuiltIn; |
_EGLDriver *Driver; |
} _EGLModule; |
static mtx_t _eglModuleMutex = _MTX_INITIALIZER_NP; |
static _EGLArray *_eglModules; |
const struct { |
const char *name; |
_EGLMain_t main; |
} _eglBuiltInDrivers[] = { |
#ifdef _EGL_BUILT_IN_DRIVER_DRI2 |
{ "egl_dri2", _eglBuiltInDriverDRI2 }, |
#endif |
#ifdef _EGL_BUILT_IN_DRIVER_HAIKU |
{ "egl_haiku", _eglBuiltInDriverHaiku }, |
#endif |
{ NULL, NULL } |
}; |
/** |
* Load a module and create the driver object. |
*/ |
static EGLBoolean |
_eglLoadModule(_EGLModule *mod) |
{ |
_EGLDriver *drv; |
if (mod->Driver) |
return EGL_TRUE; |
if (!mod->BuiltIn) |
return EGL_FALSE; |
drv = mod->BuiltIn(NULL); |
if (!drv || !drv->Name) |
return EGL_FALSE; |
mod->Driver = drv; |
return EGL_TRUE; |
} |
/** |
* Unload a module. |
*/ |
static void |
_eglUnloadModule(_EGLModule *mod) |
{ |
#if defined(_EGL_OS_UNIX) |
/* destroy the driver */ |
if (mod->Driver && mod->Driver->Unload) |
mod->Driver->Unload(mod->Driver); |
#elif defined(_EGL_OS_WINDOWS) |
/* XXX Windows unloads DLLs before atexit */ |
#endif |
mod->Driver = NULL; |
} |
/** |
* Add a module to the module array. |
*/ |
static _EGLModule * |
_eglAddModule(const char *name) |
{ |
_EGLModule *mod; |
EGLint i; |
if (!_eglModules) { |
_eglModules = _eglCreateArray("Module", 8); |
if (!_eglModules) |
return NULL; |
} |
/* find duplicates */ |
for (i = 0; i < _eglModules->Size; i++) { |
mod = _eglModules->Elements[i]; |
if (strcmp(mod->Name, name) == 0) |
return mod; |
} |
/* allocate a new one */ |
mod = calloc(1, sizeof(*mod)); |
if (mod) { |
mod->Name = _eglstrdup(name); |
if (!mod->Name) { |
free(mod); |
mod = NULL; |
} |
} |
if (mod) { |
_eglAppendArray(_eglModules, (void *) mod); |
_eglLog(_EGL_DEBUG, "added %s to module array", mod->Name); |
} |
return mod; |
} |
/** |
* Free a module. |
*/ |
static void |
_eglFreeModule(void *module) |
{ |
_EGLModule *mod = (_EGLModule *) module; |
_eglUnloadModule(mod); |
free(mod->Name); |
free(mod); |
} |
/** |
* Add the user driver to the module array. |
* |
* The user driver is specified by EGL_DRIVER. |
*/ |
static EGLBoolean |
_eglAddUserDriver(void) |
{ |
char *env; |
env = getenv("EGL_DRIVER"); |
if (env) { |
EGLint i; |
for (i = 0; _eglBuiltInDrivers[i].name; i++) { |
if (!strcmp(_eglBuiltInDrivers[i].name, env)) { |
_EGLModule *mod = _eglAddModule(env); |
if (mod) |
mod->BuiltIn = _eglBuiltInDrivers[i].main; |
return EGL_TRUE; |
} |
} |
} |
return EGL_FALSE; |
} |
/** |
* Add built-in drivers to the module array. |
*/ |
static void |
_eglAddBuiltInDrivers(void) |
{ |
_EGLModule *mod; |
EGLint i; |
for (i = 0; _eglBuiltInDrivers[i].name; i++) { |
mod = _eglAddModule(_eglBuiltInDrivers[i].name); |
if (mod) |
mod->BuiltIn = _eglBuiltInDrivers[i].main; |
} |
} |
/** |
* Add drivers to the module array. Drivers will be loaded as they are matched |
* to displays. |
*/ |
static EGLBoolean |
_eglAddDrivers(void) |
{ |
if (_eglModules) |
return EGL_TRUE; |
if (!_eglAddUserDriver()) { |
/* |
* Add other drivers only when EGL_DRIVER is not set. The order here |
* decides the priorities. |
*/ |
_eglAddBuiltInDrivers(); |
} |
return (_eglModules != NULL); |
} |
/** |
* A helper function for _eglMatchDriver. It finds the first driver that can |
* initialize the display and return. |
*/ |
static _EGLDriver * |
_eglMatchAndInitialize(_EGLDisplay *dpy) |
{ |
_EGLDriver *drv = NULL; |
EGLint i = 0; |
if (!_eglAddDrivers()) { |
_eglLog(_EGL_WARNING, "failed to find any driver"); |
return NULL; |
} |
if (dpy->Driver) { |
drv = dpy->Driver; |
/* no re-matching? */ |
if (!drv->API.Initialize(drv, dpy)) |
drv = NULL; |
return drv; |
} |
while (i < _eglModules->Size) { |
_EGLModule *mod = (_EGLModule *) _eglModules->Elements[i]; |
if (!_eglLoadModule(mod)) { |
/* remove invalid modules */ |
_eglEraseArray(_eglModules, i, _eglFreeModule); |
continue; |
} |
if (mod->Driver->API.Initialize(mod->Driver, dpy)) { |
drv = mod->Driver; |
break; |
} |
else { |
i++; |
} |
} |
return drv; |
} |
/** |
* Match a display to a driver. The display is initialized unless test_only is |
* true. The matching is done by finding the first driver that can initialize |
* the display. |
*/ |
_EGLDriver * |
_eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only) |
{ |
_EGLDriver *best_drv; |
assert(!dpy->Initialized); |
mtx_lock(&_eglModuleMutex); |
/* set options */ |
dpy->Options.TestOnly = test_only; |
dpy->Options.UseFallback = EGL_FALSE; |
best_drv = _eglMatchAndInitialize(dpy); |
if (!best_drv) { |
dpy->Options.UseFallback = EGL_TRUE; |
best_drv = _eglMatchAndInitialize(dpy); |
} |
mtx_unlock(&_eglModuleMutex); |
if (best_drv) { |
_eglLog(_EGL_DEBUG, "the best driver is %s%s", |
best_drv->Name, (test_only) ? " (test only) " : ""); |
if (!test_only) { |
dpy->Driver = best_drv; |
dpy->Initialized = EGL_TRUE; |
} |
} |
return best_drv; |
} |
__eglMustCastToProperFunctionPointerType |
_eglGetDriverProc(const char *procname) |
{ |
EGLint i; |
_EGLProc proc = NULL; |
if (!_eglModules) { |
/* load the driver for the default display */ |
EGLDisplay egldpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); |
_EGLDisplay *dpy = _eglLookupDisplay(egldpy); |
if (!dpy || !_eglMatchDriver(dpy, EGL_TRUE)) |
return NULL; |
} |
for (i = 0; i < _eglModules->Size; i++) { |
_EGLModule *mod = (_EGLModule *) _eglModules->Elements[i]; |
if (!mod->Driver) |
break; |
proc = mod->Driver->API.GetProcAddress(mod->Driver, procname); |
if (proc) |
break; |
} |
return proc; |
} |
/** |
* Unload all drivers. |
*/ |
void |
_eglUnloadDrivers(void) |
{ |
/* this is called at atexit time */ |
if (_eglModules) { |
_eglDestroyArray(_eglModules, _eglFreeModule); |
_eglModules = NULL; |
} |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/egldriver.h |
---|
0,0 → 1,129 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLDRIVER_INCLUDED |
#define EGLDRIVER_INCLUDED |
#include "c99_compat.h" |
#include "egltypedefs.h" |
#include "eglapi.h" |
#include <stddef.h> |
#ifdef __cplusplus |
extern "C" { |
#endif |
/** |
* Define an inline driver typecast function. |
* |
* Note that this macro defines a function and should not be ended with a |
* semicolon when used. |
*/ |
#define _EGL_DRIVER_TYPECAST(drvtype, egltype, code) \ |
static inline struct drvtype *drvtype(const egltype *obj) \ |
{ return (struct drvtype *) code; } |
/** |
* Define the driver typecast functions for _EGLDriver, _EGLDisplay, |
* _EGLContext, _EGLSurface, and _EGLConfig. |
* |
* Note that this macro defines several functions and should not be ended with |
* a semicolon when used. |
*/ |
#define _EGL_DRIVER_STANDARD_TYPECASTS(drvname) \ |
_EGL_DRIVER_TYPECAST(drvname ## _driver, _EGLDriver, obj) \ |
/* note that this is not a direct cast */ \ |
_EGL_DRIVER_TYPECAST(drvname ## _display, _EGLDisplay, obj->DriverData) \ |
_EGL_DRIVER_TYPECAST(drvname ## _context, _EGLContext, obj) \ |
_EGL_DRIVER_TYPECAST(drvname ## _surface, _EGLSurface, obj) \ |
_EGL_DRIVER_TYPECAST(drvname ## _config, _EGLConfig, obj) |
typedef _EGLDriver *(*_EGLMain_t)(const char *args); |
/** |
* Base class for device drivers. |
*/ |
struct _egl_driver |
{ |
const char *Name; /**< name of this driver */ |
/** |
* Release the driver resource. |
* |
* It is called before dlclose(). |
*/ |
void (*Unload)(_EGLDriver *drv); |
_EGLAPI API; /**< EGL API dispatch table */ |
}; |
extern _EGLDriver * |
_eglBuiltInDriverDRI2(const char *args); |
extern _EGLDriver* |
_eglBuiltInDriverHaiku(const char* args); |
extern _EGLDriver * |
_eglMatchDriver(_EGLDisplay *dpy, EGLBoolean test_only); |
extern __eglMustCastToProperFunctionPointerType |
_eglGetDriverProc(const char *procname); |
extern void |
_eglUnloadDrivers(void); |
/* defined in eglfallbacks.c */ |
extern void |
_eglInitDriverFallbacks(_EGLDriver *drv); |
extern void |
_eglSearchPathForEach(EGLBoolean (*callback)(const char *, size_t, void *), |
void *callback_data); |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLDRIVER_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglfallbacks.c |
---|
0,0 → 1,109 |
/************************************************************************** |
* |
* Copyright 2010 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#include <string.h> |
#include "egltypedefs.h" |
#include "egldriver.h" |
#include "eglconfig.h" |
#include "eglcontext.h" |
#include "eglsurface.h" |
#include "eglsync.h" |
static EGLBoolean |
_eglReturnFalse(void) |
{ |
return EGL_FALSE; |
} |
/** |
* Plug all the available fallback routines into the given driver's |
* dispatch table. |
*/ |
void |
_eglInitDriverFallbacks(_EGLDriver *drv) |
{ |
memset(&drv->API, 0, sizeof(drv->API)); |
/* the driver has to implement these */ |
drv->API.Initialize = NULL; |
drv->API.Terminate = NULL; |
drv->API.GetConfigs = _eglGetConfigs; |
drv->API.ChooseConfig = _eglChooseConfig; |
drv->API.GetConfigAttrib = _eglGetConfigAttrib; |
drv->API.CreateContext = (CreateContext_t) _eglReturnFalse; |
drv->API.DestroyContext = (DestroyContext_t) _eglReturnFalse; |
drv->API.MakeCurrent = (MakeCurrent_t) _eglReturnFalse; |
drv->API.QueryContext = _eglQueryContext; |
drv->API.CreateWindowSurface = (CreateWindowSurface_t) _eglReturnFalse; |
drv->API.CreatePixmapSurface = (CreatePixmapSurface_t) _eglReturnFalse; |
drv->API.CreatePbufferSurface = (CreatePbufferSurface_t) _eglReturnFalse; |
drv->API.CreatePbufferFromClientBuffer = |
(CreatePbufferFromClientBuffer_t) _eglReturnFalse; |
drv->API.DestroySurface = (DestroySurface_t) _eglReturnFalse; |
drv->API.QuerySurface = _eglQuerySurface; |
drv->API.SurfaceAttrib = _eglSurfaceAttrib; |
drv->API.BindTexImage = (BindTexImage_t) _eglReturnFalse; |
drv->API.ReleaseTexImage = (ReleaseTexImage_t) _eglReturnFalse; |
drv->API.CopyBuffers = (CopyBuffers_t) _eglReturnFalse; |
drv->API.SwapBuffers = (SwapBuffers_t) _eglReturnFalse; |
drv->API.SwapInterval = _eglSwapInterval; |
drv->API.WaitClient = (WaitClient_t) _eglReturnFalse; |
drv->API.WaitNative = (WaitNative_t) _eglReturnFalse; |
drv->API.GetProcAddress = (GetProcAddress_t) _eglReturnFalse; |
drv->API.CreateImageKHR = NULL; |
drv->API.DestroyImageKHR = NULL; |
drv->API.CreateSyncKHR = NULL; |
drv->API.DestroySyncKHR = NULL; |
drv->API.ClientWaitSyncKHR = NULL; |
drv->API.WaitSyncKHR = NULL; |
drv->API.SignalSyncKHR = NULL; |
drv->API.GetSyncAttribKHR = _eglGetSyncAttribKHR; |
#ifdef EGL_MESA_drm_image |
drv->API.CreateDRMImageMESA = NULL; |
drv->API.ExportDRMImageMESA = NULL; |
#endif |
#ifdef EGL_NOK_swap_region |
drv->API.SwapBuffersRegionNOK = NULL; |
#endif |
#ifdef EGL_MESA_image_dma_buf_export |
drv->API.ExportDMABUFImageQueryMESA = NULL; |
drv->API.ExportDMABUFImageMESA = NULL; |
#endif |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglglobals.c |
---|
0,0 → 1,100 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#include <stdlib.h> |
#include <assert.h> |
#include "c11/threads.h" |
#include "eglglobals.h" |
#include "egldisplay.h" |
#include "egldriver.h" |
static mtx_t _eglGlobalMutex = _MTX_INITIALIZER_NP; |
struct _egl_global _eglGlobal = |
{ |
&_eglGlobalMutex, /* Mutex */ |
NULL, /* DisplayList */ |
2, /* NumAtExitCalls */ |
{ |
/* default AtExitCalls, called in reverse order */ |
_eglUnloadDrivers, /* always called last */ |
_eglFiniDisplay |
}, |
/* ClientExtensions */ |
{ |
true, /* EGL_EXT_client_extensions */ |
true, /* EGL_EXT_platform_base */ |
true, /* EGL_EXT_platform_x11 */ |
true, /* EGL_EXT_platform_wayland */ |
true, /* EGL_MESA_platform_gbm */ |
true, /* EGL_KHR_client_get_all_proc_addresses */ |
}, |
/* ClientExtensionsString */ |
"EGL_EXT_client_extensions" |
" EGL_EXT_platform_base" |
" EGL_EXT_platform_x11" |
" EGL_EXT_platform_wayland" |
" EGL_MESA_platform_gbm" |
" EGL_KHR_client_get_all_proc_addresses" |
}; |
static void |
_eglAtExit(void) |
{ |
EGLint i; |
for (i = _eglGlobal.NumAtExitCalls - 1; i >= 0; i--) |
_eglGlobal.AtExitCalls[i](); |
} |
void |
_eglAddAtExitCall(void (*func)(void)) |
{ |
if (func) { |
static EGLBoolean registered = EGL_FALSE; |
mtx_lock(_eglGlobal.Mutex); |
if (!registered) { |
atexit(_eglAtExit); |
registered = EGL_TRUE; |
} |
assert(_eglGlobal.NumAtExitCalls < ARRAY_SIZE(_eglGlobal.AtExitCalls)); |
_eglGlobal.AtExitCalls[_eglGlobal.NumAtExitCalls++] = func; |
mtx_unlock(_eglGlobal.Mutex); |
} |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglglobals.h |
---|
0,0 → 1,73 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLGLOBALS_INCLUDED |
#define EGLGLOBALS_INCLUDED |
#include <stdbool.h> |
#include "c11/threads.h" |
#include "egltypedefs.h" |
/** |
* Global library data |
*/ |
struct _egl_global |
{ |
mtx_t *Mutex; |
/* the list of all displays */ |
_EGLDisplay *DisplayList; |
EGLint NumAtExitCalls; |
void (*AtExitCalls[10])(void); |
struct _egl_client_extensions { |
bool EXT_client_extensions; |
bool EXT_platform_base; |
bool EXT_platform_x11; |
bool EXT_platform_wayland; |
bool MESA_platform_gbm; |
bool KHR_get_all_proc_addresses; |
} ClientExtensions; |
const char *ClientExtensionString; |
}; |
extern struct _egl_global _eglGlobal; |
extern void |
_eglAddAtExitCall(void (*func)(void)); |
#endif /* EGLGLOBALS_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglimage.c |
---|
0,0 → 1,193 |
/************************************************************************** |
* |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#include <assert.h> |
#include <string.h> |
#include "eglimage.h" |
#include "egllog.h" |
/** |
* Parse the list of image attributes and return the proper error code. |
*/ |
EGLint |
_eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy, |
const EGLint *attrib_list) |
{ |
EGLint i, err = EGL_SUCCESS; |
(void) dpy; |
memset(attrs, 0, sizeof(*attrs)); |
attrs->ImagePreserved = EGL_FALSE; |
attrs->GLTextureLevel = 0; |
attrs->GLTextureZOffset = 0; |
if (!attrib_list) |
return err; |
for (i = 0; attrib_list[i] != EGL_NONE; i++) { |
EGLint attr = attrib_list[i++]; |
EGLint val = attrib_list[i]; |
switch (attr) { |
/* EGL_KHR_image_base */ |
case EGL_IMAGE_PRESERVED_KHR: |
attrs->ImagePreserved = val; |
break; |
/* EGL_KHR_gl_image */ |
case EGL_GL_TEXTURE_LEVEL_KHR: |
attrs->GLTextureLevel = val; |
break; |
case EGL_GL_TEXTURE_ZOFFSET_KHR: |
attrs->GLTextureZOffset = val; |
break; |
/* EGL_MESA_drm_image */ |
case EGL_WIDTH: |
attrs->Width = val; |
break; |
case EGL_HEIGHT: |
attrs->Height = val; |
break; |
case EGL_DRM_BUFFER_FORMAT_MESA: |
attrs->DRMBufferFormatMESA = val; |
break; |
case EGL_DRM_BUFFER_USE_MESA: |
attrs->DRMBufferUseMESA = val; |
break; |
case EGL_DRM_BUFFER_STRIDE_MESA: |
attrs->DRMBufferStrideMESA = val; |
break; |
/* EGL_WL_bind_wayland_display */ |
case EGL_WAYLAND_PLANE_WL: |
attrs->PlaneWL = val; |
break; |
case EGL_LINUX_DRM_FOURCC_EXT: |
attrs->DMABufFourCC.Value = val; |
attrs->DMABufFourCC.IsPresent = EGL_TRUE; |
break; |
case EGL_DMA_BUF_PLANE0_FD_EXT: |
attrs->DMABufPlaneFds[0].Value = val; |
attrs->DMABufPlaneFds[0].IsPresent = EGL_TRUE; |
break; |
case EGL_DMA_BUF_PLANE0_OFFSET_EXT: |
attrs->DMABufPlaneOffsets[0].Value = val; |
attrs->DMABufPlaneOffsets[0].IsPresent = EGL_TRUE; |
break; |
case EGL_DMA_BUF_PLANE0_PITCH_EXT: |
attrs->DMABufPlanePitches[0].Value = val; |
attrs->DMABufPlanePitches[0].IsPresent = EGL_TRUE; |
break; |
case EGL_DMA_BUF_PLANE1_FD_EXT: |
attrs->DMABufPlaneFds[1].Value = val; |
attrs->DMABufPlaneFds[1].IsPresent = EGL_TRUE; |
break; |
case EGL_DMA_BUF_PLANE1_OFFSET_EXT: |
attrs->DMABufPlaneOffsets[1].Value = val; |
attrs->DMABufPlaneOffsets[1].IsPresent = EGL_TRUE; |
break; |
case EGL_DMA_BUF_PLANE1_PITCH_EXT: |
attrs->DMABufPlanePitches[1].Value = val; |
attrs->DMABufPlanePitches[1].IsPresent = EGL_TRUE; |
break; |
case EGL_DMA_BUF_PLANE2_FD_EXT: |
attrs->DMABufPlaneFds[2].Value = val; |
attrs->DMABufPlaneFds[2].IsPresent = EGL_TRUE; |
break; |
case EGL_DMA_BUF_PLANE2_OFFSET_EXT: |
attrs->DMABufPlaneOffsets[2].Value = val; |
attrs->DMABufPlaneOffsets[2].IsPresent = EGL_TRUE; |
break; |
case EGL_DMA_BUF_PLANE2_PITCH_EXT: |
attrs->DMABufPlanePitches[2].Value = val; |
attrs->DMABufPlanePitches[2].IsPresent = EGL_TRUE; |
break; |
case EGL_YUV_COLOR_SPACE_HINT_EXT: |
if (val != EGL_ITU_REC601_EXT && val != EGL_ITU_REC709_EXT && |
val != EGL_ITU_REC2020_EXT) { |
err = EGL_BAD_ATTRIBUTE; |
} else { |
attrs->DMABufYuvColorSpaceHint.Value = val; |
attrs->DMABufYuvColorSpaceHint.IsPresent = EGL_TRUE; |
} |
break; |
case EGL_SAMPLE_RANGE_HINT_EXT: |
if (val != EGL_YUV_FULL_RANGE_EXT && val != EGL_YUV_NARROW_RANGE_EXT) { |
err = EGL_BAD_ATTRIBUTE; |
} else { |
attrs->DMABufSampleRangeHint.Value = val; |
attrs->DMABufSampleRangeHint.IsPresent = EGL_TRUE; |
} |
break; |
case EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT: |
if (val != EGL_YUV_CHROMA_SITING_0_EXT && |
val != EGL_YUV_CHROMA_SITING_0_5_EXT) { |
err = EGL_BAD_ATTRIBUTE; |
} else { |
attrs->DMABufChromaHorizontalSiting.Value = val; |
attrs->DMABufChromaHorizontalSiting.IsPresent = EGL_TRUE; |
} |
break; |
case EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT: |
if (val != EGL_YUV_CHROMA_SITING_0_EXT && |
val != EGL_YUV_CHROMA_SITING_0_5_EXT) { |
err = EGL_BAD_ATTRIBUTE; |
} else { |
attrs->DMABufChromaVerticalSiting.Value = val; |
attrs->DMABufChromaVerticalSiting.IsPresent = EGL_TRUE; |
} |
break; |
default: |
/* unknown attrs are ignored */ |
break; |
} |
if (err != EGL_SUCCESS) { |
_eglLog(_EGL_DEBUG, "bad image attribute 0x%04x", attr); |
break; |
} |
} |
return err; |
} |
EGLBoolean |
_eglInitImage(_EGLImage *img, _EGLDisplay *dpy) |
{ |
_eglInitResource(&img->Resource, sizeof(*img), dpy); |
return EGL_TRUE; |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglimage.h |
---|
0,0 → 1,173 |
/************************************************************************** |
* |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLIMAGE_INCLUDED |
#define EGLIMAGE_INCLUDED |
#include "c99_compat.h" |
#include "egltypedefs.h" |
#include "egldisplay.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
struct _egl_image_attrib_int |
{ |
EGLint Value; |
EGLBoolean IsPresent; |
}; |
struct _egl_image_attribs |
{ |
/* EGL_KHR_image_base */ |
EGLBoolean ImagePreserved; |
/* EGL_KHR_gl_image */ |
EGLint GLTextureLevel; |
EGLint GLTextureZOffset; |
/* EGL_MESA_drm_image */ |
EGLint Width; |
EGLint Height; |
EGLint DRMBufferFormatMESA; |
EGLint DRMBufferUseMESA; |
EGLint DRMBufferStrideMESA; |
/* EGL_WL_bind_wayland_display */ |
EGLint PlaneWL; |
/* EGL_EXT_image_dma_buf_import */ |
struct _egl_image_attrib_int DMABufFourCC; |
struct _egl_image_attrib_int DMABufPlaneFds[3]; |
struct _egl_image_attrib_int DMABufPlaneOffsets[3]; |
struct _egl_image_attrib_int DMABufPlanePitches[3]; |
struct _egl_image_attrib_int DMABufYuvColorSpaceHint; |
struct _egl_image_attrib_int DMABufSampleRangeHint; |
struct _egl_image_attrib_int DMABufChromaHorizontalSiting; |
struct _egl_image_attrib_int DMABufChromaVerticalSiting; |
}; |
/** |
* "Base" class for device driver images. |
*/ |
struct _egl_image |
{ |
/* An image is a display resource */ |
_EGLResource Resource; |
}; |
extern EGLint |
_eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy, |
const EGLint *attrib_list); |
extern EGLBoolean |
_eglInitImage(_EGLImage *img, _EGLDisplay *dpy); |
/** |
* Increment reference count for the image. |
*/ |
static inline _EGLImage * |
_eglGetImage(_EGLImage *img) |
{ |
if (img) |
_eglGetResource(&img->Resource); |
return img; |
} |
/** |
* Decrement reference count for the image. |
*/ |
static inline EGLBoolean |
_eglPutImage(_EGLImage *img) |
{ |
return (img) ? _eglPutResource(&img->Resource) : EGL_FALSE; |
} |
/** |
* Link an image to its display and return the handle of the link. |
* The handle can be passed to client directly. |
*/ |
static inline EGLImageKHR |
_eglLinkImage(_EGLImage *img) |
{ |
_eglLinkResource(&img->Resource, _EGL_RESOURCE_IMAGE); |
return (EGLImageKHR) img; |
} |
/** |
* Unlink a linked image from its display. |
* Accessing an unlinked image should generate EGL_BAD_PARAMETER error. |
*/ |
static inline void |
_eglUnlinkImage(_EGLImage *img) |
{ |
_eglUnlinkResource(&img->Resource, _EGL_RESOURCE_IMAGE); |
} |
/** |
* Lookup a handle to find the linked image. |
* Return NULL if the handle has no corresponding linked image. |
*/ |
static inline _EGLImage * |
_eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy) |
{ |
_EGLImage *img = (_EGLImage *) image; |
if (!dpy || !_eglCheckResource((void *) img, _EGL_RESOURCE_IMAGE, dpy)) |
img = NULL; |
return img; |
} |
/** |
* Return the handle of a linked image, or EGL_NO_IMAGE_KHR. |
*/ |
static inline EGLImageKHR |
_eglGetImageHandle(_EGLImage *img) |
{ |
_EGLResource *res = (_EGLResource *) img; |
return (res && _eglIsResourceLinked(res)) ? |
(EGLImageKHR) img : EGL_NO_IMAGE_KHR; |
} |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLIMAGE_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/egllog.c |
---|
0,0 → 1,208 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
/** |
* Logging facility for debug/info messages. |
* _EGL_FATAL messages are printed to stderr |
* The EGL_LOG_LEVEL var controls the output of other warning/info/debug msgs. |
*/ |
#include <stdarg.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include "c11/threads.h" |
#include "egllog.h" |
#include "eglstring.h" |
#define MAXSTRING 1000 |
#define FALLBACK_LOG_LEVEL _EGL_WARNING |
static struct { |
mtx_t mutex; |
EGLBoolean initialized; |
EGLint level; |
_EGLLogProc logger; |
EGLint num_messages; |
} logging = { |
_MTX_INITIALIZER_NP, |
EGL_FALSE, |
FALLBACK_LOG_LEVEL, |
NULL, |
0 |
}; |
static const char *level_strings[] = { |
/* the order is important */ |
"fatal", |
"warning", |
"info", |
"debug", |
NULL |
}; |
/** |
* Set the function to be called when there is a message to log. |
* Note that the function will be called with an internal lock held. |
* Recursive logging is not allowed. |
*/ |
void |
_eglSetLogProc(_EGLLogProc logger) |
{ |
EGLint num_messages = 0; |
mtx_lock(&logging.mutex); |
if (logging.logger != logger) { |
logging.logger = logger; |
num_messages = logging.num_messages; |
logging.num_messages = 0; |
} |
mtx_unlock(&logging.mutex); |
if (num_messages) |
_eglLog(_EGL_DEBUG, |
"New logger installed. " |
"Messages before the new logger might not be available."); |
} |
/** |
* Set the log reporting level. |
*/ |
void |
_eglSetLogLevel(EGLint level) |
{ |
switch (level) { |
case _EGL_FATAL: |
case _EGL_WARNING: |
case _EGL_INFO: |
case _EGL_DEBUG: |
mtx_lock(&logging.mutex); |
logging.level = level; |
mtx_unlock(&logging.mutex); |
break; |
default: |
break; |
} |
} |
/** |
* The default logger. It prints the message to stderr. |
*/ |
static void |
_eglDefaultLogger(EGLint level, const char *msg) |
{ |
fprintf(stderr, "libEGL %s: %s\n", level_strings[level], msg); |
} |
/** |
* Initialize the logging facility. |
*/ |
static void |
_eglInitLogger(void) |
{ |
const char *log_env; |
EGLint i, level = -1; |
if (logging.initialized) |
return; |
log_env = getenv("EGL_LOG_LEVEL"); |
if (log_env) { |
for (i = 0; level_strings[i]; i++) { |
if (_eglstrcasecmp(log_env, level_strings[i]) == 0) { |
level = i; |
break; |
} |
} |
} |
else { |
level = FALLBACK_LOG_LEVEL; |
} |
logging.logger = _eglDefaultLogger; |
logging.level = (level >= 0) ? level : FALLBACK_LOG_LEVEL; |
logging.initialized = EGL_TRUE; |
/* it is fine to call _eglLog now */ |
if (log_env && level < 0) { |
_eglLog(_EGL_WARNING, |
"Unrecognized EGL_LOG_LEVEL environment variable value. " |
"Expected one of \"fatal\", \"warning\", \"info\", \"debug\". " |
"Got \"%s\". Falling back to \"%s\".", |
log_env, level_strings[FALLBACK_LOG_LEVEL]); |
} |
} |
/** |
* Log a message with message logger. |
* \param level one of _EGL_FATAL, _EGL_WARNING, _EGL_INFO, _EGL_DEBUG. |
*/ |
void |
_eglLog(EGLint level, const char *fmtStr, ...) |
{ |
va_list args; |
char msg[MAXSTRING]; |
int ret; |
/* one-time initialization; a little race here is fine */ |
if (!logging.initialized) |
_eglInitLogger(); |
if (level > logging.level || level < 0) |
return; |
mtx_lock(&logging.mutex); |
if (logging.logger) { |
va_start(args, fmtStr); |
ret = vsnprintf(msg, MAXSTRING, fmtStr, args); |
if (ret < 0 || ret >= MAXSTRING) |
strcpy(msg, "<message truncated>"); |
va_end(args); |
logging.logger(level, msg); |
logging.num_messages++; |
} |
mtx_unlock(&logging.mutex); |
if (level == _EGL_FATAL) |
exit(1); /* or abort()? */ |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/egllog.h |
---|
0,0 → 1,66 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLLOG_INCLUDED |
#define EGLLOG_INCLUDED |
#include "egltypedefs.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _EGL_FATAL 0 /* unrecoverable error */ |
#define _EGL_WARNING 1 /* recoverable error/problem */ |
#define _EGL_INFO 2 /* just useful info */ |
#define _EGL_DEBUG 3 /* useful info for debugging */ |
typedef void (*_EGLLogProc)(EGLint level, const char *msg); |
extern void |
_eglSetLogProc(_EGLLogProc logger); |
extern void |
_eglSetLogLevel(EGLint level); |
extern void |
_eglLog(EGLint level, const char *fmtStr, ...); |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLLOG_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglstring.c |
---|
0,0 → 1,54 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
/** |
* String utils. |
*/ |
#include <stdlib.h> |
#include <string.h> |
#include "eglstring.h" |
char * |
_eglstrdup(const char *s) |
{ |
if (s) { |
size_t l = strlen(s); |
char *s2 = malloc(l + 1); |
if (s2) |
strcpy(s2, s); |
return s2; |
} |
return NULL; |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglstring.h |
---|
0,0 → 1,50 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010-2011 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLSTRING_INCLUDED |
#define EGLSTRING_INCLUDED |
#include <string.h> |
#include <stdio.h> |
#ifdef _EGL_OS_WINDOWS |
#define _eglstrcasecmp _stricmp |
#define _eglsnprintf _snprintf |
#else |
#include <strings.h> // for strcasecmp |
#define _eglstrcasecmp strcasecmp |
#define _eglsnprintf snprintf |
#endif |
extern char * |
_eglstrdup(const char *s); |
#endif /* EGLSTRING_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglsurface.c |
---|
0,0 → 1,497 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
/** |
* Surface-related functions. |
*/ |
#include <assert.h> |
#include <stdlib.h> |
#include <string.h> |
#include "egldisplay.h" |
#include "egldriver.h" |
#include "eglcontext.h" |
#include "eglconfig.h" |
#include "eglcurrent.h" |
#include "egllog.h" |
#include "eglsurface.h" |
static void |
_eglClampSwapInterval(_EGLSurface *surf, EGLint interval) |
{ |
EGLint bound = surf->Config->MaxSwapInterval; |
if (interval >= bound) { |
interval = bound; |
} |
else { |
bound = surf->Config->MinSwapInterval; |
if (interval < bound) |
interval = bound; |
} |
surf->SwapInterval = interval; |
} |
/** |
* Parse the list of surface attributes and return the proper error code. |
*/ |
static EGLint |
_eglParseSurfaceAttribList(_EGLSurface *surf, const EGLint *attrib_list) |
{ |
_EGLDisplay *dpy = surf->Resource.Display; |
EGLint type = surf->Type; |
EGLint texture_type = EGL_PBUFFER_BIT; |
EGLint i, err = EGL_SUCCESS; |
if (!attrib_list) |
return EGL_SUCCESS; |
if (dpy->Extensions.NOK_texture_from_pixmap) |
texture_type |= EGL_PIXMAP_BIT; |
for (i = 0; attrib_list[i] != EGL_NONE; i++) { |
EGLint attr = attrib_list[i++]; |
EGLint val = attrib_list[i]; |
switch (attr) { |
/* common attributes */ |
case EGL_VG_COLORSPACE: |
switch (val) { |
case EGL_VG_COLORSPACE_sRGB: |
case EGL_VG_COLORSPACE_LINEAR: |
break; |
default: |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (err != EGL_SUCCESS) |
break; |
surf->VGColorspace = val; |
break; |
case EGL_VG_ALPHA_FORMAT: |
switch (val) { |
case EGL_VG_ALPHA_FORMAT_NONPRE: |
case EGL_VG_ALPHA_FORMAT_PRE: |
break; |
default: |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (err != EGL_SUCCESS) |
break; |
surf->VGAlphaFormat = val; |
break; |
/* window surface attributes */ |
case EGL_RENDER_BUFFER: |
if (type != EGL_WINDOW_BIT) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (val != EGL_BACK_BUFFER && val != EGL_SINGLE_BUFFER) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
surf->RenderBuffer = val; |
break; |
case EGL_POST_SUB_BUFFER_SUPPORTED_NV: |
if (!dpy->Extensions.NV_post_sub_buffer || |
type != EGL_WINDOW_BIT) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (val != EGL_TRUE && val != EGL_FALSE) { |
err = EGL_BAD_PARAMETER; |
break; |
} |
surf->PostSubBufferSupportedNV = val; |
break; |
/* pbuffer surface attributes */ |
case EGL_WIDTH: |
if (type != EGL_PBUFFER_BIT) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (val < 0) { |
err = EGL_BAD_PARAMETER; |
break; |
} |
surf->Width = val; |
break; |
case EGL_HEIGHT: |
if (type != EGL_PBUFFER_BIT) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (val < 0) { |
err = EGL_BAD_PARAMETER; |
break; |
} |
surf->Height = val; |
break; |
case EGL_LARGEST_PBUFFER: |
if (type != EGL_PBUFFER_BIT) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
surf->LargestPbuffer = !!val; |
break; |
/* for eglBindTexImage */ |
case EGL_TEXTURE_FORMAT: |
if (!(type & texture_type)) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
switch (val) { |
case EGL_TEXTURE_RGB: |
case EGL_TEXTURE_RGBA: |
case EGL_NO_TEXTURE: |
break; |
default: |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (err != EGL_SUCCESS) |
break; |
surf->TextureFormat = val; |
break; |
case EGL_TEXTURE_TARGET: |
if (!(type & texture_type)) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
switch (val) { |
case EGL_TEXTURE_2D: |
case EGL_NO_TEXTURE: |
break; |
default: |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (err != EGL_SUCCESS) |
break; |
surf->TextureTarget = val; |
break; |
case EGL_MIPMAP_TEXTURE: |
if (!(type & texture_type)) { |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
surf->MipmapTexture = !!val; |
break; |
/* no pixmap surface specific attributes */ |
default: |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (err != EGL_SUCCESS) { |
_eglLog(_EGL_WARNING, "bad surface attribute 0x%04x", attr); |
break; |
} |
} |
return err; |
} |
/** |
* Do error check on parameters and initialize the given _EGLSurface object. |
* \return EGL_TRUE if no errors, EGL_FALSE otherwise. |
*/ |
EGLBoolean |
_eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, |
_EGLConfig *conf, const EGLint *attrib_list) |
{ |
const char *func; |
EGLint renderBuffer = EGL_BACK_BUFFER; |
EGLint swapBehavior = EGL_BUFFER_PRESERVED; |
EGLint err; |
switch (type) { |
case EGL_WINDOW_BIT: |
func = "eglCreateWindowSurface"; |
swapBehavior = EGL_BUFFER_DESTROYED; |
break; |
case EGL_PIXMAP_BIT: |
func = "eglCreatePixmapSurface"; |
renderBuffer = EGL_SINGLE_BUFFER; |
break; |
case EGL_PBUFFER_BIT: |
func = "eglCreatePBufferSurface"; |
break; |
default: |
_eglLog(_EGL_WARNING, "Bad type in _eglInitSurface"); |
return EGL_FALSE; |
} |
if ((conf->SurfaceType & type) == 0) { |
/* The config can't be used to create a surface of this type */ |
_eglError(EGL_BAD_CONFIG, func); |
return EGL_FALSE; |
} |
_eglInitResource(&surf->Resource, sizeof(*surf), dpy); |
surf->Type = type; |
surf->Config = conf; |
surf->Width = 0; |
surf->Height = 0; |
surf->TextureFormat = EGL_NO_TEXTURE; |
surf->TextureTarget = EGL_NO_TEXTURE; |
surf->MipmapTexture = EGL_FALSE; |
surf->LargestPbuffer = EGL_FALSE; |
surf->RenderBuffer = renderBuffer; |
surf->VGAlphaFormat = EGL_VG_ALPHA_FORMAT_NONPRE; |
surf->VGColorspace = EGL_VG_COLORSPACE_sRGB; |
surf->MipmapLevel = 0; |
surf->MultisampleResolve = EGL_MULTISAMPLE_RESOLVE_DEFAULT; |
surf->SwapBehavior = swapBehavior; |
surf->HorizontalResolution = EGL_UNKNOWN; |
surf->VerticalResolution = EGL_UNKNOWN; |
surf->AspectRatio = EGL_UNKNOWN; |
surf->PostSubBufferSupportedNV = EGL_FALSE; |
/* the default swap interval is 1 */ |
_eglClampSwapInterval(surf, 1); |
err = _eglParseSurfaceAttribList(surf, attrib_list); |
if (err != EGL_SUCCESS) |
return _eglError(err, func); |
return EGL_TRUE; |
} |
EGLBoolean |
_eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, |
EGLint attribute, EGLint *value) |
{ |
switch (attribute) { |
case EGL_WIDTH: |
*value = surface->Width; |
break; |
case EGL_HEIGHT: |
*value = surface->Height; |
break; |
case EGL_CONFIG_ID: |
*value = surface->Config->ConfigID; |
break; |
case EGL_LARGEST_PBUFFER: |
*value = surface->LargestPbuffer; |
break; |
case EGL_TEXTURE_FORMAT: |
/* texture attributes: only for pbuffers, no error otherwise */ |
if (surface->Type == EGL_PBUFFER_BIT) |
*value = surface->TextureFormat; |
break; |
case EGL_TEXTURE_TARGET: |
if (surface->Type == EGL_PBUFFER_BIT) |
*value = surface->TextureTarget; |
break; |
case EGL_MIPMAP_TEXTURE: |
if (surface->Type == EGL_PBUFFER_BIT) |
*value = surface->MipmapTexture; |
break; |
case EGL_MIPMAP_LEVEL: |
if (surface->Type == EGL_PBUFFER_BIT) |
*value = surface->MipmapLevel; |
break; |
case EGL_SWAP_BEHAVIOR: |
*value = surface->SwapBehavior; |
break; |
case EGL_RENDER_BUFFER: |
*value = surface->RenderBuffer; |
break; |
case EGL_PIXEL_ASPECT_RATIO: |
*value = surface->AspectRatio; |
break; |
case EGL_HORIZONTAL_RESOLUTION: |
*value = surface->HorizontalResolution; |
break; |
case EGL_VERTICAL_RESOLUTION: |
*value = surface->VerticalResolution; |
break; |
case EGL_MULTISAMPLE_RESOLVE: |
*value = surface->MultisampleResolve; |
break; |
case EGL_VG_ALPHA_FORMAT: |
*value = surface->VGAlphaFormat; |
break; |
case EGL_VG_COLORSPACE: |
*value = surface->VGColorspace; |
break; |
case EGL_POST_SUB_BUFFER_SUPPORTED_NV: |
*value = surface->PostSubBufferSupportedNV; |
break; |
case EGL_BUFFER_AGE_EXT: |
if (!dpy->Extensions.EXT_buffer_age) { |
_eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); |
return EGL_FALSE; |
} |
*value = drv->API.QueryBufferAge(drv, dpy, surface); |
break; |
default: |
_eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface"); |
return EGL_FALSE; |
} |
return EGL_TRUE; |
} |
/** |
* Default fallback routine - drivers might override this. |
*/ |
EGLBoolean |
_eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, |
EGLint attribute, EGLint value) |
{ |
EGLint confval; |
EGLint err = EGL_SUCCESS; |
EGLint all_es_bits = EGL_OPENGL_ES_BIT | |
EGL_OPENGL_ES2_BIT | |
EGL_OPENGL_ES3_BIT_KHR; |
switch (attribute) { |
case EGL_MIPMAP_LEVEL: |
confval = surface->Config->RenderableType; |
if (!(confval & all_es_bits)) { |
err = EGL_BAD_PARAMETER; |
break; |
} |
surface->MipmapLevel = value; |
break; |
case EGL_MULTISAMPLE_RESOLVE: |
switch (value) { |
case EGL_MULTISAMPLE_RESOLVE_DEFAULT: |
break; |
case EGL_MULTISAMPLE_RESOLVE_BOX: |
confval = surface->Config->SurfaceType; |
if (!(confval & EGL_MULTISAMPLE_RESOLVE_BOX_BIT)) |
err = EGL_BAD_MATCH; |
break; |
default: |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (err != EGL_SUCCESS) |
break; |
surface->MultisampleResolve = value; |
break; |
case EGL_SWAP_BEHAVIOR: |
switch (value) { |
case EGL_BUFFER_DESTROYED: |
break; |
case EGL_BUFFER_PRESERVED: |
confval = surface->Config->SurfaceType; |
if (!(confval & EGL_SWAP_BEHAVIOR_PRESERVED_BIT)) |
err = EGL_BAD_MATCH; |
break; |
default: |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (err != EGL_SUCCESS) |
break; |
surface->SwapBehavior = value; |
break; |
default: |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (err != EGL_SUCCESS) |
return _eglError(err, "eglSurfaceAttrib"); |
return EGL_TRUE; |
} |
EGLBoolean |
_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, |
EGLint buffer) |
{ |
EGLint texture_type = EGL_PBUFFER_BIT; |
/* Just do basic error checking and return success/fail. |
* Drivers must implement the real stuff. |
*/ |
if (dpy->Extensions.NOK_texture_from_pixmap) |
texture_type |= EGL_PIXMAP_BIT; |
if (!(surface->Type & texture_type)) { |
_eglError(EGL_BAD_SURFACE, "eglBindTexImage"); |
return EGL_FALSE; |
} |
if (surface->TextureFormat == EGL_NO_TEXTURE) { |
_eglError(EGL_BAD_MATCH, "eglBindTexImage"); |
return EGL_FALSE; |
} |
if (surface->TextureTarget == EGL_NO_TEXTURE) { |
_eglError(EGL_BAD_MATCH, "eglBindTexImage"); |
return EGL_FALSE; |
} |
if (buffer != EGL_BACK_BUFFER) { |
_eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); |
return EGL_FALSE; |
} |
surface->BoundToTexture = EGL_TRUE; |
return EGL_TRUE; |
} |
EGLBoolean |
_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, |
EGLint buffer) |
{ |
/* TODO: do basic error checking and return success/fail. |
* Drivers must implement the real stuff. |
*/ |
return EGL_TRUE; |
} |
EGLBoolean |
_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, |
EGLint interval) |
{ |
_eglClampSwapInterval(surf, interval); |
return EGL_TRUE; |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglsurface.h |
---|
0,0 → 1,185 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLSURFACE_INCLUDED |
#define EGLSURFACE_INCLUDED |
#include "c99_compat.h" |
#include "egltypedefs.h" |
#include "egldisplay.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
/** |
* "Base" class for device driver surfaces. |
*/ |
struct _egl_surface |
{ |
/* A surface is a display resource */ |
_EGLResource Resource; |
/* The context that is currently bound to the surface */ |
_EGLContext *CurrentContext; |
_EGLConfig *Config; |
EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */ |
/* attributes set by attribute list */ |
EGLint Width, Height; |
EGLenum TextureFormat; |
EGLenum TextureTarget; |
EGLBoolean MipmapTexture; |
EGLBoolean LargestPbuffer; |
EGLenum RenderBuffer; |
EGLenum VGAlphaFormat; |
EGLenum VGColorspace; |
/* attributes set by eglSurfaceAttrib */ |
EGLint MipmapLevel; |
EGLenum MultisampleResolve; |
EGLenum SwapBehavior; |
EGLint HorizontalResolution, VerticalResolution; |
EGLint AspectRatio; |
EGLint SwapInterval; |
/* True if the surface is bound to an OpenGL ES texture */ |
EGLBoolean BoundToTexture; |
EGLBoolean PostSubBufferSupportedNV; |
}; |
extern EGLBoolean |
_eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, |
_EGLConfig *config, const EGLint *attrib_list); |
extern EGLBoolean |
_eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint *value); |
extern EGLBoolean |
_eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint attribute, EGLint value); |
extern EGLBoolean |
_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer); |
extern EGLBoolean |
_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer); |
extern EGLBoolean |
_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval); |
/** |
* Increment reference count for the surface. |
*/ |
static inline _EGLSurface * |
_eglGetSurface(_EGLSurface *surf) |
{ |
if (surf) |
_eglGetResource(&surf->Resource); |
return surf; |
} |
/** |
* Decrement reference count for the surface. |
*/ |
static inline EGLBoolean |
_eglPutSurface(_EGLSurface *surf) |
{ |
return (surf) ? _eglPutResource(&surf->Resource) : EGL_FALSE; |
} |
/** |
* Link a surface to its display and return the handle of the link. |
* The handle can be passed to client directly. |
*/ |
static inline EGLSurface |
_eglLinkSurface(_EGLSurface *surf) |
{ |
_eglLinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE); |
return (EGLSurface) surf; |
} |
/** |
* Unlink a linked surface from its display. |
* Accessing an unlinked surface should generate EGL_BAD_SURFACE error. |
*/ |
static inline void |
_eglUnlinkSurface(_EGLSurface *surf) |
{ |
_eglUnlinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE); |
} |
/** |
* Lookup a handle to find the linked surface. |
* Return NULL if the handle has no corresponding linked surface. |
*/ |
static inline _EGLSurface * |
_eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy) |
{ |
_EGLSurface *surf = (_EGLSurface *) surface; |
if (!dpy || !_eglCheckResource((void *) surf, _EGL_RESOURCE_SURFACE, dpy)) |
surf = NULL; |
return surf; |
} |
/** |
* Return the handle of a linked surface, or EGL_NO_SURFACE. |
*/ |
static inline EGLSurface |
_eglGetSurfaceHandle(_EGLSurface *surf) |
{ |
_EGLResource *res = (_EGLResource *) surf; |
return (res && _eglIsResourceLinked(res)) ? |
(EGLSurface) surf : EGL_NO_SURFACE; |
} |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLSURFACE_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglsync.c |
---|
0,0 → 1,175 |
/************************************************************************** |
* |
* Copyright 2010 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#include <string.h> |
#include "eglsync.h" |
#include "eglcurrent.h" |
#include "egldriver.h" |
#include "egllog.h" |
/** |
* Parse the list of sync attributes and return the proper error code. |
*/ |
static EGLint |
_eglParseSyncAttribList(_EGLSync *sync, const EGLint *attrib_list) |
{ |
EGLint i, err = EGL_SUCCESS; |
if (!attrib_list) |
return EGL_SUCCESS; |
for (i = 0; attrib_list[i] != EGL_NONE; i++) { |
EGLint attr = attrib_list[i++]; |
EGLint val = attrib_list[i]; |
switch (attr) { |
default: |
(void) val; |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (err != EGL_SUCCESS) { |
_eglLog(_EGL_DEBUG, "bad sync attribute 0x%04x", attr); |
break; |
} |
} |
return err; |
} |
static EGLint |
_eglParseSyncAttribList64(_EGLSync *sync, const EGLAttribKHR *attrib_list) |
{ |
EGLint i, err = EGL_SUCCESS; |
if (!attrib_list) |
return EGL_SUCCESS; |
for (i = 0; attrib_list[i] != EGL_NONE; i++) { |
EGLint attr = attrib_list[i++]; |
EGLint val = attrib_list[i]; |
switch (attr) { |
case EGL_CL_EVENT_HANDLE_KHR: |
if (sync->Type == EGL_SYNC_CL_EVENT_KHR) { |
sync->CLEvent = val; |
break; |
} |
/* fall through */ |
default: |
(void) val; |
err = EGL_BAD_ATTRIBUTE; |
break; |
} |
if (err != EGL_SUCCESS) { |
_eglLog(_EGL_DEBUG, "bad sync attribute 0x%04x", attr); |
break; |
} |
} |
return err; |
} |
EGLBoolean |
_eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type, |
const EGLint *attrib_list, const EGLAttribKHR *attrib_list64) |
{ |
EGLint err; |
if (!(type == EGL_SYNC_REUSABLE_KHR && dpy->Extensions.KHR_reusable_sync) && |
!(type == EGL_SYNC_FENCE_KHR && dpy->Extensions.KHR_fence_sync) && |
!(type == EGL_SYNC_CL_EVENT_KHR && dpy->Extensions.KHR_cl_event2 && |
attrib_list64)) |
return _eglError(EGL_BAD_ATTRIBUTE, "eglCreateSyncKHR"); |
_eglInitResource(&sync->Resource, sizeof(*sync), dpy); |
sync->Type = type; |
sync->SyncStatus = EGL_UNSIGNALED_KHR; |
switch (type) { |
case EGL_SYNC_CL_EVENT_KHR: |
sync->SyncCondition = EGL_SYNC_CL_EVENT_COMPLETE_KHR; |
break; |
default: |
sync->SyncCondition = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR; |
} |
if (attrib_list64) |
err = _eglParseSyncAttribList64(sync, attrib_list64); |
else |
err = _eglParseSyncAttribList(sync, attrib_list); |
if (err != EGL_SUCCESS) |
return _eglError(err, "eglCreateSyncKHR"); |
if (type == EGL_SYNC_CL_EVENT_KHR && !sync->CLEvent) |
return _eglError(EGL_BAD_ATTRIBUTE, "eglCreateSyncKHR"); |
return EGL_TRUE; |
} |
EGLBoolean |
_eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, |
EGLint attribute, EGLint *value) |
{ |
if (!value) |
return _eglError(EGL_BAD_PARAMETER, "eglGetSyncAttribKHR"); |
switch (attribute) { |
case EGL_SYNC_TYPE_KHR: |
*value = sync->Type; |
break; |
case EGL_SYNC_STATUS_KHR: |
/* update the sync status */ |
if (sync->SyncStatus != EGL_SIGNALED_KHR && |
(sync->Type == EGL_SYNC_FENCE_KHR || |
sync->Type == EGL_SYNC_CL_EVENT_KHR)) |
drv->API.ClientWaitSyncKHR(drv, dpy, sync, 0, 0); |
*value = sync->SyncStatus; |
break; |
case EGL_SYNC_CONDITION_KHR: |
if (sync->Type != EGL_SYNC_FENCE_KHR && |
sync->Type != EGL_SYNC_CL_EVENT_KHR) |
return _eglError(EGL_BAD_ATTRIBUTE, "eglGetSyncAttribKHR"); |
*value = sync->SyncCondition; |
break; |
default: |
return _eglError(EGL_BAD_ATTRIBUTE, "eglGetSyncAttribKHR"); |
break; |
} |
return EGL_TRUE; |
} |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/eglsync.h |
---|
0,0 → 1,134 |
/************************************************************************** |
* |
* Copyright 2010 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLSYNC_INCLUDED |
#define EGLSYNC_INCLUDED |
#include "c99_compat.h" |
#include "egltypedefs.h" |
#include "egldisplay.h" |
/** |
* "Base" class for device driver syncs. |
*/ |
struct _egl_sync |
{ |
/* A sync is a display resource */ |
_EGLResource Resource; |
EGLenum Type; |
EGLenum SyncStatus; |
EGLenum SyncCondition; |
EGLAttribKHR CLEvent; |
}; |
extern EGLBoolean |
_eglInitSync(_EGLSync *sync, _EGLDisplay *dpy, EGLenum type, |
const EGLint *attrib_list, const EGLAttribKHR *attrib_list64); |
extern EGLBoolean |
_eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync, |
EGLint attribute, EGLint *value); |
/** |
* Increment reference count for the sync. |
*/ |
static inline _EGLSync * |
_eglGetSync(_EGLSync *sync) |
{ |
if (sync) |
_eglGetResource(&sync->Resource); |
return sync; |
} |
/** |
* Decrement reference count for the sync. |
*/ |
static inline EGLBoolean |
_eglPutSync(_EGLSync *sync) |
{ |
return (sync) ? _eglPutResource(&sync->Resource) : EGL_FALSE; |
} |
/** |
* Link a sync to its display and return the handle of the link. |
* The handle can be passed to client directly. |
*/ |
static inline EGLSyncKHR |
_eglLinkSync(_EGLSync *sync) |
{ |
_eglLinkResource(&sync->Resource, _EGL_RESOURCE_SYNC); |
return (EGLSyncKHR) sync; |
} |
/** |
* Unlink a linked sync from its display. |
*/ |
static inline void |
_eglUnlinkSync(_EGLSync *sync) |
{ |
_eglUnlinkResource(&sync->Resource, _EGL_RESOURCE_SYNC); |
} |
/** |
* Lookup a handle to find the linked sync. |
* Return NULL if the handle has no corresponding linked sync. |
*/ |
static inline _EGLSync * |
_eglLookupSync(EGLSyncKHR handle, _EGLDisplay *dpy) |
{ |
_EGLSync *sync = (_EGLSync *) handle; |
if (!dpy || !_eglCheckResource((void *) sync, _EGL_RESOURCE_SYNC, dpy)) |
sync = NULL; |
return sync; |
} |
/** |
* Return the handle of a linked sync, or EGL_NO_SYNC_KHR. |
*/ |
static inline EGLSyncKHR |
_eglGetSyncHandle(_EGLSync *sync) |
{ |
_EGLResource *res = (_EGLResource *) sync; |
return (res && _eglIsResourceLinked(res)) ? |
(EGLSyncKHR) sync : EGL_NO_SYNC_KHR; |
} |
#endif /* EGLSYNC_INCLUDED */ |
/contrib/sdk/sources/Mesa/mesa-10.6.0/src/egl/main/egltypedefs.h |
---|
0,0 → 1,79 |
/************************************************************************** |
* |
* Copyright 2008 VMware, Inc. |
* Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com> |
* Copyright 2010 LunarG, Inc. |
* All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the |
* "Software"), to deal in the Software without restriction, including |
* without limitation the rights to use, copy, modify, merge, publish, |
* distribute, sub license, and/or sell copies of the Software, and to |
* permit persons to whom the Software is furnished to do so, subject to |
* the following conditions: |
* |
* The above copyright notice and this permission notice (including the |
* next paragraph) shall be included in all copies or substantial portions |
* of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
* DEALINGS IN THE SOFTWARE. |
* |
**************************************************************************/ |
#ifndef EGLTYPEDEFS_INCLUDED |
#define EGLTYPEDEFS_INCLUDED |
#include <EGL/egl.h> |
#include <EGL/eglext.h> |
#include "eglcompiler.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
typedef struct _egl_api _EGLAPI; |
typedef struct _egl_array _EGLArray; |
typedef struct _egl_config _EGLConfig; |
typedef struct _egl_context _EGLContext; |
typedef struct _egl_display _EGLDisplay; |
typedef struct _egl_driver _EGLDriver; |
typedef struct _egl_extensions _EGLExtensions; |
typedef struct _egl_image _EGLImage; |
typedef struct _egl_image_attribs _EGLImageAttribs; |
typedef struct _egl_mode _EGLMode; |
typedef struct _egl_resource _EGLResource; |
typedef struct _egl_screen _EGLScreen; |
typedef struct _egl_surface _EGLSurface; |
typedef struct _egl_sync _EGLSync; |
typedef struct _egl_thread_info _EGLThreadInfo; |
#ifdef __cplusplus |
} |
#endif |
#endif /* EGLTYPEDEFS_INCLUDED */ |