texture: Document constructors as threadsafe
authorMatthias Clasen <mclasen@redhat.com>
Wed, 22 Sep 2021 03:08:09 +0000 (23:08 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 22 Sep 2021 03:10:53 +0000 (23:10 -0400)
We aren't providing async loading apis here,
but we want to allow applications to create
textures in a thread, to avoid blocking the
main thread.

gdk/gdktexture.c

index 3f602cc5cc9f23531d7b8a2a22f1c45b9d724319..e04adfbb33127e046a481b8017e8279c1ccd97cc 100644 (file)
@@ -409,6 +409,10 @@ gdk_texture_new_for_surface (cairo_surface_t *surface)
  *
  * Creates a new texture object representing the `GdkPixbuf`.
  *
+ * This function is threadsafe, so that you can e.g. use GTask
+ * and g_task_run_in_thread() to avoid blocking the main thread
+ * while loading a big image.
+ *
  * Returns: a new `GdkTexture`
  */
 GdkTexture *
@@ -451,6 +455,10 @@ gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf)
  * If you are unsure about the validity of a resource, use
  * [ctor@Gdk.Texture.new_from_file] to load it.
  *
+ * This function is threadsafe, so that you can e.g. use GTask
+ * and g_task_run_in_thread() to avoid blocking the main thread
+ * while loading a big image.
+ *
  * Return value: A newly-created `GdkTexture`
  */
 GdkTexture *
@@ -489,6 +497,10 @@ gdk_texture_new_from_resource (const char *resource_path)
  *
  * If %NULL is returned, then @error will be set.
  *
+ * This function is threadsafe, so that you can e.g. use GTask
+ * and g_task_run_in_thread() to avoid blocking the main thread
+ * while loading a big image.
+ *
  * Return value: A newly-created `GdkTexture`
  */
 GdkTexture *
@@ -578,6 +590,10 @@ gdk_texture_new_from_bytes_pixbuf (GBytes  *bytes,
  *
  * If %NULL is returned, then @error will be set.
  *
+ * This function is threadsafe, so that you can e.g. use GTask
+ * and g_task_run_in_thread() to avoid blocking the main thread
+ * while loading a big image.
+ *
  * Return value: A newly-created `GdkTexture`
  *
  * Since: 4.6
@@ -620,6 +636,10 @@ gdk_texture_new_from_bytes (GBytes  *bytes,
  *
  * If %NULL is returned, then @error will be set.
  *
+ * This function is threadsafe, so that you can e.g. use GTask
+ * and g_task_run_in_thread() to avoid blocking the main thread
+ * while loading a big image.
+ *
  * Return value: A newly-created `GdkTexture`
  */
 GdkTexture *