loader: drop the [gs]et_swap_interval callbacks
authorEmil Velikov <emil.velikov@collabora.com>
Tue, 1 Aug 2017 23:59:26 +0000 (00:59 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 4 Aug 2017 22:57:22 +0000 (23:57 +0100)
Having two callbacks to manage a single int seems like an overkill.
Use a cached copy and update that when needed.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
Might want to look if the dimensions dance in .query_surface ...
speaking of which close to nobody implements that ...

src/egl/drivers/dri2/platform_x11_dri3.c
src/glx/dri3_glx.c
src/loader/loader_dri3_helper.c
src/loader/loader_dri3_helper.h

index 9548a2493472a64461611da093392ec43f2f91bc..3a0efc6ccc97d25531a26142ad833476b1f0a4ff 100644 (file)
@@ -45,22 +45,6 @@ loader_drawable_to_egl_surface(struct loader_dri3_drawable *draw) {
    return (struct dri3_egl_surface *)(((void*) draw) - offset);
 }
 
-static int
-egl_dri3_get_swap_interval(struct loader_dri3_drawable *draw)
-{
-   struct dri3_egl_surface *dri3_surf = loader_drawable_to_egl_surface(draw);
-
-   return dri3_surf->base.SwapInterval;
-}
-
-static void
-egl_dri3_set_swap_interval(struct loader_dri3_drawable *draw, int interval)
-{
-   struct dri3_egl_surface *dri3_surf = loader_drawable_to_egl_surface(draw);
-
-   dri3_surf->base.SwapInterval = interval;
-}
-
 static void
 egl_dri3_set_drawable_size(struct loader_dri3_drawable *draw,
                            int width, int height)
@@ -112,8 +96,6 @@ egl_dri3_flush_drawable(struct loader_dri3_drawable *draw, unsigned flags)
 }
 
 static const struct loader_dri3_vtable egl_dri3_vtable = {
-   .get_swap_interval = egl_dri3_get_swap_interval,
-   .set_swap_interval = egl_dri3_set_swap_interval,
    .set_drawable_size = egl_dri3_set_drawable_size,
    .in_current_context = egl_dri3_in_current_context,
    .get_dri_context = egl_dri3_get_dri_context,
@@ -142,6 +124,7 @@ dri3_set_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
 {
    struct dri3_egl_surface *dri3_surf = dri3_egl_surface(surf);
 
+   dri3_surf->base.SwapInterval = interval;
    loader_dri3_set_swap_interval(&dri3_surf->loader_drawable, interval);
 
    return EGL_TRUE;
index 64c0b9e7b9c333f81747873cca630ba06e4cc07a..024e8ab0479917cb63f9073d68ddb4bc8994b4f5 100644 (file)
@@ -86,22 +86,6 @@ loader_drawable_to_dri3_drawable(struct loader_dri3_drawable *draw) {
    return (struct dri3_drawable *)(((void*) draw) - offset);
 }
 
-static int
-glx_dri3_get_swap_interval(struct loader_dri3_drawable *draw)
-{
-   struct dri3_drawable *priv = loader_drawable_to_dri3_drawable(draw);
-
-   return priv->swap_interval;
-}
-
-static void
-glx_dri3_set_swap_interval(struct loader_dri3_drawable *draw, int interval)
-{
-   struct dri3_drawable *priv = loader_drawable_to_dri3_drawable(draw);
-
-   priv->swap_interval = interval;
-}
-
 static void
 glx_dri3_set_drawable_size(struct loader_dri3_drawable *draw,
                            int width, int height)
@@ -173,8 +157,6 @@ glx_dri3_show_fps(struct loader_dri3_drawable *draw, uint64_t current_ust)
 }
 
 static const struct loader_dri3_vtable glx_dri3_vtable = {
-   .get_swap_interval = glx_dri3_get_swap_interval,
-   .set_swap_interval = glx_dri3_set_swap_interval,
    .set_drawable_size = glx_dri3_set_drawable_size,
    .in_current_context = glx_dri3_in_current_context,
    .get_dri_context = glx_dri3_get_dri_context,
@@ -637,6 +619,7 @@ dri3_set_swap_interval(__GLXDRIdrawable *pdraw, int interval)
       break;
    }
 
+   priv->swap_interval = interval;
    loader_dri3_set_swap_interval(&priv->loader_drawable, interval);
 
    return 0;
index 1f666fcb8d43465a81befde7037b0276244ac2dd..9d24130291803cd831bdf31d0dd404fc075eddfd 100644 (file)
@@ -77,7 +77,7 @@ dri3_update_num_back(struct loader_dri3_drawable *draw)
 void
 loader_dri3_set_swap_interval(struct loader_dri3_drawable *draw, int interval)
 {
-   draw->vtable->set_swap_interval(draw, interval);
+   draw->swap_interval = interval;
    dri3_update_num_back(draw);
 }
 
@@ -164,7 +164,7 @@ loader_dri3_drawable_init(xcb_connection_t *conn,
       swap_interval = 1;
       break;
    }
-   draw->vtable->set_swap_interval(draw, swap_interval);
+   draw->swap_interval = swap_interval;
 
    dri3_update_num_back(draw);
 
@@ -634,10 +634,8 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
    __DRIcontext *dri_context;
    int64_t ret = 0;
    uint32_t options = XCB_PRESENT_OPTION_NONE;
-   int swap_interval;
 
    dri_context = draw->vtable->get_dri_context(draw);
-   swap_interval = draw->vtable->get_swap_interval(draw);
 
    draw->vtable->flush_drawable(draw, flush_flags);
 
@@ -673,7 +671,7 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
        */
       ++draw->send_sbc;
       if (target_msc == 0 && divisor == 0 && remainder == 0)
-         target_msc = draw->msc + swap_interval *
+         target_msc = draw->msc + draw->swap_interval *
                       (draw->send_sbc - draw->recv_sbc);
       else if (divisor == 0 && remainder > 0) {
          /* From the GLX_OML_sync_control spec:
@@ -697,7 +695,7 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
        * behaviour by not using XCB_PRESENT_OPTION_ASYNC, but this should not be
        * the default.
        */
-      if (swap_interval == 0)
+      if (draw->swap_interval == 0)
           options |= XCB_PRESENT_OPTION_ASYNC;
       if (force_copy)
           options |= XCB_PRESENT_OPTION_COPY;
index 90ee2007afb743d2805394cb95998cf060fe62f6..af42425df7f9f83889a51b393bef5d623b4d0a24 100644 (file)
@@ -97,8 +97,6 @@ struct loader_dri3_extensions {
 struct loader_dri3_drawable;
 
 struct loader_dri3_vtable {
-   int (*get_swap_interval)(struct loader_dri3_drawable *);
-   void (*set_swap_interval)(struct loader_dri3_drawable *, int);
    void (*set_drawable_size)(struct loader_dri3_drawable *, int, int);
    bool (*in_current_context)(struct loader_dri3_drawable *);
    __DRIcontext *(*get_dri_context)(struct loader_dri3_drawable *);
@@ -156,6 +154,7 @@ struct loader_dri3_drawable {
    xcb_special_event_t *special_event;
 
    bool first_init;
+   int swap_interval;
 
    struct loader_dri3_extensions *ext;
    const struct loader_dri3_vtable *vtable;