From fd1a10743670548b50c664d800ebe1501de6b614 Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Thu, 2 Jan 2020 17:03:32 -0600 Subject: [PATCH 1/3] image-source: Change default size to size of canvas --- plugins/image-source/color-source.c | 35 +++++++++++++++++++++++++---- plugins/image-source/image-source.c | 6 +++-- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/plugins/image-source/color-source.c b/plugins/image-source/color-source.c index 5739200b2..d4910d2f4 100644 --- a/plugins/image-source/color-source.c +++ b/plugins/image-source/color-source.c @@ -99,22 +99,49 @@ static uint32_t color_source_getheight(void *data) return context->height; } -static void color_source_defaults(obs_data_t *settings) +static void color_source_defaults_v1(obs_data_t *settings) { obs_data_set_default_int(settings, "color", 0xFFFFFFFF); obs_data_set_default_int(settings, "width", 400); obs_data_set_default_int(settings, "height", 400); } -struct obs_source_info color_source_info = { +static void color_source_defaults_v2(obs_data_t *settings) +{ + struct obs_video_info ovi; + obs_get_video_info(&ovi); + + obs_data_set_default_int(settings, "color", 0xFFFFFFFF); + obs_data_set_default_int(settings, "width", ovi.base_width); + obs_data_set_default_int(settings, "height", ovi.base_width); +} + +struct obs_source_info color_source_info_v1 = { .id = "color_source", .type = OBS_SOURCE_TYPE_INPUT, - .output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW, + .output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW | + OBS_SOURCE_CAP_OBSOLETE, .create = color_source_create, .destroy = color_source_destroy, .update = color_source_update, .get_name = color_source_get_name, - .get_defaults = color_source_defaults, + .get_defaults = color_source_defaults_v1, + .get_width = color_source_getwidth, + .get_height = color_source_getheight, + .video_render = color_source_render, + .get_properties = color_source_properties, + .icon_type = OBS_ICON_TYPE_COLOR, +}; + +struct obs_source_info color_source_info_v2 = { + .id = "color_source_v2", + .type = OBS_SOURCE_TYPE_INPUT, + .output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW, + .create = color_source_create, + .destroy = color_source_destroy, + .update = color_source_update, + .get_name = color_source_get_name, + .get_defaults = color_source_defaults_v2, .get_width = color_source_getwidth, .get_height = color_source_getheight, .video_render = color_source_render, diff --git a/plugins/image-source/image-source.c b/plugins/image-source/image-source.c index 5817c9c62..7e46c88e5 100644 --- a/plugins/image-source/image-source.c +++ b/plugins/image-source/image-source.c @@ -277,12 +277,14 @@ MODULE_EXPORT const char *obs_module_description(void) } extern struct obs_source_info slideshow_info; -extern struct obs_source_info color_source_info; +extern struct obs_source_info color_source_info_v1; +extern struct obs_source_info color_source_info_v2; bool obs_module_load(void) { obs_register_source(&image_source_info); - obs_register_source(&color_source_info); + obs_register_source(&color_source_info_v1); + obs_register_source(&color_source_info_v2); obs_register_source(&slideshow_info); return true; } From b5d2d26b5b1a71e0bcf4307537bab20fcc56f54e Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Thu, 2 Jan 2020 17:06:29 -0600 Subject: [PATCH 2/3] text-freetype2: Change default size of text to 256 --- plugins/text-freetype2/text-freetype2.c | 43 +++++++++++++++++++++---- plugins/text-freetype2/text-freetype2.h | 3 +- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/plugins/text-freetype2/text-freetype2.c b/plugins/text-freetype2/text-freetype2.c index dc220b3b1..27bec7589 100644 --- a/plugins/text-freetype2/text-freetype2.c +++ b/plugins/text-freetype2/text-freetype2.c @@ -35,16 +35,33 @@ MODULE_EXPORT const char *obs_module_description(void) uint32_t texbuf_w = 2048, texbuf_h = 2048; -static struct obs_source_info freetype2_source_info = { +static struct obs_source_info freetype2_source_info_v1 = { .id = "text_ft2_source", .type = OBS_SOURCE_TYPE_INPUT, + .output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CAP_OBSOLETE | + OBS_SOURCE_CUSTOM_DRAW, + .get_name = ft2_source_get_name, + .create = ft2_source_create_v1, + .destroy = ft2_source_destroy, + .update = ft2_source_update, + .get_width = ft2_source_get_width, + .get_height = ft2_source_get_height, + .video_render = ft2_source_render, + .video_tick = ft2_video_tick, + .get_properties = ft2_source_properties, + .icon_type = OBS_ICON_TYPE_TEXT, +}; + +static struct obs_source_info freetype2_source_info_v2 = { + .id = "text_ft2_source_v2", + .type = OBS_SOURCE_TYPE_INPUT, .output_flags = OBS_SOURCE_VIDEO | #ifdef _WIN32 OBS_SOURCE_DEPRECATED | #endif OBS_SOURCE_CUSTOM_DRAW, .get_name = ft2_source_get_name, - .create = ft2_source_create, + .create = ft2_source_create_v2, .destroy = ft2_source_destroy, .update = ft2_source_update, .get_width = ft2_source_get_width, @@ -83,7 +100,8 @@ bool obs_module_load() bfree(config_dir); } - obs_register_source(&freetype2_source_info); + obs_register_source(&freetype2_source_info_v1); + obs_register_source(&freetype2_source_info_v2); return true; } @@ -469,7 +487,8 @@ error: #define DEFAULT_FACE "Sans Serif" #endif -static void *ft2_source_create(obs_data_t *settings, obs_source_t *source) +static void *ft2_source_create(obs_data_t *settings, obs_source_t *source, + int ver) { struct ft2_source *srcdata = bzalloc(sizeof(struct ft2_source)); obs_data_t *font_obj = obs_data_create(); @@ -477,10 +496,12 @@ static void *ft2_source_create(obs_data_t *settings, obs_source_t *source) init_plugin(); - srcdata->font_size = 32; + const uint16_t font_size = ver == 1 ? 32 : 256; + + srcdata->font_size = font_size; obs_data_set_default_string(font_obj, "face", DEFAULT_FACE); - obs_data_set_default_int(font_obj, "size", 32); + obs_data_set_default_int(font_obj, "size", font_size); obs_data_set_default_obj(settings, "font", font_obj); obs_data_set_default_int(settings, "log_lines", 6); @@ -494,3 +515,13 @@ static void *ft2_source_create(obs_data_t *settings, obs_source_t *source) return srcdata; } + +static void *ft2_source_create_v1(obs_data_t *settings, obs_source_t *source) +{ + return ft2_source_create(settings, source, 1); +} + +static void *ft2_source_create_v2(obs_data_t *settings, obs_source_t *source) +{ + return ft2_source_create(settings, source, 2); +} diff --git a/plugins/text-freetype2/text-freetype2.h b/plugins/text-freetype2/text-freetype2.h index b9af53b34..25a1fd2e2 100644 --- a/plugins/text-freetype2/text-freetype2.h +++ b/plugins/text-freetype2/text-freetype2.h @@ -69,7 +69,8 @@ struct ft2_source { extern FT_Library ft2_lib; -static void *ft2_source_create(obs_data_t *settings, obs_source_t *source); +static void *ft2_source_create_v1(obs_data_t *settings, obs_source_t *source); +static void *ft2_source_create_v2(obs_data_t *settings, obs_source_t *source); static void ft2_source_destroy(void *data); static void ft2_source_update(void *data, obs_data_t *settings); static void ft2_source_render(void *data, gs_effect_t *effect); From 6a282360f02d3930cba9d756d5018d0afa9bca56 Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Wed, 15 Jan 2020 02:18:33 -0800 Subject: [PATCH 3/3] obs-text: Change default size of text to 256 --- plugins/obs-text/gdiplus/obs-text.cpp | 67 ++++++++++++++++----------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/plugins/obs-text/gdiplus/obs-text.cpp b/plugins/obs-text/gdiplus/obs-text.cpp index 0a34e988b..6c09d2ab1 100644 --- a/plugins/obs-text/gdiplus/obs-text.cpp +++ b/plugins/obs-text/gdiplus/obs-text.cpp @@ -1035,12 +1035,41 @@ static obs_properties_t *get_properties(void *data) return props; } +static void defaults(obs_data_t *settings, int ver) +{ + obs_data_t *font_obj = obs_data_create(); + obs_data_set_default_string(font_obj, "face", "Arial"); + obs_data_set_default_int(font_obj, "size", ver == 1 ? 36 : 256); + + obs_data_set_default_obj(settings, S_FONT, font_obj); + obs_data_set_default_string(settings, S_ALIGN, S_ALIGN_LEFT); + obs_data_set_default_string(settings, S_VALIGN, S_VALIGN_TOP); + obs_data_set_default_int(settings, S_COLOR, 0xFFFFFF); + obs_data_set_default_int(settings, S_OPACITY, 100); + obs_data_set_default_int(settings, S_GRADIENT_COLOR, 0xFFFFFF); + obs_data_set_default_int(settings, S_GRADIENT_OPACITY, 100); + obs_data_set_default_double(settings, S_GRADIENT_DIR, 90.0); + obs_data_set_default_int(settings, S_BKCOLOR, 0x000000); + obs_data_set_default_int(settings, S_BKOPACITY, 0); + obs_data_set_default_int(settings, S_OUTLINE_SIZE, 2); + obs_data_set_default_int(settings, S_OUTLINE_COLOR, 0xFFFFFF); + obs_data_set_default_int(settings, S_OUTLINE_OPACITY, 100); + obs_data_set_default_int(settings, S_CHATLOG_LINES, 6); + obs_data_set_default_bool(settings, S_EXTENTS_WRAP, true); + obs_data_set_default_int(settings, S_EXTENTS_CX, 100); + obs_data_set_default_int(settings, S_EXTENTS_CY, 100); + obs_data_set_default_int(settings, S_TRANSFORM, S_TRANSFORM_NONE); + + obs_data_release(font_obj); +}; + bool obs_module_load(void) { obs_source_info si = {}; si.id = "text_gdiplus"; si.type = OBS_SOURCE_TYPE_INPUT; - si.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW; + si.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW | + OBS_SOURCE_CAP_OBSOLETE; si.get_properties = get_properties; si.icon_type = OBS_ICON_TYPE_TEXT; @@ -1057,33 +1086,7 @@ bool obs_module_load(void) si.get_height = [](void *data) { return reinterpret_cast(data)->cy; }; - si.get_defaults = [](obs_data_t *settings) { - obs_data_t *font_obj = obs_data_create(); - obs_data_set_default_string(font_obj, "face", "Arial"); - obs_data_set_default_int(font_obj, "size", 36); - - obs_data_set_default_obj(settings, S_FONT, font_obj); - obs_data_set_default_string(settings, S_ALIGN, S_ALIGN_LEFT); - obs_data_set_default_string(settings, S_VALIGN, S_VALIGN_TOP); - obs_data_set_default_int(settings, S_COLOR, 0xFFFFFF); - obs_data_set_default_int(settings, S_OPACITY, 100); - obs_data_set_default_int(settings, S_GRADIENT_COLOR, 0xFFFFFF); - obs_data_set_default_int(settings, S_GRADIENT_OPACITY, 100); - obs_data_set_default_double(settings, S_GRADIENT_DIR, 90.0); - obs_data_set_default_int(settings, S_BKCOLOR, 0x000000); - obs_data_set_default_int(settings, S_BKOPACITY, 0); - obs_data_set_default_int(settings, S_OUTLINE_SIZE, 2); - obs_data_set_default_int(settings, S_OUTLINE_COLOR, 0xFFFFFF); - obs_data_set_default_int(settings, S_OUTLINE_OPACITY, 100); - obs_data_set_default_int(settings, S_CHATLOG_LINES, 6); - obs_data_set_default_bool(settings, S_EXTENTS_WRAP, true); - obs_data_set_default_int(settings, S_EXTENTS_CX, 100); - obs_data_set_default_int(settings, S_EXTENTS_CY, 100); - obs_data_set_default_int(settings, S_TRANSFORM, - S_TRANSFORM_NONE); - - obs_data_release(font_obj); - }; + si.get_defaults = [](obs_data_t *settings) { defaults(settings, 1); }; si.update = [](void *data, obs_data_t *settings) { reinterpret_cast(data)->Update(settings); }; @@ -1094,7 +1097,15 @@ bool obs_module_load(void) reinterpret_cast(data)->Render(); }; + obs_source_info si_v2 = si; + si_v2.id = "text_gdiplus_v2"; + si_v2.output_flags &= ~OBS_SOURCE_CAP_OBSOLETE; + si_v2.get_defaults = [](obs_data_t *settings) { + defaults(settings, 2); + }; + obs_register_source(&si); + obs_register_source(&si_v2); const GdiplusStartupInput gdip_input; GdiplusStartup(&gdip_token, &gdip_input, nullptr);