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 ...
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)
}
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,
{
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;
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)
}
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,
break;
}
+ priv->swap_interval = interval;
loader_dri3_set_swap_interval(&priv->loader_drawable, interval);
return 0;
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);
}
swap_interval = 1;
break;
}
- draw->vtable->set_swap_interval(draw, swap_interval);
+ draw->swap_interval = swap_interval;
dri3_update_num_back(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);
*/
++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:
* 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;
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 *);
xcb_special_event_t *special_event;
bool first_init;
+ int swap_interval;
struct loader_dri3_extensions *ext;
const struct loader_dri3_vtable *vtable;