drawcontext: Add gdk_draw_context_in_frame() API
authorBenjamin Otte <otte@redhat.com>
Mon, 23 Apr 2018 16:24:29 +0000 (18:24 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 24 Apr 2018 21:16:58 +0000 (23:16 +0200)
This makes the previous gdk_draw_context_is_drawing() function public
under a new name.

I decided against the old name because we use the term "frame" for a
drawing operation, so I wanted to have this boolean flag reuse the term.

docs/reference/gdk/gdk4-sections.txt
gdk/gdkcairocontext.c
gdk/gdkdrawcontext.c
gdk/gdkdrawcontext.h
gdk/gdkdrawcontextprivate.h
gdk/gdkvulkancontext.c
gdk/wayland/gdkglcontext-wayland.c
gdk/x11/gdkglcontext-x11.c

index 18ba178c7785a1170bdbab93e9ffaa640a93ff26..ab95d6d6b56b64a1ae1e1c06e123fbb6ddbec636 100644 (file)
@@ -1104,6 +1104,7 @@ gdk_draw_context_get_display
 gdk_draw_context_get_surface
 gdk_draw_context_begin_frame
 gdk_draw_context_end_frame
+gdk_draw_context_in_frame
 gdk_draw_context_get_frame_region
 
 <SUBSECTION Standard>
index 34d3c7fa1765d5931214db998cac4fa7c9bb2a7a..3e4a31274ebc66a228db9fd3b9d9e45329a570ce 100644 (file)
@@ -88,7 +88,7 @@ gdk_cairo_context_default_cairo_create (GdkCairoContext *self)
   g_return_val_if_fail (GDK_IS_CAIRO_CONTEXT (self), NULL);
 
   context = GDK_DRAW_CONTEXT (self);
-  if (!gdk_draw_context_is_drawing (context))
+  if (!gdk_draw_context_is_in_frame (context))
     return NULL;
 
   surface = gdk_draw_context_get_surface (context);
index 7c5859e859039b362c7155e91ce3b97bba1327aa..52728d6ac3f64a2c8a1057605af6d431fa3c11b6 100644 (file)
@@ -179,21 +179,25 @@ gdk_draw_context_init (GdkDrawContext *self)
 {
 }
 
-/*< private >
- * gdk_draw_context_is_drawing:
+/**
+ * gdk_draw_context_is_in_frame:
  * @context: a #GdkDrawContext
  *
- * Returns %TRUE if @context is in the process of drawing to its surface. In such
- * cases, it will have access to the surface's backbuffer to render the new frame
- * onto it.
+ * Returns %TRUE if @context is in the process of drawing to its surface
+ * after a call to gdk_draw_context_begin_frame() and not yet having called
+ * gdk_draw_context_end_frame().
+ * In this situation, drawing commands may be effecting the contents of a
+ * @context's surface.
  *
  * Returns: %TRUE if the context is between begin_frame() and end_frame() calls.
  */
 gboolean
-gdk_draw_context_is_drawing (GdkDrawContext *context)
+gdk_draw_context_is_in_frame (GdkDrawContext *context)
 {
   GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
 
+  g_return_val_if_fail (GDK_IS_DRAW_CONTEXT (context), FALSE);
+
   return priv->frame_region != NULL;
 }
 
index 4fdc2898d7fbef930fb8ffa1cff76c0c31c06052..6a851d1951669d55c0fb1dd0651f022ac151c0da 100644 (file)
@@ -48,6 +48,8 @@ void                    gdk_draw_context_begin_frame            (GdkDrawContext
 GDK_AVAILABLE_IN_ALL
 void                    gdk_draw_context_end_frame              (GdkDrawContext         *context);
 GDK_AVAILABLE_IN_ALL
+gboolean                gdk_draw_context_is_in_frame            (GdkDrawContext         *context);
+GDK_AVAILABLE_IN_ALL
 const cairo_region_t *  gdk_draw_context_get_frame_region       (GdkDrawContext         *context);
 
 G_END_DECLS
index ef9efcf73b365c313f708d2527edf8ef8c99fb4b..9ea9eaed8cd949267860046838d5fe817d5adb88 100644 (file)
@@ -48,8 +48,6 @@ struct _GdkDrawContextClass
   void                  (* surface_resized)                     (GdkDrawContext         *context);
 };
 
-gboolean                gdk_draw_context_is_drawing             (GdkDrawContext         *context);
-
 void                    gdk_draw_context_surface_resized        (GdkDrawContext         *context);
 
 G_END_DECLS
index dae1de9632e847bb7a4ed4703752c03db207293d..fca08fed95cac155f9f2424ae80e08046c75697e 100644 (file)
@@ -718,7 +718,7 @@ gdk_vulkan_context_get_draw_index (GdkVulkanContext *context)
   GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
 
   g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), 0);
-  g_return_val_if_fail (gdk_draw_context_is_drawing (GDK_DRAW_CONTEXT (context)), 0);
+  g_return_val_if_fail (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)), 0);
 
   return priv->draw_index;
 }
@@ -741,7 +741,7 @@ gdk_vulkan_context_get_draw_semaphore (GdkVulkanContext *context)
   GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
 
   g_return_val_if_fail (GDK_IS_VULKAN_CONTEXT (context), VK_NULL_HANDLE);
-  g_return_val_if_fail (gdk_draw_context_is_drawing (GDK_DRAW_CONTEXT (context)), VK_NULL_HANDLE);
+  g_return_val_if_fail (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)), VK_NULL_HANDLE);
 
   return priv->draw_semaphore;
 }
index 03fcea28435c7584500d9f051df2fcd5c96ee15a..18863c3c8adcc68b76c7968d945133c632a9d99b 100644 (file)
@@ -504,7 +504,7 @@ gdk_wayland_display_make_gl_context_current (GdkDisplay   *display,
   context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
   surface = gdk_gl_context_get_surface (context);
 
-  if (context_wayland->is_attached || gdk_draw_context_is_drawing (GDK_DRAW_CONTEXT (context)))
+  if (context_wayland->is_attached || gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)))
     egl_surface = gdk_wayland_surface_get_egl_surface (surface->impl_surface, context_wayland->egl_config);
   else
     {
index dc8948331159a2741a450d867a93a708b48dec4e..f5d00eeb272aa5125c65f7c4bf9b5de3d954c24a 100644 (file)
@@ -1250,7 +1250,7 @@ gdk_x11_display_make_gl_context_current (GdkDisplay   *display,
       return FALSE;
     }
 
-  if (context_x11->is_attached || gdk_draw_context_is_drawing (GDK_DRAW_CONTEXT (context)))
+  if (context_x11->is_attached || gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)))
     drawable = context_x11->attached_drawable;
   else
     drawable = context_x11->unattached_drawable;