Browse Source

libobs: Allow transitions to give placeholder

The fade transition could benefit by providing NULL to differentiate a
real source texture from the transparent placeholder. This would give it
a chance to fade correctly for source transitions.
jpark37 3 years ago
parent
commit
8194e9431e
3 changed files with 21 additions and 2 deletions
  1. 5 0
      docs/sphinx/reference-sources.rst
  2. 11 2
      libobs/obs-source-transition.c
  3. 5 0
      libobs/obs.h

+ 5 - 0
docs/sphinx/reference-sources.rst

@@ -1576,6 +1576,7 @@ Functions used by transitions
 ---------------------
 ---------------------
 
 
 .. function:: void obs_transition_video_render(obs_source_t *transition, obs_transition_video_render_callback_t callback)
 .. function:: void obs_transition_video_render(obs_source_t *transition, obs_transition_video_render_callback_t callback)
+              void obs_transition_video_render2(obs_source_t *transition, obs_transition_video_render_callback_t callback, gs_texture_t *placeholder_texture)
 
 
    Helper function used for rendering transitions.  This function will
    Helper function used for rendering transitions.  This function will
    render two distinct textures for source A and source B of the
    render two distinct textures for source A and source B of the
@@ -1587,6 +1588,10 @@ Functions used by transitions
    (0.0f..1.0f), *cx* and *cy* are the current dimensions of the
    (0.0f..1.0f), *cx* and *cy* are the current dimensions of the
    transition, and *data* is the implementation's private data.
    transition, and *data* is the implementation's private data.
 
 
+   The *placeholder_texture* parameter allows a callback to receive
+   a replacement that isn't the default transparent texture, including
+   NULL if the caller desires.
+
    Relevant data types used with this function:
    Relevant data types used with this function:
 
 
 .. code:: cpp
 .. code:: cpp

+ 11 - 2
libobs/obs-source-transition.c

@@ -725,6 +725,15 @@ void obs_transition_force_stop(obs_source_t *transition)
 
 
 void obs_transition_video_render(obs_source_t *transition,
 void obs_transition_video_render(obs_source_t *transition,
 				 obs_transition_video_render_callback_t callback)
 				 obs_transition_video_render_callback_t callback)
+{
+	obs_transition_video_render2(transition, callback,
+				     obs->video.transparent_texture);
+}
+
+void obs_transition_video_render2(
+	obs_source_t *transition,
+	obs_transition_video_render_callback_t callback,
+	gs_texture_t *placeholder_texture)
 {
 {
 	struct transition_state state;
 	struct transition_state state;
 	struct matrix4 matrices[2];
 	struct matrix4 matrices[2];
@@ -773,9 +782,9 @@ void obs_transition_video_render(obs_source_t *transition,
 					     source_space);
 					     source_space);
 				tex[i] = get_texture(transition, i);
 				tex[i] = get_texture(transition, i);
 				if (!tex[i])
 				if (!tex[i])
-					tex[i] = obs->video.transparent_texture;
+					tex[i] = placeholder_texture;
 			} else {
 			} else {
-				tex[i] = obs->video.transparent_texture;
+				tex[i] = placeholder_texture;
 			}
 			}
 		}
 		}
 
 

+ 5 - 0
libobs/obs.h

@@ -1587,6 +1587,11 @@ EXPORT void
 obs_transition_video_render(obs_source_t *transition,
 obs_transition_video_render(obs_source_t *transition,
 			    obs_transition_video_render_callback_t callback);
 			    obs_transition_video_render_callback_t callback);
 
 
+EXPORT void
+obs_transition_video_render2(obs_source_t *transition,
+			     obs_transition_video_render_callback_t callback,
+			     gs_texture_t *placeholder_texture);
+
 EXPORT enum gs_color_space
 EXPORT enum gs_color_space
 obs_transition_video_get_color_space(obs_source_t *transition);
 obs_transition_video_get_color_space(obs_source_t *transition);