Skip to content
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

Merged
merged 4 commits into from Sep 4, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Normalize small borders to solid.

  • Loading branch information
emilio committed Sep 4, 2018
commit 574bb241963021cbc3ab686d3a5560b824d2d574
@@ -428,7 +428,10 @@ impl BrushKind {

// Construct a brush that is a border with `border` style and `widths`
// dimensions.
pub fn new_border(border: NormalBorder, widths: BorderWidths) -> BrushKind {
pub fn new_border(mut border: NormalBorder, widths: BorderWidths) -> BrushKind {
// FIXME(emilio): Is this the best place to do this?
border.normalize(&widths);

let cache_key = BorderCacheKey::new(&border, &widths);
BrushKind::Border {
source: BorderSource::Border {
@@ -273,6 +273,33 @@ impl NormalBorder {
b.bottom.color = color;
b
}

/// Normalizes a border so that we don't render disallowed stuff, like inset
/// borders that are less than two pixels wide.
#[inline]
pub fn normalize(&mut self, widths: &BorderWidths) {
#[inline]
fn renders_small_border_solid(style: BorderStyle) -> bool {
match style {
BorderStyle::Groove |
BorderStyle::Ridge |
BorderStyle::Inset |
BorderStyle::Outset => true,
_ => false,
}
}

let normalize_side = |side: &mut BorderSide, width: f32| {
if renders_small_border_solid(side.style) && width < 2. {
side.style = BorderStyle::Solid;
}
};

normalize_side(&mut self.left, widths.left);
normalize_side(&mut self.right, widths.right);
normalize_side(&mut self.top, widths.top);
normalize_side(&mut self.bottom, widths.bottom);
}
}

#[repr(u32)]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.