Bug 1567472 - Fix bug in preserve-3d batching code in WebRender. r=nical a=RyanVM
The code to batch preserve-3d elements was incorrectly using the
bounds and visibility mask from the parent element. This could
result in batching bugs in some cases, which were showing up as
draw order issues.
Differential Revision:
https://phabricator.services.mozilla.com/D38834
--- a/gfx/wr/webrender/src/batch.rs
+++ b/gfx/wr/webrender/src/batch.rs
@@ -1114,36 +1114,40 @@ impl BatchBuilder {
let (uv_rect_address, _) = render_tasks.resolve_surface(
ctx.surfaces[raster_config.surface_index.0]
.render_tasks
.expect("BUG: no surface")
.root,
gpu_cache,
);
+ // Need a new z-id for each child preserve-3d context added
+ // by this inner loop.
+ let z_id = z_generator.next();
+
let prim_header_index = prim_headers.push(&prim_header, z_id, [
uv_rect_address.as_int(),
if raster_config.establishes_raster_root { 1 } else { 0 },
0,
clip_task_address.0 as i32,
]);
let key = BatchKey::new(
BatchKind::SplitComposite,
BlendMode::PremultipliedAlpha,
BatchTextures::no_texture(),
);
self.add_split_composite_instance_to_batches(
key,
- &prim_info.clip_chain.pic_clip_rect,
+ &child_prim_info.clip_chain.pic_clip_rect,
z_id,
prim_header_index,
child.gpu_address,
- prim_info.visibility_mask,
+ child_prim_info.visibility_mask,
);
}
}
// Ignore the 3D pictures that are not in the root of preserve-3D
// hierarchy, since we process them with the root.
Picture3DContext::In { root_data: None, .. } => return,
// Proceed for non-3D pictures.
Picture3DContext::Out => ()
new file mode 100644
--- /dev/null
+++ b/gfx/wr/wrench/reftests/split/order-3-ref.yaml
@@ -0,0 +1,15 @@
+---
+root:
+ items:
+ -
+ type: rect
+ bounds: [8, 8, 200, 200]
+ color: blue
+ -
+ type: rect
+ bounds: [8, 208, 200, 200]
+ color: blue
+ -
+ type: rect
+ bounds: [8, 408, 200, 200]
+ color: blue
new file mode 100644
--- /dev/null
+++ b/gfx/wr/wrench/reftests/split/order-3.yaml
@@ -0,0 +1,31 @@
+# Ensure that preserve-3d items are correctly batched with transparent siblings.
+---
+root:
+ items:
+ -
+ type: stacking-context
+ transform-style: "preserve-3d"
+ items:
+ -
+ type: rect
+ bounds: [8, 8, 200, 200]
+ color: blue
+ -
+ type: stacking-context
+ transform-style: "preserve-3d"
+ items:
+ -
+ type: rect
+ bounds: [8, 208, 200, 200]
+ color: blue
+ - type: rect
+ color: [255, 0, 0, 0.5]
+ bounds: [8, 408, 200, 200]
+ -
+ type: stacking-context
+ transform-style: "preserve-3d"
+ items:
+ -
+ type: rect
+ bounds: [8, 408, 200, 200]
+ color: blue
--- a/gfx/wr/wrench/reftests/split/reftest.list
+++ b/gfx/wr/wrench/reftests/split/reftest.list
@@ -14,8 +14,9 @@ skip_on(android,emulator) fuzzy(1,20) ==
# Note: on windows the image is rendered at a slightly different spot.
# similarly, a lot of tests in "transform" are non-windows. TODO: investigate
platform(linux,mac) fuzzy(1,20) == same-plane.yaml same-plane.png
#TODO: https://github.com/servo/webrender/issues/2946
#== cross.yaml cross-ref.yaml
== mixed-order.yaml mixed-order-ref.yaml
fuzzy(1,40000) == filter.yaml filter-ref.yaml
fuzzy(1,10000) == gradient.yaml gradient-ref.yaml
+== order-3.yaml order-3-ref.yaml