Compare commits
3 Commits
bisect-tem
...
chadv/revi
Author | SHA1 | Date | |
---|---|---|---|
|
202ef9b8eb | ||
|
58bfeb4ef2 | ||
|
9c2b74ba2a |
@@ -264,10 +264,15 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct dri2_egl_surface *dri2_sur
|
||||
}
|
||||
|
||||
static void
|
||||
droid_window_cancel_buffer(_EGLDisplay *disp, struct dri2_egl_surface *dri2_surf)
|
||||
droid_window_cancel_buffer(struct dri2_egl_surface *dri2_surf)
|
||||
{
|
||||
/* no cancel buffer? */
|
||||
droid_window_enqueue_buffer(disp, dri2_surf);
|
||||
int ret;
|
||||
|
||||
ret = dri2_surf->window->cancelBuffer(dri2_surf->window, dri2_surf->buffer, -1);
|
||||
if (ret < 0) {
|
||||
_eglLog(_EGL_WARNING, "ANativeWindow::cancelBuffer failed");
|
||||
dri2_surf->base.Lost = true;
|
||||
}
|
||||
}
|
||||
|
||||
static __DRIbuffer *
|
||||
@@ -399,7 +404,7 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
|
||||
|
||||
if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
|
||||
if (dri2_surf->buffer)
|
||||
droid_window_cancel_buffer(disp, dri2_surf);
|
||||
droid_window_cancel_buffer(dri2_surf);
|
||||
|
||||
dri2_surf->window->common.decRef(&dri2_surf->window->common);
|
||||
}
|
||||
@@ -426,12 +431,16 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
|
||||
static int
|
||||
update_buffers(struct dri2_egl_surface *dri2_surf)
|
||||
{
|
||||
if (dri2_surf->base.Lost)
|
||||
return -1;
|
||||
|
||||
if (dri2_surf->base.Type != EGL_WINDOW_BIT)
|
||||
return 0;
|
||||
|
||||
/* try to dequeue the next back buffer */
|
||||
if (!dri2_surf->buffer && !droid_window_dequeue_buffer(dri2_surf)) {
|
||||
_eglLog(_EGL_WARNING, "Could not dequeue buffer from native window");
|
||||
dri2_surf->base.Lost = true;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -623,6 +632,12 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
|
||||
|
||||
dri2_flush_drawable_for_swapbuffers(disp, draw);
|
||||
|
||||
/* dri2_surf->buffer can be null even when no error has occured. For
|
||||
* example, if the user has called no GL rendering commands since the
|
||||
* previous eglSwapBuffers, then the driver may have not triggered
|
||||
* a callback to ANativeWindow::dequeueBuffer, in which case
|
||||
* dri2_surf->buffer remains null.
|
||||
*/
|
||||
if (dri2_surf->buffer)
|
||||
droid_window_enqueue_buffer(disp, dri2_surf);
|
||||
|
||||
|
@@ -828,6 +828,33 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read,
|
||||
RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_FALSE);
|
||||
}
|
||||
|
||||
_EGLThreadInfo *t =_eglGetCurrentThread();
|
||||
_EGLContext *old_ctx = t->CurrentContext;
|
||||
_EGLSurface *old_draw_surf = old_ctx ? old_ctx->DrawSurface : NULL;
|
||||
_EGLSurface *old_read_surf = old_ctx ? old_ctx->ReadSurface : NULL;
|
||||
|
||||
/* From the EGL 1.5 spec, Section 3.7.3 Binding Context and Drawables:
|
||||
*
|
||||
* If the previous context of the calling thread has unflushed commands,
|
||||
* and the previous surface is no longer valid, an
|
||||
* EGL_BAD_CURRENT_SURFACE error is generated.
|
||||
*
|
||||
* It's difficult to check if the context has unflushed commands, but it's
|
||||
* easy to check if the surface is no longer valid.
|
||||
*/
|
||||
if (old_draw_surf && old_draw_surf->Lost)
|
||||
RETURN_EGL_ERROR(disp, EGL_BAD_CURRENT_SURFACE, EGL_FALSE);
|
||||
if (old_read_surf && old_read_surf->Lost)
|
||||
RETURN_EGL_ERROR(disp, EGL_BAD_CURRENT_SURFACE, EGL_FALSE);
|
||||
|
||||
/* If a native window underlying either draw or read is no longer valid,
|
||||
* an EGL_BAD_NATIVE_WINDOW error is generated.
|
||||
*/
|
||||
if (draw_surf && draw_surf->Lost)
|
||||
RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_FALSE);
|
||||
if (read_surf && read_surf->Lost)
|
||||
RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_FALSE);
|
||||
|
||||
ret = drv->API.MakeCurrent(drv, disp, draw_surf, read_surf, context);
|
||||
|
||||
RETURN_EGL_EVAL(disp, ret);
|
||||
@@ -1215,6 +1242,15 @@ eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
|
||||
RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
|
||||
#endif
|
||||
|
||||
/* From the EGL 1.5 spec:
|
||||
*
|
||||
* If eglSwapBuffers is called and the native window associated with
|
||||
* surface is no longer valid, an EGL_BAD_NATIVE_WINDOW error is
|
||||
* generated.
|
||||
*/
|
||||
if (surf->Lost)
|
||||
RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_FALSE);
|
||||
|
||||
ret = drv->API.SwapBuffers(drv, disp, surf);
|
||||
|
||||
RETURN_EGL_EVAL(disp, ret);
|
||||
|
@@ -295,6 +295,7 @@ _eglInitSurface(_EGLSurface *surf, _EGLDisplay *dpy, EGLint type,
|
||||
_eglInitResource(&surf->Resource, sizeof(*surf), dpy);
|
||||
surf->Type = type;
|
||||
surf->Config = conf;
|
||||
surf->Lost = EGL_FALSE;
|
||||
|
||||
surf->Width = 0;
|
||||
surf->Height = 0;
|
||||
|
@@ -56,6 +56,11 @@ struct _egl_surface
|
||||
|
||||
EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */
|
||||
|
||||
/* The native surface is lost. The EGL spec requires certain functions
|
||||
* to generate EGL_BAD_NATIVE_WINDOW when given this surface.
|
||||
*/
|
||||
EGLBoolean Lost;
|
||||
|
||||
/* attributes set by attribute list */
|
||||
EGLint Width, Height;
|
||||
EGLenum TextureFormat;
|
||||
|
Reference in New Issue
Block a user