office-gobmx/vcl/skia
Luboš Luňák 12147e0322 merge needlessly split polygons back in Skia drawing (tdf#133016)
There are places in LO code that needlessly split polygons into
a group of adjacent polygons. These should theoretically result
in the same, but only if antialiasing is not used (where Skia
has a problem and according to Skia developers that's not really
Skia's fault). So whenever a possibly problematic polygon is
asked to be drawn, delay it and try to merge it with followup
polygons back into one polygon where those needlessly created
problematic edges do not exist.
This is indeed just a hack and those problematic places should
be fixed, but oh well :/.

Change-Id: I1b03fe7c2f5e8c962b0dcb8962196b7fea090146
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98887
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2020-07-16 16:02:05 +02:00
..
win flush all Skia drawing before drawing to the screen 2020-07-16 15:59:46 +02:00
x11 flush all Skia drawing before drawing to the screen 2020-07-16 15:59:46 +02:00
gdiimpl.cxx merge needlessly split polygons back in Skia drawing (tdf#133016) 2020-07-16 16:02:05 +02:00
README
salbmp.cxx prevent SkiaSalBitmap::Scale() from breaking indexed bitmaps (tdf#134574) 2020-07-08 09:31:12 +02:00
skia_denylist_vulkan.xml replace usage of whitelist with allowlist 2020-07-10 01:36:07 +02:00
SkiaHelper.cxx replace usage of blacklist with denylist 2020-07-10 01:34:54 +02:00
zone.cxx

This is code for using the Skia library as a drawing library in VCL backends.
See external/skia for info on the library itself.

Environment variables:
======================

See README.vars in the toplevel vcl/ directory. Note that many backends do not
use Skia. E.g. on Linux it is necessary to also use SAL_USE_VCLPLUGIN=gen .

There are also GUI options for controlling whether Skia is enabled.

Skia drawing methods:
=====================

Skia supports several methods to draw:
- Raster - CPU-based drawing (here primarily used for debugging)
- Vulkan - Vulkan-based GPU drawing, this is the default

There are more (OpenGL, Metal on Mac, etc.), but (as of now) they are not supported by VCL.

Logging:
========

Run LO with 'SAL_LOG=+INFO.vcl.skia' to get log information about Skia including
tracing each drawing operation. If you want log information without drawing operations,
use 'SAL_LOG=+INFO.vcl.skia-INFO.vcl.skia.trace'.

Debugging:
==========

Both SkiaSalBitmap and SkiaSalGraphicsImpl have a dump() method that writes a PNG
with the current contents. There is also SkiaHelper::dump() for dumping contents
of SkBitmap, SkImage and SkSurface.

If there is a drawing problem, you can use something like the following piece of code
to dump an image after each relevant operation (or do it in postDraw() if you don't
know which operation is responsible). You can then find the relevant image
and match it with the responsible operation (run LO with 'SAL_LOG=+INFO.vcl.skia').

    static int cnt = 0;
    ++cnt;
    char buf[100];
    sprintf(buf,"/tmp/a%05d.png", cnt);
    SAL_DEBUG("CNT:" << cnt);
    if(cnt > 4000) // skip some initial drawing operations
        dump(buf);


Testing:
========

Currently unittests always use the 'headless' VCL backend. Use something like the following
to run VCL unittests with Skia (and possibly skip slowcheck):

SAL_SKIA=raster SAL_ENABLESKIA=1 SAL_USE_VCLPLUGIN=gen make vcl.build vcl.unitcheck vcl.slowcheck

You can also use 'visualbackendtest' to visually check some operations. Use something like:

SAL_SKIA=raster SAL_ENABLESKIA=1 SAL_USE_VCLPLUGIN=gen [srcdir]/bin/run visualbackendtest


GrContext sharing:
==================

We use Skia's sk_app::WindowContext class for creating surfaces for windows, that class
takes care of the internals. But of offscreen drawing, we need an instance of class
GrContext. There is sk_app::WindowContext::getGrContext(), but each instance creates
its own GrContext, and apparently it does not work to mix them. Which means that
for offscreen drawing we would need to know which window (and only that window)
the contents will be eventually painted to, which is not possible (it may not even
be known at the time).

To solve this problem we patch sk_app::WindowContext to create just one GrContext object
and share it between instances. Additionally, using sk_app::WindowContext::SharedGrContext
it is possible to share it also for offscreen drawing, including keeping proper reference
count.