Optimize blur a bit more.
This commit is contained in:
parent
8c304f6d9a
commit
873302649a
19
cairo-util.c
19
cairo-util.c
@ -100,6 +100,8 @@ buffer_create_from_cairo_surface(int fd, cairo_surface_t *surface)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
|
||||
|
||||
void
|
||||
blur_surface(cairo_surface_t *surface, int margin)
|
||||
{
|
||||
@ -107,10 +109,11 @@ blur_surface(cairo_surface_t *surface, int margin)
|
||||
int32_t width, height, stride, x, y, z, w;
|
||||
uint8_t *src, *dst;
|
||||
uint32_t *s, *d, a, p;
|
||||
int i, j, k, size = 17, half;
|
||||
uint8_t kernel[100];
|
||||
int i, j, k, size, half;
|
||||
uint8_t kernel[10];
|
||||
double f;
|
||||
|
||||
size = ARRAY_LENGTH(kernel);
|
||||
width = cairo_image_surface_get_width(surface);
|
||||
height = cairo_image_surface_get_height(surface);
|
||||
stride = cairo_image_surface_get_stride(surface);
|
||||
@ -131,9 +134,11 @@ blur_surface(cairo_surface_t *surface, int margin)
|
||||
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)
|
||||
if (margin < j && j < width - margin) {
|
||||
d[j] = s[j];
|
||||
continue;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
@ -156,9 +161,11 @@ blur_surface(cairo_surface_t *surface, int margin)
|
||||
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)
|
||||
if (margin <= i && i < height - margin) {
|
||||
d[j] = s[j];
|
||||
continue;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
|
5
window.c
5
window.c
@ -88,7 +88,7 @@ draw_window(void *data)
|
||||
cairo_set_source_rgba(cr, 0, 0, 0, 0.5);
|
||||
rounded_rect(cr, 0, 0, window->width, window->height, radius);
|
||||
cairo_fill(cr);
|
||||
blur_surface(surface, 16 + radius);
|
||||
blur_surface(surface, 24 + radius);
|
||||
|
||||
cairo_translate(cr, -5, -3);
|
||||
cairo_set_line_width (cr, border);
|
||||
@ -148,7 +148,6 @@ draw_window(void *data)
|
||||
cairo_set_source_rgb(cr, 1, 1, 1);
|
||||
cairo_fill(cr);
|
||||
cairo_destroy(cr);
|
||||
|
||||
if (window->buffer != NULL)
|
||||
buffer_destroy(window->buffer, window->fd);
|
||||
buffer = buffer_create_from_cairo_surface(window->fd, surface);
|
||||
@ -381,7 +380,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
wl_display_set_event_handler(display, event_handler, window);
|
||||
|
||||
g_timeout_add(20, draw, window);
|
||||
g_timeout_add(50, draw, window);
|
||||
|
||||
g_main_loop_run(loop);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user