antialias when drawing line not work in skia 91 , but ok in skia 75?

Skip to first unread message


Jun 9, 2021, 10:54:49 AM (3 days ago) Jun 9
to skia-discuss
hello, guys, I'm upgrading skia from 75 to 91 in my project.
but i confront with a problem that, the same code of drawing a line antialias work well in skia 75, but not working in skia 91. is there some new configuration should i do for skia ?

code of drawing line   
1. create the sksurface to draw 
static sk_sp<SkSurface> CreateOffscreenSurface(GrDirectContext *context,
const SkISize &size) {
      const SkImageInfo image_info = SkImageInfo::Make(
             size.fWidth, size.fHeight, kRGBA_8888_SkColorType, kPremul_SkAlphaType,                        SkColorSpace::MakeSRGB());

             const SkSurfaceProps surface_props(
                   0, SkPixelGeometry::kRGB_H_SkPixelGeometry);
              return SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, image_info, 0,
                         kBottomLeft_GrSurfaceOrigin,  &surface_props);

2. draw lines
//drawline antialias
canvas->drawPath(path, skPaint);

//draw line without antialias
canvas->drawPath(path, skPaint);

skia 75

skia 91

it shows that ,  skpaint antialias in skia 91 not working .  is there other factor affect 
antialias to take in effect. and the same code works well in skia 75, but not well in skia 91, is there some change on antialias logic from skia 75 to skia 91?

Thank you for help ! 


Jun 10, 2021, 12:42:06 AM (3 days ago) Jun 10
to skia-discuss
sorry, it's my fault !!!

I'm using skia to implement the canvas of js web, 
my test code in old project embed skia 75, drawline code just execute once.
while my test code in skia upgrade project (embed skia 91), drawline code is registered to a raf ( called each frame) with out clearCanvas.
And for performance, we cached the draw command result in a offscreen_canvas( SkCanvas) by drawPicture. and each frame we will append new draw command to the cached result , which mean that , without clear the canvas, the final result is  a huge quantity of lines with atialias effect ( which sampled pixels of the line edge) overlaped.
That means that the sampled effect of antialias will be counteracted by the overlapping of the same lines.
Reply all
Reply to author
0 new messages