Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
46b7ae4
Upgrade skia commit to m87
kyamagu Nov 20, 2020
599f984
Remove Canvas.getGrContext
kyamagu Nov 20, 2020
56bbdf6
Remove incompatible GrVkImageInfo constructor
kyamagu Nov 20, 2020
81a665b
Remove flag argument in PictureRecorder
kyamagu Nov 20, 2020
d5096ff
Remove private PathConvexity methods
kyamagu Nov 20, 2020
ef888fd
Add Matrix.RotateDeg overload
kyamagu Nov 20, 2020
7e5e16b
Remove createBackendTexture from characterization
kyamagu Nov 20, 2020
4875c17
Remove getContext and make from texture characterization
kyamagu Nov 20, 2020
d7f14f0
Remove tests for removed methods
kyamagu Nov 20, 2020
6d73caa
Remove internal enum values
kyamagu Nov 20, 2020
faec719
Add GrBackendSurfaceMutableState methods
kyamagu Nov 20, 2020
f52d1ae
Update setBackendTextureState and setBackendRenderTargetState args
kyamagu Nov 20, 2020
ccdd1fc
Implement YUVAInfo and tests
kyamagu Nov 20, 2020
23e73ed
Implement YUVAPixmapInfo, YUVAPixmaps, and relevant APIs
kyamagu Nov 20, 2020
4df032e
Increment version
kyamagu Nov 20, 2020
3559a6b
Implement MipmapBuilder
kyamagu Nov 20, 2020
c11b8cc
Implement static Image constructors from texture
kyamagu Nov 20, 2020
cae2543
Add Matrix.rc
kyamagu Nov 20, 2020
9f9c73f
Update EncodedOriginToMatrix docstring
kyamagu Nov 24, 2020
24c4ae4
Add HSLAMatrix overload
kyamagu Nov 24, 2020
c5d49ac
Fix syntax error
kyamagu Nov 24, 2020
b92b4f9
Add readPixels overload with context arg
kyamagu Nov 24, 2020
8f9881d
Add withDefaultMipmaps
kyamagu Nov 24, 2020
2d79bb2
Add missing Path constructors
kyamagu Nov 24, 2020
e66bba9
Implement PathBuilder
kyamagu Nov 24, 2020
4c33897
Fix syntax error
kyamagu Nov 24, 2020
3ed54d4
Add RRect.dumpToString
kyamagu Nov 24, 2020
41fef32
Add Typeface.getPostScriptName
kyamagu Nov 24, 2020
f195001
Add GrRecordingContext methods
kyamagu Nov 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
pass

NAME = 'skia-python'
__version__ = '86.1'
__version__ = '87.0'

SKIA_PATH = os.getenv('SKIA_PATH', 'skia')
SKIA_OUT_PATH = os.getenv(
Expand Down
2 changes: 1 addition & 1 deletion skia
Submodule skia updated from b939c2 to 489348
18 changes: 0 additions & 18 deletions src/skia/Canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@ py::class_<SkAutoCanvasRestore>(m, "AutoCanvasRestore", R"docstring(
py::enum_<SkClipOp>(m, "ClipOp")
.value("kDifference", SkClipOp::kDifference)
.value("kIntersect", SkClipOp::kIntersect)
.value("kExtraEnumNeedInternallyPleaseIgnoreWillGoAway2",
SkClipOp::kExtraEnumNeedInternallyPleaseIgnoreWillGoAway2)
.value("kExtraEnumNeedInternallyPleaseIgnoreWillGoAway3",
SkClipOp::kExtraEnumNeedInternallyPleaseIgnoreWillGoAway3)
.value("kExtraEnumNeedInternallyPleaseIgnoreWillGoAway4",
SkClipOp::kExtraEnumNeedInternallyPleaseIgnoreWillGoAway4)
.value("kExtraEnumNeedInternallyPleaseIgnoreWillGoAway5",
SkClipOp::kExtraEnumNeedInternallyPleaseIgnoreWillGoAway5)
.value("kMax_EnumValue", SkClipOp::kMax_EnumValue)
.export_values();

py::class_<SkCanvas> canvas(m, "Canvas", R"docstring(
Expand Down Expand Up @@ -427,15 +418,6 @@ canvas
:rtype: skia.Surface or None
)docstring",
py::arg("info"), py::arg("props") = nullptr)
.def("getGrContext", &SkCanvas::getGrContext,
R"docstring(
Returns GPU context of the GPU surface associated with
:py:class:`Canvas`.

:return: GPU context, if available; nullptr otherwise
:rtype: skia.GrContext or None
)docstring",
py::return_value_policy::reference)
.def("getSurface", &SkCanvas::getSurface,
R"docstring(
Sometimes a canvas is owned by a surface.
Expand Down
54 changes: 35 additions & 19 deletions src/skia/Codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ py::enum_<SkEncodedOrigin>(m, "EncodedOrigin",

m.def("EncodedOriginToMatrix", &SkEncodedOriginToMatrix,
R"docstring(
Given an encoded origin and the width and height of the source data, returns
a matrix that transforms the source rectangle [0, 0, w, h] to a correctly
oriented destination rectangle, with the upper left corner still at [0, 0].
Given an encoded origin and the width and height of the source data,
returns a matrix that transforms the source rectangle with upper left
corner at [0, 0] and origin to a correctly oriented destination rectangle
of [0, 0, w, h].
)docstring",
py::arg("origin"), py::arg("w"), py::arg("h"));

Expand Down Expand Up @@ -476,22 +477,37 @@ codec
py::overload_cast<const SkPixmap&, const SkCodec::Options*>(
&SkCodec::getPixels),
py::arg("pixmap"), py::arg("options") = nullptr)
/*.def("queryYUV8", &SkCodec::queryYUV8,
R"docstring(
If decoding to YUV is supported, this returns true. Otherwise, this
returns false and does not modify any of the parameters.

:param sizeInfo: Output parameter indicating the sizes and required
allocation widths of the Y, U, V, and A planes. Given current codec
limitations the size of the A plane will always be 0 and the Y, U, V
channels will always be planar.
:param colorSpace: Output parameter. If non-NULL this is set to kJPEG,
otherwise this is ignored.
)docstring")
.def("getYUV8Planes", &SkCodec::getYUV8Planes,
"docstring(
)docstring"
)*/
.def("queryYUVAInfo",
[] (const SkCodec& codec,
const SkYUVAPixmapInfo::SupportedDataTypes& supportedDataTypes)
-> py::object {
SkYUVAPixmapInfo yuvaPixmapInfo;
if (codec.queryYUVAInfo(supportedDataTypes, &yuvaPixmapInfo))
return py::cast(yuvaPixmapInfo);
return py::none();
},
R"docstring(
If decoding to YUV is supported, this returns true. Otherwise, this
returns false;

:param supportedDataTypes: Indicates the data type/planar config
combinations that are supported by the caller. If the generator
supports decoding to YUV(A), but not as a type in
supportedDataTypes, this method returns false.
:return: Output that specifies the planar configuration, subsampling,
orientation, chroma siting, plane color types, and row bytes.
)docstring",
py::arg("supportedDataTypes"))
.def("getYUVAPlanes", &SkCodec::getYUVAPlanes,
R"docstring(
Returns kSuccess, or another value explaining the type of failure.
This always attempts to perform a full decode. To get the planar
configuration without decoding use queryYUVAInfo().

:param yuvaPixmaps: Contains preallocated pixmaps configured according
to a successful call to :py:meth:`~queryYUVAInfo`.
)docstring",
py::arg("yuvaPixmaps"))
.def("startIncrementalDecode",
[] (SkCodec& codec, const SkImageInfo& info, py::buffer data,
size_t rowBytes, const SkCodec::Options* options) {
Expand Down
7 changes: 7 additions & 0 deletions src/skia/ColorFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ py::class_<SkColorFilters>(m, "ColorFilters")
return SkColorFilters::HSLAMatrix(&rowMajor[0]);
},
py::arg("rowMajor"))
.def_static("HSLAMatrix",
py::overload_cast<const SkColorMatrix&>(&SkColorFilters::HSLAMatrix),
R"docstring(
A version of Matrix which operates in HSLA space instead of RGBA.
i.e. ``HSLA-to-RGBA(Matrix(RGBA-to-HSLA(input)))``.
)docstring",
py::arg("colorMatrix"))
.def_static("LinearToSRGBGamma", &SkColorFilters::LinearToSRGBGamma)
.def_static("SRGBToLinearGamma", &SkColorFilters::SRGBToLinearGamma)
.def_static("Lerp",
Expand Down
11 changes: 11 additions & 0 deletions src/skia/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,17 @@ typeface
It will always be returned encoded as UTF8, but the language of the name
is whatever the host platform chooses.
)docstring")
.def("getPostScriptName",
[] (const SkTypeface& typeface) {
SkString name;
typeface.getPostScriptName(&name);
return py::str(name.c_str(), name.size());
},
R"docstring(
Return the PostScript name for this typeface.
Value may change based on variation parameters.
Returns false if no PostScript name is available.
)docstring")
// .def("openStream", &SkTypeface::openStream,
// "Return a stream for the contents of the font data, or NULL on "
// "failure.")
Expand Down
149 changes: 88 additions & 61 deletions src/skia/GrContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,25 @@ py::class_<GrBackendSurfaceMutableState>(m, "GrBackendSurfaceMutableState",

Vulkan: VkImageLayout and QueueFamilyIndex
)docstring")
.def(py::init<>())
#ifdef SK_VULKAN
.def(py::init<VkImageLayout, uint32_t>())
.def(py::init<VkImageLayout, uint32_t>(),
py::arg("layout"), py::arg("queueFamilyIndex"))
.def("getVkImageLayout",
&GrBackendSurfaceMutableState::getVkImageLayout,
R"docstring(
If this class is not Vulkan backed it will return value of
VK_IMAGE_LAYOUT_UNDEFINED. Otherwise it will return the VkImageLayout.
)docstring")
.def("getQueueFamilyIndex",
&GrBackendSurfaceMutableState::getQueueFamilyIndex,
R"docstring(
If this class is not Vulkan backed it will return value of
VK_QUEUE_FAMILY_IGNORED. Otherwise it will return the VkImageLayout.
)docstring")
#endif
.def("isValid", &GrBackendSurfaceMutableState::isValid)
.def("backend", &GrBackendSurfaceMutableState::backend)
;

py::class_<GrBackendRenderTarget>(m, "GrBackendRenderTarget")
Expand All @@ -326,10 +342,9 @@ py::class_<GrBackendRenderTarget>(m, "GrBackendRenderTarget")
py::arg("width"), py::arg("height"), py::arg("sampleCnt"),
py::arg("stencilBits"), py::arg("glInfo"))
#ifdef SK_VULKAN
.def(py::init<int, int, int, int, const GrVkImageInfo&>(),
py::arg("width"), py::arg("height"), py::arg("sampleCnt"),
py::arg("stencilBits"), py::arg("vkInfo"))
.def(py::init<int, int, int, const GrVkImageInfo&>(),
py::arg("width"), py::arg("height"), py::arg("vkInfo"))
.def(py::init<int, int, int, int, const GrVkImageInfo&>(),
py::arg("width"), py::arg("height"), py::arg("sampleCnt"),
py::arg("vkInfo"))
#endif
Expand Down Expand Up @@ -444,6 +459,19 @@ py::class_<GrRecordingContext, sk_sp<GrRecordingContext>, GrImageContext>(
:py:meth:`~GrRecordingContext.maxSurfaceSampleCountForColorType`.
)docstring",
py::arg("colorType"))
.def("maxTextureSize", &GrRecordingContext::maxTextureSize,
R"docstring(
Gets the maximum supported texture size.
)docstring")
.def("maxRenderTargetSize", &GrRecordingContext::maxRenderTargetSize,
R"docstring(
Gets the maximum supported render target size.
)docstring")
.def("colorTypeSupportedAsImage",
&GrRecordingContext::colorTypeSupportedAsImage,
R"docstring(
Can a :py:class:`Image` be created with the given color type.
)docstring")
.def("maxSurfaceSampleCountForColorType",
&GrRecordingContext::maxSurfaceSampleCountForColorType,
R"docstring(
Expand Down Expand Up @@ -771,24 +799,11 @@ py::class_<GrContext, sk_sp<GrContext>, GrRecordingContext>(m, "GrContext")
py::overload_cast<int, int, const GrBackendFormat&, GrMipmapped,
GrRenderable, GrProtected>(&GrContext::createBackendTexture),
R"docstring(
The explicitly allocated backend texture API allows clients to use Skia
to create backend objects outside of Skia proper (i.e., Skia's caching
system will not know about them.)

It is the client's responsibility to delete all these objects (using
:py:meth:`deleteBackendTexture`) before deleting the
:py:class:`GrContext` used to create them. If the backend is Vulkan, the
textures must be deleted before abandoning the :py:class:`GrContext` as
well. Additionally, clients should only delete these objects on the
thread for which that :py:class:`GrContext` is active.

The client is responsible for ensuring synchronization between different
uses of the backend object (i.e., wrapping it in a surface, rendering to
it, deleting the surface, rewrapping it in a image and drawing the image
will require explicit sychronization on the client's part). If possible,
create an uninitialized backend texture. The client should ensure that
the returned backend texture is valid. For the Vulkan backend the layout
of the created VkImage will be: VK_IMAGE_LAYOUT_UNDEFINED.
If possible, create an uninitialized backend texture.

The client should ensure that the returned backend texture is valid.
For the Vulkan backend the layout of the created VkImage will be:
VK_IMAGE_LAYOUT_UNDEFINED.
)docstring",
py::arg("width"), py::arg("height"), py::arg("backendFormat"),
py::arg("mipMapped"), py::arg("renderable"),
Expand All @@ -807,18 +822,6 @@ py::class_<GrContext, sk_sp<GrContext>, GrRecordingContext>(m, "GrContext")
py::arg("width"), py::arg("height"), py::arg("colorType"),
py::arg("mipMapped"), py::arg("renderable"),
py::arg("isProtected") = GrProtected::kNo)
.def("createBackendTexture",
py::overload_cast<const SkSurfaceCharacterization &>(
&GrContext::createBackendTexture),
R"docstring(
If possible, create an uninitialized backend texture that is compatible
with the provided characterization.

The client should ensure that the returned backend texture is valid. For
the Vulkan backend the layout of the created VkImage will be:
VK_IMAGE_LAYOUT_UNDEFINED.
)docstring",
py::arg("characterization"))
.def("createBackendTexture",
[] (GrContext& context, int width, int height,
const GrBackendFormat& backendFormat, const SkColor4f& color,
Expand All @@ -831,9 +834,14 @@ py::class_<GrContext, sk_sp<GrContext>, GrRecordingContext>(m, "GrContext")
R"docstring(
If possible, create a backend texture initialized to a particular color.

The client should ensure that the returned backend texture is valid.
The client should ensure that the returned backend texture is valid. The
client can pass in a finishedProc to be notified when the data has been
uploaded by the gpu and the texture can be deleted. The client is
required to call GrContext::submit to send the upload work to the gpu.
The finishedProc will always get called even if we failed to create the
GrBackendTexture.
For the Vulkan backend the layout of the created VkImage will be:
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
)docstring",
py::arg("width"), py::arg("height"), py::arg("backendFormat"),
py::arg("color"), py::arg("mipMapped"), py::arg("renderable"),
Expand All @@ -852,37 +860,43 @@ py::class_<GrContext, sk_sp<GrContext>, GrRecordingContext>(m, "GrContext")

The client should ensure that the returned backend texture is valid.
If successful, the created backend texture will be compatible with the
provided SkColorType. For the Vulkan backend the layout of the created
VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
provided :py:class:`~skia.ColorType`. For the Vulkan backend the layout
of the created VkImage will be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
)docstring",
py::arg("width"), py::arg("height"), py::arg("colorType"),
py::arg("color"), py::arg("mipMapped"), py::arg("renderable"),
py::arg("isProtected") = GrProtected::kNo)
.def("createBackendTexture",
[] (GrContext& context,
const SkSurfaceCharacterization& characterization,
const SkColor4f& color) {
return context.createBackendTexture(characterization, color);
},
R"docstring(
If possible, create a backend texture initialized to a particular color
that is compatible with the provided characterization.

The client should ensure that the returned backend texture is valid.
For the Vulkan backend the layout of the created VkImage will be:
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL if texturaeble
VK_IMAGE_LAYOUT_UNDEFINED if not textureable
)docstring",
py::arg("characterization"), py::arg("color"))
.def("createBackendTexture",
[] (GrContext& context, const std::vector<SkPixmap>& srcData,
GrRenderable renderable, GrProtected isProtected) {
return context.createBackendTexture(
(srcData.empty()) ? nullptr : &srcData[0],
(srcData.empty()) ? nullptr : srcData.data(),
srcData.size(),
renderable,
isProtected);
},
R"docstring(
If possible, create a backend texture initialized with the provided
pixmap data. The client should ensure that the returned backend texture
is valid. The client can pass in a finishedProc to be notified when the
data has been uploaded by the gpu and the texture can be deleted. The
client is required to call GrContext::submit to send the upload work to
the gpu. The finishedProc will always get called even if we failed to
create the GrBackendTexture. If successful, the created backend texture
will be compatible with the provided pixmap(s). Compatible, in this
case, means that the backend format will be the result of calling
defaultBackendFormat on the base pixmap's colortype. The src data can be
deleted when this call returns.

If numLevels is 1 a non-mipMapped texture will result. If a mipMapped
texture is desired the data for all the mipmap levels must be
provided. In the mipmapped case all the colortypes of the provided
pixmaps must be the same. Additionally, all the miplevels must be
sized correctly (please see SkMipmap::ComputeLevelSize and
ComputeLevelCount). Note: the pixmap's alphatypes and colorspaces are
ignored. For the Vulkan backend the layout of the created VkImage will
be: VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
)docstring",
py::arg("srcData"), py::arg("renderable"),
py::arg("isProtected") = GrProtected::kNo)
.def("createBackendTexture",
Expand Down Expand Up @@ -1005,9 +1019,10 @@ py::class_<GrContext, sk_sp<GrContext>, GrRecordingContext>(m, "GrContext")
py::arg("mipMapped"), py::arg("isProtected") = GrProtected::kNo)
.def("setBackendTextureState",
[] (GrContext& context, const GrBackendTexture& texture,
const GrBackendSurfaceMutableState& mutableState) {
const GrBackendSurfaceMutableState& mutableState,
GrBackendSurfaceMutableState* previousState) {
return context.setBackendTextureState(
texture, mutableState, nullptr, nullptr);
texture, mutableState, previousState, nullptr, nullptr);
},
R"docstring(
Updates the state of the GrBackendTexture/RenderTarget to have the
Expand All @@ -1023,15 +1038,27 @@ py::class_<GrContext, sk_sp<GrContext>, GrRecordingContext>(m, "GrContext")

See :py:class:`GrBackendSurfaceMutableState` to see what state can be
set via this call.

If the backend API is Vulkan, the caller can set the
GrBackendSurfaceMutableState's VkImageLayout to
VK_IMAGE_LAYOUT_UNDEFINED or queueFamilyIndex to VK_QUEUE_FAMILY_IGNORED
to tell Skia to not change those respective states.

If previousState is not null and this returns true, then Skia will have
filled in previousState to have the values of the state before this
call.
)docstring",
py::arg("texture"), py::arg("mutableState"))
py::arg("texture"), py::arg("mutableState"),
py::arg("previousState") = nullptr)
.def("setBackendRenderTargetState",
[] (GrContext& context, const GrBackendRenderTarget& target,
const GrBackendSurfaceMutableState& mutableState) {
const GrBackendSurfaceMutableState& mutableState,
GrBackendSurfaceMutableState* previousState) {
return context.setBackendRenderTargetState(
target, mutableState, nullptr, nullptr);
target, mutableState, previousState, nullptr, nullptr);
},
py::arg("target"), py::arg("mutableState"))
py::arg("target"), py::arg("mutableState"),
py::arg("previousState") = nullptr)
.def("deleteBackendTexture", &GrContext::deleteBackendTexture,
py::arg("texture"))
.def("precompileShader", &GrContext::precompileShader,
Expand Down
2 changes: 0 additions & 2 deletions src/skia/GrContext_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ py::class_<GrVkImageInfo>(m, "GrVkImageInfo",
// py::arg("currentQueueFamily") = VK_QUEUE_FAMILY_IGNORED,
// py::arg("isProtected") = GrProtected::kNo,
// py::arg("ycbcrConversionInfo") = nullptr)
.def(py::init<const GrVkImageInfo&, VkImageLayout, uint32_t>(),
py::arg("info"), py::arg("layout"), py::arg("familyQueueIndex"))
// .def_readwrite("fImage", &GrVkImageInfo::fImage)
.def_readwrite("fAlloc", &GrVkImageInfo::fAlloc)
// .def_readwrite("fImageTiling", &GrVkImageInfo::fImageTiling)
Expand Down
Loading