Open Bug 1617039 Opened 2 years ago Updated 5 months ago

Implement conic-gradient for Cairo graphics backend (printing support)


(Core :: Graphics, enhancement, P5)





(Reporter: ntim, Unassigned)




(1 file, 2 obsolete files)

Cairo is used exclusively for printing.

According to jrmuizel, the easiest way to do this is to paint the gradient using a different backend then send the image over to Cairo for printing.

Priority: -- → P5

Markus, do you think you could provide a bit of guidance ? I'm not sure this is on the right path. Thanks!

Flags: needinfo?(mstange)

The approach is looking pretty good to me! The hard part is going to be the computation of the surface bounds, I think. Unless there's some "get current clip extents" helper around.

Flags: needinfo?(mstange)

Oh, actually, I think it would be best to handle the transform in Skia. For example, let's say you have a 50x50 DrawTargetCairo, set a scale(5) transform on it, and then draw a 10x10 user space conic gradient that should fill the entire DrawTarget. In that case, you'll get blurry rendering if you let Skia render the conic gradient into a 10x10 surface and then scale that surface up to 50x50. It's better if you make a surface of the device space bounds (50x50), pass the current transform to Skia, let Skia fill the 50x50 surface with the correct transform, turn that into a SurfacePattern with the inverse transform set on it, and then draw that SurfacePattern into the DrawTargetCairo so that it's drawn without any transform.

Type: task → enhancement
Assignee: nobody → mohamed
Attachment #9136219 - Attachment is obsolete: true
Assignee: mohamed → nobody
Summary: Implement conic-gradient for Cairo graphics backend → Implement conic-gradient for Cairo graphics backend (printing support)
Assignee: nobody → mohamed
Attachment #9190463 - Attachment is obsolete: true
Assignee: mohamed → nobody

Cairo can draw conic gradients using the mesh gradient API. See this test case for an example.

This is preferable to embedding an image as it uses vector output on the PS/PDF output.

You just need to ensure there is at least one patch every 90 degrees to maintain a good approximation of a circle as described here.

FWIW, the WebKitGTK/WPE WebKit ports feature an implementation of conic gradients using Cairo as graphics backend. Perhaps that could be useful.

You need to log in before you can comment on or make changes to this bug.