X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fdraw%2Fao_draw.h;h=74d5dc09e654fc53a525d038a95244d23ecfb495;hb=b0ea39f7eb18aa73160b0b848a9000892f43c0e7;hp=fbbc61c419cc909653c149ad7aaf92c2b707154a;hpb=2e784b9e726a59f2aed71c20d96ebc94aa2d19fb;p=fw%2Faltos diff --git a/src/draw/ao_draw.h b/src/draw/ao_draw.h index fbbc61c4..74d5dc09 100644 --- a/src/draw/ao_draw.h +++ b/src/draw/ao_draw.h @@ -18,18 +18,79 @@ #include #include #include "ao_font.h" +#include "ao_box.h" struct ao_bitmap { uint32_t *base; int16_t stride; /* in units */ int16_t width; /* in pixels */ int16_t height; /* in pixels */ + struct ao_box damage; }; +#define AO_BITMAP_STRIDE(width) (((width) + 31) >> 5) + struct ao_coord { float x, y; }; +struct ao_transform { + float x_scale, x_off; + float y_scale, y_off; +}; + +static inline float ao_t_x(float x, float y, const struct ao_transform *t) +{ + (void) y; + return x * t->x_scale + t->x_off; +} + +static inline int16_t ao_t_xi(float x, float y, const struct ao_transform *t) +{ + return (int16_t) (ao_t_x(x, y, t) + 0.5f); +} + +static inline float ao_t_y(float x, float y, const struct ao_transform *t) +{ + (void) x; + return y * t->y_scale + t->y_off; +} + +static inline int16_t ao_t_yi(float x, float y, const struct ao_transform *t) +{ + return (int16_t) (ao_t_y(x, y, t) + 0.5f); +} + +static inline float ao_t_x_c(const struct ao_coord *c, + const struct ao_transform *t) +{ + return ao_t_x(c->x, c->y, t); +} + +static inline float ao_t_y_c(const struct ao_coord *c, + const struct ao_transform *t) +{ + return ao_t_y(c->x, c->y, t); +} + +static inline int16_t +ao_stride(int16_t width) +{ + return (int16_t) ((width + 31) >> 5); +} + +static inline int16_t +ao_stride_bytes(int16_t width) +{ + return (int16_t) ((width + 7) >> 3); +} + +static inline void +ao_damage_set_empty(struct ao_bitmap *dst) +{ + ao_box_set_empty(&dst->damage); +} + struct ao_pattern { uint8_t pattern[8]; }; @@ -46,13 +107,13 @@ struct ao_font { const uint8_t *bytes; const uint16_t *pos; const struct ao_glyph_metrics *metrics; - int max_width; - int max_height; - int ascent; + int16_t max_width; + int16_t max_height; + int16_t ascent; }; void -ao_copy(const struct ao_bitmap *dst, +ao_copy(struct ao_bitmap *dst, int16_t dst_x, int16_t dst_y, int16_t width, @@ -63,7 +124,7 @@ ao_copy(const struct ao_bitmap *dst, uint8_t rop); void -ao_rect(const struct ao_bitmap *dst, +ao_rect(struct ao_bitmap *dst, int16_t x, int16_t y, int16_t width, @@ -72,7 +133,7 @@ ao_rect(const struct ao_bitmap *dst, uint8_t rop); void -ao_pattern(const struct ao_bitmap *dst, +ao_pattern(struct ao_bitmap *dst, int16_t x, int16_t y, int16_t width, @@ -83,7 +144,7 @@ ao_pattern(const struct ao_bitmap *dst, uint8_t rop); void -ao_line(const struct ao_bitmap *dst, +ao_line(struct ao_bitmap *dst, int16_t x1, int16_t y1, int16_t x2, @@ -92,14 +153,15 @@ ao_line(const struct ao_bitmap *dst, uint8_t rop); void -ao_poly(const struct ao_bitmap *dst, - const struct ao_coord *coords, - uint16_t ncoords, - uint32_t fill, - uint8_t rop); +ao_poly(struct ao_bitmap *dst, + const struct ao_coord *coords, + uint16_t ncoords, + const struct ao_transform *transform, + uint32_t fill, + uint8_t rop); void -ao_text(const struct ao_bitmap *dst, +ao_text(struct ao_bitmap *dst, const struct ao_font *font, int16_t x, int16_t y, @@ -108,12 +170,13 @@ ao_text(const struct ao_bitmap *dst, uint8_t rop); void -ao_logo(const struct ao_bitmap *dst, - const struct ao_font *font, - uint32_t fill, - uint8_t rop); +ao_logo(struct ao_bitmap *dst, + const struct ao_transform *transform, + const struct ao_font *font, + uint32_t fill, + uint8_t rop); -extern const struct ao_font FrutigerLT_Roman_50_font; +extern const struct ao_transform ao_identity; #define AO_SHIFT 5 #define AO_UNIT (1 << AO_SHIFT) @@ -148,4 +211,7 @@ extern const struct ao_font FrutigerLT_Roman_50_font; #define AO_NAND 0xe /* NOT src OR NOT dst */ #define AO_SET 0xf /* 1 */ +#define AO_WHITE 0xffffffff +#define AO_BLACK 0x00000000 + #endif /* _AO_DRAW_H_ */