[gtk+/client-side-decorations] Remove drop-shadow code.
- From: Cody Russell <bratsche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/client-side-decorations] Remove drop-shadow code.
- Date: Thu, 20 May 2010 20:16:58 +0000 (UTC)
commit f48314129acb6ae6b64f6a6789a8464a34687977
Author: Cody Russell <bratsche gnome org>
Date: Wed May 19 15:31:48 2010 -0500
Remove drop-shadow code.
gtk/gtkstyle.c | 254 --------------------------------------------------------
1 files changed, 0 insertions(+), 254 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 58ce5cb..03610b7 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -26,7 +26,6 @@
#include "config.h"
#include <math.h>
-#include <pixman.h>
#include <stdlib.h>
#include <string.h>
#include <gobject/gvaluecollector.h>
@@ -3492,244 +3491,6 @@ option_menu_get_props (GtkWidget *widget,
*indicator_spacing = default_option_indicator_spacing;
}
-/* gaussian blur kernel */
-static pixman_fixed_t *
-create_blur_kernel (gint radius,
- gint *length)
-{
- const gdouble radiusf = fabs (radius) + 1.0f;
- const gdouble sigma = sqrt (-(radiusf * radiusf) / (2.0f * log (1.0f / 255.0f)));
- const gdouble scale2 = 2.0f * sigma * sigma;
- const gdouble scale1 = 1.0f / (G_PI * scale2);
- const gint size = 2 * radius + 1;
- const gint n_params = size * size;
- pixman_fixed_t *params;
- gdouble *tmp;
- gdouble sum;
- gint x;
- gint y;
- gint i;
-
- tmp = g_newa (double, n_params);
-
- for (i = 0, sum = 0, x = -radius; x <= radius; ++x)
- {
- for (y = -radius; y <= radius; ++y, ++i)
- {
- const gdouble u = x * x;
- const gdouble v = y * y;
-
- tmp[i] = scale1 * exp (-(u + v) / scale2);
-
- sum += tmp[i];
- }
- }
-
- params = g_new (pixman_fixed_t, n_params + 2);
-
- params[0] = pixman_int_to_fixed (size);
- params[1] = pixman_int_to_fixed (size);
-
- for (i = 0; i < n_params; ++i)
- params[2 + i] = pixman_double_to_fixed (tmp[i] / sum);
-
- if (length)
- *length = n_params + 2;
-
- return params;
-}
-
-static void
-blur_image_surface (cairo_surface_t *surface,
- gint radius)
-{
- cairo_format_t format;
- pixman_fixed_t *params = NULL;
- gint n_params;
- pixman_image_t *src;
- gint w;
- gint h;
- gint s;
- gpointer p;
-
- if (radius == 0 ||
- cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS ||
- cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_IMAGE)
- {
- return;
- }
-
- format = cairo_image_surface_get_format (surface);
- if (format != CAIRO_FORMAT_A8 &&
- format != CAIRO_FORMAT_RGB24 &&
- format != CAIRO_FORMAT_ARGB32)
- {
- return;
- }
-
- cairo_surface_flush (surface);
-
- w = cairo_image_surface_get_width (surface);
- h = cairo_image_surface_get_height (surface);
- s = cairo_image_surface_get_stride (surface);
-
- p = cairo_image_surface_get_data (surface);
- src = pixman_image_create_bits (PIXMAN_a8r8g8b8, w, h, p, s);
-
- params = create_blur_kernel (radius, &n_params);
- pixman_image_set_filter (src,
- PIXMAN_FILTER_CONVOLUTION,
- params,
- n_params);
- g_free (params);
-
- pixman_image_composite (PIXMAN_OP_SRC,
- src,
- NULL,
- src,
- 0, 0,
- 0, 0,
- 0, 0,
- w, h);
-
- pixman_image_unref (src);
-
- cairo_surface_mark_dirty (surface);
-}
-
-typedef struct _TileData
-{
- guchar *data;
- cairo_format_t format;
- gint width;
- gint height;
- gint stride;
-} TileData;
-
-/* XXX - leak */
-static TileData *tile = NULL;
-
-static void
-paint_window_shadow (cairo_t *cr,
- gint width,
- gint height,
- gint shadow_radius,
- gint corner_radius)
-{
- cairo_surface_t *tmp_surface = NULL;
- cairo_surface_t *new_surface = NULL;
- cairo_pattern_t *pattern = NULL;
- cairo_t *cr_surf = NULL;
- cairo_matrix_t matrix;
-
- if (!tile)
- {
- guchar *data;
-
- tmp_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- 4 * shadow_radius,
- 4 * shadow_radius);
- if (cairo_surface_status (tmp_surface) != CAIRO_STATUS_SUCCESS)
- return;
-
- cr_surf = cairo_create (tmp_surface);
- if (cairo_status (cr_surf) != CAIRO_STATUS_SUCCESS)
- {
- cairo_surface_destroy (tmp_surface);
- return;
- }
-
- cairo_scale (cr_surf, 1.0f, 1.0f);
- cairo_set_operator (cr_surf, CAIRO_OPERATOR_CLEAR);
- cairo_paint (cr_surf);
- cairo_set_operator (cr_surf, CAIRO_OPERATOR_OVER);
- cairo_set_source_rgba (cr_surf, 0.0f, 0.0f, 0.0f, 0.75f);
- cairo_arc (cr_surf,
- 2 * shadow_radius,
- 2 * shadow_radius,
- 2.0f * corner_radius,
- 0.0f,
- 360.0f * (G_PI / 180.f));
- cairo_fill (cr_surf);
- cairo_destroy (cr_surf);
-
- blur_image_surface (tmp_surface, shadow_radius);
-
- tile = g_new0 (TileData, 1);
- tile->format = cairo_image_surface_get_format (tmp_surface);
- tile->width = cairo_image_surface_get_width (tmp_surface) / 2;
- tile->height = cairo_image_surface_get_height (tmp_surface) / 2;
- tile->stride = cairo_image_surface_get_stride (tmp_surface);
-
- data = cairo_image_surface_get_data (tmp_surface);
-
- tile->data = g_malloc (tile->height * tile->stride);
- memcpy (tile->data, data, tile->height * tile->stride);
- }
-
- new_surface = cairo_image_surface_create_for_data (tile->data,
- tile->format,
- tile->width,
- tile->height,
- tile->stride);
-
- pattern = cairo_pattern_create_for_surface (new_surface);
- if (cairo_pattern_status (pattern) != CAIRO_STATUS_SUCCESS)
- {
- cairo_surface_destroy (tmp_surface);
- cairo_surface_destroy (new_surface);
- return;
- }
-
- /* top left */
- cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
- cairo_set_source (cr, pattern);
- cairo_rectangle (cr,
- 0.0f,
- 0.0f,
- width - 2 * shadow_radius,
- 2 * shadow_radius);
- cairo_fill (cr);
-
- /* bottom left */
- cairo_matrix_init_scale (&matrix, 1.0f, -1.0f);
- cairo_matrix_translate (&matrix, 0.0f, -height);
- cairo_pattern_set_matrix (pattern, &matrix);
- cairo_rectangle (cr,
- 0.0f,
- 2 * shadow_radius,
- 2 * shadow_radius,
- height - 2 * shadow_radius);
- cairo_fill (cr);
-
- /* top right */
- cairo_matrix_init_scale (&matrix, -1.0f, 1.0f);
- cairo_matrix_translate (&matrix, -width, 0.0f);
- cairo_pattern_set_matrix (pattern, &matrix);
- cairo_rectangle (cr,
- width - 2 * shadow_radius,
- 0.0f,
- 2 * shadow_radius,
- height - 2 * shadow_radius);
- cairo_fill (cr);
-
- /* bottom right */
- cairo_matrix_init_scale (&matrix, -1.0f, -1.0f);
- cairo_matrix_translate (&matrix, -width, -height);
- cairo_pattern_set_matrix (pattern, &matrix);
- cairo_rectangle (cr,
- 2 * shadow_radius,
- height - 2 * shadow_radius,
- width - 2 * shadow_radius,
- 2 * shadow_radius);
- cairo_fill (cr);
-
-
- cairo_pattern_destroy (pattern);
- cairo_surface_destroy (tmp_surface);
- cairo_surface_destroy (new_surface);
-}
-
static void
paint_decorated_window (GtkStyle *style,
GdkWindow *window,
@@ -3777,21 +3538,6 @@ paint_decorated_window (GtkStyle *style,
}
else
{
- gboolean paint_shadows;
-
- gtk_widget_style_get (widget,
- "client-side-drop-shadows", &paint_shadows,
- NULL);
-
- if (paint_shadows)
- {
- paint_window_shadow (cr,
- width,
- height,
- x / 2 + 2.5,
- radius);
- }
-
cairo_move_to (cr, hmargin, vmargin + radius);
cairo_arc (cr, hmargin + radius, vmargin + radius,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]