mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-28 04:45:13 +00:00
Improve safety notes on the slint::Image texture import functions
Elaborate how to call this function safely, and copy the same description to the C++ docs.
This commit is contained in:
parent
279c143d31
commit
aa41277df1
2 changed files with 18 additions and 2 deletions
|
@ -126,6 +126,16 @@ public:
|
|||
///
|
||||
/// The texture must be bindable against the `GL_TEXTURE_2D` target, have `GL_RGBA` as format
|
||||
/// for the pixel data.
|
||||
///
|
||||
/// Safety:
|
||||
///
|
||||
/// This function is unsafe because invalid texture ids may lead to undefind behavior in OpenGL
|
||||
/// drivers. A valid texture id is one that was created by the same OpenGL context that is
|
||||
/// current during any of the invocations of the callback set on
|
||||
/// [`Window::set_rendering_notifier()`]. OpenGL contexts between instances of [`slint::Window`]
|
||||
/// are not sharing resources. Consequently
|
||||
/// [`slint::Image`] objects created from borrowed OpenGL textures cannot be shared between
|
||||
/// different windows.
|
||||
[[nodiscard]] static Image create_from_borrowed_gl_2d_rgba_texture(uint32_t texture_id,
|
||||
Size<unsigned int> size)
|
||||
{
|
||||
|
|
|
@ -619,8 +619,14 @@ impl Image {
|
|||
/// The texture must be bindable against the `GL_TEXTURE_2D` target, have `GL_RGBA` as format
|
||||
/// for the pixel data.
|
||||
///
|
||||
/// Safety: This method is marked as unsafe as passing invalid texture ids may result in
|
||||
/// undefined behavior in OpenGL drivers.
|
||||
/// # Safety
|
||||
///
|
||||
/// This function is unsafe because invalid texture ids may lead to undefind behavior in OpenGL
|
||||
/// drivers. A valid texture id is one that was created by the same OpenGL context that is
|
||||
/// current during any of the invocations of the callback set on [`Window::set_rendering_notifier()`](crate::api::Window::set_rendering_notifier).
|
||||
/// OpenGL contexts between instances of [`slint::Window`](crate::api::Window) are not sharing resources. Consequently
|
||||
/// [`slint::Image`](Self) objects created from borrowed OpenGL textures cannot be shared between
|
||||
/// different windows.
|
||||
#[allow(unsafe_code)]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub unsafe fn from_borrowed_gl_2d_rgba_texture(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue