* Return TRUE if window/pixmap surfaces use the buffers of the native
* types.
*/
- NATIVE_PARAM_USE_NATIVE_BUFFER
+ NATIVE_PARAM_USE_NATIVE_BUFFER,
+
+ /**
+ * Return TRUE if native_surface::present can preserve the buffer.
+ */
+ NATIVE_PARAM_PRESERVE_BUFFER,
+
+ /**
+ * Return the maximum supported swap interval.
+ */
+ NATIVE_PARAM_MAX_SWAP_INTERVAL
};
struct native_surface {
*/
boolean (*flush_frontbuffer)(struct native_surface *nsurf);
+ /**
+ * Present the given buffer to the native engine.
+ */
+ boolean (*present)(struct native_surface *nsurf,
+ enum native_attachment natt,
+ boolean preserve,
+ uint swap_interval);
+
/**
* Validate the buffers of the surface. textures, if not NULL, points to an
* array of size NUM_NATIVE_ATTACHMENTS and the returned textures are owned
return TRUE;
}
+static boolean
+drm_surface_present(struct native_surface *nsurf,
+ enum native_attachment natt,
+ boolean preserve,
+ uint swap_interval)
+{
+ boolean ret;
+
+ if (preserve || swap_interval)
+ return FALSE;
+
+ switch (natt) {
+ case NATIVE_ATTACHMENT_FRONT_LEFT:
+ ret = drm_surface_flush_frontbuffer(nsurf);
+ break;
+ case NATIVE_ATTACHMENT_BACK_LEFT:
+ ret = drm_surface_swap_buffers(nsurf);
+ break;
+ default:
+ ret = FALSE;
+ break;
+ }
+
+ return ret;
+}
+
static void
drm_surface_wait(struct native_surface *nsurf)
{
drmsurf->base.destroy = drm_surface_destroy;
drmsurf->base.swap_buffers = drm_surface_swap_buffers;
drmsurf->base.flush_frontbuffer = drm_surface_flush_frontbuffer;
+ drmsurf->base.present = drm_surface_present;
drmsurf->base.validate = drm_surface_validate;
drmsurf->base.wait = drm_surface_wait;
int val;
switch (param) {
+ case NATIVE_PARAM_USE_NATIVE_BUFFER:
+ case NATIVE_PARAM_PRESERVE_BUFFER:
+ case NATIVE_PARAM_MAX_SWAP_INTERVAL:
default:
val = 0;
break;
return ret;
}
+static boolean
+fbdev_surface_present(struct native_surface *nsurf,
+ enum native_attachment natt,
+ boolean preserve,
+ uint swap_interval)
+{
+ boolean ret;
+
+ if (preserve || swap_interval)
+ return FALSE;
+
+ switch (natt) {
+ case NATIVE_ATTACHMENT_FRONT_LEFT:
+ ret = fbdev_surface_flush_frontbuffer(nsurf);
+ break;
+ case NATIVE_ATTACHMENT_BACK_LEFT:
+ ret = fbdev_surface_swap_buffers(nsurf);
+ break;
+ default:
+ ret = FALSE;
+ break;
+ }
+
+ return ret;
+}
+
static void
fbdev_surface_wait(struct native_surface *nsurf)
{
fbsurf->base.destroy = fbdev_surface_destroy;
fbsurf->base.swap_buffers = fbdev_surface_swap_buffers;
fbsurf->base.flush_frontbuffer = fbdev_surface_flush_frontbuffer;
+ fbsurf->base.present = fbdev_surface_present;
fbsurf->base.validate = fbdev_surface_validate;
fbsurf->base.wait = fbdev_surface_wait;
int val;
switch (param) {
+ case NATIVE_PARAM_USE_NATIVE_BUFFER:
+ case NATIVE_PARAM_PRESERVE_BUFFER:
+ case NATIVE_PARAM_MAX_SWAP_INTERVAL:
default:
val = 0;
break;
return ret;
}
+static boolean
+gdi_surface_present(struct native_surface *nsurf,
+ enum native_attachment natt,
+ boolean preserve,
+ uint swap_interval)
+{
+ boolean ret;
+
+ if (preserve || swap_interval)
+ return FALSE;
+
+ switch (natt) {
+ case NATIVE_ATTACHMENT_FRONT_LEFT:
+ ret = gdi_surface_flush_frontbuffer(nsurf);
+ break;
+ case NATIVE_ATTACHMENT_BACK_LEFT:
+ ret = gdi_surface_swap_buffers(nsurf);
+ break;
+ default:
+ ret = FALSE;
+ break;
+ }
+
+ return ret;
+}
+
static boolean
gdi_surface_validate(struct native_surface *nsurf, uint attachment_mask,
unsigned int *seq_num, struct pipe_resource **textures,
gsurf->base.destroy = gdi_surface_destroy;
gsurf->base.swap_buffers = gdi_surface_swap_buffers;
gsurf->base.flush_frontbuffer = gdi_surface_flush_frontbuffer;
+ xsurf->base.present = gdi_surface_present;
gsurf->base.validate = gdi_surface_validate;
gsurf->base.wait = gdi_surface_wait;
/* private buffers are allocated */
val = FALSE;
break;
+ case NATIVE_PARAM_PRESERVE_BUFFER:
+ case NATIVE_PARAM_MAX_SWAP_INTERVAL:
default:
val = 0;
break;
return TRUE;
}
+static boolean
+dri2_surface_present(struct native_surface *nsurf,
+ enum native_attachment natt,
+ boolean preserve,
+ uint swap_interval)
+{
+ boolean ret;
+
+ if (swap_interval)
+ return FALSE;
+
+ switch (natt) {
+ case NATIVE_ATTACHMENT_FRONT_LEFT:
+ ret = dri2_surface_flush_frontbuffer(nsurf);
+ break;
+ case NATIVE_ATTACHMENT_BACK_LEFT:
+ ret = dri2_surface_swap_buffers(nsurf);
+ break;
+ default:
+ ret = FALSE;
+ break;
+ }
+
+ return ret;
+}
+
static boolean
dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask,
unsigned int *seq_num, struct pipe_resource **textures,
dri2surf->base.destroy = dri2_surface_destroy;
dri2surf->base.swap_buffers = dri2_surface_swap_buffers;
dri2surf->base.flush_frontbuffer = dri2_surface_flush_frontbuffer;
+ dri2surf->base.present = dri2_surface_present;
dri2surf->base.validate = dri2_surface_validate;
dri2surf->base.wait = dri2_surface_wait;
switch (param) {
case NATIVE_PARAM_USE_NATIVE_BUFFER:
- /* DRI2GetBuffers use the native buffers */
+ /* DRI2GetBuffers uses the native buffers */
+ val = TRUE;
+ break;
+ case NATIVE_PARAM_PRESERVE_BUFFER:
+ /* DRI2CopyRegion is used */
val = TRUE;
break;
+ case NATIVE_PARAM_MAX_SWAP_INTERVAL:
default:
val = 0;
break;
return ret;
}
+static boolean
+ximage_surface_present(struct native_surface *nsurf,
+ enum native_attachment natt,
+ boolean preserve,
+ uint swap_interval)
+{
+ boolean ret;
+
+ if (preserve || swap_interval)
+ return FALSE;
+
+ switch (natt) {
+ case NATIVE_ATTACHMENT_FRONT_LEFT:
+ ret = ximage_surface_flush_frontbuffer(nsurf);
+ break;
+ case NATIVE_ATTACHMENT_BACK_LEFT:
+ ret = ximage_surface_swap_buffers(nsurf);
+ break;
+ default:
+ ret = FALSE;
+ break;
+ }
+
+ return ret;
+}
+
static boolean
ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask,
unsigned int *seq_num, struct pipe_resource **textures,
xsurf->base.destroy = ximage_surface_destroy;
xsurf->base.swap_buffers = ximage_surface_swap_buffers;
xsurf->base.flush_frontbuffer = ximage_surface_flush_frontbuffer;
+ xsurf->base.present = ximage_surface_present;
xsurf->base.validate = ximage_surface_validate;
xsurf->base.wait = ximage_surface_wait;
/* private buffers are allocated */
val = FALSE;
break;
+ case NATIVE_PARAM_PRESERVE_BUFFER:
+ case NATIVE_PARAM_MAX_SWAP_INTERVAL:
default:
val = 0;
break;