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 -
m87
users would likely find most existing python scripts work. Some routines need a newskia.SamplingOptions()
argument, or switch fromskia.FilterQuality
toskia.SamplingOptions()
. Please reportAttributeError: 'skia.AAA' object has no attribute 'BBB'
errors, to prioritize fixing remaining differences betweenm87
andm116
. -
The number of public symbols/routines in upstream skia is around 2400, consistently between
m87
andm116
(m88
,m98
,m103
were examined). skia-pythonm87
accesses 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
m87
APIs (about 5% in total, many in theImageFilter
namespace) 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
m87
APIs disappear, emulations withm116
is 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
GrContext
class methods were merged intoGrDirectContext
class methods. For now, we have an alias between those two classes, and internally, useGrContext
as it is shorter. In the long term, people should useGrDirectContext
, to align with upstream documentation. -
New
SamplingOptions
class; there is only a default constructor in m116 for now. Many APIs changes fromm87
tom116
concern adding new options with it, or changing fromFilterQuality
enum toSamplingOptions
.m124 Addendum: m124 completed
SamplingOptions
class. In m124 or later, to migrate from m87 FilterQuality-based code:FilterQuality.kHigh_FilterQuality -> SamplingOptions(CubicResampler.Mitchell()) FilterQuality.kMedium_FilterQuality -> SamplingOptions(FilterMode.kLinear, MipmapMode.kNearest) // cpu or SamplingOptions(FilterMode.kLinear, MipmapMode.kLinear) // gpu FilterQuality.kLow_FilterQuality -> SamplingOptions(FilterMode.kLinear, MipmapMode.kNone) FilterQuality.kNone_FilterQuality -> SamplingOptions(FilterMode.kNearest, MipmapMode.kNone)
-
yuvainfo.PlanarConfig
enums were splitted into a combination ofyuvainfo.PlaneConfig
andyuvainfo.Subsampling
enums. Where the former enum was used inm87
, it is the equivalent of a combination of the latter two inm116
.