(API Change) Remove obs_graphics()

API Removed:
- graphics_t obs_graphics();
Replaced With:
- void obs_enter_graphics();
- void obs_leave_graphics();

Description:
  obs_graphics() was somewhat of a pointless function.  The only time
that it was ever necessary was to pass it as a parameter to
gs_entercontext() followed by a subsequent gs_leavecontext() call after
that.  So, I felt that it made a bit more sense just to implement
obs_enter_graphics() and obs_leave_graphics() functions to do the exact
same thing without having to repeat that code.  There's really no need
to ever "hold" the graphics pointer, though I suppose that could change
in the future so having a similar function come back isn't out of the
question.

Still, this at least reduces the amount of unnecessary repeated code for
the time being.
This commit is contained in:
jp9000
2014-08-04 05:48:58 -07:00
parent b007c6b139
commit 41176eef27
14 changed files with 66 additions and 56 deletions

View File

@@ -63,7 +63,7 @@ static void display_capture_destroy(void *data)
if (!dc)
return;
gs_entercontext(obs_graphics());
obs_enter_graphics();
destroy_display_stream(dc);
@@ -72,7 +72,7 @@ static void display_capture_destroy(void *data)
if (dc->draw_effect)
effect_destroy(dc->draw_effect);
gs_leavecontext();
obs_leave_graphics();
pthread_mutex_destroy(&dc->mutex);
bfree(dc);
@@ -168,7 +168,7 @@ static void *display_capture_create(obs_data_t settings,
dc->source = source;
gs_entercontext(obs_graphics());
obs_enter_graphics();
struct gs_sampler_info info = {
.filter = GS_FILTER_LINEAR,
@@ -187,7 +187,7 @@ static void *display_capture_create(obs_data_t settings,
if (!dc->draw_effect)
goto fail;
gs_leavecontext();
obs_leave_graphics();
dc->display = obs_data_getint(settings, "display");
pthread_mutex_init(&dc->mutex, NULL);
@@ -198,7 +198,7 @@ static void *display_capture_create(obs_data_t settings,
return dc;
fail:
gs_leavecontext();
obs_leave_graphics();
display_capture_destroy(dc);
return NULL;
}
@@ -222,12 +222,12 @@ static void display_capture_video_tick(void *data, float seconds)
if (prev_prev == dc->prev)
return;
gs_entercontext(obs_graphics());
obs_enter_graphics();
if (dc->tex)
texture_rebind_iosurface(dc->tex, dc->prev);
else
dc->tex = gs_create_texture_from_iosurface(dc->prev);
gs_leavecontext();
obs_leave_graphics();
if (prev_prev) {
IOSurfaceDecrementUseCount(prev_prev);
@@ -288,14 +288,14 @@ static void display_capture_update(void *data, obs_data_t settings)
if (dc->display == display && dc->hide_cursor != show_cursor)
return;
gs_entercontext(obs_graphics());
obs_enter_graphics();
destroy_display_stream(dc);
dc->display = display;
dc->hide_cursor = !show_cursor;
init_display_stream(dc);
gs_leavecontext();
obs_leave_graphics();
}
static obs_properties_t display_capture_properties(void)