Skip to content

Commit 31da924

Browse files
authored
Merge pull request #112 from sysprog21/header-consolidation
Refine documentation for public API
2 parents b1f88b0 + b78b340 commit 31da924

File tree

5 files changed

+729
-545
lines changed

5 files changed

+729
-545
lines changed

apps/clock.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,23 @@ static void apps_clock_hand(twin_custom_widget_t *clock,
6363
twin_argb32_t out_pixel)
6464
{
6565
twin_path_t *stroke = twin_path_create();
66-
twin_path_t *pen = twin_path_create();
67-
twin_path_t *path = twin_path_create();
68-
twin_matrix_t m;
6966

7067
apps_clock_set_transform(clock, stroke);
7168

7269
twin_path_rotate(stroke, angle);
7370
twin_path_move(stroke, D(0), D(0));
7471
twin_path_draw(stroke, len, D(0));
7572

76-
m = twin_path_current_matrix(stroke);
77-
m.m[2][0] = 0;
78-
m.m[2][1] = 0;
79-
twin_path_set_matrix(pen, m);
80-
twin_path_set_matrix(path, m);
81-
twin_path_circle(pen, 0, 0, fill_width);
82-
twin_path_convolve(path, stroke, pen);
83-
84-
twin_paint_path(_apps_clock_pixmap(clock), fill_pixel, path);
73+
/* Draw the filled part of the hand */
74+
if (fill_width > 0)
75+
twin_paint_stroke(_apps_clock_pixmap(clock), fill_pixel, stroke,
76+
fill_width * 2);
8577

86-
twin_paint_stroke(_apps_clock_pixmap(clock), out_pixel, path, out_width);
78+
/* Draw the outline if needed */
79+
if (out_width > 0 && out_pixel != fill_pixel)
80+
twin_paint_stroke(_apps_clock_pixmap(clock), out_pixel, stroke,
81+
(fill_width + out_width) * 2);
8782

88-
twin_path_destroy(path);
89-
twin_path_destroy(pen);
9083
twin_path_destroy(stroke);
9184
}
9285

apps/multi.c

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

apps/spline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static twin_dispatch_result_t _apps_spline_update_pos(
143143
spline->points[spline->which].y =
144144
twin_matrix_transform_y(&(spline->inverse_transition), x, y);
145145
twin_custom_widget_queue_paint(custom);
146-
twin_widget_children_paint(twin_custom_widget_base(custom)->parent);
146+
/* Parent will be repainted automatically */
147147
return TwinDispatchDone;
148148
}
149149

0 commit comments

Comments
 (0)