Skip to content

Commit

Permalink
m88->m116: Allow some m1xx APIs in Surface
Browse files Browse the repository at this point in the history
Adding direct call to SkSurfaces::WrapBackendRenderTarget

Make Surface.Raster the same as Surface.MakeRaster
  • Loading branch information
HinTak committed Jul 19, 2024
1 parent adf6e3f commit d2bf301
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/skia/Surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GrRecordingContext*, skgpu::Budgeted, const SkImageInfo&, int,
GrSurfaceOrigin, const SkSurfaceProps*, bool, bool>(
Expand Down Expand Up @@ -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");
}

0 comments on commit d2bf301

Please sign in to comment.