*/
#include <assert.h>
+#include <stdio.h>
#include <string.h>
#include "pipe/p_screen.h"
#include "util/u_memory.h"
#include "util/u_rect.h"
+#include "util/u_inlines.h"
#include "egldriver.h"
#include "eglcurrent.h"
#include "eglconfigutil.h"
return EGL_TRUE;
}
-/**
- * Return the current context of the given API.
- */
-static struct egl_g3d_context *
-egl_g3d_get_current_context(EGLint api)
-{
- _EGLThreadInfo *t = _eglGetCurrentThread();
- EGLint api_index = _eglConvertApiToIndex(api);
- return egl_g3d_context(t->CurrentContexts[api_index]);
-}
-
/**
* Return the state tracker for the given context.
*/
struct egl_g3d_config *gconf;
EGLBoolean valid;
+ gconf = CALLOC_STRUCT(egl_g3d_config);
+ if (!gconf)
+ continue;
+
+ _eglInitConfig(&gconf->base, dpy, id);
+
api_mask = get_mode_api_mask(&native_configs[i]->mode, gdrv->api_mask);
if (!api_mask) {
_eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x",
native_configs[i]->mode.visualID);
- continue;
}
- gconf = CALLOC_STRUCT(egl_g3d_config);
- if (!gconf)
- continue;
-
- _eglInitConfig(&gconf->base, id);
valid = _eglConfigFromContextModesRec(&gconf->base,
&native_configs[i]->mode, api_mask, api_mask);
if (valid) {
egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private)
{
struct egl_g3d_context *gctx = egl_g3d_context(context_private);
-
- /**
- * It is likely that the surface has changed when this function is called.
- * Set force_validate to skip an unnecessary check.
- */
- gctx->force_validate = EGL_TRUE;
egl_g3d_validate_context(gctx->base.Resource.Display, &gctx->base);
}
return NULL;
}
- if (!_eglInitContext(drv, &gctx->base, conf, attribs)) {
+ if (!_eglInitContext(&gctx->base, dpy, conf, attribs)) {
free(gctx);
return NULL;
}
}
mode = &gconf->native->mode;
- gctx->pipe =
- gdpy->native->create_context(gdpy->native, (void *) &gctx->base);
+
+ gctx->pipe = gdpy->native->screen->context_create(
+ gdpy->native->screen,
+ (void *) &gctx->base);
+
if (!gctx->pipe) {
free(gctx);
return NULL;
return NULL;
}
- if (!_eglInitSurface(drv, &gsurf->base, EGL_WINDOW_BIT, conf, attribs)) {
+ if (!_eglInitSurface(&gsurf->base, dpy, EGL_WINDOW_BIT, conf, attribs)) {
free(gsurf);
return NULL;
}
return NULL;
}
- if (!_eglInitSurface(drv, &gsurf->base, EGL_PIXMAP_BIT, conf, attribs)) {
+ if (!_eglInitSurface(&gsurf->base, dpy, EGL_PIXMAP_BIT, conf, attribs)) {
free(gsurf);
return NULL;
}
return NULL;
}
- if (!_eglInitSurface(drv, &gsurf->base, EGL_PBUFFER_BIT, conf, attribs)) {
+ if (!_eglInitSurface(&gsurf->base, dpy, EGL_PBUFFER_BIT, conf, attribs)) {
free(gsurf);
return NULL;
}
_EGLSurface *surf, EGLint buffer)
{
struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+ _EGLContext *es1 = _eglGetAPIContext(EGL_OPENGL_ES_API);
struct egl_g3d_context *gctx;
enum pipe_format target_format;
int target;
return _eglError(EGL_BAD_MATCH, "eglBindTexImage");
}
+ if (!es1)
+ return EGL_TRUE;
+ if (!gsurf->render_surface)
+ return EGL_FALSE;
+
/* flush properly if the surface is bound */
- if (gsurf->base.Binding) {
- gctx = egl_g3d_context(gsurf->base.Binding);
+ if (gsurf->base.CurrentContext) {
+ gctx = egl_g3d_context(gsurf->base.CurrentContext);
gctx->stapi->st_flush(gctx->st_ctx,
PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL);
}
- /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */
- gctx = egl_g3d_get_current_context(EGL_OPENGL_API);
- if (gctx) {
- if (!gsurf->render_surface)
- return EGL_FALSE;
+ gctx = egl_g3d_context(es1);
+ gctx->stapi->st_bind_texture_surface(gsurf->render_surface,
+ target, gsurf->base.MipmapLevel, target_format);
- gctx->stapi->st_bind_texture_surface(gsurf->render_surface,
- target, gsurf->base.MipmapLevel, target_format);
- gsurf->base.BoundToTexture = EGL_TRUE;
- }
+ gsurf->base.BoundToTexture = EGL_TRUE;
return EGL_TRUE;
}
return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage");
if (gsurf->render_surface) {
- _EGLThreadInfo *t = _eglGetCurrentThread();
- /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */
- struct egl_g3d_context *gctx = egl_g3d_context(
- t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_API)]);
+ _EGLContext *ctx = _eglGetAPIContext(EGL_OPENGL_ES_API);
+ struct egl_g3d_context *gctx = egl_g3d_context(ctx);
/* what if the context the surface binds to is no longer current? */
if (gctx)
return NULL;
}
- if (!_eglInitSurface(drv, &gsurf->base,
+ if (!_eglInitSurface(&gsurf->base, dpy,
EGL_SCREEN_BIT_MESA, conf, attribs)) {
free(gsurf);
return NULL;