Bug 1888400 - Rename add_segment into add_render_task. r=gw

And hoist the create_task condition out. This makes it easier to see what's going on.

Differential Revision: https://phabricator.services.mozilla.com/D206035
This commit is contained in:
Nicolas Silva 2024-04-16 16:26:27 +00:00
Родитель f76fa95c6f
Коммит eea54e699a
1 изменённых файлов: 68 добавлений и 69 удалений

Просмотреть файл

@ -161,10 +161,10 @@ pub fn push_quad(
match strategy {
QuadRenderStrategy::Direct => {}
QuadRenderStrategy::Indirect => {
let segment = add_segment(
let task_id = add_render_task_with_mask(
pattern,
&clipped_surface_rect,
true,
clipped_surface_rect.size(),
clipped_surface_rect.min.to_f32(),
clip_chain,
prim_spatial_node_index,
pic_context.raster_spatial_node_index,
@ -177,14 +177,15 @@ pub fn push_quad(
frame_state,
);
let rect = clipped_surface_rect.to_f32().cast_unit();
add_composite_prim(
pattern,
prim_instance_index,
segment.rect,
rect,
quad_flags,
frame_state,
targets,
&[segment],
&[QuadSegment { rect, task_id }],
);
}
QuadRenderStrategy::Tiled { x_tiles, y_tiles } => {
@ -225,16 +226,17 @@ pub fn push_quad(
continue;
}
let create_task = true;
let rect = DeviceIntRect {
let int_rect = DeviceIntRect {
min: point2(x0, y0),
max: point2(x1, y1),
};
let segment = add_segment(
let rect = int_rect.to_f32();
let task_id = add_render_task_with_mask(
pattern,
&rect,
create_task,
int_rect.size(),
rect.min,
clip_chain,
prim_spatial_node_index,
pic_context.raster_spatial_node_index,
@ -246,7 +248,8 @@ pub fn push_quad(
needs_scissor,
frame_state,
);
scratch.quad_segments.push(segment);
scratch.quad_segments.push(QuadSegment { rect: rect.cast_unit(), task_id });
}
}
@ -321,17 +324,18 @@ pub fn push_quad(
let rect = DeviceIntRect::new(point2(x0, y0), point2(x1, y1));
let rect = match rect.intersection(&clipped_surface_rect) {
let device_rect = match rect.intersection(&clipped_surface_rect) {
Some(rect) => rect,
None => {
continue;
}
};
let segment = add_segment(
let task_id = if create_task {
add_render_task_with_mask(
pattern,
&rect,
create_task,
device_rect.size(),
device_rect.min.to_f32(),
clip_chain,
prim_spatial_node_index,
pic_context.raster_spatial_node_index,
@ -342,8 +346,13 @@ pub fn push_quad(
device_pixel_scale,
false,
frame_state,
);
scratch.quad_segments.push(segment);
)
} else {
RenderTaskId::INVALID
};
let rect = device_rect.to_f32().cast_unit();
scratch.quad_segments.push(QuadSegment { rect, task_id });
}
}
@ -432,10 +441,10 @@ fn get_prim_render_strategy(
}
}
fn add_segment(
fn add_render_task_with_mask(
pattern: &Pattern,
rect: &DeviceIntRect,
create_task: bool,
task_size: DeviceIntSize,
content_origin: DevicePoint,
clip_chain: &ClipChainInstance,
prim_spatial_node_index: SpatialNodeIndex,
raster_spatial_node_index: SpatialNodeIndex,
@ -446,12 +455,7 @@ fn add_segment(
device_pixel_scale: DevicePixelScale,
needs_scissor_rect: bool,
frame_state: &mut FrameBuildingState,
) -> QuadSegment {
let task_size = rect.size();
let rect = rect.to_f32();
let content_origin = rect.min;
let task_id = if create_task {
) -> RenderTaskId {
let task_id = frame_state.rg_builder.add().init(RenderTask::new_dynamic(
task_size,
RenderTaskKind::new_prim(
@ -484,11 +488,6 @@ fn add_segment(
.add_child_render_task(task_id, frame_state.rg_builder);
task_id
} else {
RenderTaskId::INVALID
};
QuadSegment { rect: rect.cast_unit(), task_id }
}
fn add_composite_prim(