(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-08 11:04:45 -07:00
parent b007c6b139
commit 41176eef27
14 changed files with 66 additions and 56 deletions
+3 -3
View File
@@ -48,7 +48,7 @@ obs_display_t obs_display_create(struct gs_init_data *graphics_data)
{
struct obs_display *display = bzalloc(sizeof(struct obs_display));
gs_entercontext(obs_graphics());
gs_entercontext(obs->video.graphics);
if (!graphics_data->num_backbuffers)
graphics_data->num_backbuffers = 1;
@@ -91,9 +91,9 @@ void obs_display_destroy(obs_display_t display)
display->next->prev_next = display->prev_next;
pthread_mutex_unlock(&obs->data.displays_mutex);
gs_entercontext(obs_graphics());
obs_enter_graphics();
obs_display_free(display);
gs_leavecontext();
obs_leave_graphics();
bfree(display);
}
+2 -2
View File
@@ -56,7 +56,7 @@ static inline void render_displays(void)
if (!obs->data.valid)
return;
gs_entercontext(obs_graphics());
gs_entercontext(obs->video.graphics);
/* render extra displays/swaps */
pthread_mutex_lock(&obs->data.displays_mutex);
@@ -411,7 +411,7 @@ static inline void output_frame(uint64_t timestamp)
memset(&frame, 0, sizeof(struct video_data));
frame.timestamp = timestamp;
gs_entercontext(obs_graphics());
gs_entercontext(video->graphics);
render_video(video, cur_texture, prev_texture);
frame_ready = download_frame(video, prev_texture, &frame);
+9 -2
View File
@@ -808,9 +808,16 @@ bool obs_enum_service_types(size_t idx, const char **id)
return true;
}
graphics_t obs_graphics(void)
void obs_enter_graphics(void)
{
return (obs != NULL) ? obs->video.graphics : NULL;
if (obs && obs->video.graphics)
gs_entercontext(obs->video.graphics);
}
void obs_leave_graphics(void)
{
if (obs && obs->video.graphics)
gs_leavecontext();
}
audio_t obs_audio(void)
+5 -2
View File
@@ -380,8 +380,11 @@ EXPORT bool obs_enum_encoder_types(size_t idx, const char **id);
/** Enumerates all available service types. */
EXPORT bool obs_enum_service_types(size_t idx, const char **id);
/** Gets the main graphics context for this OBS context */
EXPORT graphics_t obs_graphics(void);
/** Helper function for entering the OBS graphics context */
EXPORT void obs_enter_graphics(void);
/** Helper function for leaving the OBS graphics context */
EXPORT void obs_leave_graphics(void);
/** Gets the main audio output handler for this OBS context */
EXPORT audio_t obs_audio(void);