diff options
author | Benjamin Otte <otte@redhat.com> | 2023-04-22 16:33:35 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2023-04-22 16:33:35 +0200 |
commit | 893862a51a5a8734575000f2c66a5556d52a9f83 (patch) | |
tree | e6de39f1f7f83e27775227dd0e669888ffd750f6 | |
parent | 823eb4c6d9c03772bdac7cb21e8b3e53c36b5f9c (diff) | |
download | gtk+-893862a51a5a8734575000f2c66a5556d52a9f83.tar.gz |
surface: Refactor code
Move the early exit conditions to the top and turn them into early exits
instead of nesting if statements.
-rw-r--r-- | gdk/gdksurface.c | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 385f5e3e91..34052799e8 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -1355,46 +1355,36 @@ 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; + surface->pending_phases &= ~GDK_FRAME_CLOCK_PHASE_PAINT; - /* Ensure the surface lives while updating it */ - g_object_ref (surface); - - /* 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) - { - cairo_region_t *expose_region; + /* Ensure the surface lives while updating it */ + g_object_ref (surface); - expose_region = surface->update_area; - surface->update_area = NULL; + expose_region = surface->update_area; + surface->update_area = NULL; - if (GDK_SURFACE_IS_MAPPED (surface)) - { - gboolean handled; + if (GDK_SURFACE_IS_MAPPED (surface)) + { + gboolean handled; - g_signal_emit (surface, signals[RENDER], 0, expose_region, &handled); - } + g_signal_emit (surface, signals[RENDER], 0, expose_region, &handled); + } - cairo_region_destroy (expose_region); - } + cairo_region_destroy (expose_region); - g_object_unref (surface); - } + g_object_unref (surface); g_object_unref (surface); } |