summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2021-02-16 21:51:33 -0800
committerVito Caputo <vcaputo@pengaru.com>2021-02-16 21:51:33 -0800
commit9e56788affedd6b01df6764732a4ba786f7a47f3 (patch)
tree89243765d939c4477de95435ab774f307fdb8f3c
parent11b87c843e20f66bd68e02353ba4a1072e1230a6 (diff)
*fb: plumb outer fb_t down to fb_ops_t methods
None of the existing fb_ops_t implementations need this, but due to how GTK+ works, the GTK+ frontend using librototiller will likely want to wire up calling fb_flip() on the fb from behind fb_ops.
-rw-r--r--src/drm_fb.c12
-rw-r--r--src/fb.c12
-rw-r--r--src/fb.h17
-rw-r--r--src/sdl_fb.c12
4 files changed, 27 insertions, 26 deletions
diff --git a/src/drm_fb.c b/src/drm_fb.c
index a25c889..9d70b91 100644
--- a/src/drm_fb.c
+++ b/src/drm_fb.c
@@ -422,7 +422,7 @@ _err:
}
-static void drm_fb_shutdown(void *context)
+static void drm_fb_shutdown(fb_t *fb, void *context)
{
drm_fb_t *c = context;
@@ -435,7 +435,7 @@ static void drm_fb_shutdown(void *context)
}
-static int drm_fb_acquire(void *context, void *page)
+static int drm_fb_acquire(fb_t *fb, void *context, void *page)
{
drm_fb_t *c = context;
drm_fb_page_t *p = page;
@@ -444,13 +444,13 @@ static int drm_fb_acquire(void *context, void *page)
}
-static void drm_fb_release(void *context)
+static void drm_fb_release(fb_t *fb, void *context)
{
/* TODO restore the existing mode @ last acquire? */
}
-static void * drm_fb_page_alloc(void *context, fb_page_t *res_page)
+static void * drm_fb_page_alloc(fb_t *fb, void *context, fb_page_t *res_page)
{
struct drm_mode_create_dumb create_dumb = { .bpp = 32 };
struct drm_mode_map_dumb map_dumb = {};
@@ -493,7 +493,7 @@ static void * drm_fb_page_alloc(void *context, fb_page_t *res_page)
}
-static int drm_fb_page_free(void *context, void *page)
+static int drm_fb_page_free(fb_t *fb, void *context, void *page)
{
struct drm_mode_destroy_dumb destroy_dumb = {};
drm_fb_t *c = context;
@@ -511,7 +511,7 @@ static int drm_fb_page_free(void *context, void *page)
}
-static int drm_fb_page_flip(void *context, void *page)
+static int drm_fb_page_flip(fb_t *fb, void *context, void *page)
{
drmEventContext drm_ev_ctx = {
.version = DRM_EVENT_CONTEXT_VERSION,
diff --git a/src/fb.c b/src/fb.c
index baa1322..03a04ac 100644
--- a/src/fb.c
+++ b/src/fb.c
@@ -108,7 +108,7 @@ int fb_flip(fb_t *fb)
pthread_mutex_unlock(&fb->ready_mutex);
/* submit the next active page for page flip on vsync, and wait for it. */
- r = fb->ops->page_flip(fb->ops_context, next_active_page->ops_page);
+ r = fb->ops->page_flip(fb, fb->ops_context, next_active_page->ops_page);
if (r < 0) /* TODO: vet this: what happens to this page? */
return r;
@@ -130,7 +130,7 @@ static int fb_acquire(fb_t *fb, _fb_page_t *page)
{
int ret;
- ret = fb->ops->acquire(fb->ops_context, page->ops_page);
+ ret = fb->ops->acquire(fb, fb->ops_context, page->ops_page);
if (ret < 0)
return ret;
@@ -143,7 +143,7 @@ static int fb_acquire(fb_t *fb, _fb_page_t *page)
/* release the fb, making the visible page inactive */
static void fb_release(fb_t *fb)
{
- fb->ops->release(fb->ops_context);
+ fb->ops->release(fb, fb->ops_context);
fb->active_page->next = fb->inactive_pages;
fb->inactive_pages = fb->active_page;
fb->active_page = NULL;
@@ -158,7 +158,7 @@ static void fb_page_new(fb_t *fb)
page = calloc(1, sizeof(_fb_page_t));
assert(page);
- page->ops_page = fb->ops->page_alloc(fb->ops_context, &page->public_page);
+ page->ops_page = fb->ops->page_alloc(fb, fb->ops_context, &page->public_page);
pthread_mutex_lock(&fb->inactive_mutex);
page->next = fb->inactive_pages;
@@ -170,7 +170,7 @@ static void fb_page_new(fb_t *fb)
static void _fb_page_free(fb_t *fb, _fb_page_t *page)
{
- fb->ops->page_free(fb->ops_context, page->ops_page);
+ fb->ops->page_free(fb, fb->ops_context, page->ops_page);
free(page);
}
@@ -247,7 +247,7 @@ void fb_free(fb_t *fb)
/* TODO: free all the pages */
if (fb->ops->shutdown && fb->ops_context)
- fb->ops->shutdown(fb->ops_context);
+ fb->ops->shutdown(fb, fb->ops_context);
pthread_mutex_destroy(&fb->ready_mutex);
pthread_cond_destroy(&fb->ready_cond);
diff --git a/src/fb.h b/src/fb.h
index b06ecb8..3a3646a 100644
--- a/src/fb.h
+++ b/src/fb.h
@@ -31,25 +31,26 @@ typedef struct fb_page_t {
fb_fragment_t fragment;
} fb_page_t;
+typedef struct fb_t fb_t;
+
/* Supply this struct to fb_new() with the appropriate context */
typedef struct fb_ops_t {
int (*setup)(const settings_t *settings, setting_desc_t **next);
int (*init)(const settings_t *settings, void **res_context);
- void (*shutdown)(void *context);
- int (*acquire)(void *context, void *page);
- void (*release)(void *context);
- void * (*page_alloc)(void *context, fb_page_t *res_page);
- int (*page_free)(void *context, void *page);
- int (*page_flip)(void *context, void *page);
+ void (*shutdown)(fb_t *fb, void *context);
+ int (*acquire)(fb_t *fb, void *context, void *page);
+ void (*release)(fb_t *fb, void *context);
+ void * (*page_alloc)(fb_t *fb, void *context, fb_page_t *res_page);
+ int (*page_free)(fb_t *fb, void *context, void *page);
+ int (*page_flip)(fb_t *fb, void *context, void *page);
} fb_ops_t;
-typedef struct fb_t fb_t;
-
fb_page_t * fb_page_get(fb_t *fb);
void fb_page_put(fb_t *fb, fb_page_t *page);
void fb_free(fb_t *fb);
void fb_get_put_pages_count(fb_t *fb, unsigned *count);
int fb_new(const fb_ops_t *ops, settings_t *settings, int n_pages, fb_t **res_fb);
+void * fb_context(fb_t *fb);
int fb_flip(fb_t *fb);
void fb_fragment_divide(fb_fragment_t *fragment, unsigned n_fragments, fb_fragment_t fragments[]);
int fb_fragment_slice_single(const fb_fragment_t *fragment, unsigned n_fragments, unsigned num, fb_fragment_t *res_fragment);
diff --git a/src/sdl_fb.c b/src/sdl_fb.c
index 8e48329..bff7b90 100644
--- a/src/sdl_fb.c
+++ b/src/sdl_fb.c
@@ -162,7 +162,7 @@ static int sdl_fb_init(const settings_t *settings, void **res_context)
}
-static void sdl_fb_shutdown(void *context)
+static void sdl_fb_shutdown(fb_t *fb, void *context)
{
sdl_fb_t *c = context;
@@ -171,7 +171,7 @@ static void sdl_fb_shutdown(void *context)
}
-static int sdl_fb_acquire(void *context, void *page)
+static int sdl_fb_acquire(fb_t *fb, void *context, void *page)
{
sdl_fb_t *c = context;
sdl_fb_page_t *p = page;
@@ -192,7 +192,7 @@ static int sdl_fb_acquire(void *context, void *page)
}
-static void sdl_fb_release(void *context)
+static void sdl_fb_release(fb_t *fb, void *context)
{
sdl_fb_t *c = context;
@@ -202,7 +202,7 @@ static void sdl_fb_release(void *context)
}
-static void * sdl_fb_page_alloc(void *context, fb_page_t *res_page)
+static void * sdl_fb_page_alloc(fb_t *fb, void *context, fb_page_t *res_page)
{
sdl_fb_t *c = context;
sdl_fb_page_t *p;
@@ -225,7 +225,7 @@ static void * sdl_fb_page_alloc(void *context, fb_page_t *res_page)
}
-static int sdl_fb_page_free(void *context, void *page)
+static int sdl_fb_page_free(fb_t *fb, void *context, void *page)
{
sdl_fb_t *c = context;
sdl_fb_page_t *p = page;
@@ -253,7 +253,7 @@ static int sdl_ready()
}
-static int sdl_fb_page_flip(void *context, void *page)
+static int sdl_fb_page_flip(fb_t *fb, void *context, void *page)
{
sdl_fb_t *c = context;
sdl_fb_page_t *p = page;
© All Rights Reserved