Browse Source

(API Change) libobs: Remove main window funcs/vars

(Non-compiling commit: windowless-context branch)

API Changed:
---------------------
Removed functions:
- obs_add_draw_callback
- obs_remove_draw_callback
- obs_resize
- obs_preview_set_enabled
- obs_preview_enabled

Removed member variables from struct obs_video_info:
- window_width
- window_height
- window

Summary:
---------------------
Changes the core libobs API to not be dependent upon a main window/view.
If you wish to draw to a window/view, use an obs_display object to
handle it.

This allows the use of libobs without requiring a window to be present
on the system.  This is also prunes code that had to be needlessly
duplicated to handle the "main" window.
jp9000 10 years ago
parent
commit
b89ea47b96
4 changed files with 1 additions and 85 deletions
  1. 0 2
      libobs/obs-internal.h
  2. 0 3
      libobs/obs-video.c
  3. 1 59
      libobs/obs.c
  4. 0 21
      libobs/obs.h

+ 0 - 2
libobs/obs-internal.h

@@ -235,8 +235,6 @@ struct obs_core_video {
 	uint32_t                        base_height;
 	float                           color_matrix[16];
 	enum obs_scale_type             scale_type;
-
-	struct obs_display              main_display;
 };
 
 struct obs_core_audio {

+ 0 - 3
libobs/obs-video.c

@@ -113,9 +113,6 @@ static inline void render_displays(void)
 
 	pthread_mutex_unlock(&obs->data.displays_mutex);
 
-	/* render main display */
-	render_display(&obs->video.main_display);
-
 	gs_leave_context();
 }
 

+ 1 - 59
libobs/obs.c

@@ -28,18 +28,6 @@ struct obs_core *obs = NULL;
 extern void add_default_module_paths(void);
 extern char *find_libobs_data_file(const char *file);
 
-static inline void make_gs_init_data(struct gs_init_data *gid,
-		const struct obs_video_info *ovi)
-{
-	memcpy(&gid->window, &ovi->window, sizeof(struct gs_window));
-	gid->cx              = ovi->window_width;
-	gid->cy              = ovi->window_height;
-	gid->num_backbuffers = 2;
-	gid->format          = GS_RGBA;
-	gid->zsformat        = GS_ZS_NONE;
-	gid->adapter         = ovi->adapter;
-}
-
 static inline void make_video_info(struct video_output_info *vi,
 		struct obs_video_info *ovi)
 {
@@ -230,14 +218,11 @@ static bool obs_init_textures(struct obs_video_info *ovi)
 static int obs_init_graphics(struct obs_video_info *ovi)
 {
 	struct obs_core_video *video = &obs->video;
-	struct gs_init_data graphics_data;
 	bool success = true;
 	int errorcode;
 
-	make_gs_init_data(&graphics_data, ovi);
-
 	errorcode = gs_create(&video->graphics, ovi->graphics_module,
-			&graphics_data);
+			ovi->adapter);
 	if (errorcode != GS_SUCCESS) {
 		switch (errorcode) {
 		case GS_ERROR_MODULE_NOT_FOUND:
@@ -360,12 +345,6 @@ static int obs_init_video(struct obs_video_info *ovi)
 		return OBS_VIDEO_FAIL;
 	}
 
-	if (!obs_display_init(&video->main_display, NULL))
-		return OBS_VIDEO_FAIL;
-
-	video->main_display.cx = ovi->window_width;
-	video->main_display.cy = ovi->window_height;
-
 	gs_enter_context(video->graphics);
 
 	if (ovi->gpu_conversion && !obs_init_gpu_conversion(ovi))
@@ -404,8 +383,6 @@ static void obs_free_video(void)
 	struct obs_core_video *video = &obs->video;
 
 	if (video->video) {
-		obs_display_free(&video->main_display);
-
 		video_output_close(video->video);
 		video->video = NULL;
 
@@ -1375,30 +1352,6 @@ proc_handler_t *obs_get_proc_handler(void)
 	return obs->procs;
 }
 
-void obs_add_draw_callback(
-		void (*draw)(void *param, uint32_t cx, uint32_t cy),
-		void *param)
-{
-	if (!obs) return;
-
-	obs_display_add_draw_callback(&obs->video.main_display, draw, param);
-}
-
-void obs_remove_draw_callback(
-		void (*draw)(void *param, uint32_t cx, uint32_t cy),
-		void *param)
-{
-	if (!obs) return;
-
-	obs_display_remove_draw_callback(&obs->video.main_display, draw, param);
-}
-
-void obs_resize(uint32_t cx, uint32_t cy)
-{
-	if (!obs || !obs->video.video || !obs->video.graphics) return;
-	obs_display_resize(&obs->video.main_display, cx, cy);
-}
-
 void obs_render_main_view(void)
 {
 	if (!obs) return;
@@ -1755,14 +1708,3 @@ void obs_context_data_setname(struct obs_context_data *context,
 
 	pthread_mutex_unlock(&context->rename_cache_mutex);
 }
-
-void obs_preview_set_enabled(bool enable)
-{
-	if (obs)
-		obs->video.main_display.enabled = enable;
-}
-
-bool obs_preview_enabled(void)
-{
-	return obs ? obs->video.main_display.enabled : false;
-}

+ 0 - 21
libobs/obs.h

@@ -155,9 +155,6 @@ struct obs_video_info {
 	uint32_t            fps_num;       /**< Output FPS numerator */
 	uint32_t            fps_den;       /**< Output FPS denominator */
 
-	uint32_t            window_width;  /**< Window width */
-	uint32_t            window_height; /**< Window height */
-
 	uint32_t            base_width;    /**< Base compositing width */
 	uint32_t            base_height;   /**< Base compositing height */
 
@@ -168,8 +165,6 @@ struct obs_video_info {
 	/** Video adapter index to use (NOTE: avoid for optimus laptops) */
 	uint32_t            adapter;
 
-	struct gs_window    window;        /**< Window to render to */
-
 	/** Use shaders to convert to different color formats */
 	bool                gpu_conversion;
 
@@ -528,19 +523,6 @@ EXPORT signal_handler_t *obs_get_signal_handler(void);
 /** Returns the primary obs procedure handler */
 EXPORT proc_handler_t *obs_get_proc_handler(void);
 
-/** Adds a draw callback to the main render context */
-EXPORT void obs_add_draw_callback(
-		void (*draw)(void *param, uint32_t cx, uint32_t cy),
-		void *param);
-
-/** Removes a draw callback to the main render context */
-EXPORT void obs_remove_draw_callback(
-		void (*draw)(void *param, uint32_t cx, uint32_t cy),
-		void *param);
-
-/** Changes the size of the main view */
-EXPORT void obs_resize(uint32_t cx, uint32_t cy);
-
 /** Renders the main view */
 EXPORT void obs_render_main_view(void);
 
@@ -568,9 +550,6 @@ EXPORT void obs_load_sources(obs_data_array_t *array);
 /** Saves sources to a data array */
 EXPORT obs_data_array_t *obs_save_sources(void);
 
-EXPORT void obs_preview_set_enabled(bool enable);
-EXPORT bool obs_preview_enabled(void);
-
 
 /* ------------------------------------------------------------------------- */
 /* View context */