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
Be consistent about how the algorithm we use to modulate colors. #3010
Changes from 1 commit
File filter...
Jump to…
Be consistent about how the algorithm we use to modulate colors.
In particular, if the color is black, every browser does its best to infer the color. Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1488294 This should require a couple test updates in Gecko I presume.
- Loading branch information
Unverified
| @@ -102,22 +102,41 @@ vec2 get_outer_corner_scale(int segment) { | ||
| return p; | ||
| } | ||
|
|
||
| vec4 mod_color(vec4 color, float f) { | ||
| return vec4(clamp(color.rgb * f, vec3(0.0), vec3(color.a)), color.a); | ||
| // NOTE(emilio): If you change this algorithm, do the same change | ||
| // in border.rs | ||
| vec4 mod_color(vec4 color, bool is_black, bool lighter) { | ||
| const float light_black = 0.7; | ||
| const float dark_black = 0.3; | ||
|
|
||
| const float dark_scale = 0.66666666; | ||
| const float light_scale = 1.0; | ||
|
|
||
| if (is_black) { | ||
| if (lighter) { | ||
| return vec4(vec3(light_black), color.a); | ||
| } | ||
| return vec4(vec3(dark_black), color.a); | ||
| } | ||
|
|
||
| if (lighter) { | ||
| return vec4(color.rgb * light_scale, color.a); | ||
| } | ||
| return vec4(color.rgb * dark_scale, color.a); | ||
| } | ||
|
|
||
| vec4[2] get_colors_for_side(vec4 color, int style) { | ||
| vec4 result[2]; | ||
| const vec2 f = vec2(1.3, 0.7); | ||
|
|
||
| bool is_black = color.rgb == vec3(0.0, 0.0, 0.0); | ||
nical
Collaborator
|
||
|
|
||
| switch (style) { | ||
| case BORDER_STYLE_GROOVE: | ||
| result[0] = mod_color(color, f.x); | ||
| result[1] = mod_color(color, f.y); | ||
| result[0] = mod_color(color, is_black, true); | ||
| result[1] = mod_color(color, is_black, false); | ||
| break; | ||
| case BORDER_STYLE_RIDGE: | ||
| result[0] = mod_color(color, f.y); | ||
| result[1] = mod_color(color, f.x); | ||
| result[0] = mod_color(color, is_black, false); | ||
| result[1] = mod_color(color, is_black, true); | ||
| break; | ||
| default: | ||
| result[0] = color; | ||
This may not be portable. IIRC, vector comparison produces vector of booleans. We should be using
dot(color.rgb,color.rgb)orall(color.rgb == vec3(0.0, 0.0, 0.0))