Skip to content

Commit

Permalink
Bug 1908834 - Support outset box-shadows with quad based rendering r=…
Browse files Browse the repository at this point in the history
…gfx-reviewers,lsalzman

This initial patch does not contain any of the more subtle or
complex optimizations that we'll land as follow ups, and thus
only enables the new path for a subset of box-shadow primitives.

Differential Revision: https://phabricator.services.mozilla.com/D217060
  • Loading branch information
Glenn Watson committed Aug 12, 2024
1 parent 8dbcd81 commit 83fb97d
Show file tree
Hide file tree
Showing 15 changed files with 637 additions and 192 deletions.
8 changes: 2 additions & 6 deletions webrender/src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,18 +829,14 @@ impl BatchBuilder {
PrimitiveCommand::Instance { prim_instance_index, gpu_buffer_address } => {
(prim_instance_index, Some(gpu_buffer_address.as_int()))
}
PrimitiveCommand::Quad { pattern, pattern_input, prim_instance_index, gpu_buffer_address, quad_flags, edge_flags, transform_id } => {
PrimitiveCommand::Quad { pattern, pattern_input, prim_instance_index, gpu_buffer_address, quad_flags, edge_flags, transform_id, src_color_task_id } => {
let prim_instance = &prim_instances[prim_instance_index.0 as usize];
let prim_info = &prim_instance.vis;
let bounding_rect = &prim_info.clip_chain.pic_coverage_rect;
let render_task_address = self.batcher.render_task_address;

if segments.is_empty() {
let z_id = z_generator.next();
// TODO: Some pattern types will sample from render tasks.
// At the moment quads only use a render task as source for
// segments which have been pre-rendered and masked.
let src_color_task_id = RenderTaskId::INVALID;

quad::add_to_batch(
*pattern,
Expand All @@ -851,7 +847,7 @@ impl BatchBuilder {
*quad_flags,
*edge_flags,
INVALID_SEGMENT_INDEX as u8,
src_color_task_id,
*src_color_task_id,
z_id,
render_tasks,
gpu_buffer_builder,
Expand Down
32 changes: 18 additions & 14 deletions webrender/src/border.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,24 +175,28 @@ pub fn ensure_no_corner_overlap(
let bottom_right_radius = &mut radius.bottom_right;
let bottom_left_radius = &mut radius.bottom_left;

let sum = top_left_radius.width + top_right_radius.width;
if size.width < sum {
ratio = f32::min(ratio, size.width / sum);
}
if size.width > 0.0 {
let sum = top_left_radius.width + top_right_radius.width;
if size.width < sum {
ratio = f32::min(ratio, size.width / sum);
}

let sum = bottom_left_radius.width + bottom_right_radius.width;
if size.width < sum {
ratio = f32::min(ratio, size.width / sum);
let sum = bottom_left_radius.width + bottom_right_radius.width;
if size.width < sum {
ratio = f32::min(ratio, size.width / sum);
}
}

let sum = top_left_radius.height + bottom_left_radius.height;
if size.height < sum {
ratio = f32::min(ratio, size.height / sum);
}
if size.height > 0.0 {
let sum = top_left_radius.height + bottom_left_radius.height;
if size.height < sum {
ratio = f32::min(ratio, size.height / sum);
}

let sum = top_right_radius.height + bottom_right_radius.height;
if size.height < sum {
ratio = f32::min(ratio, size.height / sum);
let sum = top_right_radius.height + bottom_right_radius.height;
if size.height < sum {
ratio = f32::min(ratio, size.height / sum);
}
}

if ratio < 1. {
Expand Down
Loading

0 comments on commit 83fb97d

Please sign in to comment.