Skip to content

Gradients in hybrid don't work as expected within a clip layer #1278

@ajakubowicz-canva

Description

@ajakubowicz-canva

Minimal repro test (which I reproduced by adding to vello_sparse_tests clip.rs):

#[vello_test(width = 600, height = 200)]
fn clip_with_gradient_fill(ctx: &mut impl Renderer) {
    use crate::util::stops_green_blue;
    // Border to see crop.
    ctx.set_paint(PINK);
    ctx.fill_rect(&Rect::new(0., 0., 600., 200.));

    // Crop 10px border around image.
    let clip = Rect::new(10., 10., 590., 190.0);
    ctx.push_clip_layer(&clip.to_path(0.));
    
    // Fill a full screen rect with a gradient.
    let box_rect = Rect::new(0., 0., 600.0, 200.0);
    
    let gradient = Gradient {
        kind: LinearGradientPosition {
            start: Point::new(100.0, 100.0),
            end: Point::new(300.0, 100.0),
        }.into(),
        stops: stops_green_blue(),
        ..Default::default()
    };
    
    ctx.set_paint(gradient);
    ctx.fill_rect(&box_rect);
    
    ctx.pop_layer();
}

Expected Image

Image

Note – this image is consistent with Vello CPU.

Hybrid's incorrect result

Image

Image is divided into three regions. Expected, different pixels, hybrid's render.

Metadata

Metadata

Assignees

Labels

C-hybridApplies to the vello_hybrid crate

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions