*/
mtx_unlock(&disp->Mutex);
- /* Queue the buffer without a sync fence. This informs the ANativeWindow
- * that it may access the buffer immediately.
+ /* Queue the buffer with stored out fence fd. The ANativeWindow or buffer
+ * consumer may choose to wait for the fence to signal before accessing
+ * it. If fence fd value is -1, buffer can be accessed by consumer
+ * immediately. Consumer or application shouldn't rely on timestamp
+ * associated with fence if the fence fd is -1.
*
- * From ANativeWindow::dequeueBuffer:
- *
- * The fenceFd argument specifies a libsync fence file descriptor for
- * a fence that must signal before the buffer can be accessed. If
- * the buffer can be accessed immediately then a value of -1 should
- * be used. The caller must not use the file descriptor after it
- * is passed to queueBuffer, and the ANativeWindow implementation
- * is responsible for closing it.
+ * Ownership of fd is transferred to consumer after queueBuffer and the
+ * consumer is responsible for closing it. Caller must not use the fd
+ * after passing it to queueBuffer.
*/
- int fence_fd = -1;
+ int fence_fd = dri2_surf->out_fence_fd;
+ dri2_surf->out_fence_fd = -1;
dri2_surf->window->queueBuffer(dri2_surf->window, dri2_surf->buffer,
fence_fd);
droid_window_cancel_buffer(struct dri2_egl_surface *dri2_surf)
{
int ret;
+ int fence_fd = dri2_surf->out_fence_fd;
- ret = dri2_surf->window->cancelBuffer(dri2_surf->window, dri2_surf->buffer, -1);
+ dri2_surf->out_fence_fd = -1;
+ ret = dri2_surf->window->cancelBuffer(dri2_surf->window,
+ dri2_surf->buffer, fence_fd);
if (ret < 0) {
_eglLog(_EGL_WARNING, "ANativeWindow::cancelBuffer failed");
dri2_surf->base.Lost = EGL_TRUE;
return NULL;
}
- if (!dri2_init_surface(&dri2_surf->base, disp, type, conf, attrib_list, false))
+ if (!dri2_init_surface(&dri2_surf->base, disp, type, conf, attrib_list, true))
goto cleanup_surface;
if (type == EGL_WINDOW_BIT) {