diff options
author | Stéphane Marchesin <[email protected]> | 2011-08-26 17:37:25 -0700 |
---|---|---|
committer | Stéphane Marchesin <[email protected]> | 2011-08-26 17:37:25 -0700 |
commit | f8e6d19f3f40931be741b44d3edf210c38e13f0f (patch) | |
tree | e99e4c619901412ac6448534b0f57ce1c4295c6b /src/egl | |
parent | 974c49ed176de55aadb335a2956ef5dfec774a23 (diff) | |
parent | e3b0e3776646d0367206e4544229622eb22fe9f8 (diff) |
Merge branch 'master' of git://anongit.freedesktop.org/mesa/mesa
Diffstat (limited to 'src/egl')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 28 | ||||
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.h | 3 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_drm.c | 25 | ||||
-rw-r--r-- | src/egl/drivers/glx/egl_glx.c | 19 | ||||
-rw-r--r-- | src/egl/main/Android.mk | 64 | ||||
-rw-r--r-- | src/egl/main/Makefile | 15 | ||||
-rw-r--r-- | src/egl/main/eglapi.c | 33 | ||||
-rw-r--r-- | src/egl/main/eglapi.h | 8 | ||||
-rw-r--r-- | src/egl/main/eglconfig.c | 5 | ||||
-rw-r--r-- | src/egl/main/egldisplay.c | 136 | ||||
-rw-r--r-- | src/egl/main/egldisplay.h | 6 | ||||
-rw-r--r-- | src/egl/main/eglmisc.c | 3 | ||||
-rw-r--r-- | src/egl/main/eglsurface.c | 4 | ||||
-rw-r--r-- | src/egl/wayland/wayland-drm/protocol/wayland-drm.xml | 27 |
14 files changed, 348 insertions, 28 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 0aca929e6aa..f09ae14f10c 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -592,6 +592,13 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp) wl_display_destroy(dri2_dpy->wl_dpy); break; #endif +#ifdef HAVE_DRM_PLATFORM + case _EGL_PLATFORM_DRM: + if (dri2_dpy->own_gbm_device) { + gbm_device_destroy(&dri2_dpy->gbm_dri->base.base); + } + break; +#endif default: break; } @@ -719,6 +726,23 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, } /** + * Called via eglDestroyContext(), drv->API.DestroyContext(). + */ +static EGLBoolean +dri2_destroy_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx) +{ + struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + + if (_eglPutContext(ctx)) { + dri2_dpy->core->destroyContext(dri2_ctx->dri_context); + free(dri2_ctx); + } + + return EGL_TRUE; +} + +/** * Called via eglMakeCurrent(), drv->API.MakeCurrent(). */ static EGLBoolean @@ -758,9 +782,8 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, drv->API.DestroySurface(drv, disp, old_dsurf); if (old_rsurf) drv->API.DestroySurface(drv, disp, old_rsurf); - /* no destroy? */ if (old_ctx) - _eglPutContext(old_ctx); + drv->API.DestroyContext(drv, disp, old_ctx); return EGL_TRUE; } else { @@ -1341,6 +1364,7 @@ _EGL_MAIN(const char *args) dri2_drv->base.API.Initialize = dri2_initialize; dri2_drv->base.API.Terminate = dri2_terminate; dri2_drv->base.API.CreateContext = dri2_create_context; + dri2_drv->base.API.DestroyContext = dri2_destroy_context; dri2_drv->base.API.MakeCurrent = dri2_make_current; dri2_drv->base.API.GetProcAddress = dri2_get_proc_address; dri2_drv->base.API.WaitClient = dri2_wait_client; diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index 3854200bc69..db93eec14ba 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -86,6 +86,7 @@ struct dri2_egl_display #ifdef HAVE_DRM_PLATFORM struct gbm_dri_device *gbm_dri; + int own_gbm_device; #endif char *device_name; @@ -122,8 +123,6 @@ enum wayland_buffer_type { WL_BUFFER_THIRD, WL_BUFFER_COUNT }; - -#define __DRI_BUFFER_COUNT 10 #endif enum dri2_surface_type { diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 579baf9f9d2..04b10e279ec 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -30,6 +30,10 @@ #include <string.h> #include <xf86drm.h> #include <dlfcn.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> #include "egl_dri2.h" @@ -90,6 +94,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy; struct gbm_device *gbm; + int fd = -1; int i; dri2_dpy = malloc(sizeof *dri2_dpy); @@ -100,7 +105,15 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) disp->DriverData = (void *) dri2_dpy; - gbm = (struct gbm_device *) disp->PlatformDisplay; + gbm = disp->PlatformDisplay; + if (gbm == NULL) { + fd = open("/dev/dri/card0", O_RDWR); + dri2_dpy->own_gbm_device = 1; + gbm = gbm_create_device(fd); + if (gbm == NULL) + return EGL_FALSE; + } + if (strcmp(gbm_device_get_backend_name(gbm), "drm") != 0) { free(dri2_dpy); return EGL_FALSE; @@ -112,7 +125,15 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp) return EGL_FALSE; } - dri2_dpy->fd = gbm_device_get_fd(gbm); + if (fd < 0) { + fd = dup(gbm_device_get_fd(gbm)); + if (fd < 0) { + free(dri2_dpy); + return EGL_FALSE; + } + } + + dri2_dpy->fd = fd; dri2_dpy->device_name = dri2_get_device_name_for_fd(dri2_dpy->fd); dri2_dpy->driver_name = dri2_dpy->gbm_dri->base.driver_name; diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 7cf8f4d5514..042936f960e 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -713,6 +713,24 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, return &GLX_ctx->Base; } +/** + * Called via eglDestroyContext(), drv->API.DestroyContext(). + */ +static EGLBoolean +GLX_eglDestroyContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx) +{ + struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv); + struct GLX_egl_context *GLX_ctx = GLX_egl_context(ctx); + + if (_eglPutContext(ctx)) { + assert(GLX_ctx); + GLX_drv->glXDestroyContext(disp, ctx); + + free(GLX_ctx); + } + + return EGL_TRUE; +} /** * Destroy a surface. The display is allowed to be uninitialized. @@ -1142,6 +1160,7 @@ _EGL_MAIN(const char *args) GLX_drv->Base.API.Initialize = GLX_eglInitialize; GLX_drv->Base.API.Terminate = GLX_eglTerminate; GLX_drv->Base.API.CreateContext = GLX_eglCreateContext; + GLX_drv->Base.API.DestroyContext = GLX_eglDestroyContext; GLX_drv->Base.API.MakeCurrent = GLX_eglMakeCurrent; GLX_drv->Base.API.CreateWindowSurface = GLX_eglCreateWindowSurface; GLX_drv->Base.API.CreatePixmapSurface = GLX_eglCreatePixmapSurface; diff --git a/src/egl/main/Android.mk b/src/egl/main/Android.mk new file mode 100644 index 00000000000..25a7c657676 --- /dev/null +++ b/src/egl/main/Android.mk @@ -0,0 +1,64 @@ +# Mesa 3-D graphics library +# +# Copyright (C) 2010-2011 Chia-I Wu <[email protected]> +# Copyright (C) 2010-2011 LunarG Inc. +# +# 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 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. + +# Android.mk for core EGL + +LOCAL_PATH := $(call my-dir) + +# from Makefile +SOURCES = \ + eglapi.c \ + eglarray.c \ + eglconfig.c \ + eglcontext.c \ + eglcurrent.c \ + egldisplay.c \ + egldriver.c \ + eglfallbacks.c \ + eglglobals.c \ + eglimage.c \ + egllog.c \ + eglmisc.c \ + eglmode.c \ + eglscreen.c \ + eglstring.c \ + eglsurface.c \ + eglsync.c + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(SOURCES) + +LOCAL_CFLAGS := \ + -D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_ANDROID \ + -D_EGL_DRIVER_SEARCH_DIR=\"/system/lib/egl\" \ + -D_EGL_OS_UNIX=1 + +ifeq ($(strip $(MESA_BUILD_GALLIUM)),true) +LOCAL_CFLAGS += -D_EGL_BUILT_IN_DRIVER_GALLIUM +endif + +LOCAL_MODULE := libmesa_egl + +include $(MESA_COMMON_MK) +include $(BUILD_STATIC_LIBRARY) diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 775fbbe178b..3172ad2ec03 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -63,6 +63,7 @@ EGL_LIB_DEPS += $(XCB_DRI2_LIBS) endif ifneq ($(findstring drm, $(EGL_PLATFORMS)),) EGL_LIB_DEPS += -lgbm +INCLUDE_DIRS += -I$(TOP)/src/gbm/main endif EGL_LIB_DEPS += $(LIBUDEV_LIBS) $(DLOPEN_LIBS) $(LIBDRM_LIB) $(WAYLAND_LIBS) endif @@ -70,6 +71,7 @@ endif ifneq ($(findstring wayland, $(EGL_PLATFORMS)),) LOCAL_LIBS += $(TOP)/src/egl/wayland/wayland-drm/libwayland-drm.a +INCLUDE_DIRS += $(WAYLAND_CFLAGS) endif ifeq ($(filter glx, $(EGL_DRIVERS_DIRS)),glx) @@ -93,6 +95,19 @@ ifeq ($(firstword $(EGL_PLATFORMS)),fbdev) EGL_NATIVE_PLATFORM=_EGL_PLATFORM_FBDEV endif +ifneq ($(findstring x11, $(EGL_PLATFORMS)),) +LOCAL_CFLAGS += -DHAVE_X11_PLATFORM +endif +ifneq ($(findstring wayland, $(EGL_PLATFORMS)),) +LOCAL_CFLAGS += -DHAVE_WAYLAND_PLATFORM +endif +ifneq ($(findstring drm, $(EGL_PLATFORMS)),) +LOCAL_CFLAGS += -DHAVE_DRM_PLATFORM +endif +ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),) +LOCAL_CFLAGS += -DHAVE_FBDEV_PLATFORM +endif + LOCAL_CFLAGS += \ -D_EGL_NATIVE_PLATFORM=$(EGL_NATIVE_PLATFORM) \ -D_EGL_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\" diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 0ba7794e2c9..3cb1a5baaf3 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -301,7 +301,7 @@ _eglUnlockDisplay(_EGLDisplay *dpy) EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType nativeDisplay) { - _EGLPlatformType plat = _eglGetNativePlatform(); + _EGLPlatformType plat = _eglGetNativePlatform(nativeDisplay); _EGLDisplay *dpy = _eglFindDisplay(plat, (void *) nativeDisplay); return _eglGetDisplayHandle(dpy); } @@ -538,7 +538,7 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLSurface ret; _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); - if (disp->Platform != _eglGetNativePlatform()) + if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay)) RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); surf = drv->API.CreateWindowSurface(drv, disp, conf, window, attrib_list); @@ -559,7 +559,7 @@ eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLSurface ret; _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); - if (disp->Platform != _eglGetNativePlatform()) + if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay)) RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_NO_SURFACE); surf = drv->API.CreatePixmapSurface(drv, disp, conf, pixmap, attrib_list); @@ -720,7 +720,7 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) EGLBoolean ret; _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); - if (disp->Platform != _eglGetNativePlatform()) + if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay)) RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_FALSE); ret = drv->API.CopyBuffers(drv, disp, surf, target); @@ -948,6 +948,9 @@ eglGetProcAddress(const char *procname) { "eglBindWaylandDisplayWL", (_EGLProc) eglBindWaylandDisplayWL }, { "eglUnbindWaylandDisplayWL", (_EGLProc) eglUnbindWaylandDisplayWL }, #endif +#ifdef EGL_ANDROID_swap_rectangle + { "eglSetSwapRectangleANDROID", (_EGLProc) eglSetSwapRectangleANDROID }, +#endif { NULL, NULL } }; EGLint i; @@ -1565,3 +1568,25 @@ eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display) RETURN_EGL_EVAL(disp, ret); } #endif + +#ifdef EGL_ANDROID_swap_rectangle +EGLBoolean EGLAPIENTRY +eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw, + EGLint left, EGLint top, + EGLint width, EGLint height) +{ + _EGLDisplay *disp = _eglLockDisplay(dpy); + _EGLSurface *surf = _eglLookupSurface(draw, disp); + _EGLDriver *drv; + EGLBoolean ret; + + _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); + + if (!disp->Extensions.ANDROID_swap_rectangle) + RETURN_EGL_EVAL(disp, EGL_FALSE); + + ret = drv->API.SetSwapRectangleANDROID(drv, disp, surf, left, top, width, height); + + RETURN_EGL_EVAL(disp, ret); +} +#endif diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index 4fcbe40cd4c..1e0aef69dd7 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -131,6 +131,10 @@ typedef EGLBoolean (*BindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp, typedef EGLBoolean (*UnbindWaylandDisplayWL_t)(_EGLDriver *drv, _EGLDisplay *disp, struct wl_display *display); #endif +#ifdef EGL_ANDROID_swap_rectangle +typedef EGLBoolean (*SetSwapRectangleANDROID_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw, EGLint left, EGLint top, EGLint width, EGLint height); +#endif + /** * The API dispatcher jumps through these functions */ @@ -210,6 +214,10 @@ struct _egl_api BindWaylandDisplayWL_t BindWaylandDisplayWL; UnbindWaylandDisplayWL_t UnbindWaylandDisplayWL; #endif + +#ifdef EGL_ANDROID_swap_rectangle + SetSwapRectangleANDROID_t SetSwapRectangleANDROID; +#endif }; #endif /* EGLAPI_INCLUDED */ diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 483d9807cf0..e1d53da3cd5 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -529,8 +529,9 @@ _eglParseConfigAttribList(_EGLConfig *conf, _EGLDisplay *dpy, if (!_eglValidateConfig(conf, EGL_TRUE)) return EGL_FALSE; - /* the spec says that EGL_LEVEL cannot be EGL_DONT_CARE */ - if (conf->Level == EGL_DONT_CARE) + /* 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 */ diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 60f31777272..1d05e57c429 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -43,6 +43,39 @@ #include "eglmutex.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 +#ifdef HAVE_FBDEV_PLATFORM +#include <stdint.h> +#include <sys/types.h> +#include <sys/stat.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_FBDEV, "fbdev" }, + { _EGL_PLATFORM_ANDROID, "android" } +}; + /** * Return the native platform by parsing EGL_PLATFORM. @@ -50,17 +83,6 @@ static _EGLPlatformType _eglGetNativePlatformFromEnv(void) { - /* 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_FBDEV, "fbdev" } - }; _EGLPlatformType plat = _EGL_INVALID_PLATFORM; const char *plat_name; EGLint i; @@ -84,19 +106,105 @@ _eglGetNativePlatformFromEnv(void) /** + * 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(EGLNativeDisplayType nativeDisplay) +{ +#ifdef HAVE_FBDEV_PLATFORM + struct stat buf; +#endif + + if (nativeDisplay == EGL_DEFAULT_DISPLAY) + return _EGL_INVALID_PLATFORM; + +#ifdef HAVE_FBDEV_PLATFORM + /* fbdev is the only platform that can be a file descriptor. */ + if (fstat((intptr_t) nativeDisplay, &buf) == 0 && S_ISCHR(buf.st_mode)) + return _EGL_PLATFORM_FBDEV; +#endif + + if (_eglPointerIsDereferencable(nativeDisplay)) { + void *first_pointer = *(void **) nativeDisplay; + +#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 + } + + return _EGL_INVALID_PLATFORM; +} + + +/** * Return the native platform. It is the platform of the EGL native types. */ _EGLPlatformType -_eglGetNativePlatform(void) +_eglGetNativePlatform(EGLNativeDisplayType nativeDisplay) { static _EGLPlatformType native_platform = _EGL_INVALID_PLATFORM; + char *detection_method = NULL; if (native_platform == _EGL_INVALID_PLATFORM) { native_platform = _eglGetNativePlatformFromEnv(); - if (native_platform == _EGL_INVALID_PLATFORM) - native_platform = _EGL_NATIVE_PLATFORM; + 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; } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 9cd4dbfcc8a..cddea803c24 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -44,6 +44,7 @@ enum _egl_platform_type { _EGL_PLATFORM_WAYLAND, _EGL_PLATFORM_DRM, _EGL_PLATFORM_FBDEV, + _EGL_PLATFORM_ANDROID, _EGL_NUM_PLATFORMS, _EGL_INVALID_PLATFORM = -1 @@ -107,6 +108,9 @@ struct _egl_extensions EGLBoolean NOK_swap_region; EGLBoolean NOK_texture_from_pixmap; + + EGLBoolean ANDROID_image_native_buffer; + EGLBoolean ANDROID_swap_rectangle; }; @@ -150,7 +154,7 @@ struct _egl_display extern _EGLPlatformType -_eglGetNativePlatform(void); +_eglGetNativePlatform(EGLNativeDisplayType nativeDisplay); extern void diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index da189b689a3..ab48bc68218 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -113,6 +113,9 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy) _EGL_CHECK_EXTENSION(NOK_swap_region); _EGL_CHECK_EXTENSION(NOK_texture_from_pixmap); + + _EGL_CHECK_EXTENSION(ANDROID_image_native_buffer); + _EGL_CHECK_EXTENSION(ANDROID_swap_rectangle); #undef _EGL_CHECK_EXTENSION } diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index c9cfb01388e..3564ecd01b0 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -269,11 +269,13 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, { 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"; @@ -315,7 +317,7 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type, surf->MipmapLevel = 0; surf->MultisampleResolve = EGL_MULTISAMPLE_RESOLVE_DEFAULT; - surf->SwapBehavior = EGL_BUFFER_DESTROYED; + surf->SwapBehavior = swapBehavior; surf->HorizontalResolution = EGL_UNKNOWN; surf->VerticalResolution = EGL_UNKNOWN; diff --git a/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml b/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml index 0331f124e80..cde943060ca 100644 --- a/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml +++ b/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml @@ -1,5 +1,32 @@ <?xml version="1.0" encoding="UTF-8"?> <protocol name="drm"> + + <copyright> + Copyright © 2008-2011 Kristian Høgsberg + Copyright © 2010-2011 Intel Corporation + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that\n the above copyright notice appear in + all copies and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + the copyright holders not be used in advertising or publicity + pertaining to distribution of the software without specific, + written prior permission. The copyright holders make no + representations about the suitability of this software for any + purpose. It is provided "as is" without express or implied + warranty. + + THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + THIS SOFTWARE. + </copyright> + <!-- drm support. This object is created by the server and published using the display's global event. --> <interface name="wl_drm" version="1"> |