Bug 1597319 - Use rounded rect FAST_PATH more agressively r=gw
Differential Revision: https://phabricator.services.mozilla.com/D53999 --HG-- extra : rebase_source : 4bde6755f4fa92d85300888dc286b9fd97100c90 extra : source : d65ded00cb51c7c5e3e1a23145b2a8bf15e5e52e
|
@ -4,11 +4,10 @@
|
|||
|
||||
#include shared,clip_shared,ellipse
|
||||
|
||||
varying vec4 vLocalPos;
|
||||
#ifdef WR_FEATURE_FAST_PATH
|
||||
varying vec2 vLocalPos;
|
||||
flat varying vec3 vClipParams; // xy = box size, z = radius
|
||||
#else
|
||||
varying vec4 vLocalPos;
|
||||
flat varying vec4 vClipCenter_Radius_TL;
|
||||
flat varying vec4 vClipCenter_Radius_TR;
|
||||
flat varying vec4 vClipCenter_Radius_BL;
|
||||
|
@ -83,18 +82,16 @@ void main(void) {
|
|||
);
|
||||
|
||||
vClipMode = clip.rect.mode.x;
|
||||
vLocalPos = vi.local_pos;
|
||||
|
||||
#ifdef WR_FEATURE_FAST_PATH
|
||||
// If the radii are all uniform, we can use a much simpler 2d
|
||||
// signed distance function to get a rounded rect clip.
|
||||
vec2 half_size = 0.5 * local_rect.size;
|
||||
float radius = clip.top_left.outer_inner_radius.x;
|
||||
vLocalPos = vi.local_pos.xy - half_size - cmi.local_pos;
|
||||
vClipParams.xy = half_size - vec2(radius);
|
||||
vClipParams.z = radius;
|
||||
vLocalPos.xy -= (half_size + cmi.local_pos) * vi.local_pos.w;
|
||||
vClipParams = vec3(half_size - vec2(radius), radius);
|
||||
#else
|
||||
vLocalPos = vi.local_pos;
|
||||
|
||||
RectWithEndpoint clip_rect = to_rect_with_endpoint(local_rect);
|
||||
|
||||
vec2 r_tl = clip.top_left.outer_inner_radius.xy;
|
||||
|
@ -127,22 +124,17 @@ float sdf_rounded_rect(vec2 pos, vec3 clip_params) {
|
|||
#endif
|
||||
|
||||
void main(void) {
|
||||
#ifdef WR_FEATURE_FAST_PATH
|
||||
vec2 local_pos = vLocalPos.xy;
|
||||
#else
|
||||
vec2 local_pos = vLocalPos.xy / vLocalPos.w;
|
||||
#endif
|
||||
float aa_range = compute_aa_range(local_pos);
|
||||
|
||||
#ifdef WR_FEATURE_FAST_PATH
|
||||
float d = sdf_rounded_rect(local_pos, vClipParams);
|
||||
float f = distance_aa(aa_range, d);
|
||||
float r = mix(f, 1.0 - f, vClipMode);
|
||||
oFragColor = vec4(r);
|
||||
float final_alpha = mix(f, 1.0 - f, vClipMode);
|
||||
#else
|
||||
float alpha = init_transform_fs(local_pos.xy);
|
||||
float alpha = init_transform_fs(local_pos);
|
||||
|
||||
float clip_alpha = rounded_rect(local_pos.xy,
|
||||
float clip_alpha = rounded_rect(local_pos,
|
||||
vClipCenter_Radius_TL,
|
||||
vClipCenter_Radius_TR,
|
||||
vClipCenter_Radius_BR,
|
||||
|
@ -153,9 +145,9 @@ void main(void) {
|
|||
|
||||
// Select alpha or inverse alpha depending on clip in/out.
|
||||
float final_alpha = mix(combined_alpha, 1.0 - combined_alpha, vClipMode);
|
||||
float final_final_alpha = vLocalPos.w > 0.0 ? final_alpha : 0.0;
|
||||
|
||||
oFragColor = vec4(final_final_alpha, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
float final_final_alpha = vLocalPos.w > 0.0 ? final_alpha : 0.0;
|
||||
oFragColor = vec4(final_final_alpha, 0.0, 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -97,7 +97,7 @@ use api::{BoxShadowClipMode, ImageKey, ImageRendering};
|
|||
use api::units::*;
|
||||
use crate::border::{ensure_no_corner_overlap, BorderRadiusAu};
|
||||
use crate::box_shadow::{BLUR_SAMPLE_SCALE, BoxShadowClipSource, BoxShadowCacheKey};
|
||||
use crate::clip_scroll_tree::{ROOT_SPATIAL_NODE_INDEX, CoordinateSystemId, ClipScrollTree, SpatialNodeIndex};
|
||||
use crate::clip_scroll_tree::{ROOT_SPATIAL_NODE_INDEX, ClipScrollTree, SpatialNodeIndex};
|
||||
use crate::ellipse::Ellipse;
|
||||
use crate::gpu_cache::{GpuCache, GpuCacheHandle, ToGpuBlocks};
|
||||
use crate::gpu_types::{BoxShadowStretchMode};
|
||||
|
@ -354,15 +354,14 @@ impl ClipNodeInfo {
|
|||
let mut flags = self.conversion.to_flags();
|
||||
|
||||
// Some clip shaders support a fast path mode for simple clips.
|
||||
// For now, the fast path is only selected if:
|
||||
// - The clip item content supports fast path
|
||||
// - Both clip and primitive are in the root coordinate system (no need for AA along edges)
|
||||
// TODO(gw): We could also apply fast path when segments are created, since we only write
|
||||
// the mask for a single corner at a time then, so can always consider radii uniform.
|
||||
let clip_spatial_node = &clip_scroll_tree.spatial_nodes[node.item.spatial_node_index.0 as usize];
|
||||
if clip_spatial_node.coordinate_system_id == CoordinateSystemId::root() &&
|
||||
flags.contains(ClipNodeFlags::SAME_COORD_SYSTEM) &&
|
||||
node.item.kind.supports_fast_path_rendering() {
|
||||
let is_raster_2d =
|
||||
flags.contains(ClipNodeFlags::SAME_COORD_SYSTEM) ||
|
||||
clip_scroll_tree
|
||||
.get_world_viewport_transform(node.item.spatial_node_index)
|
||||
.is_2d_axis_aligned();
|
||||
if is_raster_2d && node.item.kind.supports_fast_path_rendering() {
|
||||
flags |= ClipNodeFlags::USE_FAST_PATH;
|
||||
}
|
||||
|
||||
|
@ -1269,6 +1268,8 @@ impl ClipItemKind {
|
|||
|
||||
/// Returns true if this clip mask can run through the fast path
|
||||
/// for the given clip item type.
|
||||
///
|
||||
/// Note: this logic has to match `ClipBatcher::add` behavior.
|
||||
fn supports_fast_path_rendering(&self) -> bool {
|
||||
match *self {
|
||||
ClipItemKind::Rectangle { .. } |
|
||||
|
|
|
@ -184,6 +184,14 @@ impl<Src, Dst> CoordinateSpaceMapping<Src, Dst> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_2d_axis_aligned(&self) -> bool {
|
||||
match *self {
|
||||
CoordinateSpaceMapping::Local |
|
||||
CoordinateSpaceMapping::ScaleOffset(_) => true,
|
||||
CoordinateSpaceMapping::Transform(ref transform) => transform.preserves_2d_axis_alignment(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scale_factors(&self) -> (f32, f32) {
|
||||
match *self {
|
||||
CoordinateSpaceMapping::Local => (1.0, 1.0),
|
||||
|
|
Двоичные данные
gfx/wr/wrench/reftests/snap/preserve-3d.png
До Ширина: | Высота: | Размер: 6.7 KiB После Ширина: | Высота: | Размер: 6.6 KiB |
Двоичные данные
gfx/wr/wrench/reftests/text/perspective-clip.png
До Ширина: | Высота: | Размер: 1.7 KiB После Ширина: | Высота: | Размер: 1.7 KiB |
Двоичные данные
gfx/wr/wrench/reftests/transforms/perspective-clip-1.png
До Ширина: | Высота: | Размер: 2.0 KiB После Ширина: | Высота: | Размер: 2.0 KiB |
Двоичные данные
gfx/wr/wrench/reftests/transforms/perspective-clip.png
До Ширина: | Высота: | Размер: 17 KiB После Ширина: | Высота: | Размер: 16 KiB |
Двоичные данные
gfx/wr/wrench/reftests/transforms/rotated-clip-large.png
До Ширина: | Высота: | Размер: 7.2 KiB После Ширина: | Высота: | Размер: 7.3 KiB |
Двоичные данные
gfx/wr/wrench/reftests/transforms/rotated-clip.png
До Ширина: | Высота: | Размер: 3.7 KiB После Ширина: | Высота: | Размер: 3.7 KiB |
|
@ -51,7 +51,7 @@ fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),0-1,0-5) == clipping-5-image
|
|||
fuzzy-if(skiaContent,0-1,0-77) == clipping-5-overflow-hidden.html clipping-5-ref.html
|
||||
fuzzy-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu),0-1,0-4) fuzzy-if(Android,0-5,0-21) fuzzy-if(skiaContent,0-1,0-97) == clipping-5-refi.html clipping-5-ref.html
|
||||
fuzzy-if(true,0-1,0-7) fuzzy-if(d2d,0-55,0-95) fuzzy-if(cocoaWidget,0-1,0-99) fuzzy-if(Android,0-99,0-115) fuzzy-if(skiaContent,0-1,0-77) == clipping-5-refc.html clipping-5-ref.html # bug 732535
|
||||
fuzzy-if(Android,0-8,0-469) fuzzy-if(skiaContent,0-21,0-76) fuzzy-if(winWidget,0-144,0-335) fuzzy-if(webrender&&cocoaWidget,1-1,8-8) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == clipping-6.html clipping-6-ref.html # PaintedLayer and MaskLayer with transforms that aren't identical, bug 1392106
|
||||
fuzzy-if(Android,0-8,0-469) fuzzy-if(skiaContent,0-21,0-76) fuzzy-if(winWidget,0-144,0-335) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == clipping-6.html clipping-6-ref.html # PaintedLayer and MaskLayer with transforms that aren't identical, bug 1392106
|
||||
fuzzy-if(true,0-2,0-29) fuzzy-if(d2d,0-46,0-71) fuzzy-if(Android,0-255,0-586) fuzzy-if(skiaContent,0-28,0-97) == clipping-7.html clipping-7-ref.html # ColorLayer and MaskLayer with transforms that aren't identical. Reference image rendered without using layers (which causes fuzzy failures).
|
||||
fuzzy-if(/^Windows\x20NT\x206\.2/.test(http.oscpu),0-1,0-5) == clipping-and-zindex-1.html clipping-and-zindex-1-ref.html
|
||||
fuzzy-if(cocoaWidget,0-1,0-4) fuzzy-if(d2d,0-59,0-342) fuzzy-if(d3d11&&advancedLayers&&!d2d,0-30,0-3) == intersecting-clipping-1-canvas.html intersecting-clipping-1-refc.html
|
||||
|
|
|
@ -317,7 +317,7 @@ fuzzy-if(Android,0-3,0-50) fuzzy-if(skiaContent,0-1,0-133) == 273681-1.html 2736
|
|||
== 283686-2.html 283686-2-ref.html
|
||||
== 283686-3.html about:blank
|
||||
== 289384-1.xhtml 289384-ref.xhtml
|
||||
random-if(d2d) fuzzy(0-1,0-16) fuzzy-if(Android,0-8,0-1439) fuzzy-if(webrender,0-9,0-2024) HTTP == 289480.html#top 289480-ref.html # basically-verbatim acid2 test, HTTP for a 404 page -- bug 578114 for the d2d failures
|
||||
random-if(d2d) fuzzy(0-1,0-16) fuzzy-if(Android,0-8,0-1439) fuzzy-if(webrender,0-9,0-2040) HTTP == 289480.html#top 289480-ref.html # basically-verbatim acid2 test, HTTP for a 404 page -- bug 578114 for the d2d failures
|
||||
== 290129-1.html 290129-1-ref.html
|
||||
== 291078-1.html 291078-1-ref.html
|
||||
== 291078-2.html 291078-2-ref.html
|
||||
|
|
|
@ -82,8 +82,8 @@ fuzzy(0-1,0-10000) == opacity-preserve3d-3.html opacity-preserve3d-3-ref.html
|
|||
fuzzy(0-1,0-10000) == opacity-preserve3d-4.html opacity-preserve3d-4-ref.html
|
||||
== opacity-preserve3d-5.html opacity-preserve3d-5-ref.html
|
||||
== snap-perspective-1.html snap-perspective-1-ref.html
|
||||
fuzzy-if(webrender,8-9,32-132) == mask-layer-1.html mask-layer-ref.html
|
||||
fuzzy-if(webrender,8-9,32-132) == mask-layer-2.html mask-layer-ref.html
|
||||
== mask-layer-1.html mask-layer-ref.html
|
||||
== mask-layer-2.html mask-layer-ref.html
|
||||
fuzzy-if(webrender,0-16,0-132) == mask-layer-3.html mask-layer-ref.html
|
||||
== split-intersect1.html split-intersect1-ref.html
|
||||
fuzzy(0-255,0-150) == split-intersect2.html split-intersect2-ref.html
|
||||
|
|