Commit 9777c423 authored by Emil Velikov's avatar Emil Velikov Committed by Emil Velikov

loader: drop the [gs]et_swap_interval callbacks

Having two callbacks to manage a single int seems like an overkill.
Use a cached copy and update that when needed.
Signed-off-by: default avatarEmil Velikov <emil.velikov@collabora.com>
---
Might want to look if the dimensions dance in .query_surface ...
speaking of which close to nobody implements that ...
parent c961b679
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment