From 6348da808246d8a8302f98a4734cea3a1836d866 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Fri, 12 Apr 2019 09:58:24 +0000 Subject: [PATCH] Bug 1543844 - Fix incorrect max scale detection in WR border rendering. r=emilio The local rect for border segments is not solely determined by the widths and/or radius. Instead of determining the max scale based on those parameters, use the calculated border segment rects to determine an appropriate max scale factor. Differential Revision: https://phabricator.services.mozilla.com/D27189 --HG-- extra : moz-landing-system : lando --- gfx/wr/webrender/src/border.rs | 22 ++++++------------- gfx/wr/webrender/src/prim_store/mod.rs | 3 +-- .../wrench/reftests/border/max-scale-ref.yaml | 9 ++++++++ gfx/wr/wrench/reftests/border/max-scale.yaml | 12 ++++++++++ gfx/wr/wrench/reftests/border/reftest.list | 1 + 5 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 gfx/wr/wrench/reftests/border/max-scale-ref.yaml create mode 100644 gfx/wr/wrench/reftests/border/max-scale.yaml diff --git a/gfx/wr/webrender/src/border.rs b/gfx/wr/webrender/src/border.rs index fee8cddbe3a4..e602a767299a 100644 --- a/gfx/wr/webrender/src/border.rs +++ b/gfx/wr/webrender/src/border.rs @@ -11,7 +11,7 @@ use display_list_flattener::DisplayListFlattener; use gpu_types::{BorderInstance, BorderSegment, BrushFlags}; use prim_store::{BorderSegmentInfo, BrushSegment, NinePatchDescriptor}; use prim_store::{EdgeAaSegmentMask, ScrollNodeAndClipChain}; -use prim_store::borders::NormalBorderPrim; +use prim_store::borders::{NormalBorderPrim, NormalBorderData}; use util::{lerp, RectHelpers}; // Using 2048 as the maximum radius in device space before which we @@ -872,21 +872,13 @@ pub fn create_border_segments( /// resolution and stretching them, so they will have the right shape, but /// blurrier. pub fn get_max_scale_for_border( - radii: &BorderRadius, - widths: &LayoutSideOffsets + border_data: &NormalBorderData, ) -> 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(widths.top) - .max(widths.bottom) - .max(widths.left) - .max(widths.right); + let mut r = 1.0; + for segment in &border_data.border_segments { + let size = segment.local_task_size; + r = size.width.max(size.height.max(r)); + } LayoutToDeviceScale::new(MAX_BORDER_RESOLUTION as f32 / r) } diff --git a/gfx/wr/webrender/src/prim_store/mod.rs b/gfx/wr/webrender/src/prim_store/mod.rs index e3918e50a614..d6800bb1309c 100644 --- a/gfx/wr/webrender/src/prim_store/mod.rs +++ b/gfx/wr/webrender/src/prim_store/mod.rs @@ -2583,8 +2583,7 @@ impl PrimitiveStore { // Pick the maximum dimension as scale let world_scale = LayoutToWorldScale::new(scale_width.max(scale_height)); let mut scale = world_scale * device_pixel_scale; - let max_scale = get_max_scale_for_border(&border_data.border.radius, - &border_data.widths); + let max_scale = get_max_scale_for_border(border_data); scale.0 = scale.0.min(max_scale.0); // For each edge and corner, request the render task by content key diff --git a/gfx/wr/wrench/reftests/border/max-scale-ref.yaml b/gfx/wr/wrench/reftests/border/max-scale-ref.yaml new file mode 100644 index 000000000000..0647a7a86465 --- /dev/null +++ b/gfx/wr/wrench/reftests/border/max-scale-ref.yaml @@ -0,0 +1,9 @@ +--- +root: + items: + - type: border + bounds: [ 0, 0, 4000, 1 ] + width: [ 1, 0, 0, 0 ] + border-type: normal + style: solid + color: red diff --git a/gfx/wr/wrench/reftests/border/max-scale.yaml b/gfx/wr/wrench/reftests/border/max-scale.yaml new file mode 100644 index 000000000000..cf292d57980f --- /dev/null +++ b/gfx/wr/wrench/reftests/border/max-scale.yaml @@ -0,0 +1,12 @@ +--- +root: + items: + - type: stacking-context + transform: scale(3000, 1) + items: + - type: border + bounds: [ 0, 0, 100, 100 ] + width: [ 1, 0, 0, 0 ] + border-type: normal + style: solid + color: red diff --git a/gfx/wr/wrench/reftests/border/reftest.list b/gfx/wr/wrench/reftests/border/reftest.list index 4d37fc2ddb59..e90c7cfa4534 100644 --- a/gfx/wr/wrench/reftests/border/reftest.list +++ b/gfx/wr/wrench/reftests/border/reftest.list @@ -28,3 +28,4 @@ platform(linux,mac) == border-dashed-dotted-caching.yaml border-dashed-dotted-ca != small-inset-outset.yaml small-inset-outset-notref.yaml == no-aa.yaml green-square.yaml border-double-1px.yaml border-double-1px-ref.yaml +== max-scale.yaml max-scale-ref.yaml