summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-11-08 23:27:27 -0500
committerKristian Høgsberg <krh@redhat.com>2008-11-08 23:27:27 -0500
commit10bdd298b836f9859b8bc5a1645bf0ee48e8a252 (patch)
tree6324b21cc76406fb39e18324bfce8201de58214f
parent2f2cfae227d0ea9c8f811b257ca1190bfcc3d845 (diff)
Optimize window blur calculation.
-rw-r--r--cairo-util.c10
-rw-r--r--cairo-util.h2
-rw-r--r--pointer.c2
-rw-r--r--window.c3
4 files changed, 11 insertions, 6 deletions
diff --git a/cairo-util.c b/cairo-util.c
index 4891f87..94c7b03 100644
--- a/cairo-util.c
+++ b/cairo-util.c
@@ -101,13 +101,13 @@ buffer_create_from_cairo_surface(int fd, cairo_surface_t *surface)
}
void
-blur_surface(cairo_surface_t *surface)
+blur_surface(cairo_surface_t *surface, int margin)
{
cairo_surface_t *tmp;
int32_t width, height, stride, x, y, z, w;
uint8_t *src, *dst;
uint32_t *s, *d, a, p;
- int i, j, k, size = 23, half;
+ int i, j, k, size = 17, half;
uint8_t kernel[100];
double f;
@@ -131,6 +131,9 @@ blur_surface(cairo_surface_t *surface)
s = (uint32_t *) (src + i * stride);
d = (uint32_t *) (dst + i * stride);
for (j = 0; j < width; j++) {
+ if (margin < j && j < width - margin &&
+ margin < i && i < height - margin)
+ continue;
x = 0;
y = 0;
z = 0;
@@ -153,6 +156,9 @@ blur_surface(cairo_surface_t *surface)
s = (uint32_t *) (dst + i * stride);
d = (uint32_t *) (src + i * stride);
for (j = 0; j < width; j++) {
+ if (margin <= j && j < width - margin &&
+ margin <= i && i < height - margin)
+ continue;
x = 0;
y = 0;
z = 0;
diff --git a/cairo-util.h b/cairo-util.h
index 06eac5a..cc2dc65 100644
--- a/cairo-util.h
+++ b/cairo-util.h
@@ -19,6 +19,6 @@ struct buffer *
buffer_create_from_cairo_surface(int fd, cairo_surface_t *surface);
void
-blur_surface(cairo_surface_t *surface);
+blur_surface(cairo_surface_t *surface, int margin);
#endif
diff --git a/pointer.c b/pointer.c
index 2544388..4da4053 100644
--- a/pointer.c
+++ b/pointer.c
@@ -48,7 +48,7 @@ draw_pointer(int width, int height)
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_stroke_preserve(cr);
cairo_fill(cr);
- blur_surface(surface);
+ blur_surface(surface, INT_MAX);
pointer_path(cr, hotspot_x, hotspot_y);
cairo_stroke_preserve(cr);
diff --git a/window.c b/window.c
index ba8c1c5..0781d6a 100644
--- a/window.c
+++ b/window.c
@@ -89,7 +89,7 @@ draw_window(void *data)
rounded_rect(cr, 1, 1, window->width - 1, window->height - 1, radius);
cairo_stroke_preserve(cr);
cairo_fill(cr);
- blur_surface(surface);
+ blur_surface(surface, 16 + radius);
cairo_translate(cr, -5, -3);
cairo_set_line_width (cr, border);
@@ -148,7 +148,6 @@ draw_window(void *data)
cairo_stroke_preserve(cr);
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_fill(cr);
-
cairo_destroy(cr);
if (window->buffer != NULL)