AntiAliasing not working with skia hardware rendering

821 views
Skip to first unread message

Abhishek Gupta

unread,
Mar 6, 2017, 12:10:33 PM3/6/17
to skia-discuss
Hi,
I have been trying to use hardware accelerated (GPU backed) 2D rendering using Skia. I have been able to do so, but I am seeing jagged edges even when I have enabled antialiasing.
The simplified relevant code is as follows:-

    context = GrContext::Create( GrBackend::kOpenGL_GrBackend, NULL /*backendContext*/ );

    GrBackendRenderTargetDesc desc;
    desc.fWidth = width;
    desc.fHeight = height;
    desc.fConfig = kRGBA_8888_GrPixelConfig;
    desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
    desc.fSampleCnt = 2;
    desc.fStencilBits = 0;
    desc.fRenderTargetHandle = 0;
   
    sk_sp<SkSurface> surface = SkSurface::MakeFromBackendRenderTarget( context, desc, nullptr /*surfaceProps*/ )
    SkCanvas* canvas = surface->getCanvas();
   
    SkPaint paint;
    paint.setAntiAlias( true );
    paint.setColor( color );
    paint.setStyle( SkPaint::kFill_Style );
   
    canvas->drawOval( rectangle, paint );
   
I have attached the screenshot. I cannot repro the issue on fiddle. Any help in this matter would be greatly appreciated.

Thanks,
Abhishek
skia_screenshot.png

Brian Salomon

unread,
Mar 6, 2017, 12:28:59 PM3/6/17
to skia-discuss
Hi, the circle is antialiased using multisampling. You'll only get as many color steps in the antialiasing as there are samples per pixel in the destination. If the quality isn't high enough you can either increase the sample count or turn off multisampling which will cause Skia to use alpha blending to perform antialiasing. 

Brian

--
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 post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages