From d2bf301acc7976cb70568480f8f36468702b5a84 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 15 Jul 2024 01:56:31 +0100 Subject: [PATCH] m88->m116: Allow some m1xx APIs in Surface Adding direct call to SkSurfaces::WrapBackendRenderTarget Make Surface.Raster the same as Surface.MakeRaster --- src/skia/Surface.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/skia/Surface.cpp b/src/skia/Surface.cpp index fb0fc133..e9101e85 100644 --- a/src/skia/Surface.cpp +++ b/src/skia/Surface.cpp @@ -1106,6 +1106,39 @@ surface py::arg("context"), py::arg("backendRenderTarget"), py::arg("origin"), py::arg("colorType"), py::arg("colorSpace"), py::arg("surfaceProps") = nullptr) + .def_static("WrapBackendRenderTarget", &SkSurfaces::WrapBackendRenderTarget, + R"docstring( + Wraps a GPU-backed buffer into :py:class:`Surface`. + + Caller must ensure backendRenderTarget is valid for the lifetime of + returned :py:class:`Surface`. + + :py:class:`Surface` is returned if all parameters are valid. + backendRenderTarget is valid if its pixel configuration agrees with + colorSpace and context; for instance, if backendRenderTarget has an sRGB + configuration, then context must support sRGB, and colorSpace must be + present. Further, backendRenderTarget width and height must not exceed + context capabilities, and the context must be able to support back-end + render targets. + + Upon success releaseProc is called when it is safe to delete the render + target in the backend API (accounting only for use of the render target + by this surface). If :py:class:`Surface` creation fails releaseProc is + called before this function returns. + + If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr. + + :param context: GPU context + :param backendRenderTarget: GPU intermediate memory buffer + :param colorSpace: range of colors + :param surfaceProps: LCD striping orientation and setting for device + independent fonts; may be nullptr + :return: :py:class:`Surface` if all parameters are valid; otherwise, + nullptr + )docstring", + py::arg("context"), py::arg("backendRenderTarget"), py::arg("origin"), + py::arg("colorType"), py::arg("colorSpace"), + py::arg("surfaceProps") = nullptr, py::arg("releaseProc") = nullptr, py::arg("releaseContext") = nullptr) .def_static("MakeRenderTarget", py::overload_cast( @@ -1237,4 +1270,8 @@ surface )docstring", py::arg("width"), py::arg("height")) ; + +// Surfaces is a namespace +m.attr("Surfaces") = m.attr("Surface"); +m.attr("Surface").attr("Raster") = m.attr("Surface").attr("MakeRaster"); }