Remove nvnc_set_render_fn

fb-api-v3
Andri Yngvason 2021-08-29 18:22:25 +00:00
parent 981256d8d5
commit f566105ab5
5 changed files with 5 additions and 56 deletions

View File

@ -98,7 +98,6 @@ struct nvnc {
struct nvnc_common common; struct nvnc_common common;
int fd; int fd;
struct aml_handler* poll_handle; struct aml_handler* poll_handle;
struct aml_idle* dispatch_handler;
struct nvnc_client_list clients; struct nvnc_client_list clients;
char name[256]; char name[256];
void* userdata; void* userdata;

View File

@ -29,5 +29,4 @@ struct nvnc_display {
struct nvnc* server; struct nvnc* server;
uint16_t x_pos, y_pos; uint16_t x_pos, y_pos;
struct nvnc_fb* buffer; struct nvnc_fb* buffer;
nvnc_render_fn render_fn;
}; };

View File

@ -49,7 +49,6 @@ typedef void (*nvnc_client_fn)(struct nvnc_client*);
typedef void (*nvnc_damage_fn)(struct pixman_region16* damage, void* userdata); typedef void (*nvnc_damage_fn)(struct pixman_region16* damage, void* userdata);
typedef bool (*nvnc_auth_fn)(const char* username, const char* password, typedef bool (*nvnc_auth_fn)(const char* username, const char* password,
void* userdata); 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_cut_text_fn)(struct nvnc*, const char* text, uint32_t len);
typedef void (*nvnc_fb_release_fn)(struct nvnc_fb*, void* userdata); typedef void (*nvnc_fb_release_fn)(struct nvnc_fb*, void* userdata);
@ -114,7 +113,6 @@ void nvnc_display_unref(struct nvnc_display*);
struct nvnc* nvnc_display_get_server(const struct nvnc_display*); struct nvnc* nvnc_display_get_server(const struct nvnc_display*);
void nvnc_display_set_render_fn(struct nvnc_display* self, nvnc_render_fn fn);
void nvnc_display_set_buffer(struct nvnc_display*, struct nvnc_fb*); void nvnc_display_set_buffer(struct nvnc_display*, struct nvnc_fb*);
void nvnc_display_damage_region(struct nvnc_display*, void nvnc_display_damage_region(struct nvnc_display*,

View File

@ -77,12 +77,6 @@ void nvnc_display_set_buffer(struct nvnc_display* self, struct nvnc_fb* fb)
nvnc_fb_hold(fb); nvnc_fb_hold(fb);
} }
EXPORT
void nvnc_display_set_render_fn(struct nvnc_display* self, nvnc_render_fn fn)
{
self->render_fn = fn;
}
EXPORT EXPORT
void nvnc_display_damage_region(struct nvnc_display* self, void nvnc_display_damage_region(struct nvnc_display* self,
const struct pixman_region16* region) const struct pixman_region16* region)

View File

@ -1104,39 +1104,6 @@ static int bind_address(const char* name, uint16_t port, enum addrtype type)
abort(); abort();
} }
static bool nvnc__is_damaged(struct nvnc* self)
{
struct nvnc_client* client;
LIST_FOREACH(client, &self->clients, link)
if (pixman_region_not_empty(&client->damage))
return true;
return false;
}
static void on_main_dispatch(void* aml_obj)
{
struct nvnc* self = aml_get_userdata(aml_obj);
struct nvnc_client* client;
if (!nvnc__is_damaged(self))
return;
LIST_FOREACH(client, &self->clients, link)
if (client->is_updating) {
log_debug("Can't render yet: still encoding for client %p\n",
client);
return;
}
struct nvnc_display* display = self->display;
if (display && display->render_fn)
display->render_fn(display, display->buffer);
LIST_FOREACH(client, &self->clients, link)
process_fb_update_requests(client);
}
static struct nvnc* open_common(const char* address, uint16_t port, enum addrtype type) static struct nvnc* open_common(const char* address, uint16_t port, enum addrtype type)
{ {
aml_require_workers(aml_get_default(), -1); aml_require_workers(aml_get_default(), -1);
@ -1163,19 +1130,8 @@ static struct nvnc* open_common(const char* address, uint16_t port, enum addrtyp
if (aml_start(aml_get_default(), self->poll_handle) < 0) if (aml_start(aml_get_default(), self->poll_handle) < 0)
goto poll_start_failure; goto poll_start_failure;
self->dispatch_handler = aml_idle_new(on_main_dispatch, self, NULL);
if (!self->dispatch_handler)
goto new_idle_failure;
if (aml_start(aml_get_default(), self->dispatch_handler) < 0)
goto idle_start_failure;
return self; return self;
idle_start_failure:
aml_unref(self->dispatch_handler);
new_idle_failure:
aml_stop(aml_get_default(), self->poll_handle);
poll_start_failure: poll_start_failure:
aml_unref(self->poll_handle); aml_unref(self->poll_handle);
handle_failure: handle_failure:
@ -1226,7 +1182,6 @@ void nvnc_close(struct nvnc* self)
LIST_FOREACH_SAFE (client, &self->clients, link, tmp) LIST_FOREACH_SAFE (client, &self->clients, link, tmp)
client_unref(client); client_unref(client);
aml_stop(aml_get_default(), self->dispatch_handler);
aml_stop(aml_get_default(), self->poll_handle); aml_stop(aml_get_default(), self->poll_handle);
unlink_fd_path(self->fd); unlink_fd_path(self->fd);
close(self->fd); close(self->fd);
@ -1238,7 +1193,6 @@ void nvnc_close(struct nvnc* self)
} }
#endif #endif
aml_unref(self->dispatch_handler);
aml_unref(self->poll_handle); aml_unref(self->poll_handle);
free(self); free(self);
} }
@ -1251,6 +1205,7 @@ static void on_write_frame_done(void* userdata, enum stream_req_status status)
nvnc_fb_release(client->current_fb); nvnc_fb_release(client->current_fb);
nvnc_fb_unref(client->current_fb); nvnc_fb_unref(client->current_fb);
client->current_fb = NULL; client->current_fb = NULL;
process_fb_update_requests(client);
client_unref(client); client_unref(client);
} }
@ -1338,6 +1293,7 @@ static void finish_fb_update(struct nvnc_client* client, struct vec* frame)
nvnc_fb_unref(client->current_fb); nvnc_fb_unref(client->current_fb);
client->current_fb = NULL; client->current_fb = NULL;
vec_destroy(frame); vec_destroy(frame);
process_fb_update_requests(client);
client_unref(client); client_unref(client);
} }
@ -1477,6 +1433,9 @@ void nvnc__damage_region(struct nvnc* self, const struct pixman_region16* damage
if (client->net_stream->state != STREAM_STATE_CLOSED) if (client->net_stream->state != STREAM_STATE_CLOSED)
pixman_region_union(&client->damage, &client->damage, pixman_region_union(&client->damage, &client->damage,
(struct pixman_region16*)damage); (struct pixman_region16*)damage);
LIST_FOREACH(client, &self->clients, link)
process_fb_update_requests(client);
} }
EXPORT EXPORT