mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
libobs: Add functions to defer scene item update
Allows the ability to defer updating the item transform until all functions have been executed.
This commit is contained in:
parent
96d848f3d2
commit
0d7a969ebf
@ -293,6 +293,9 @@ static void update_item_transform(struct obs_scene_item *item)
|
||||
struct calldata params;
|
||||
uint8_t stack[128];
|
||||
|
||||
if (os_atomic_load_long(&item->defer_update) > 0)
|
||||
return;
|
||||
|
||||
vec2_zero(&base_origin);
|
||||
vec2_zero(&origin);
|
||||
|
||||
@ -1573,3 +1576,20 @@ void obs_scene_atomic_update(obs_scene_t *scene,
|
||||
full_unlock(scene);
|
||||
obs_scene_release(scene);
|
||||
}
|
||||
|
||||
void obs_sceneitem_defer_update_begin(obs_sceneitem_t *item)
|
||||
{
|
||||
if (!obs_ptr_valid(item, "obs_sceneitem_defer_update_begin"))
|
||||
return;
|
||||
|
||||
os_atomic_inc_long(&item->defer_update);
|
||||
}
|
||||
|
||||
void obs_sceneitem_defer_update_end(obs_sceneitem_t *item)
|
||||
{
|
||||
if (!obs_ptr_valid(item, "obs_sceneitem_defer_update_end"))
|
||||
return;
|
||||
|
||||
if (os_atomic_dec_long(&item->defer_update) == 0)
|
||||
update_item_transform(item);
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ struct obs_scene_item {
|
||||
struct obs_scene *parent;
|
||||
struct obs_source *source;
|
||||
volatile long active_refs;
|
||||
volatile long defer_update;
|
||||
bool user_visible;
|
||||
bool visible;
|
||||
bool selected;
|
||||
|
@ -1237,6 +1237,9 @@ EXPORT void obs_sceneitem_get_box_transform(const obs_sceneitem_t *item,
|
||||
EXPORT bool obs_sceneitem_visible(const obs_sceneitem_t *item);
|
||||
EXPORT bool obs_sceneitem_set_visible(obs_sceneitem_t *item, bool visible);
|
||||
|
||||
EXPORT void obs_sceneitem_defer_update_begin(obs_sceneitem_t *item);
|
||||
EXPORT void obs_sceneitem_defer_update_end(obs_sceneitem_t *item);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Outputs */
|
||||
|
Loading…
Reference in New Issue
Block a user