diff options
| -rw-r--r-- | include/plugins.h | 2 | ||||
| -rw-r--r-- | plugin/examples/hello_triangle/triangle.c | 10 | ||||
| -rw-r--r-- | plugin/plugin.h | 6 | ||||
| -rw-r--r-- | src/main.cpp | 3 | ||||
| -rw-r--r-- | src/plugins.c | 18 |
5 files changed, 39 insertions, 0 deletions
diff --git a/include/plugins.h b/include/plugins.h index 7588b61..db10336 100644 --- a/include/plugins.h +++ b/include/plugins.h @@ -34,5 +34,7 @@ void gsr_plugins_deinit(gsr_plugins *self); bool gsr_plugins_load_plugin(gsr_plugins *self, const char *plugin_filepath); void gsr_plugins_draw(gsr_plugins *self); +bool gsr_plugins_is_damaged(gsr_plugins *self); +void gsr_plugins_clear_damage(gsr_plugins *self); #endif /* GSR_PLUGINS_H */ diff --git a/plugin/examples/hello_triangle/triangle.c b/plugin/examples/hello_triangle/triangle.c index 194cf92..fd27a3d 100644 --- a/plugin/examples/hello_triangle/triangle.c +++ b/plugin/examples/hello_triangle/triangle.c @@ -62,6 +62,14 @@ static void draw(const gsr_plugin_draw_params *params, void *userdata) { ++triangle->counter; } +static bool is_damaged(void *userdata) { + return true; +} + +static void clear_damage(void *userdata) { + +} + bool gsr_plugin_init(const gsr_plugin_init_params *params, gsr_plugin_init_return *ret) { Triangle *triangle = calloc(1, sizeof(Triangle)); if(!triangle) @@ -98,6 +106,8 @@ bool gsr_plugin_init(const gsr_plugin_init_params *params, gsr_plugin_init_retur ret->version = 1; ret->userdata = triangle; ret->draw = draw; + ret->is_damaged = is_damaged; + ret->clear_damage = clear_damage; return true; } diff --git a/plugin/plugin.h b/plugin/plugin.h index 902d1d7..769a629 100644 --- a/plugin/plugin.h +++ b/plugin/plugin.h @@ -43,6 +43,12 @@ typedef struct { /* Optional, called when the plugin is expected to draw something to the current framebuffer */ void (*draw)(const gsr_plugin_draw_params *params, void *userdata); + /* Optional, returns false if this function is NULL. If this function is defined then this should return true + if there is an update visually that the plugin wants to display. This is useful when used with the "content" framerate mode + which only captures a frame when the frame has changed */ + bool (*is_damaged)(void *userdata); + /* Optional */ + void (*clear_damage)(void *userdata); } gsr_plugin_init_return; /* The plugin is expected to implement these functions and export them: */ diff --git a/src/main.cpp b/src/main.cpp index c2a5516..f0fbfc0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4388,6 +4388,8 @@ int main(int argc, char **argv) { damaged = true; } + damaged |= gsr_plugins_is_damaged(&plugins); + // TODO: Readd wayland sync warning when removing this if(arg_parser.framerate_mode != GSR_FRAMERATE_MODE_CONTENT) damaged = true; @@ -4417,6 +4419,7 @@ int main(int argc, char **argv) { egl.glClear(0); gsr_damage_clear(&damage); + gsr_plugins_clear_damage(&plugins); gsr_capture_kms_cleanup_kms_fds(); if(kms_client_initialized) { diff --git a/src/plugins.c b/src/plugins.c index 764dbc7..053b2a3 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -135,3 +135,21 @@ void gsr_plugins_draw(gsr_plugins *self) { self->egl->glBindFramebuffer(GL_FRAMEBUFFER, 0); } + +bool gsr_plugins_is_damaged(gsr_plugins *self) { + bool damaged = false; + for(int i = 0; i < self->num_plugins; ++i) { + const gsr_plugin *plugin = &self->plugins[i]; + if(plugin->data.is_damaged) + damaged |= plugin->data.is_damaged(plugin->data.userdata); + } + return damaged; +} + +void gsr_plugins_clear_damage(gsr_plugins *self) { + for(int i = 0; i < self->num_plugins; ++i) { + const gsr_plugin *plugin = &self->plugins[i]; + if(plugin->data.clear_damage) + plugin->data.clear_damage(plugin->data.userdata); + } +} |
