diff options
author | Chia-I Wu <[email protected]> | 2011-09-02 21:26:24 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2011-09-08 11:16:11 +0800 |
commit | 08e1076fd2d3f6fb879dd2529e7d035d6a399da2 (patch) | |
tree | aeec3914333754dc2745c4f747a3a6bc69f4a1e0 /src | |
parent | c0470bf77a038fd45441d1e55e6c89100996ff4b (diff) |
st/egl: add native_present_control
Replace the parameters of native_surface::present by a struct,
native_present_control. Using a struct allows us to add more control
options without having to update each backend every time.
Diffstat (limited to 'src')
11 files changed, 57 insertions, 49 deletions
diff --git a/src/gallium/state_trackers/egl/android/native_android.cpp b/src/gallium/state_trackers/egl/android/native_android.cpp index 338427d6925..5f4638a679a 100644 --- a/src/gallium/state_trackers/egl/android/native_android.cpp +++ b/src/gallium/state_trackers/egl/android/native_android.cpp @@ -386,24 +386,22 @@ copy_resources(struct native_display *ndpy, 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)); diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c b/src/gallium/state_trackers/egl/common/egl_g3d_api.c index f897054a540..27bc8be4e48 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c @@ -551,6 +551,7 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) 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 || @@ -569,10 +570,12 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) 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 diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c index b839f848d7b..50ed669ba30 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c @@ -192,9 +192,12 @@ egl_g3d_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, { _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 diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h index 58593a489cd..0c86b752c92 100644 --- a/src/gallium/state_trackers/egl/common/native.h +++ b/src/gallium/state_trackers/egl/common/native.h @@ -73,6 +73,20 @@ enum native_param_type { 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. @@ -85,9 +99,7 @@ struct native_surface { * 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 diff --git a/src/gallium/state_trackers/egl/common/native_helper.c b/src/gallium/state_trackers/egl/common/native_helper.c index cca1e1c6295..ebe5144b367 100644 --- a/src/gallium/state_trackers/egl/common/native_helper.c +++ b/src/gallium/state_trackers/egl/common/native_helper.c @@ -393,12 +393,16 @@ native_display_copy_to_pixmap(struct native_display *ndpy, 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) diff --git a/src/gallium/state_trackers/egl/drm/modeset.c b/src/gallium/state_trackers/egl/drm/modeset.c index 73968d1343b..b33323b9d60 100644 --- a/src/gallium/state_trackers/egl/drm/modeset.c +++ b/src/gallium/state_trackers/egl/drm/modeset.c @@ -194,21 +194,19 @@ drm_surface_swap_buffers(struct native_surface *nsurf) 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); diff --git a/src/gallium/state_trackers/egl/fbdev/native_fbdev.c b/src/gallium/state_trackers/egl/fbdev/native_fbdev.c index 6772d379f73..e126888df90 100644 --- a/src/gallium/state_trackers/egl/fbdev/native_fbdev.c +++ b/src/gallium/state_trackers/egl/fbdev/native_fbdev.c @@ -183,17 +183,15 @@ fbdev_surface_update_drawable(struct native_surface *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) { @@ -206,7 +204,7 @@ fbdev_surface_present(struct native_surface *nsurf, /* 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; @@ -223,7 +221,7 @@ fbdev_surface_present(struct native_surface *nsurf, else { /* the drawable never changes */ ret = resource_surface_present(fbsurf->rsurf, - natt, (void *) &fbsurf->drawable); + ctrl->natt, (void *) &fbsurf->drawable); } return ret; diff --git a/src/gallium/state_trackers/egl/gdi/native_gdi.c b/src/gallium/state_trackers/egl/gdi/native_gdi.c index 6bf0d4e4668..d3fec719a21 100644 --- a/src/gallium/state_trackers/egl/gdi/native_gdi.c +++ b/src/gallium/state_trackers/egl/gdi/native_gdi.c @@ -161,16 +161,14 @@ gdi_surface_swap_buffers(struct native_surface *nsurf) 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; diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c b/src/gallium/state_trackers/egl/wayland/native_wayland.c index ded4cc481d1..29c9b46d612 100644 --- a/src/gallium/state_trackers/egl/wayland/native_wayland.c +++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c @@ -294,18 +294,16 @@ wayland_surface_swap_buffers(struct native_surface *nsurf) 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; diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index 4b8be7bc759..47547446ffd 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -342,16 +342,14 @@ dri2_surface_swap_buffers(struct native_surface *nsurf) 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; diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index e7794f0d3d7..c0108fc5525 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -170,16 +170,14 @@ ximage_surface_swap_buffers(struct native_surface *nsurf) 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; |