diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 14:14:28 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 14:14:28 +0300 |
| commit | 339e1ad7adb8340732ee856d0f6f0d2c7f1455d1 (patch) | |
| tree | 55d2735987f240e5eaacf6581ed3ce5db2c0e3a8 /tests/common/test_tablet_example.c | |
| parent | e185a9d719d469a0fd7edcf09a6342f7b10cbb8e (diff) | |
Inline trivial internal helpers at their call sites
Diffstat (limited to 'tests/common/test_tablet_example.c')
| -rw-r--r-- | tests/common/test_tablet_example.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/tests/common/test_tablet_example.c b/tests/common/test_tablet_example.c index 1658174..15dde9c 100644 --- a/tests/common/test_tablet_example.c +++ b/tests/common/test_tablet_example.c @@ -11,43 +11,48 @@ static void pointer(struct app *app, enum yasl_pointer_kind kind, input(app, &event); } -static uint32_t pixel(const struct app *app, int x, int y) -{ - return app->canvas[(size_t)y * app->geometry.size.x + x]; -} - int main(void) { struct app app = {0}; assert(resize_canvas(&app, (struct yasl_geometry){{400, 300}, 120})); pointer(&app, YASL_PTR_MOTION, YASL_PTR_DEV_PEN, 3, 80, 160, 65535); - assert(pixel(&app, 80, 160) == PAPER); /* Hover never paints. */ + /* Hover never paints. */ + assert(app.canvas[(size_t)160 * app.geometry.size.x + 80] == PAPER); pointer(&app, YASL_PTR_PRESS, YASL_PTR_DEV_PEN, 2, 80, 160, 65535); - assert(!app.down && pixel(&app, 80, 160) == PAPER); /* Side button isn't the tip. */ + /* Side button isn't the tip. */ + assert(!app.down && + app.canvas[(size_t)160 * app.geometry.size.x + 80] == PAPER); pointer(&app, YASL_PTR_PRESS, YASL_PTR_DEV_PEN, 0, 80, 160, 0); - assert(app.down && pixel(&app, 80, 160) == INK && pixel(&app, 90, 160) == PAPER); + assert(app.down && + app.canvas[(size_t)160 * app.geometry.size.x + 80] == INK && + app.canvas[(size_t)160 * app.geometry.size.x + 90] == PAPER); pointer(&app, YASL_PTR_MOTION, YASL_PTR_DEV_PEN, 0, 80, 160, 65535); - assert(pixel(&app, 100, 160) == INK); /* Stationary pressure widens brush. */ + /* Stationary pressure widens brush. */ + assert(app.canvas[(size_t)160 * app.geometry.size.x + 100] == INK); pointer(&app, YASL_PTR_MOTION, YASL_PTR_DEV_PEN, 0, 180, 160, 20000); - assert(pixel(&app, 130, 160) == INK); /* Segments are continuous. */ + /* Segments are continuous. */ + assert(app.canvas[(size_t)160 * app.geometry.size.x + 130] == INK); pointer(&app, YASL_PTR_RELEASE, YASL_PTR_DEV_PEN, 0, 180, 160, 0); pointer(&app, YASL_PTR_MOTION, YASL_PTR_DEV_PEN, 3, 250, 160, 65535); - assert(!app.down && pixel(&app, 250, 160) == PAPER); + assert(!app.down && app.canvas[(size_t)160 * app.geometry.size.x + 250] == PAPER); pointer(&app, YASL_PTR_PRESS, YASL_PTR_DEV_ERASER, 0, 80, 160, 65535); - assert(pixel(&app, 80, 160) == PAPER && pixel(&app, 130, 160) == INK); + assert(app.canvas[(size_t)160 * app.geometry.size.x + 80] == PAPER && + app.canvas[(size_t)160 * app.geometry.size.x + 130] == INK); struct yasl_input_event reset = {.kind = YASL_INPUT_RESET}; input(&app, &reset); pointer(&app, YASL_PTR_MOTION, YASL_PTR_DEV_ERASER, 0, 130, 160, 65535); - assert(!app.down && pixel(&app, 130, 160) == INK); + assert(!app.down && app.canvas[(size_t)160 * app.geometry.size.x + 130] == INK); pointer(&app, YASL_PTR_PRESS, YASL_PTR_DEV_MOUSE, 0, 300, 200, 0); - assert(pixel(&app, 300, 200) == INK); + assert(app.canvas[(size_t)200 * app.geometry.size.x + 300] == INK); struct yasl_input_event blur = {.kind = YASL_INPUT_FOCUS, .focus.focused = false}; input(&app, &blur); assert(!app.down); assert(resize_canvas(&app, (struct yasl_geometry){{800, 600}, 240})); - assert(pixel(&app, 600, 400) == INK && !app.previous); /* DPI preserves logical drawing. */ + /* DPI preserves logical drawing. */ + assert(app.canvas[(size_t)400 * app.geometry.size.x + 600] == INK && + !app.previous); clear_canvas(&app); - assert(pixel(&app, 600, 400) == PAPER); + assert(app.canvas[(size_t)400 * app.geometry.size.x + 600] == PAPER); free(app.canvas); return 0; } |
