This is a partial port of skia-python
from m87 to m116, possibly disabling any m87 APIs that have no close m116 equivalents.
It concentrates on OT-SVG, and fixing these two issues:
- SkSVGDOM::renderNode() is not exposed in python
- three-args contructor to SkMemoryStream not exposed.
The SVG module left experimental in m88 upstream. It has received many improvements since.
Some COLRv1-related Skia internals from upstream's on-going effort in this area are also exposed for access. This experimental functionality is available to Linux/FreeType users only.
Special mention of 0lru who provided a draft m98 pull for which some ideas of this update had taken from.
-
TL;DR -
m87users would likely find most existing python scripts work. Some routines need a newskia.SamplingOptions()argument, or switch fromskia.FilterQualitytoskia.SamplingOptions(). Please reportAttributeError: 'skia.AAA' object has no attribute 'BBB'errors, to prioritize fixing remaining differences betweenm87andm116. -
The number of public symbols/routines in upstream skia is around 2400, consistently between
m87andm116(m88,m98,m103were examined). skia-pythonm87accesses just over ~1000 at link time, and possibly another 100 or two viadynamic_cast'ing at runtime. Less than ~800 of them has exact equivalents inm116. A good proportion of the 200+ differ by additional arguments, often with defaults (e.g.skia.SamplingOptions()). A few with not-useful arguments have them removed. Some of the rest, like the Image I/O routines and Surface routines, are considered too often used and too important, and are emulated in m116. The rest ... read on: -
Be WARN'ed: some
m87APIs (about 5% in total, many in theImageFilternamespace) are removed/disabled when there are no obvious new-equivalents, or not-too-troblesome emulations withm116. The "AttributeError" error mentioned above. -
Where it is possible, when
m87APIs disappear, emulations withm116is done. So these are "new emulations of old APIs". While they work, they might be withdrawn/changed later:Image I/O and decoding routines -
encodeToData,MakeRasterCopy,MakeFromRaster,MakeFromBitmap,MakeFromEncoded,MakeTextureFromCompressed,MakeRasterFromCompressed,MakeFromTexture,MakeFromCompressedTexture,MakeCrossContextFromPixmap,MakeFromAdoptedTexture,MakeFromYUVATexturesCopy,MakeFromYUVATexturesCopyWithExternalBackend,MakeFromYUVATextures,MakeFromYUVAPixmaps,MakeFromYUVAPixmaps,MakeFromPicture,MakeBackendTextureFromSkImage,MakeBackendTextureFromSkImage- these are emulated in
m116. In particular, upstream recommends using the graphic format encoding/decoding routines directly. Not yet directly exposed inskia-python.
Surface methods -
Surface.MakeRasterN32Premul,Surface.MakeRasterDirect,Surface.getBackendTexture,Surface.getBackendRenderTarget,Surface.MakeRaster,Surface.MakeFromBackendTexture,Surface.MakeFromBackendRenderTarget,Surface::MakeRenderTarget,Surface.MakeNull.- these are simple renamings; we might add the new names and remove the old names, and document them as renamed.
- these are emulated in
-
Most
GrContextclass methods were merged intoGrDirectContextclass methods. For now, we have an alias between those two classes, and internally, useGrContextas it is shorter. In the long term, people should useGrDirectContext, to align with upstream documentation. -
New
SamplingOptionsclass; there is only a default constructor for now. Many APIs changes fromm87tom116concern adding new options with it, or changing fromFilterQualityenum toSamplingOptions. If you use any value other than the defaultFilterQuality.kMedium_SkFilterQualityenum, you'll need to request addition to theSamplingOptionsclass. -
yuvainfo.PlanarConfigenums were splitted into a combination ofyuvainfo.PlaneConfigandyuvainfo.Subsamplingenums. Where the former enum was used inm87, it is the equivalent of a combination of the latter two inm116.