-
Notifications
You must be signed in to change notification settings - Fork 26
feat: add color-key transparency #160
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
CyberShadow
wants to merge
1
commit into
wlrfx:main
Choose a base branch
from
CyberShadow:colorkey
base: main
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.
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
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
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
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
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
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
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
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 |
|---|---|---|
|
|
@@ -340,6 +340,11 @@ static void scene_node_opaque_region(struct wlr_scene_node *node, int x, int y, | |
| return; | ||
| } | ||
|
|
||
| // Colorkey with transparent destination means buffer is not opaque | ||
| if (scene_buffer->colorkey_enabled && scene_buffer->colorkey_dst[3] < 1.0f) { | ||
| return; | ||
| } | ||
|
|
||
| if (!scene_buffer->buffer_is_opaque) { | ||
| pixman_region32_copy(opaque, &scene_buffer->opaque_region); | ||
| pixman_region32_intersect_rect(opaque, opaque, 0, 0, width, height); | ||
|
|
@@ -1550,6 +1555,34 @@ void wlr_scene_buffer_set_opacity(struct wlr_scene_buffer *scene_buffer, | |
| scene_node_update(&scene_buffer->node, NULL); | ||
| } | ||
|
|
||
| void wlr_scene_buffer_set_colorkey(struct wlr_scene_buffer *scene_buffer, | ||
| bool enabled, const float colorkey_src[static 4], | ||
| const float colorkey_dst[static 4]) { | ||
| bool changed = scene_buffer->colorkey_enabled != enabled; | ||
| if (enabled) { | ||
| for (int i = 0; i < 4; i++) { | ||
| if (scene_buffer->colorkey_src[i] != colorkey_src[i] || | ||
| scene_buffer->colorkey_dst[i] != colorkey_dst[i]) { | ||
| changed = true; | ||
| break; | ||
| } | ||
| } | ||
|
Comment on lines
+1563
to
+1569
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. Not really a fan of the loops, but I guess the compiler will unroll it though. Any one else with input regarding this? |
||
| } | ||
|
|
||
| if (!changed) { | ||
| return; | ||
| } | ||
|
|
||
| scene_buffer->colorkey_enabled = enabled; | ||
| if (enabled) { | ||
| for (int i = 0; i < 4; i++) { | ||
| scene_buffer->colorkey_src[i] = colorkey_src[i]; | ||
| scene_buffer->colorkey_dst[i] = colorkey_dst[i]; | ||
| } | ||
|
Comment on lines
+1578
to
+1581
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. Same here |
||
| } | ||
| scene_node_update(&scene_buffer->node, NULL); | ||
| } | ||
|
|
||
| void wlr_scene_buffer_set_filter_mode(struct wlr_scene_buffer *scene_buffer, | ||
| enum wlr_scale_filter_mode filter_mode) { | ||
| if (scene_buffer->filter_mode == filter_mode) { | ||
|
|
@@ -2063,6 +2096,19 @@ static void scene_entry_render(struct render_list_entry *entry, const struct ren | |
| .corners = buffer_corners, | ||
| .corner_radius = scene_buffer->corner_radius * data->scale, | ||
| .clipped_region = {0}, | ||
| .colorkey_enabled = scene_buffer->colorkey_enabled, | ||
| .colorkey_src = { | ||
| scene_buffer->colorkey_src[0], | ||
| scene_buffer->colorkey_src[1], | ||
| scene_buffer->colorkey_src[2], | ||
| scene_buffer->colorkey_src[3], | ||
| }, | ||
| .colorkey_dst = { | ||
| scene_buffer->colorkey_dst[0], | ||
| scene_buffer->colorkey_dst[1], | ||
| scene_buffer->colorkey_dst[2], | ||
| scene_buffer->colorkey_dst[3], | ||
| }, | ||
| }; | ||
|
|
||
| fx_render_pass_add_texture(data->render_pass, &tex_options); | ||
|
|
||
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.
please use
#define/#ifand a new shader object for this, so perfomance stays identical when disabledUh oh!
There was an error while loading. Please reload this page.
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.
AFAIU, because this is a
uniform, theifshould already be inlined. Are you aware of this causing any impact beyond shader compilation?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.
Not sure how accurate this is, but
https://gist.github.com/CyberShadow/d5608b15998194aa75504016b7dd5b75
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.
The issue isn't with high-end hardware, but with power limited "weak" (in comparison) laptop GPUs, especially with all the other things being rendered during the same frame, like poorly damaged toplevels, blur, shadows, etc.
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.
Fair, here are the results on my 8-year-old laptop on the integrated GPU:
If you insist, I'll apply the patch if that's what you want. Or do you want me to test any specific combination?
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.
Sorry, I missed this comment, yeah this is true so shouldn't be anything to worry about, but I am worrying about the increasing size and number of uniforms of the shader though. Might be too much for low end hardware, but would require testing ofc :)
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.
Ah, fair! Let me have a look.