@@ -65,7 +65,7 @@ static void apps_circletext_start(twin_screen_t *screen,
6565 twin_path_utf8 (path , "Hello, world!" );
6666 twin_path_restore (path , & state );
6767 }
68- twin_fill_path (alpha , path , 0 , 0 );
68+ twin_paint_path (alpha , 0xff000000 , path );
6969 twin_path_destroy (path );
7070 twin_path_destroy (pen );
7171 source .source_kind = TWIN_SOLID ;
@@ -112,7 +112,7 @@ static void apps_quickbrown_start(twin_screen_t *screen,
112112 fy += D (s );
113113 }
114114
115- twin_fill_path (alpha , path , 0 , 0 );
115+ twin_paint_path (alpha , 0xff000000 , path );
116116 twin_path_destroy (path );
117117 twin_path_destroy (pen );
118118 source .source_kind = TWIN_SOLID ;
@@ -160,7 +160,7 @@ static void apps_ascii_start(twin_screen_t *screen, int x, int y, int w, int h)
160160 fy += D (s + 2 );
161161 }
162162
163- twin_fill_path (alpha , path , 0 , 0 );
163+ twin_paint_path (alpha , 0xff000000 , path );
164164 twin_path_destroy (path );
165165 twin_path_destroy (pen );
166166 source .source_kind = TWIN_SOLID ;
@@ -285,15 +285,15 @@ static void apps_blur(twin_screen_t *screen, int x, int y, int w, int h)
285285 twin_window_t * window = twin_window_create (
286286 screen , TWIN_ARGB32 , TwinWindowApplication , x , y , w , h );
287287 twin_window_set_name (window , "Blur" );
288- twin_pixmap_t * scaled_background = twin_pixmap_create (
289- TWIN_ARGB32 , window -> pixmap -> width , window -> pixmap -> height );
288+ int client_width = window -> client .right - window -> client .left ;
289+ int client_height = window -> client .bottom - window -> client .top ;
290+ twin_pixmap_t * scaled_background =
291+ twin_pixmap_create (TWIN_ARGB32 , client_width , client_height );
290292 twin_fixed_t sx , sy ;
291- sx = twin_fixed_div (
292- twin_int_to_fixed (raw_background -> width ),
293- twin_int_to_fixed (window -> client .right - window -> client .left ));
294- sy = twin_fixed_div (
295- twin_int_to_fixed (raw_background -> height ),
296- twin_int_to_fixed (window -> client .bottom - window -> client .top ));
293+ sx = twin_fixed_div (twin_int_to_fixed (raw_background -> width ),
294+ twin_int_to_fixed (client_width ));
295+ sy = twin_fixed_div (twin_int_to_fixed (raw_background -> height ),
296+ twin_int_to_fixed (client_height ));
297297
298298 twin_matrix_scale (& raw_background -> transform , sx , sy );
299299 twin_operand_t srcop = {
@@ -304,18 +304,15 @@ static void apps_blur(twin_screen_t *screen, int x, int y, int w, int h)
304304 twin_composite (scaled_background , 0 , 0 , & srcop , 0 , 0 , 0 , 0 , 0 , TWIN_SOURCE ,
305305 scaled_background -> width , scaled_background -> height );
306306
307- twin_pointer_t src , dst ;
308- for (int y = window -> client .top ; y < window -> client .bottom ; y ++ )
309- for (int x = window -> client .left ; x < window -> client .right ; x ++ ) {
310- src =
311- twin_pixmap_pointer (scaled_background , x - window -> client .left ,
312- y - window -> client .top );
313- dst = twin_pixmap_pointer (window -> pixmap , x , y );
314- * dst .argb32 = * src .argb32 | 0xff000000 ;
315- }
316- twin_stack_blur (window -> pixmap , 5 , window -> client .left ,
317- window -> client .right , window -> client .top ,
318- window -> client .bottom );
307+ /* Apply blur effect to the scaled background */
308+ twin_stack_blur (scaled_background , 16 , 0 , scaled_background -> width - 1 , 0 ,
309+ scaled_background -> height - 1 );
310+
311+ /* Copy the blurred background to the window */
312+ srcop .u .pixmap = scaled_background ;
313+ twin_composite (window -> pixmap , window -> client .left , window -> client .top ,
314+ & srcop , 0 , 0 , NULL , 0 , 0 , TWIN_SOURCE , client_width ,
315+ client_height );
319316
320317 twin_pixmap_destroy (scaled_background );
321318 twin_pixmap_destroy (raw_background );
0 commit comments