New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -40,9 +40,9 @@ static struct obs_source_info freetype2_source_info = {
|
|||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.output_flags = OBS_SOURCE_VIDEO |
|
||||
#ifdef _WIN32
|
||||
OBS_SOURCE_DEPRECATED |
|
||||
OBS_SOURCE_DEPRECATED |
|
||||
#endif
|
||||
OBS_SOURCE_CUSTOM_DRAW,
|
||||
OBS_SOURCE_CUSTOM_DRAW,
|
||||
.get_name = ft2_source_get_name,
|
||||
.create = ft2_source_create,
|
||||
.destroy = ft2_source_destroy,
|
||||
|
|
@ -128,42 +128,38 @@ static obs_properties_t *ft2_source_properties(void *unused)
|
|||
// Better/pixel shader outline/drop shadow
|
||||
// Some way to pull text files from network, I dunno
|
||||
|
||||
obs_properties_add_font(props, "font",
|
||||
obs_module_text("Font"));
|
||||
obs_properties_add_font(props, "font", obs_module_text("Font"));
|
||||
|
||||
obs_properties_add_text(props, "text",
|
||||
obs_module_text("Text"), OBS_TEXT_MULTILINE);
|
||||
obs_properties_add_text(props, "text", obs_module_text("Text"),
|
||||
OBS_TEXT_MULTILINE);
|
||||
|
||||
obs_properties_add_bool(props, "from_file",
|
||||
obs_module_text("ReadFromFile"));
|
||||
obs_module_text("ReadFromFile"));
|
||||
|
||||
obs_properties_add_bool(props, "log_mode",
|
||||
obs_module_text("ChatLogMode"));
|
||||
obs_module_text("ChatLogMode"));
|
||||
|
||||
obs_properties_add_int(props, "log_lines",
|
||||
obs_module_text("ChatLogLines"), 1, 1000, 1);
|
||||
obs_module_text("ChatLogLines"), 1, 1000, 1);
|
||||
|
||||
obs_properties_add_path(props,
|
||||
"text_file", obs_module_text("TextFile"),
|
||||
OBS_PATH_FILE, obs_module_text("TextFileFilter"), NULL);
|
||||
obs_properties_add_path(props, "text_file", obs_module_text("TextFile"),
|
||||
OBS_PATH_FILE,
|
||||
obs_module_text("TextFileFilter"), NULL);
|
||||
|
||||
obs_properties_add_color(props, "color1",
|
||||
obs_module_text("Color1"));
|
||||
obs_properties_add_color(props, "color1", obs_module_text("Color1"));
|
||||
|
||||
obs_properties_add_color(props, "color2",
|
||||
obs_module_text("Color2"));
|
||||
obs_properties_add_color(props, "color2", obs_module_text("Color2"));
|
||||
|
||||
obs_properties_add_bool(props, "outline",
|
||||
obs_module_text("Outline"));
|
||||
obs_properties_add_bool(props, "outline", obs_module_text("Outline"));
|
||||
|
||||
obs_properties_add_bool(props, "drop_shadow",
|
||||
obs_module_text("DropShadow"));
|
||||
obs_module_text("DropShadow"));
|
||||
|
||||
obs_properties_add_int(props, "custom_width",
|
||||
obs_module_text("CustomWidth"), 0, 4096, 1);
|
||||
obs_module_text("CustomWidth"), 0, 4096, 1);
|
||||
|
||||
obs_properties_add_bool(props, "word_wrap",
|
||||
obs_module_text("WordWrap"));
|
||||
obs_module_text("WordWrap"));
|
||||
|
||||
return props;
|
||||
}
|
||||
|
|
@ -220,17 +216,22 @@ static void ft2_source_destroy(void *data)
|
|||
static void ft2_source_render(void *data, gs_effect_t *effect)
|
||||
{
|
||||
struct ft2_source *srcdata = data;
|
||||
if (srcdata == NULL) return;
|
||||
if (srcdata == NULL)
|
||||
return;
|
||||
|
||||
if (srcdata->tex == NULL || srcdata->vbuf == NULL) return;
|
||||
if (srcdata->text == NULL || *srcdata->text == 0) return;
|
||||
if (srcdata->tex == NULL || srcdata->vbuf == NULL)
|
||||
return;
|
||||
if (srcdata->text == NULL || *srcdata->text == 0)
|
||||
return;
|
||||
|
||||
gs_reset_blend_state();
|
||||
if (srcdata->outline_text) draw_outlines(srcdata);
|
||||
if (srcdata->drop_shadow) draw_drop_shadow(srcdata);
|
||||
if (srcdata->outline_text)
|
||||
draw_outlines(srcdata);
|
||||
if (srcdata->drop_shadow)
|
||||
draw_drop_shadow(srcdata);
|
||||
|
||||
draw_uv_vbuffer(srcdata->vbuf, srcdata->tex,
|
||||
srcdata->draw_effect, (uint32_t)wcslen(srcdata->text) * 6);
|
||||
draw_uv_vbuffer(srcdata->vbuf, srcdata->tex, srcdata->draw_effect,
|
||||
(uint32_t)wcslen(srcdata->text) * 6);
|
||||
|
||||
UNUSED_PARAMETER(effect);
|
||||
}
|
||||
|
|
@ -238,8 +239,10 @@ static void ft2_source_render(void *data, gs_effect_t *effect)
|
|||
static void ft2_video_tick(void *data, float seconds)
|
||||
{
|
||||
struct ft2_source *srcdata = data;
|
||||
if (srcdata == NULL) return;
|
||||
if (!srcdata->from_file || !srcdata->text_file) return;
|
||||
if (srcdata == NULL)
|
||||
return;
|
||||
if (!srcdata->from_file || !srcdata->text_file)
|
||||
return;
|
||||
|
||||
if (os_gettime_ns() - srcdata->last_checked >= 1000000000) {
|
||||
time_t t = get_modified_timestamp(srcdata->text_file);
|
||||
|
|
@ -250,7 +253,7 @@ static void ft2_video_tick(void *data, float seconds)
|
|||
read_from_end(srcdata, srcdata->text_file);
|
||||
else
|
||||
load_text_from_file(srcdata,
|
||||
srcdata->text_file);
|
||||
srcdata->text_file);
|
||||
cache_glyphs(srcdata, srcdata->text);
|
||||
set_up_vertex_buffer(srcdata);
|
||||
srcdata->update_file = false;
|
||||
|
|
@ -269,7 +272,8 @@ static bool init_font(struct ft2_source *srcdata)
|
|||
{
|
||||
FT_Long index;
|
||||
const char *path = get_font_path(srcdata->font_name, srcdata->font_size,
|
||||
srcdata->font_style, srcdata->font_flags, &index);
|
||||
srcdata->font_style,
|
||||
srcdata->font_flags, &index);
|
||||
if (!path)
|
||||
return false;
|
||||
|
||||
|
|
@ -290,10 +294,10 @@ static void ft2_source_update(void *data, obs_data_t *settings)
|
|||
uint32_t color[2];
|
||||
uint32_t custom_width = 0;
|
||||
|
||||
const char *font_name = obs_data_get_string(font_obj, "face");
|
||||
const char *font_name = obs_data_get_string(font_obj, "face");
|
||||
const char *font_style = obs_data_get_string(font_obj, "style");
|
||||
uint16_t font_size = (uint16_t)obs_data_get_int(font_obj, "size");
|
||||
uint32_t font_flags = (uint32_t)obs_data_get_int(font_obj, "flags");
|
||||
uint16_t font_size = (uint16_t)obs_data_get_int(font_obj, "size");
|
||||
uint32_t font_flags = (uint32_t)obs_data_get_int(font_obj, "flags");
|
||||
|
||||
if (!font_obj)
|
||||
return;
|
||||
|
|
@ -311,8 +315,7 @@ static void ft2_source_update(void *data, obs_data_t *settings)
|
|||
srcdata->custom_width = custom_width;
|
||||
vbuf_needs_update = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (srcdata->custom_width >= 100)
|
||||
vbuf_needs_update = true;
|
||||
srcdata->custom_width = 0;
|
||||
|
|
@ -339,14 +342,14 @@ static void ft2_source_update(void *data, obs_data_t *settings)
|
|||
}
|
||||
srcdata->log_mode = chat_log_mode;
|
||||
|
||||
if (ft2_lib == NULL) goto error;
|
||||
if (ft2_lib == NULL)
|
||||
goto error;
|
||||
|
||||
if (srcdata->draw_effect == NULL) {
|
||||
char *effect_file = NULL;
|
||||
char *error_string = NULL;
|
||||
|
||||
effect_file =
|
||||
obs_module_file("text_default.effect");
|
||||
effect_file = obs_module_file("text_default.effect");
|
||||
|
||||
if (effect_file) {
|
||||
obs_enter_graphics();
|
||||
|
|
@ -360,18 +363,17 @@ static void ft2_source_update(void *data, obs_data_t *settings)
|
|||
}
|
||||
}
|
||||
|
||||
if (srcdata->font_size != font_size ||
|
||||
srcdata->from_file != from_file)
|
||||
if (srcdata->font_size != font_size || srcdata->from_file != from_file)
|
||||
vbuf_needs_update = true;
|
||||
|
||||
srcdata->file_load_failed = false;
|
||||
srcdata->from_file = from_file;
|
||||
|
||||
if (srcdata->font_name != NULL) {
|
||||
if (strcmp(font_name, srcdata->font_name) == 0 &&
|
||||
if (strcmp(font_name, srcdata->font_name) == 0 &&
|
||||
strcmp(font_style, srcdata->font_style) == 0 &&
|
||||
font_flags == srcdata->font_flags &&
|
||||
font_size == srcdata->font_size)
|
||||
font_size == srcdata->font_size)
|
||||
goto skip_font_load;
|
||||
|
||||
bfree(srcdata->font_name);
|
||||
|
|
@ -382,17 +384,16 @@ static void ft2_source_update(void *data, obs_data_t *settings)
|
|||
vbuf_needs_update = true;
|
||||
}
|
||||
|
||||
srcdata->font_name = bstrdup(font_name);
|
||||
srcdata->font_name = bstrdup(font_name);
|
||||
srcdata->font_style = bstrdup(font_style);
|
||||
srcdata->font_size = font_size;
|
||||
srcdata->font_size = font_size;
|
||||
srcdata->font_flags = font_flags;
|
||||
|
||||
if (!init_font(srcdata) || srcdata->font_face == NULL) {
|
||||
blog(LOG_WARNING, "FT2-text: Failed to load font %s",
|
||||
srcdata->font_name);
|
||||
srcdata->font_name);
|
||||
goto error;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
FT_Set_Pixel_Sizes(srcdata->font_face, 0, srcdata->font_size);
|
||||
FT_Select_Charmap(srcdata->font_face, FT_ENCODING_UNICODE);
|
||||
}
|
||||
|
|
@ -417,14 +418,15 @@ skip_font_load:
|
|||
srcdata->text = NULL;
|
||||
|
||||
os_utf8_to_wcs_ptr(emptystr, strlen(emptystr),
|
||||
&srcdata->text);
|
||||
blog(LOG_WARNING, "FT2-text: Failed to open %s for "
|
||||
"reading", tmp);
|
||||
}
|
||||
else {
|
||||
&srcdata->text);
|
||||
blog(LOG_WARNING,
|
||||
"FT2-text: Failed to open %s for "
|
||||
"reading",
|
||||
tmp);
|
||||
} else {
|
||||
if (srcdata->text_file != NULL &&
|
||||
strcmp(srcdata->text_file, tmp) == 0 &&
|
||||
!vbuf_needs_update)
|
||||
strcmp(srcdata->text_file, tmp) == 0 &&
|
||||
!vbuf_needs_update)
|
||||
goto error;
|
||||
|
||||
bfree(srcdata->text_file);
|
||||
|
|
@ -436,10 +438,10 @@ skip_font_load:
|
|||
load_text_from_file(srcdata, tmp);
|
||||
srcdata->last_checked = os_gettime_ns();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
const char *tmp = obs_data_get_string(settings, "text");
|
||||
if (!tmp || !*tmp) goto error;
|
||||
if (!tmp || !*tmp)
|
||||
goto error;
|
||||
|
||||
if (srcdata->text != NULL) {
|
||||
bfree(srcdata->text);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue