diff options
author | Alexander Mikhaylenko <alexm@gnome.org> | 2020-04-03 03:32:15 +0500 |
---|---|---|
committer | Alexander Mikhaylenko <alexm@gnome.org> | 2020-04-03 03:36:12 +0500 |
commit | 90a9498786698692472d253b69414bfd9efbfd0a (patch) | |
tree | 12368413c4286cc186c1cd4658f5ffa8d0c2c969 /src | |
parent | 06b307b45b8aa79add8daa4c1a5b8cdc6451a088 (diff) | |
download | gnome-screenshot-90a9498786698692472d253b69414bfd9efbfd0a.tar.gz |
Remove border effects
The border effects aren't included in GUI anymore, and don't work well
since window shadows are now handled by gnome-shell.
To simplify the code, just remove them.
Deprecate --border-effect CLI option, print a warning when it's in use.
Update the manpage.
Remove the corresponding gsettings key.
Diffstat (limited to 'src')
-rw-r--r-- | src/meson.build | 1 | ||||
-rw-r--r-- | src/screenshot-application.c | 22 | ||||
-rw-r--r-- | src/screenshot-config.c | 21 | ||||
-rw-r--r-- | src/screenshot-config.h | 2 | ||||
-rw-r--r-- | src/screenshot-shadow.c | 277 | ||||
-rw-r--r-- | src/screenshot-shadow.h | 26 |
6 files changed, 4 insertions, 345 deletions
diff --git a/src/meson.build b/src/meson.build index caca42f..85d68e7 100644 --- a/src/meson.build +++ b/src/meson.build @@ -9,7 +9,6 @@ sources = [ 'screenshot-dialog.c', 'screenshot-filename-builder.c', 'screenshot-interactive-dialog.c', - 'screenshot-shadow.c', 'screenshot-utils.c', ] diff --git a/src/screenshot-application.c b/src/screenshot-application.c index 11c367c..38d801d 100644 --- a/src/screenshot-application.c +++ b/src/screenshot-application.c @@ -36,7 +36,6 @@ #include "screenshot-config.h" #include "screenshot-filename-builder.h" #include "screenshot-interactive-dialog.h" -#include "screenshot-shadow.h" #include "screenshot-utils.h" #include "screenshot-dialog.h" @@ -481,25 +480,6 @@ finish_take_screenshot (ScreenshotApplication *self) return; } - if (screenshot_config->take_window_shot) - { - switch (screenshot_config->border_effect[0]) - { - case 's': /* shadow */ - screenshot_add_shadow (&screenshot); - break; - case 'b': /* border */ - screenshot_add_border (&screenshot); - break; - case 'v': /* vintage */ - screenshot_add_vintage (&screenshot); - break; - case 'n': /* none */ - default: - break; - } - } - self->priv->screenshot = screenshot; if (screenshot_config->copy_to_clipboard) @@ -613,7 +593,7 @@ static const GOptionEntry entries[] = { { "remove-border", 'B', 0, G_OPTION_ARG_NONE, NULL, N_("Remove the window border from the screenshot. This option is deprecated and window border is always included"), NULL }, { "include-pointer", 'p', 0, G_OPTION_ARG_NONE, NULL, N_("Include the pointer with the screenshot"), NULL }, { "delay", 'd', 0, G_OPTION_ARG_INT, NULL, N_("Take screenshot after specified delay [in seconds]"), N_("seconds") }, - { "border-effect", 'e', 0, G_OPTION_ARG_STRING, NULL, N_("Effect to add to the border (shadow, border, vintage or none)"), N_("effect") }, + { "border-effect", 'e', 0, G_OPTION_ARG_STRING, NULL, N_("Effect to add to the border (shadow, border, vintage or none). Note: This option is deprecated and is assumed to be none"), N_("effect") }, { "interactive", 'i', 0, G_OPTION_ARG_NONE, NULL, N_("Interactively set options"), NULL }, { "file", 'f', 0, G_OPTION_ARG_FILENAME, NULL, N_("Save screenshot directly to this file"), N_("filename") }, { "version", 0, 0, G_OPTION_ARG_NONE, &version_arg, N_("Print version information and exit"), NULL }, diff --git a/src/screenshot-config.c b/src/screenshot-config.c index 3852d0e..6abeaa5 100644 --- a/src/screenshot-config.c +++ b/src/screenshot-config.c @@ -26,7 +26,6 @@ #include "screenshot-config.h" -#define BORDER_EFFECT_KEY "border-effect" #define DELAY_KEY "delay" #define INCLUDE_POINTER_KEY "include-pointer" #define INCLUDE_ICC_PROFILE "include-icc-profile" @@ -53,9 +52,6 @@ screenshot_load_config (void) config->include_pointer = g_settings_get_boolean (config->settings, INCLUDE_POINTER_KEY); - config->border_effect = - g_settings_get_string (config->settings, - BORDER_EFFECT_KEY); config->file_type = g_settings_get_string (config->settings, DEFAULT_FILE_TYPE_KEY); @@ -63,9 +59,6 @@ screenshot_load_config (void) g_settings_get_boolean (config->settings, INCLUDE_ICC_PROFILE); - if (config->border_effect == NULL) - config->border_effect = g_strdup ("none"); - config->take_window_shot = FALSE; config->take_area_shot = FALSE; @@ -87,8 +80,6 @@ screenshot_save_config (void) g_settings_set_boolean (c->settings, INCLUDE_POINTER_KEY, c->include_pointer); - g_settings_set_string (c->settings, - BORDER_EFFECT_KEY, c->border_effect); if (!c->take_area_shot) g_settings_set_int (c->settings, DELAY_KEY, c->delay); @@ -121,6 +112,9 @@ screenshot_config_parse_command_line (gboolean clipboard_arg, if (disable_border_arg) g_warning ("Option --remove-border is deprecated and will be removed in " "gnome-screenshot 3.38.0. Window border is always included."); + if (border_effect_arg != NULL) + g_warning ("Option --border-effect is deprecated and will be removed in " + "gnome-screenshot 3.38.0. No effect will be used."); if (screenshot_config->interactive) { @@ -133,9 +127,6 @@ screenshot_config_parse_command_line (gboolean clipboard_arg, if (delay_arg > 0) screenshot_config->delay = delay_arg; - - g_free (screenshot_config->border_effect); - screenshot_config->border_effect = g_strdup ("none"); } else { @@ -149,12 +140,6 @@ screenshot_config_parse_command_line (gboolean clipboard_arg, screenshot_config->copy_to_clipboard = clipboard_arg; if (file_arg != NULL) screenshot_config->file = g_file_new_for_commandline_arg (file_arg); - - if (border_effect_arg != NULL) - { - g_free (screenshot_config->border_effect); - screenshot_config->border_effect = g_strdup (border_effect_arg); - } } screenshot_config->take_window_shot = window_arg; diff --git a/src/screenshot-config.h b/src/screenshot-config.h index d7175c3..fdf77a9 100644 --- a/src/screenshot-config.h +++ b/src/screenshot-config.h @@ -39,8 +39,6 @@ typedef struct { gboolean include_pointer; gboolean include_icc_profile; - gchar *border_effect; - guint delay; gboolean interactive; diff --git a/src/screenshot-shadow.c b/src/screenshot-shadow.c deleted file mode 100644 index f377f98..0000000 --- a/src/screenshot-shadow.c +++ /dev/null @@ -1,277 +0,0 @@ -/* screenshot-shadow.c - part of GNOME Screenshot - * - * Copyright (C) 2001-2006 Jonathan Blandford <jrb@alum.mit.edu> - * Copyright (C) 2013 Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - */ - -/* Shadow code from anders */ - -#include "config.h" - -#include "screenshot-shadow.h" -#include <math.h> - -#define BLUR_RADIUS 5 -#define SHADOW_OFFSET (BLUR_RADIUS * 4 / 5) -#define SHADOW_OPACITY 0.5 - -#define OUTLINE_RADIUS 1 -#define OUTLINE_OFFSET 0 -#define OUTLINE_OPACITY 1.0 - -#define VINTAGE_SATURATION 0.8 -#define VINTAGE_OVERLAY_COLOR 0xFFFBF2A3 -#define VINTAGE_SOURCE_ALPHA 192 -#define VINTAGE_OUTLINE_COLOR 0xFFEEEEEE -#define VINTAGE_OUTLINE_RADIUS 24 - -#define dist(x0, y0, x1, y1) sqrt(((x0) - (x1))*((x0) - (x1)) + ((y0) - (y1))*((y0) - (y1))) - -typedef struct { - int size; - double *data; -} ConvFilter; - -static double -gaussian (double x, double y, double r) -{ - return ((1 / (2 * M_PI * r)) * - exp ((- (x * x + y * y)) / (2 * r * r))); -} - -static ConvFilter * -create_blur_filter (int radius) -{ - ConvFilter *filter; - int x, y; - double sum; - - filter = g_new0 (ConvFilter, 1); - filter->size = radius * 2 + 1; - filter->data = g_new (double, filter->size * filter->size); - - sum = 0.0; - - for (y = 0 ; y < filter->size; y++) - { - for (x = 0 ; x < filter->size; x++) - { - sum += filter->data[y * filter->size + x] = gaussian (x - (filter->size >> 1), - y - (filter->size >> 1), - radius); - } - } - - for (y = 0; y < filter->size; y++) - { - for (x = 0; x < filter->size; x++) - { - filter->data[y * filter->size + x] /= sum; - } - } - - return filter; -} - -static ConvFilter * -create_outline_filter (int radius) -{ - ConvFilter *filter; - double *iter; - - filter = g_new0 (ConvFilter, 1); - filter->size = radius * 2 + 1; - filter->data = g_new (double, filter->size * filter->size); - - for (iter = filter->data; - iter < filter->data + (filter->size * filter->size); - iter++) - { - *iter = 1.0; - } - - return filter; -} - -static GdkPixbuf * -create_effect (GdkPixbuf *src, - ConvFilter const *filter, - int radius, - int offset, - double opacity) -{ - GdkPixbuf *dest; - int x, y, i, j; - int src_x, src_y; - int suma; - int dest_width, dest_height; - int src_width, src_height; - int src_rowstride, dest_rowstride; - gboolean src_has_alpha; - - guchar *src_pixels, *dest_pixels; - - src_has_alpha = gdk_pixbuf_get_has_alpha (src); - - src_width = gdk_pixbuf_get_width (src); - src_height = gdk_pixbuf_get_height (src); - dest_width = src_width + 2 * radius + offset; - dest_height = src_height + 2 * radius + offset; - - dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), - TRUE, - gdk_pixbuf_get_bits_per_sample (src), - dest_width, dest_height); - - gdk_pixbuf_fill (dest, 0); - - src_pixels = gdk_pixbuf_get_pixels (src); - src_rowstride = gdk_pixbuf_get_rowstride (src); - - dest_pixels = gdk_pixbuf_get_pixels (dest); - dest_rowstride = gdk_pixbuf_get_rowstride (dest); - - for (y = 0; y < dest_height; y++) - { - for (x = 0; x < dest_width; x++) - { - suma = 0; - - src_x = x - radius; - src_y = y - radius; - - /* We don't need to compute effect here, since this pixel will be - * discarded when compositing */ - if (src_x >= 0 && src_x < src_width && - src_y >= 0 && src_y < src_height && - (!src_has_alpha || - src_pixels [src_y * src_rowstride + src_x * 4 + 3] == 0xFF)) - continue; - - for (i = 0; i < filter->size; i++) - { - for (j = 0; j < filter->size; j++) - { - src_y = -(radius + offset) + y - (filter->size >> 1) + i; - src_x = -(radius + offset) + x - (filter->size >> 1) + j; - - if (src_y < 0 || src_y >= src_height || - src_x < 0 || src_x >= src_width) - continue; - - suma += ( src_has_alpha ? - src_pixels [src_y * src_rowstride + src_x * 4 + 3] : - 0xFF ) * filter->data [i * filter->size + j]; - } - } - - dest_pixels [y * dest_rowstride + x * 4 + 3] = CLAMP (suma * opacity, 0x00, 0xFF); - } - } - - return dest; -} - -void -screenshot_add_shadow (GdkPixbuf **src) -{ - GdkPixbuf *dest; - static ConvFilter *filter = NULL; - - if (!filter) - filter = create_blur_filter (BLUR_RADIUS); - - dest = create_effect (*src, filter, - BLUR_RADIUS, - SHADOW_OFFSET, SHADOW_OPACITY); - - if (dest == NULL) - return; - - gdk_pixbuf_composite (*src, dest, - BLUR_RADIUS, BLUR_RADIUS, - gdk_pixbuf_get_width (*src), - gdk_pixbuf_get_height (*src), - BLUR_RADIUS, BLUR_RADIUS, 1.0, 1.0, - GDK_INTERP_BILINEAR, 255); - g_set_object (src, dest); -} - -void -screenshot_add_border (GdkPixbuf **src) -{ - GdkPixbuf *dest; - static ConvFilter *filter = NULL; - - if (!filter) - filter = create_outline_filter (OUTLINE_RADIUS); - - dest = create_effect (*src, filter, - OUTLINE_RADIUS, - OUTLINE_OFFSET, OUTLINE_OPACITY); - - if (dest == NULL) - return; - - gdk_pixbuf_composite (*src, dest, - OUTLINE_RADIUS, OUTLINE_RADIUS, - gdk_pixbuf_get_width (*src), - gdk_pixbuf_get_height (*src), - OUTLINE_RADIUS, OUTLINE_RADIUS, 1.0, 1.0, - GDK_INTERP_BILINEAR, 255); - g_set_object (src, dest); -} - -void -screenshot_add_vintage (GdkPixbuf **src) -{ - GdkPixbuf *dest; - static ConvFilter *filter = NULL; - - if (!filter) - filter = create_outline_filter (VINTAGE_OUTLINE_RADIUS); - - dest = create_effect (*src, filter, - VINTAGE_OUTLINE_RADIUS, - OUTLINE_OFFSET, OUTLINE_OPACITY); - - if (dest == NULL) - return; - - gdk_pixbuf_fill (dest, VINTAGE_OUTLINE_COLOR); - gdk_pixbuf_composite (*src, dest, - VINTAGE_OUTLINE_RADIUS, VINTAGE_OUTLINE_RADIUS, - gdk_pixbuf_get_width (*src), - gdk_pixbuf_get_height (*src), - VINTAGE_OUTLINE_RADIUS, VINTAGE_OUTLINE_RADIUS, 1.0, 1.0, - GDK_INTERP_HYPER, 255); - g_set_object (src, dest); - - gdk_pixbuf_saturate_and_pixelate (*src, *src, - VINTAGE_SATURATION, FALSE); - dest = gdk_pixbuf_composite_color_simple (*src, - gdk_pixbuf_get_width(*src), - gdk_pixbuf_get_height(*src), - GDK_INTERP_BILINEAR, - VINTAGE_SOURCE_ALPHA, 64, - VINTAGE_OVERLAY_COLOR, VINTAGE_OVERLAY_COLOR); - - if (dest == NULL) - return; - - g_set_object (src, dest); -} diff --git a/src/screenshot-shadow.h b/src/screenshot-shadow.h deleted file mode 100644 index 1ef88fe..0000000 --- a/src/screenshot-shadow.h +++ /dev/null @@ -1,26 +0,0 @@ -/* screenshot-shadow.h - part of GNOME Screenshot - * - * Copyright (C) 2001-2006 Jonathan Blandford <jrb@alum.mit.edu> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This program 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - */ - -#pragma once - -#include <gtk/gtk.h> - -void screenshot_add_shadow (GdkPixbuf **src); -void screenshot_add_border (GdkPixbuf **src); -void screenshot_add_vintage (GdkPixbuf **src); |