Skip to content

Commit

Permalink
Hoist out line_clip and screen_draw_*
Browse files Browse the repository at this point in the history
  • Loading branch information
dpt committed Mar 10, 2024
1 parent 849d79b commit 038f097
Show file tree
Hide file tree
Showing 6 changed files with 584 additions and 509 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ set(PUBLIC_HEADERS
include/framebuf/span.h
include/geom/box.h
include/geom/layout.h
include/geom/line.h
include/geom/packer.h
include/geom/point.h
include/io/path.h
Expand Down Expand Up @@ -225,6 +226,7 @@ set(FRAMEBUF_SOURCES
libraries/framebuf/palettes/palettes.c
libraries/framebuf/pixelfmt/log2bpp.c
libraries/framebuf/screen/screen.c
libraries/framebuf/screen/screen-draw.c
libraries/framebuf/span-registry/get.c
libraries/framebuf/span-registry/regdata.h
libraries/framebuf/span/all8888.c
Expand All @@ -249,6 +251,7 @@ set(GEOM_SOURCES
libraries/geom/box/translated.c
libraries/geom/box/union.c
libraries/geom/layout/layout.c
libraries/geom/line/line.c
libraries/geom/packer/impl.h
libraries/geom/packer/packer.c)

Expand Down
5 changes: 3 additions & 2 deletions include/framebuf/pixelfmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ typedef unsigned int pixelfmt_argb8888_t;
typedef unsigned int pixelfmt_xxxa8888_t; /* any 32bpp alpha */

typedef unsigned int pixelfmt_any_t; /* generic/unspecified pixel */
typedef unsigned short pixelfmt_any16_t; /* any 16bpp */
typedef unsigned int pixelfmt_any32_t; /* any 32bpp */
typedef unsigned char pixelfmt_any8_t; /* any 8bpp pixel */
typedef unsigned short pixelfmt_any16_t; /* any 16bpp pixel */
typedef unsigned int pixelfmt_any32_t; /* any 32bpp pixel */

/* ----------------------------------------------------------------------- */

Expand Down
31 changes: 31 additions & 0 deletions include/geom/line.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* line.h -- lines */

#ifndef GEOM_LINE_H
#define GEOM_LINE_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "geom/box.h"

/// Clips the line (x0,y0)-(x1,y1) by `clip` and returns the clipped points in `x0` and co.
///
/// - Parameters:
/// - clip: Rectangular clip region.
/// - x0: X coordinate of first point of line (in/out).
/// - y0: Y coordinate of first point of line (in/out).
/// - x1: X coordinate of second point of line (in/out).
/// - y1: Y coordinate of second point of line (in/out).
int line_clip(const box_t *clip,
int *x0,
int *y0,
int *x1,
int *y1);

#ifdef __cplusplus
}
#endif

#endif /* GEOM_LINE_H */

0 comments on commit 038f097

Please sign in to comment.