|
@@ -1,7 +1,8 @@
|
|
|
#include <obs-module.h>
|
|
|
|
|
|
struct color_source {
|
|
|
- uint32_t color;
|
|
|
+ struct vec4 color;
|
|
|
+ struct vec4 color_srgb;
|
|
|
|
|
|
uint32_t width;
|
|
|
uint32_t height;
|
|
@@ -22,7 +23,8 @@ static void color_source_update(void *data, obs_data_t *settings)
|
|
|
uint32_t width = (uint32_t)obs_data_get_int(settings, "width");
|
|
|
uint32_t height = (uint32_t)obs_data_get_int(settings, "height");
|
|
|
|
|
|
- context->color = color;
|
|
|
+ vec4_from_rgba(&context->color, color);
|
|
|
+ vec4_from_rgba_srgb(&context->color_srgb, color);
|
|
|
context->width = width;
|
|
|
context->height = height;
|
|
|
}
|
|
@@ -50,8 +52,8 @@ static obs_properties_t *color_source_properties(void *unused)
|
|
|
|
|
|
obs_properties_t *props = obs_properties_create();
|
|
|
|
|
|
- obs_properties_add_color(props, "color",
|
|
|
- obs_module_text("ColorSource.Color"));
|
|
|
+ obs_properties_add_color_alpha(props, "color",
|
|
|
+ obs_module_text("ColorSource.Color"));
|
|
|
|
|
|
obs_properties_add_int(props, "width",
|
|
|
obs_module_text("ColorSource.Width"), 0, 4096,
|
|
@@ -64,19 +66,14 @@ static obs_properties_t *color_source_properties(void *unused)
|
|
|
return props;
|
|
|
}
|
|
|
|
|
|
-static void color_source_render(void *data, gs_effect_t *effect)
|
|
|
+static void color_source_render_helper(struct color_source *context,
|
|
|
+ struct vec4 *colorVal)
|
|
|
{
|
|
|
- UNUSED_PARAMETER(effect);
|
|
|
-
|
|
|
- struct color_source *context = data;
|
|
|
-
|
|
|
gs_effect_t *solid = obs_get_base_effect(OBS_EFFECT_SOLID);
|
|
|
gs_eparam_t *color = gs_effect_get_param_by_name(solid, "color");
|
|
|
gs_technique_t *tech = gs_effect_get_technique(solid, "Solid");
|
|
|
|
|
|
- struct vec4 colorVal;
|
|
|
- vec4_from_rgba(&colorVal, context->color);
|
|
|
- gs_effect_set_vec4(color, &colorVal);
|
|
|
+ gs_effect_set_vec4(color, colorVal);
|
|
|
|
|
|
gs_technique_begin(tech);
|
|
|
gs_technique_begin_pass(tech, 0);
|
|
@@ -87,6 +84,27 @@ static void color_source_render(void *data, gs_effect_t *effect)
|
|
|
gs_technique_end(tech);
|
|
|
}
|
|
|
|
|
|
+static void color_source_render(void *data, gs_effect_t *effect)
|
|
|
+{
|
|
|
+ UNUSED_PARAMETER(effect);
|
|
|
+
|
|
|
+ struct color_source *context = data;
|
|
|
+
|
|
|
+ /* need linear path for correct alpha blending */
|
|
|
+ const bool linear_srgb = gs_get_linear_srgb() ||
|
|
|
+ (context->color.w < 1.0f);
|
|
|
+
|
|
|
+ const bool previous = gs_framebuffer_srgb_enabled();
|
|
|
+ gs_enable_framebuffer_srgb(linear_srgb);
|
|
|
+
|
|
|
+ if (linear_srgb)
|
|
|
+ color_source_render_helper(context, &context->color_srgb);
|
|
|
+ else
|
|
|
+ color_source_render_helper(context, &context->color);
|
|
|
+
|
|
|
+ gs_enable_framebuffer_srgb(previous);
|
|
|
+}
|
|
|
+
|
|
|
static uint32_t color_source_getwidth(void *data)
|
|
|
{
|
|
|
struct color_source *context = data;
|