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

Prevent border widths to allocate huge render task surfaces. #2966

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

Always

Just for now

@@ -946,19 +946,26 @@ impl BorderRenderTaskInfo {
instances
}

/// Computes the maximum scale that we allow for this set of border radii.
/// Computes the maximum scale that we allow for this set of border parameters.
/// capping the scale will result in rendering very large corners at a lower
/// resolution and stretching them, so they will have the right shape, but
/// blurrier.
pub fn get_max_scale(radii: &BorderRadius) -> LayoutToDeviceScale {
pub fn get_max_scale(
radii: &BorderRadius,
widths: &BorderWidths
) -> LayoutToDeviceScale {
let r = radii.top_left.width
.max(radii.top_left.height)
.max(radii.top_right.width)
.max(radii.top_right.height)
.max(radii.bottom_left.width)
.max(radii.bottom_left.height)
.max(radii.bottom_right.width)
.max(radii.bottom_right.height);
.max(radii.bottom_right.height)
.max(widths.top)
.max(widths.bottom)
.max(widths.left)
.max(widths.right);

LayoutToDeviceScale::new(MAX_BORDER_RESOLUTION as f32 / r)
}
@@ -1471,7 +1471,7 @@ impl PrimitiveStore {
// sized border task.
let world_scale = LayoutToWorldScale::new(1.0);
let mut scale = world_scale * frame_context.device_pixel_scale;
let max_scale = BorderRenderTaskInfo::get_max_scale(&border.radius);
let max_scale = BorderRenderTaskInfo::get_max_scale(&border.radius, &widths);
scale.0 = scale.0.min(max_scale.0);
let scale_au = Au::from_f32_px(scale.0);
let needs_update = scale_au != cache_key.scale;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.