static boolean
android_surface_present(struct native_surface *nsurf,
- enum native_attachment natt,
- boolean preserve,
- uint swap_interval)
+ const native_present_control *ctrl)
{
struct android_surface *asurf = android_surface(nsurf);
struct android_display *adpy = asurf->adpy;
boolean ret;
- if (swap_interval || natt != NATIVE_ATTACHMENT_BACK_LEFT)
+ if (ctrl->swap_interval || ctrl->natt != NATIVE_ATTACHMENT_BACK_LEFT)
return FALSE;
/* we always render to color_res first when it exists */
if (asurf->color_res) {
copy_resources(&adpy->base, asurf->color_res, asurf->buf_res);
- if (!preserve)
+ if (!ctrl->preserve)
pipe_resource_reference(&asurf->color_res, NULL);
}
- else if (preserve) {
+ else if (ctrl->preserve) {
struct pipe_resource templ;
memset(&templ, 0, sizeof(templ));
struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
_EGLContext *ctx = _eglGetCurrentContext();
struct egl_g3d_context *gctx = NULL;
+ struct native_present_control ctrl;
/* no-op for pixmap or pbuffer surface */
if (gsurf->base.Type == EGL_PIXMAP_BIT ||
gctx->stctxi->flush(gctx->stctxi, ST_FLUSH_FRONT, NULL);
}
- return gsurf->native->present(gsurf->native,
- NATIVE_ATTACHMENT_BACK_LEFT,
- gsurf->base.SwapBehavior == EGL_BUFFER_PRESERVED,
- gsurf->base.SwapInterval);
+ memset(&ctrl, 0, sizeof(ctrl));
+ ctrl.natt = NATIVE_ATTACHMENT_BACK_LEFT;
+ ctrl.preserve = (gsurf->base.SwapBehavior == EGL_BUFFER_PRESERVED);
+ ctrl.swap_interval = gsurf->base.SwapInterval;
+
+ return gsurf->native->present(gsurf->native, &ctrl);
}
static EGLBoolean
{
_EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private;
struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
+ struct native_present_control ctrl;
- return gsurf->native->present(gsurf->native,
- NATIVE_ATTACHMENT_FRONT_LEFT, FALSE, 0);
+ memset(&ctrl, 0, sizeof(ctrl));
+ ctrl.natt = NATIVE_ATTACHMENT_FRONT_LEFT;
+
+ return gsurf->native->present(gsurf->native, &ctrl);
}
static boolean
NATIVE_PARAM_MAX_SWAP_INTERVAL
};
+/**
+ * Control how a surface presentation should happen.
+ */
+struct native_present_control {
+ /**< the attachment to present */
+ enum native_attachment natt;
+
+ /**< the contents of the presented attachment should be preserved */
+ boolean preserve;
+
+ /**< wait until the given vsyncs has passed since the last presentation */
+ uint swap_interval;
+};
+
struct native_surface {
/**
* Available for caller's use.
* Present the given buffer to the native engine.
*/
boolean (*present)(struct native_surface *nsurf,
- enum native_attachment natt,
- boolean preserve,
- uint swap_interval);
+ const struct native_present_control *ctrl);
/**
* Validate the buffers of the surface. textures, if not NULL, points to an
dst = tmp[natt];
if (dst && dst->format == src->format) {
+ struct native_present_control ctrl;
struct pipe_box src_box;
u_box_origin_2d(src->width0, src->height0, &src_box);
pipe->resource_copy_region(pipe, dst, 0, 0, 0, 0, src, 0, &src_box);
pipe->flush(pipe, NULL);
- nsurf->present(nsurf, natt, FALSE, 0);
+
+ memset(&ctrl, 0, sizeof(ctrl));
+ ctrl.natt = natt;
+ nsurf->present(nsurf, &ctrl);
}
if (dst)
static boolean
drm_surface_present(struct native_surface *nsurf,
- enum native_attachment natt,
- boolean preserve,
- uint swap_interval)
+ const struct native_present_control *ctrl)
{
boolean ret;
- if (swap_interval)
+ if (ctrl->swap_interval)
return FALSE;
- switch (natt) {
+ switch (ctrl->natt) {
case NATIVE_ATTACHMENT_FRONT_LEFT:
ret = drm_surface_flush_frontbuffer(nsurf);
break;
case NATIVE_ATTACHMENT_BACK_LEFT:
- if (preserve)
+ if (ctrl->preserve)
ret = drm_surface_copy_swap(nsurf);
else
ret = drm_surface_swap_buffers(nsurf);
static boolean
fbdev_surface_present(struct native_surface *nsurf,
- enum native_attachment natt,
- boolean preserve,
- uint swap_interval)
+ const struct native_present_control *ctrl)
{
struct fbdev_surface *fbsurf = fbdev_surface(nsurf);
struct fbdev_display *fbdpy = fbsurf->fbdpy;
boolean ret = FALSE;
- if (swap_interval)
+ if (ctrl->swap_interval)
return FALSE;
- if (natt != NATIVE_ATTACHMENT_BACK_LEFT)
+ if (ctrl->natt != NATIVE_ATTACHMENT_BACK_LEFT)
return FALSE;
if (!fbdpy->assume_fixed_vinfo) {
/* present the surface */
if (fbdev_surface_update_drawable(&fbsurf->base, &vinfo)) {
ret = resource_surface_present(fbsurf->rsurf,
- natt, (void *) &fbsurf->drawable);
+ ctrl->natt, (void *) &fbsurf->drawable);
}
fbsurf->width = vinfo.xres;
else {
/* the drawable never changes */
ret = resource_surface_present(fbsurf->rsurf,
- natt, (void *) &fbsurf->drawable);
+ ctrl->natt, (void *) &fbsurf->drawable);
}
return ret;
static boolean
gdi_surface_present(struct native_surface *nsurf,
- enum native_attachment natt,
- boolean preserve,
- uint swap_interval)
+ const native_present_control *ctrl)
{
boolean ret;
- if (preserve || swap_interval)
+ if (ctrl->preserve || ctrl->swap_interval)
return FALSE;
- switch (natt) {
+ switch (ctrl->natt) {
case NATIVE_ATTACHMENT_FRONT_LEFT:
ret = gdi_surface_flush_frontbuffer(nsurf);
break;
static boolean
wayland_surface_present(struct native_surface *nsurf,
- enum native_attachment natt,
- boolean preserve,
- uint swap_interval)
+ const struct native_present_control *ctrl)
{
struct wayland_surface *surface = wayland_surface(nsurf);
uint width, height;
boolean ret;
- if (preserve || swap_interval)
+ if (ctrl->preserve || ctrl->swap_interval)
return FALSE;
- switch (natt) {
+ switch (ctrl->natt) {
case NATIVE_ATTACHMENT_FRONT_LEFT:
ret = TRUE;
break;
static boolean
dri2_surface_present(struct native_surface *nsurf,
- enum native_attachment natt,
- boolean preserve,
- uint swap_interval)
+ const struct native_present_control *ctrl)
{
boolean ret;
- if (swap_interval)
+ if (ctrl->swap_interval)
return FALSE;
- switch (natt) {
+ switch (ctrl->natt) {
case NATIVE_ATTACHMENT_FRONT_LEFT:
ret = dri2_surface_flush_frontbuffer(nsurf);
break;
static boolean
ximage_surface_present(struct native_surface *nsurf,
- enum native_attachment natt,
- boolean preserve,
- uint swap_interval)
+ const struct native_present_control *ctrl)
{
boolean ret;
- if (preserve || swap_interval)
+ if (ctrl->preserve || ctrl->swap_interval)
return FALSE;
- switch (natt) {
+ switch (ctrl->natt) {
case NATIVE_ATTACHMENT_FRONT_LEFT:
ret = ximage_surface_flush_frontbuffer(nsurf);
break;