From 2a4ffd4a596fb3790683abd0747b1c6f53fb4a3f Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 21 Mar 2018 04:07:37 +0100 Subject: [PATCH] surface: Simplify gdk_surface_invalidate_region() Remove duplicate functions and unused arguments. Functionality is identical otherwise. --- gdk/gdkinternals.h | 3 - gdk/gdksurface.c | 135 ++++++++++--------------------- gdk/gdksurface.h | 6 +- gdk/wayland/gdkdnd-wayland.c | 2 +- gdk/wayland/gdksurface-wayland.c | 11 +-- gdk/x11/gdkdisplay-x11.c | 4 +- gdk/x11/gdkgeometry-x11.c | 34 -------- gdk/x11/gdkprivate-x11.h | 5 -- gdk/x11/gdksurface-x11.c | 2 +- gdk/x11/meson.build | 1 - gtk/gtkdebugupdates.c | 2 +- gtk/gtkwidget.c | 2 +- 12 files changed, 50 insertions(+), 157 deletions(-) delete mode 100644 gdk/x11/gdkgeometry-x11.c diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 1bde905699..435cd504e8 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -342,9 +342,6 @@ void _gdk_windowing_got_event (GdkDisplay *display, #define GDK_SURFACE_IS_MAPPED(surface) (((surface)->state & GDK_SURFACE_STATE_WITHDRAWN) == 0) -void _gdk_surface_invalidate_for_expose (GdkSurface *surface, - cairo_region_t *region); - GdkSurface * _gdk_surface_find_child_at (GdkSurface *surface, double x, double y); GdkSurface * _gdk_surface_find_descendant_at (GdkSurface *toplevel, diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 4a08166002..b490ebd4b7 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -131,12 +131,6 @@ static void update_cursor (GdkDisplay *display, GdkDevice *device); static void impl_surface_add_update_area (GdkSurface *impl_surface, cairo_region_t *region); -static void gdk_surface_invalidate_region_full (GdkSurface *surface, - const cairo_region_t *region, - gboolean invalidate_children); -static void gdk_surface_invalidate_rect_full (GdkSurface *surface, - const GdkRectangle *rect, - gboolean invalidate_children); static cairo_surface_t *gdk_surface_ref_impl_surface (GdkSurface *surface); static void gdk_surface_set_frame_clock (GdkSurface *surface, @@ -2173,10 +2167,20 @@ gdk_surface_paint_on_clock (GdkFrameClock *clock, g_object_unref (surface); } -static void -gdk_surface_invalidate_rect_full (GdkSurface *surface, - const GdkRectangle *rect, - gboolean invalidate_children) +/** + * gdk_surface_invalidate_rect: + * @surface: a #GdkSurface + * @rect: (allow-none): rectangle to invalidate or %NULL to invalidate the whole + * surface + * @invalidate_children: whether to also invalidate child surfaces + * + * A convenience wrapper around gdk_surface_invalidate_region() which + * invalidates a rectangular region. See + * gdk_surface_invalidate_region() for details. + **/ +void +gdk_surface_invalidate_rect (GdkSurface *surface, + const GdkRectangle *rect) { GdkRectangle surface_rect; cairo_region_t *region; @@ -2199,29 +2203,10 @@ gdk_surface_invalidate_rect_full (GdkSurface *surface, } region = cairo_region_create_rectangle (rect); - gdk_surface_invalidate_region_full (surface, region, invalidate_children); + gdk_surface_invalidate_region (surface, region); cairo_region_destroy (region); } -/** - * gdk_surface_invalidate_rect: - * @surface: a #GdkSurface - * @rect: (allow-none): rectangle to invalidate or %NULL to invalidate the whole - * surface - * @invalidate_children: whether to also invalidate child surfaces - * - * A convenience wrapper around gdk_surface_invalidate_region() which - * invalidates a rectangular region. See - * gdk_surface_invalidate_region() for details. - **/ -void -gdk_surface_invalidate_rect (GdkSurface *surface, - const GdkRectangle *rect, - gboolean invalidate_children) -{ - gdk_surface_invalidate_rect_full (surface, rect, invalidate_children); -} - static void impl_surface_add_update_area (GdkSurface *impl_surface, cairo_region_t *region) @@ -2236,9 +2221,27 @@ impl_surface_add_update_area (GdkSurface *impl_surface, } } -static void -gdk_surface_invalidate_full (GdkSurface *surface, - const cairo_region_t *region) +/** + * gdk_surface_invalidate_region: + * @surface: a #GdkSurface + * @region: a #cairo_region_t + * @invalidate_children: %TRUE to also invalidate child surfaces + * + * Adds @region to the update area for @surface. The update area is the + * region that needs to be redrawn, or “dirty region.” + * + * GDK will process all updates whenever the frame clock schedules a redraw, + * so there’s no need to do forces redraws manually, you just need to + * invalidate regions that you know should be redrawn. + * + * The @invalidate_children parameter controls whether the region of + * each child surface that intersects @region will also be invalidated. + * If %FALSE, then the update area for child surfaces will remain + * unaffected. + **/ +void +gdk_surface_invalidate_region (GdkSurface *surface, + const cairo_region_t *region) { cairo_region_t *visible_region; cairo_rectangle_int_t r; @@ -2281,62 +2284,6 @@ gdk_surface_invalidate_full (GdkSurface *surface, cairo_region_destroy (visible_region); } -static void -gdk_surface_invalidate_region_full (GdkSurface *surface, - const cairo_region_t *region, - gboolean invalidate_children) -{ - gdk_surface_invalidate_full (surface, region); -} - -/** - * gdk_surface_invalidate_region: - * @surface: a #GdkSurface - * @region: a #cairo_region_t - * @invalidate_children: %TRUE to also invalidate child surfaces - * - * Adds @region to the update area for @surface. The update area is the - * region that needs to be redrawn, or “dirty region.” - * - * GDK will process all updates whenever the frame clock schedules a redraw, - * so there’s no need to do forces redraws manually, you just need to - * invalidate regions that you know should be redrawn. - * - * The @invalidate_children parameter controls whether the region of - * each child surface that intersects @region will also be invalidated. - * If %FALSE, then the update area for child surfaces will remain - * unaffected. - **/ -void -gdk_surface_invalidate_region (GdkSurface *surface, - const cairo_region_t *region, - gboolean invalidate_children) -{ - gdk_surface_invalidate_full (surface, region); -} - -/** - * _gdk_surface_invalidate_for_expose: - * @surface: a #GdkSurface - * @region: a #cairo_region_t - * - * Adds @region to the update area for @surface. - * - * GDK will process all updates whenever the frame clock schedules a redraw, - * so there’s no need to do forces redraws manually, you just need to - * invalidate regions that you know should be redrawn. - * - * This version of invalidation is used when you recieve expose events - * from the native surface system. It exposes the native surface, plus - * any non-native child surfaces. - **/ -void -_gdk_surface_invalidate_for_expose (GdkSurface *surface, - cairo_region_t *region) -{ - gdk_surface_invalidate_full (surface, region); -} - /** * _gdk_surface_clear_update_area: * @surface: a #GdkSurface. @@ -2770,7 +2717,7 @@ gdk_surface_show_internal (GdkSurface *surface, gboolean raise) recompute_visible_regions (surface, FALSE); if (gdk_surface_is_viewable (surface)) - gdk_surface_invalidate_rect_full (surface, NULL, TRUE); + gdk_surface_invalidate_rect (surface, NULL); } } @@ -2821,7 +2768,7 @@ gdk_surface_raise (GdkSurface *surface) !gdk_surface_is_toplevel (surface) && gdk_surface_is_viewable (surface) && !surface->input_only) - gdk_surface_invalidate_rect_full (surface, NULL, TRUE); + gdk_surface_invalidate_rect (surface, NULL); } static void @@ -2862,7 +2809,7 @@ gdk_surface_invalidate_in_parent (GdkSurface *private) child.height = private->height; gdk_rectangle_intersect (&r, &child, &r); - gdk_surface_invalidate_rect_full (private->parent, &r, TRUE); + gdk_surface_invalidate_rect (private->parent, &r); } @@ -3365,7 +3312,7 @@ gdk_surface_move_resize_internal (GdkSurface *surface, cairo_region_union (new_region, old_region); - gdk_surface_invalidate_region_full (surface->parent, new_region, TRUE); + gdk_surface_invalidate_region (surface->parent, new_region); cairo_region_destroy (old_region); cairo_region_destroy (new_region); @@ -5841,7 +5788,7 @@ gdk_surface_set_opacity (GdkSurface *surface, else { recompute_visible_regions (surface, FALSE); - gdk_surface_invalidate_rect_full (surface, NULL, TRUE); + gdk_surface_invalidate_rect (surface, NULL); } } diff --git a/gdk/gdksurface.h b/gdk/gdksurface.h index cc64c79064..8aaea64132 100644 --- a/gdk/gdksurface.h +++ b/gdk/gdksurface.h @@ -804,12 +804,10 @@ void gdk_surface_begin_move_drag_for_device (GdkSurface *surface, /* Interface for dirty-region queueing */ GDK_AVAILABLE_IN_ALL void gdk_surface_invalidate_rect (GdkSurface *surface, - const GdkRectangle *rect, - gboolean invalidate_children); + const GdkRectangle *rect); GDK_AVAILABLE_IN_ALL void gdk_surface_invalidate_region (GdkSurface *surface, - const cairo_region_t *region, - gboolean invalidate_children); + const cairo_region_t *region); GDK_AVAILABLE_IN_ALL void gdk_surface_freeze_updates (GdkSurface *surface); diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c index c9893390af..7f72a4c47f 100644 --- a/gdk/wayland/gdkdnd-wayland.c +++ b/gdk/wayland/gdkdnd-wayland.c @@ -384,7 +384,7 @@ gdk_wayland_drag_context_set_hotspot (GdkDragContext *context, _gdk_wayland_surface_offset_next_wl_buffer (context_wayland->dnd_surface, -hot_x, -hot_y); - gdk_surface_invalidate_rect (context_wayland->dnd_surface, &damage_rect, FALSE); + gdk_surface_invalidate_rect (context_wayland->dnd_surface, &damage_rect); } static void diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 463cc32605..04811eb08f 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -314,8 +314,6 @@ gdk_wayland_surface_update_size (GdkSurface *surface, int scale) { GdkSurfaceImplWayland *impl = GDK_SURFACE_IMPL_WAYLAND (surface->impl); - GdkRectangle area; - cairo_region_t *region; if ((surface->width == width) && (surface->height == height) && @@ -333,14 +331,7 @@ gdk_wayland_surface_update_size (GdkSurface *surface, if (impl->display_server.wl_surface) wl_surface_set_buffer_scale (impl->display_server.wl_surface, scale); - area.x = 0; - area.y = 0; - area.width = surface->width; - area.height = surface->height; - - region = cairo_region_create_rectangle (&area); - _gdk_surface_invalidate_for_expose (surface, region); - cairo_region_destroy (region); + gdk_surface_invalidate_rect (surface, NULL); } static const gchar * diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 844c14f02f..1386acbb49 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -748,7 +748,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator, y2 = (xevent->xexpose.y + xevent->xexpose.height + surface_impl->surface_scale -1) / surface_impl->surface_scale; expose_rect.height = y2 - expose_rect.y; - _gdk_x11_surface_process_expose (surface, xevent->xexpose.serial, &expose_rect); + gdk_surface_invalidate_rect (surface, &expose_rect); return_val = FALSE; } @@ -778,7 +778,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator, y2 = (xevent->xgraphicsexpose.y + xevent->xgraphicsexpose.height + surface_impl->surface_scale -1) / surface_impl->surface_scale; expose_rect.height = y2 - expose_rect.y; - _gdk_x11_surface_process_expose (surface, xevent->xgraphicsexpose.serial, &expose_rect); + gdk_surface_invalidate_rect (surface, &expose_rect); return_val = FALSE; } break; diff --git a/gdk/x11/gdkgeometry-x11.c b/gdk/x11/gdkgeometry-x11.c deleted file mode 100644 index 74601ebf0a..0000000000 --- a/gdk/x11/gdkgeometry-x11.c +++ /dev/null @@ -1,34 +0,0 @@ -/* GDK - The GIMP Drawing Kit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include "config.h" - -#include "gdksurface-x11.h" - - -void -_gdk_x11_surface_process_expose (GdkSurface *surface, - gulong serial, - GdkRectangle *area) -{ - cairo_region_t *invalidate_region = cairo_region_create_rectangle (area); - - if (!cairo_region_is_empty (invalidate_region)) - _gdk_surface_invalidate_for_expose (surface, invalidate_region); - - cairo_region_destroy (invalidate_region); -} diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index e89e64732d..3c9f6ca7ad 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -78,11 +78,6 @@ gint _gdk_x11_display_send_xevent (GdkDisplay *display, glong event_mask, XEvent *event_send); -/* Routines from gdkgeometry-x11.c */ -void _gdk_x11_surface_process_expose (GdkSurface *window, - gulong serial, - GdkRectangle *area); - cairo_region_t* _gdk_x11_xwindow_get_shape (Display *xdisplay, Window window, gint scale, diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index ef914c1930..60da5f2926 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -1638,7 +1638,7 @@ _gdk_x11_surface_set_surface_scale (GdkSurface *surface, surface->height * impl->surface_scale); } - gdk_surface_invalidate_rect (surface, NULL, TRUE); + gdk_surface_invalidate_rect (surface, NULL); } static void diff --git a/gdk/x11/meson.build b/gdk/x11/meson.build index 3912031c18..dbffdcca5f 100644 --- a/gdk/x11/meson.build +++ b/gdk/x11/meson.build @@ -13,7 +13,6 @@ gdk_x11_sources = files([ 'gdkdnd-x11.c', 'gdkeventsource.c', 'gdkeventtranslator.c', - 'gdkgeometry-x11.c', 'gdkglcontext-x11.c', 'gdkkeys-x11.c', 'gdkmain-x11.c', diff --git a/gtk/gtkdebugupdates.c b/gtk/gtkdebugupdates.c index 672afae4d4..b371603bc4 100644 --- a/gtk/gtkdebugupdates.c +++ b/gtk/gtkdebugupdates.c @@ -180,7 +180,7 @@ gtk_window_manage_updates (GtkWidget *widget, cairo_region_union (region, draw->region); } gtk_debug_updates_print (updates, region, "Queued update"); - gdk_surface_invalidate_region (gtk_widget_get_surface (widget), region, TRUE); + gdk_surface_invalidate_region (gtk_widget_get_surface (widget), region); cairo_region_destroy (region); /* Then remove all outdated regions */ diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 989b2d09d6..257b0e7b98 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -4338,7 +4338,7 @@ gtk_widget_queue_draw_region (GtkWidget *widget, invalidate: gtk_debug_updates_add (windowed_parent, region2); - gdk_surface_invalidate_region (_gtk_widget_get_surface (widget), region2, TRUE); + gdk_surface_invalidate_region (_gtk_widget_get_surface (widget), region2); cairo_region_destroy (region2);