summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte.benjamin@googlemail.com>2023-04-22 15:10:02 +0000
committerBenjamin Otte <otte.benjamin@googlemail.com>2023-04-22 15:10:02 +0000
commit72016341c6e7af78c3811eeb111828f5160426a3 (patch)
treec407ab2a7d14d8e437cbf88acaf4bfbc261632d7
parent27e3ac5fc501d006bcd0b8d61d4bb031467422a2 (diff)
parent104b5ef157b53c8fd766eb157485e58758b4c3dc (diff)
downloadgtk+-72016341c6e7af78c3811eeb111828f5160426a3.tar.gz
Merge branch 'wip/otte/for-main' into 'main'
surface: Clean up drawing code See merge request GNOME/gtk!5861
-rw-r--r--gdk/gdksurface.c107
-rw-r--r--gdk/gdksurfaceprivate.h5
2 files changed, 17 insertions, 95 deletions
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 7120da78db..4a3409508e 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -1270,40 +1270,6 @@ gdk_surface_create_vulkan_context (GdkSurface *surface,
NULL);
}
-/* Code for dirty-region queueing
- */
-static GSList *update_surfaces = NULL;
-
-static void
-gdk_surface_add_update_surface (GdkSurface *surface)
-{
- GSList *tmp;
-
- /* Check whether "surface" is already in "update_surfaces" list.
- * It could be added during execution of gtk_widget_destroy() when
- * setting focus widget to NULL and redrawing old focus widget.
- * See bug 711552.
- */
- tmp = g_slist_find (update_surfaces, surface);
- if (tmp != NULL)
- return;
-
- update_surfaces = g_slist_prepend (update_surfaces, g_object_ref (surface));
-}
-
-static void
-gdk_surface_remove_update_surface (GdkSurface *surface)
-{
- GSList *link;
-
- link = g_slist_find (update_surfaces, surface);
- if (link != NULL)
- {
- update_surfaces = g_slist_delete_link (update_surfaces, link);
- g_object_unref (surface);
- }
-}
-
static gboolean
gdk_surface_is_toplevel_frozen (GdkSurface *surface)
{
@@ -1333,46 +1299,6 @@ gdk_surface_schedule_update (GdkSurface *surface)
}
static void
-gdk_surface_process_updates_internal (GdkSurface *surface)
-{
- /* Ensure the surface lives while updating it */
- g_object_ref (surface);
-
- surface->in_update = TRUE;
-
- /* If an update got queued during update processing, we can get a
- * surface in the update queue that has an empty update_area.
- * just ignore it.
- */
- if (surface->update_area)
- {
- g_assert (surface->active_update_area == NULL); /* No reentrancy */
-
- surface->active_update_area = surface->update_area;
- surface->update_area = NULL;
-
- if (GDK_SURFACE_IS_MAPPED (surface))
- {
- cairo_region_t *expose_region;
- gboolean handled;
-
- expose_region = cairo_region_copy (surface->active_update_area);
-
- g_signal_emit (surface, signals[RENDER], 0, expose_region, &handled);
-
- cairo_region_destroy (expose_region);
- }
-
- cairo_region_destroy (surface->active_update_area);
- surface->active_update_area = NULL;
- }
-
- surface->in_update = FALSE;
-
- g_object_unref (surface);
-}
-
-static void
gdk_surface_layout_on_clock (GdkFrameClock *clock,
void *data)
{
@@ -1429,28 +1355,32 @@ gdk_surface_paint_on_clock (GdkFrameClock *clock,
void *data)
{
GdkSurface *surface = GDK_SURFACE (data);
+ cairo_region_t *expose_region;
g_return_if_fail (GDK_IS_SURFACE (surface));
- if (GDK_SURFACE_DESTROYED (surface))
+ if (GDK_SURFACE_DESTROYED (surface) ||
+ !surface->update_area ||
+ surface->update_freeze_count ||
+ gdk_surface_is_toplevel_frozen (surface))
return;
- g_object_ref (surface);
-
- if (surface->update_area &&
- !surface->update_freeze_count &&
- !gdk_surface_is_toplevel_frozen (surface) &&
+ surface->pending_phases &= ~GDK_FRAME_CLOCK_PHASE_PAINT;
+ expose_region = surface->update_area;
+ surface->update_area = NULL;
- /* Don't recurse into process_updates_internal, we'll
- * do the update later when idle instead. */
- !surface->in_update)
+ if (GDK_SURFACE_IS_MAPPED (surface))
{
- surface->pending_phases &= ~GDK_FRAME_CLOCK_PHASE_PAINT;
- gdk_surface_process_updates_internal (surface);
- gdk_surface_remove_update_surface (surface);
+ gboolean handled;
+
+ g_object_ref (surface);
+
+ g_signal_emit (surface, signals[RENDER], 0, expose_region, &handled);
+
+ g_object_unref (surface);
}
- g_object_unref (surface);
+ cairo_region_destroy (expose_region);
}
/*
@@ -1498,7 +1428,6 @@ impl_surface_add_update_area (GdkSurface *impl_surface,
cairo_region_union (impl_surface->update_area, region);
else
{
- gdk_surface_add_update_surface (impl_surface);
impl_surface->update_area = cairo_region_copy (region);
gdk_surface_schedule_update (impl_surface);
}
@@ -1582,8 +1511,6 @@ _gdk_surface_clear_update_area (GdkSurface *surface)
if (surface->update_area)
{
- gdk_surface_remove_update_surface (surface);
-
cairo_region_destroy (surface->update_area);
surface->update_area = NULL;
}
diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h
index 24562c7848..a8587a8442 100644
--- a/gdk/gdksurfaceprivate.h
+++ b/gdk/gdksurfaceprivate.h
@@ -55,10 +55,6 @@ struct _GdkSurface
cairo_region_t *update_area;
guint update_freeze_count;
GdkFrameClockPhase pending_phases;
- /* This is the update_area that was in effect when the current expose
- started. It may be smaller than the expose area if we'e painting
- more than we have to, but it represents the "true" damage. */
- cairo_region_t *active_update_area;
GdkToplevelState pending_set_flags;
GdkToplevelState pending_unset_flags;
@@ -71,7 +67,6 @@ struct _GdkSurface
guint modal_hint : 1;
guint destroyed : 2;
- guint in_update : 1;
guint frame_clock_events_paused : 1;
guint autohide : 1;
guint shortcuts_inhibited : 1;