• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

win/H03-Mar-2022-396306

x11/H03-Mar-2022-355230

READMEH A D03-Mar-20223.4 KiB8660

SkiaHelper.cxxH A D03-Mar-202220.8 KiB637508

gdiimpl.cxxH A D03-Mar-202286.5 KiB2,1401,721

salbmp.cxxH A D03-Mar-202252.9 KiB1,3581,110

skia_denylist_vulkan.xmlH A D03-Mar-20221.5 KiB4425

zone.cxxH A D03-Mar-20222.8 KiB8754

README

1This is code for using the Skia library as a drawing library in VCL backends.
2See external/skia for info on the library itself.
3
4Environment variables:
5======================
6
7See README.vars in the toplevel vcl/ directory. Note that many backends do not
8use Skia. E.g. on Linux it is necessary to also use SAL_USE_VCLPLUGIN=gen .
9
10There are also GUI options for controlling whether Skia is enabled.
11
12Skia drawing methods:
13=====================
14
15Skia 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
18
19There are more (OpenGL, Metal on Mac, etc.), but (as of now) they are not supported by VCL.
20
21Logging:
22========
23
24Run LO with 'SAL_LOG=+INFO.vcl.skia' to get log information about Skia including
25tracing each drawing operation. If you want log information without drawing operations,
26use 'SAL_LOG=+INFO.vcl.skia-INFO.vcl.skia.trace'.
27
28Debugging:
29==========
30
31Both SkiaSalBitmap and SkiaSalGraphicsImpl have a dump() method that writes a PNG
32with the current contents. There is also SkiaHelper::dump() for dumping contents
33of SkBitmap, SkImage and SkSurface.
34
35If there is a drawing problem, you can use something like the following piece of code
36to dump an image after each relevant operation (or do it in postDraw() if you don't
37know which operation is responsible). You can then find the relevant image
38and match it with the responsible operation (run LO with 'SAL_LOG=+INFO.vcl.skia').
39
40    static int cnt = 0;
41    ++cnt;
42    char buf[100];
43    sprintf(buf,"/tmp/a%05d.png", cnt);
44    SAL_DEBUG("CNT:" << cnt);
45    if(cnt > 4000) // skip some initial drawing operations
46        dump(buf);
47
48
49Testing:
50========
51
52Currently unittests always use the 'headless' VCL backend. Use something like the following
53to run VCL unittests with Skia (and possibly skip slowcheck):
54
55SAL_SKIA=raster SAL_ENABLESKIA=1 SAL_USE_VCLPLUGIN=gen make vcl.build vcl.unitcheck vcl.slowcheck
56
57You can also use 'visualbackendtest' to visually check some operations. Use something like:
58
59SAL_SKIA=raster SAL_ENABLESKIA=1 SAL_USE_VCLPLUGIN=gen [srcdir]/bin/run visualbackendtest
60
61
62Thread safety:
63==============
64
65SolarMutex must be held for most operations (asserted in SkiaSalGraphicsImpl::preDraw() and
66in SkiaZone constructor). The reason for this is that this restriction does not appear to be
67a problem, so there's no need to verify thread safety of the code (including the Skia library).
68There's probably no fundamental reason why the code couldn't be made thread-safe.
69
70
71GrDirectContext sharing:
72========================
73
74We use Skia's sk_app::WindowContext class for creating surfaces for windows, that class
75takes care of the internals. But of offscreen drawing, we need an instance of class
76GrDirectContext. There is sk_app::WindowContext::getGrDirectContext(), but each instance creates
77its own GrDirectContext, and apparently it does not work to mix them. Which means that
78for offscreen drawing we would need to know which window (and only that window)
79the contents will be eventually painted to, which is not possible (it may not even
80be known at the time).
81
82To solve this problem we patch sk_app::WindowContext to create just one GrDirectContext object
83and share it between instances. Additionally, using sk_app::WindowContext::SharedGrDirectContext
84it is possible to share it also for offscreen drawing, including keeping proper reference
85count.
86