Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 46 additions & 8 deletions plugins/obs-text/gdiplus/obs-text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,12 @@ inline void TextSource::Update(obs_data_t *s)
uint32_t new_bk_color = obs_data_get_uint32(s, S_BKCOLOR);
uint32_t new_bk_opacity = obs_data_get_uint32(s, S_BKOPACITY);

Align new_align = align;
VAlign new_valign = valign;

wstring old_text = text;
bool needs_render = false;

/* ----------------------------- */

wstring new_face = to_wide(font_face);
Expand All @@ -780,6 +786,8 @@ inline void TextSource::Update(obs_data_t *s)
strikeout = new_strikeout;

UpdateFont();

needs_render = true;
}

/* ----------------------------- */
Expand All @@ -789,6 +797,16 @@ inline void TextSource::Update(obs_data_t *s)
new_o_color = rgb_to_bgr(new_o_color);
new_bk_color = rgb_to_bgr(new_bk_color);

if (color != new_color || opacity != new_opacity ||
(gradient && color2 != new_color2) ||
(gradient && opacity2 != new_opacity2) ||
gradient_dir != new_grad_dir || vertical != new_vertical ||
bk_color != new_bk_color || bk_opacity != new_bk_opacity ||
use_extents != new_extents || wrap != new_extents_wrap ||
extents_cx != n_extents_cx || extents_cy != n_extents_cy ||
antialiasing != new_antialiasing)
needs_render = true;
Comment on lines +800 to +808
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (color != new_color || opacity != new_opacity ||
(gradient && color2 != new_color2) ||
(gradient && opacity2 != new_opacity2) ||
gradient_dir != new_grad_dir || vertical != new_vertical ||
bk_color != new_bk_color || bk_opacity != new_bk_opacity ||
use_extents != new_extents || wrap != new_extents_wrap ||
extents_cx != n_extents_cx || extents_cy != n_extents_cy ||
antialiasing != new_antialiasing)
needs_render = true;
if (color != new_color || opacity != new_opacity ||
(gradient && color2 != new_color2) ||
(gradient && opacity2 != new_opacity2) ||
gradient_dir != new_grad_dir || vertical != new_vertical ||
bk_color != new_bk_color || bk_opacity != new_bk_opacity ||
use_extents != new_extents || wrap != new_extents_wrap ||
extents_cx != n_extents_cx || extents_cy != n_extents_cy ||
antialiasing != new_antialiasing) {
needs_render = true;
}


color = new_color;
opacity = new_opacity;
color2 = new_color2;
Expand Down Expand Up @@ -831,26 +849,43 @@ inline void TextSource::Update(obs_data_t *s)
}
TransformText();

if (old_text != text || use_outline != new_outline ||
outline_color != new_o_color || outline_opacity != new_o_opacity ||
outline_size != roundf(float(new_o_size)))
needs_render = true;
Comment on lines +852 to +855
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (old_text != text || use_outline != new_outline ||
outline_color != new_o_color || outline_opacity != new_o_opacity ||
outline_size != roundf(float(new_o_size)))
needs_render = true;
if (old_text != text || use_outline != new_outline ||
outline_color != new_o_color || outline_opacity != new_o_opacity ||
outline_size != roundf(float(new_o_size))) {
needs_render = true;
}


use_outline = new_outline;
outline_color = new_o_color;
outline_opacity = new_o_opacity;
outline_size = roundf(float(new_o_size));

if (strcmp(align_str, S_ALIGN_CENTER) == 0)
align = Align::Center;
new_align = Align::Center;
else if (strcmp(align_str, S_ALIGN_RIGHT) == 0)
align = Align::Right;
new_align = Align::Right;
else
align = Align::Left;
new_align = Align::Left;

if (align != new_align) {
align = new_align;
needs_render = true;
}

if (strcmp(valign_str, S_VALIGN_CENTER) == 0)
valign = VAlign::Center;
new_valign = VAlign::Center;
else if (strcmp(valign_str, S_VALIGN_BOTTOM) == 0)
valign = VAlign::Bottom;
new_valign = VAlign::Bottom;
else
valign = VAlign::Top;
new_valign = VAlign::Top;

if (valign != new_valign) {
valign = new_valign;
needs_render = true;
}

if (needs_render)
RenderText();
Comment thread
exeldro marked this conversation as resolved.
Comment on lines +886 to +887
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (needs_render)
RenderText();
if (needs_render) {
RenderText();
}


RenderText();
update_time_elapsed = 0.0f;

/* ----------------------------- */
Expand All @@ -870,9 +905,12 @@ inline void TextSource::Tick(float seconds)
update_time_elapsed = 0.0f;

if (update_file) {
wstring old_text = text;
LoadFileText();
TransformText();
RenderText();
if (old_text != text)
RenderText();
Comment thread
exeldro marked this conversation as resolved.
Comment on lines +911 to +912
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (old_text != text)
RenderText();
if (old_text != text) {
RenderText();
}


update_file = false;
}

Expand Down