office-gobmx/vcl/skia/osx
Patrick Luby 0807fe3628 Improve rendering speed for native controls when using Skia/Metal
While debugging tdf#163945, Xcode's Instruments application uncovered
the following performance bottlenecks when using Skia/Metal:

1. Very slow rendering an NSBox:
   Many system colors have the NSColorTypeCatalog color type. For
   some unkown reason, setting the NSBox's fill color to a color set
   to NSColorTypeCatalog causes drawing to take at least twice as
   long as when the fill color is set to NSColorTypeComponentBased.
   So, only draw with a fill color set to NSColorTypeComponentBased.

2. Excessively large offscreen buffers when drawing native controls:
   The temporary bitmap was set to the control region expanded by
   50 * mScaling (e.g. both width and height were increased by 200
   pixels when running on a Retina display). This caused temporary
   bitmaps to be up to several times larger than needed. Also,
   drawing NSBox objects to a CGBitmapContext is noticeably slow
   so filling all that unneeded temporary bitmap area can slow down
   performance when a large number of NSBox objects like the status
   bar are redrawn in quick succession.
   Using getNativeControlRegion() isn't perfect, but it does try to
   account for the focus ring as well as the minimum width and/or
   height of the native control so union the two regions set by
   getNativeControlRegion() and add double the focus ring width on
   each side just to be safe. In most cases, this should ensure
   that the temporary bitmap is large enough to draw the entire
   native control and a focus ring.

3. Unncessary copying of bitmap buffer when drawing native controls:
   Let Skia own the CGBitmapContext's buffer so that an SkImage
   can be created without Skia making a copy of the buffer.

Change-Id: Ibd3abb4b9d7045c47268319772fe97a5c4dba3c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177225
Tested-by: Jenkins
Reviewed-by: Patrick Luby <guibomacdev@gmail.com>
2024-11-25 19:30:21 +01:00
..
bitmap.cxx
gdiimpl.cxx Improve rendering speed for native controls when using Skia/Metal 2024-11-25 19:30:21 +01:00