-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
obs-text: Render only when changed #10735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
exeldro
wants to merge
1
commit into
obsproject:master
Choose a base branch
from
exeldro:text_render_on_change_only
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+46
−8
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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); | ||||||||||||||||||||
|
|
@@ -780,6 +786,8 @@ inline void TextSource::Update(obs_data_t *s) | |||||||||||||||||||
| strikeout = new_strikeout; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| UpdateFont(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| needs_render = true; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /* ----------------------------- */ | ||||||||||||||||||||
|
|
@@ -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; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| color = new_color; | ||||||||||||||||||||
| opacity = new_opacity; | ||||||||||||||||||||
| color2 = new_color2; | ||||||||||||||||||||
|
|
@@ -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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| 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(); | ||||||||||||||||||||
|
exeldro marked this conversation as resolved.
Comment on lines
+886
to
+887
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| RenderText(); | ||||||||||||||||||||
| update_time_elapsed = 0.0f; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /* ----------------------------- */ | ||||||||||||||||||||
|
|
@@ -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(); | ||||||||||||||||||||
|
exeldro marked this conversation as resolved.
Comment on lines
+911
to
+912
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| update_file = false; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.