Bug 1892398 - Don't hard-code that quad segments with a source render task are alpha blended. r=gw

Not immediately necessary but when cached quads or patterns that read a texture are implemented, There will be opaque segments taking render tasks as input. Currently the code is a bit error prone because some parts of the code advertize a certain behavior that is later overruled. This patch makes things more explicit and flexible.

Differential Revision: https://phabricator.services.mozilla.com/D208508
This commit is contained in:
Nicolas Silva 2024-05-06 05:53:40 +00:00
parent 604bbc736c
commit 6bc956c386

View File

@ -178,11 +178,12 @@ pub fn push_quad(
); );
let rect = clipped_surface_rect.to_f32().cast_unit(); let rect = clipped_surface_rect.to_f32().cast_unit();
let is_masked = true;
add_composite_prim( add_composite_prim(
pattern, pattern,
is_masked,
prim_instance_index, prim_instance_index,
rect, rect,
pattern.is_opaque,
frame_state, frame_state,
targets, targets,
&[QuadSegment { rect, task_id }], &[QuadSegment { rect, task_id }],
@ -253,11 +254,12 @@ pub fn push_quad(
} }
} }
let is_masked = true;
add_composite_prim( add_composite_prim(
pattern, pattern,
is_masked,
prim_instance_index, prim_instance_index,
unclipped_surface_rect.cast_unit(), unclipped_surface_rect.cast_unit(),
pattern.is_opaque,
frame_state, frame_state,
targets, targets,
&scratch.quad_indirect_segments, &scratch.quad_indirect_segments,
@ -388,11 +390,12 @@ pub fn push_quad(
} }
if !scratch.quad_indirect_segments.is_empty() { if !scratch.quad_indirect_segments.is_empty() {
let is_masked = true;
add_composite_prim( add_composite_prim(
pattern, pattern,
is_masked,
prim_instance_index, prim_instance_index,
unclipped_surface_rect.cast_unit(), unclipped_surface_rect.cast_unit(),
pattern.is_opaque,
frame_state, frame_state,
targets, targets,
&scratch.quad_indirect_segments, &scratch.quad_indirect_segments,
@ -565,9 +568,9 @@ fn add_pattern_prim(
fn add_composite_prim( fn add_composite_prim(
pattern: &Pattern, pattern: &Pattern,
is_masked: bool,
prim_instance_index: PrimitiveInstanceIndex, prim_instance_index: PrimitiveInstanceIndex,
rect: LayoutRect, rect: LayoutRect,
is_opaque: bool,
frame_state: &mut FrameBuildingState, frame_state: &mut FrameBuildingState,
targets: &[CommandBufferIndex], targets: &[CommandBufferIndex],
segments: &[QuadSegment], segments: &[QuadSegment],
@ -585,7 +588,7 @@ fn add_composite_prim(
let mut quad_flags = QuadFlags::IGNORE_DEVICE_PIXEL_SCALE let mut quad_flags = QuadFlags::IGNORE_DEVICE_PIXEL_SCALE
| QuadFlags::APPLY_DEVICE_CLIP; | QuadFlags::APPLY_DEVICE_CLIP;
if is_opaque { if pattern.is_opaque && !is_masked {
quad_flags |= QuadFlags::IS_OPAQUE; quad_flags |= QuadFlags::IS_OPAQUE;
} }
@ -685,7 +688,7 @@ pub fn add_to_batch<F>(
TextureSource::Invalid, TextureSource::Invalid,
); );
let default_blend_mode = if quad_flags.contains(QuadFlags::IS_OPAQUE) && src_task_id == RenderTaskId::INVALID { let default_blend_mode = if quad_flags.contains(QuadFlags::IS_OPAQUE) {
BlendMode::None BlendMode::None
} else { } else {
BlendMode::PremultipliedAlpha BlendMode::PremultipliedAlpha