fb: Add hold/release logic
parent
d0cf1595af
commit
031555c85d
|
@ -24,6 +24,9 @@
|
|||
|
||||
struct nvnc_fb {
|
||||
int ref;
|
||||
int hold_count;
|
||||
nvnc_fb_release_fn on_release;
|
||||
void* userdata;
|
||||
void* addr;
|
||||
enum nvnc_fb_flags flags;
|
||||
size_t size;
|
||||
|
@ -32,3 +35,6 @@ struct nvnc_fb {
|
|||
uint32_t fourcc_format;
|
||||
uint64_t fourcc_modifier;
|
||||
};
|
||||
|
||||
void nvnc_fb_hold(struct nvnc_fb* fb);
|
||||
void nvnc_fb_release(struct nvnc_fb* fb);
|
||||
|
|
|
@ -50,6 +50,7 @@ typedef bool (*nvnc_auth_fn)(const char* username, const char* password,
|
|||
void* userdata);
|
||||
typedef void (*nvnc_render_fn)(struct nvnc_display*, struct nvnc_fb*);
|
||||
typedef void (*nvnc_cut_text_fn)(struct nvnc*, const char* text, uint32_t len);
|
||||
typedef void (*nvnc_fb_release_fn)(struct nvnc_fb*, void* userdata);
|
||||
|
||||
extern const char nvnc_version[];
|
||||
|
||||
|
@ -87,6 +88,8 @@ void nvnc_fb_unref(struct nvnc_fb* fb);
|
|||
|
||||
enum nvnc_fb_flags nvnc_fb_get_flags(const struct nvnc_fb*);
|
||||
void nvnc_fb_set_flags(struct nvnc_fb*, enum nvnc_fb_flags);
|
||||
void nvnc_fb_set_release_fn(struct nvnc_fb* fb, nvnc_fb_release_fn fn,
|
||||
void* userdata);
|
||||
|
||||
void* nvnc_fb_get_addr(const struct nvnc_fb* fb);
|
||||
uint16_t nvnc_fb_get_width(const struct nvnc_fb* fb);
|
||||
|
|
18
src/fb.c
18
src/fb.c
|
@ -110,3 +110,21 @@ void nvnc_fb_unref(struct nvnc_fb* fb)
|
|||
if (--fb->ref == 0)
|
||||
nvnc__fb_free(fb);
|
||||
}
|
||||
|
||||
EXPORT
|
||||
void nvnc_fb_set_release_fn(struct nvnc_fb* fb, nvnc_fb_release_fn fn, void* userdata)
|
||||
{
|
||||
fb->on_release = fn;
|
||||
fb->userdata = userdata;
|
||||
}
|
||||
|
||||
void nvnc_fb_hold(struct nvnc_fb* fb)
|
||||
{
|
||||
fb->hold_count++;
|
||||
}
|
||||
|
||||
void nvnc_fb_release(struct nvnc_fb* fb)
|
||||
{
|
||||
if (--fb->hold_count == 0 && fb->on_release)
|
||||
fb->on_release(fb, fb->userdata);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue