drawcontext: Add gdk_draw_context_in_frame() API

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.
This commit is contained in:
Benjamin Otte 2018-04-23 18:24:29 +02:00
parent 6aa89f2163
commit fd686afeb2
8 changed files with 18 additions and 13 deletions

View 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>

View 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);

View 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;
}

View 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

View 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

View 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;
}

View 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
{

View 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;