Can DrawPatch do anti-aliasing

149 views
Skip to first unread message

Claudia Potter

unread,
Nov 25, 2022, 1:31:22 AM11/25/22
to skia-discuss
Hi,
In API document of DrawPatch(), it says ”SkMaskFilter, SkPathEffect and antialiasing on Skpaint are ignored.“ Does this mean when I use texCoords to map Skshader generated from Skimage, I cannot use anti-antialiasing? 
Thank you for your attention.

Claudia Potter

unread,
Nov 27, 2022, 10:46:03 PM11/27/22
to skia-discuss
As shown in this demo:
Even I use "p.setAntiAlias(true);", you can still see obvious  jagged lines.

Greg Daniel

unread,
Nov 28, 2022, 9:18:16 AM11/28/22
to skia-d...@googlegroups.com
Hi,

So drawPatch essentially boils down to a special case version of drawVertices which inherently doesn't have any antialiasing. You need to remember that draws have two essential parts: the color produced by the shading and the pixel coverage produced by the geometry. These two values are then combined at the end to write a final value into a pixel (along with some blend mode). Antialiasing is an effect applied to the coverage calculation. When someone is using drawVertices or drawPatch, there isn't really a "real geometry", instead it is the client saying I want to draw these triangles. Thus we don't apply any antialiasing to the edges when calculating coverage (though if you're on the GPU using MSAA you would end up with some antialiasing).

When using texCoords with an SkShader from and SkImage, this is all used in the calculation of the color produced by shading. These calculations are not affected by antialiasing for any draw (besides the fact they'll be composed with the coverage from AA in the end). Is it possible you're trying to get another effect from you sampling? Bi-linear interpolation of texCoords? Dithering?

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/745f4265-d665-4588-b14f-148c51b71ed8n%40googlegroups.com.

Claudia Potter

unread,
Jan 16, 2023, 2:02:09 AM1/16/23
to skia-discuss
Thank you for your reply. SkFilterMode::kLinear mode does work for SkShader from SkImage. However, I understand what you say " to draw these triangles" but I still wonder, is it possible to solve these obvious jagged lines on the edge of the picture?
Jagged lines as shown in this demo:

Jim Van Verth

unread,
Jan 17, 2023, 9:34:51 AM1/17/23
to skia-d...@googlegroups.com
As Greg said, GPU rendering with MSAA enabled would mitigate those jaggies, but that's pretty much the only way.



--

Jim Van Verth | Software Engineer | jvan...@google.com | 919-210-7664

Reply all
Reply to author
Forward
0 new messages