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:
Simon Hausmann 2023-06-22 11:44:25 +02:00 committed by Simon Hausmann
parent 279c143d31
commit aa41277df1
2 changed files with 18 additions and 2 deletions

View file

@ -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)
{