1 This is code for using the Skia library as a drawing library in VCL backends.
2 See external/skia for info on the library itself.
7 See README.vars in the toplevel vcl/ directory. Note that many backends do not
8 use Skia. E.g. on Linux it is necessary to also use SAL_USE_VCLPLUGIN=gen .
10 There are also GUI options for controlling whether Skia is enabled.
15 Skia supports several methods to draw:
16 - Raster - CPU-based drawing (here primarily used for debugging)
17 - Vulkan - Vulkan-based GPU drawing, this is the default
19 There are more (OpenGL, Metal on Mac, etc.), but (as of now) they are not supported by VCL.
24 Run LO with 'SAL_LOG=+INFO.vcl.skia' to get log information about Skia including
25 tracing each drawing operation. If you want log information without drawing operations,
26 use 'SAL_LOG=+INFO.vcl.skia-INFO.vcl.skia.trace'.
31 Both SkiaSalBitmap and SkiaSalGraphicsImpl have a dump() method that writes a PNG
32 with the current contents. There is also SkiaHelper::dump() for dumping contents
33 of SkBitmap, SkImage and SkSurface.
35 If there is a drawing problem, you can use something like the following piece of code
36 to dump an image after each relevant operation (or do it in postDraw() if you don't
37 know which operation is responsible). You can then find the relevant image
38 and match it with the responsible operation (run LO with 'SAL_LOG=+INFO.vcl.skia').
43 sprintf(buf,"/tmp/a%05d.png", cnt);
44 SAL_DEBUG("CNT:" << cnt);
45 if(cnt > 4000) // skip some initial drawing operations
52 Currently unittests always use the 'headless' VCL backend. Use something like the following
53 to run VCL unittests with Skia (and possibly skip slowcheck):
55 SAL_SKIA=raster SAL_ENABLESKIA=1 SAL_USE_VCLPLUGIN=gen make vcl.build vcl.unitcheck vcl.slowcheck
57 You can also use 'visualbackendtest' to visually check some operations. Use something like:
59 SAL_SKIA=raster SAL_ENABLESKIA=1 SAL_USE_VCLPLUGIN=gen [srcdir]/bin/run visualbackendtest
65 SolarMutex must be held for most operations (asserted in SkiaSalGraphicsImpl::preDraw() and
66 in SkiaZone constructor). The reason for this is that this restriction does not appear to be
67 a problem, so there's no need to verify thread safety of the code (including the Skia library).
68 There's probably no fundamental reason why the code couldn't be made thread-safe.
71 GrDirectContext sharing:
72 ========================
74 We use Skia's sk_app::WindowContext class for creating surfaces for windows, that class
75 takes care of the internals. But of offscreen drawing, we need an instance of class
76 GrDirectContext. There is sk_app::WindowContext::getGrDirectContext(), but each instance creates
77 its own GrDirectContext, and apparently it does not work to mix them. Which means that
78 for offscreen drawing we would need to know which window (and only that window)
79 the contents will be eventually painted to, which is not possible (it may not even
80 be known at the time).
82 To solve this problem we patch sk_app::WindowContext to create just one GrDirectContext object
83 and share it between instances. Additionally, using sk_app::WindowContext::SharedGrDirectContext
84 it is possible to share it also for offscreen drawing, including keeping proper reference