This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 16ac5bdd29c9a7d4eb0309240a9be235a7436c0f (commit) from 5177ae606db5d0f61c99540aeffb1d7b9114ebef (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/16ac5bdd29c9a7d4eb0309240a9be235a7436...
commit 16ac5bdd29c9a7d4eb0309240a9be235a7436c0f Author: Cyril Hrubis metan@ucw.cz Date: Sun Mar 11 22:06:28 2012 +0100
text: Add text drawing that mixes with context pixels
Now we have two modes for 8BPP text rendering. One takes background color as parameter (which is what we allready had).
And the second one reads pixels from the context pixels and mixes them with the font foreground color.
diff --git a/include/text/GP_Text.h b/include/text/GP_Text.h index 86627e6..3111e73 100644 --- a/include/text/GP_Text.h +++ b/include/text/GP_Text.h @@ -42,6 +42,9 @@ * - GP_VALIGN_CENTER centers the text vertically at the point * - GP_VALIGN_BASELINE places the text baseline at the point * - GP_VALIGN_BELOW (or BOTTOM) draws the text below the point + * - GP_TEXT_NOBG mix the alpha pixels with data read from the context + * rather than mixing them with bg_color + * (which is slightly slower) */ typedef enum GP_TextAttr { GP_ALIGN_LEFT = 0x01, @@ -53,13 +56,17 @@ typedef enum GP_TextAttr { GP_VALIGN_BASELINE = 0x30, GP_VALIGN_BELOW = 0x40, GP_VALIGN_BOTTOM = GP_VALIGN_BELOW, + GP_TEXT_NOBG = 0x80, } GP_TextAttr;
/* * Raw version, doesn't use Text aligment. + * + * If flags are set to GP_TEXT_NOBG the the bg_color is ignored and + * the context pixels are used for alpha mixing. */ void GP_Text_Raw(GP_Context *context, const GP_TextStyle *style, - GP_Coord x, GP_Coord y, + GP_Coord x, GP_Coord y, uint8_t flags, GP_Pixel fg_color, GP_Pixel bg_color, const char *str);
diff --git a/libs/text/GP_Text.c b/libs/text/GP_Text.c index a5d5776..2c83a3a 100644 --- a/libs/text/GP_Text.c +++ b/libs/text/GP_Text.c @@ -52,7 +52,7 @@ static int do_align(GP_Coord *topleft_x, GP_Coord *topleft_y, int align, return 1; }
- switch (align & 0xf0) { + switch (align & 0x70) { case GP_VALIGN_ABOVE: *topleft_y = y - height + 1; break; @@ -93,7 +93,7 @@ void GP_Text(GP_Context *context, const GP_TextStyle *style, "Invalid aligment flags");
GP_Text_Raw(context, style, topleft_x, topleft_y, - fg_color, bg_color, str); + align & GP_TEXT_NOBG, fg_color, bg_color, str); }
diff --git a/libs/text/GP_Text.gen.c.t b/libs/text/GP_Text.gen.c.t index 22498af..f0acc30 100644 --- a/libs/text/GP_Text.gen.c.t +++ b/libs/text/GP_Text.gen.c.t @@ -84,13 +84,7 @@ static void text_draw_1BPP(GP_Context *context, GP_TextStyle *style, int x, int } }
-%% for pt in pixeltypes -%% if not pt.is_unknown() - -static void text_draw_8BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *style, - GP_Coord x, GP_Coord y, - GP_Pixel fg, GP_Pixel bg, const char *str) -{ +%% macro text_8BPP(pt, use_bg) const char *p;
GP_Coord y0 = y; @@ -120,10 +114,19 @@ static void text_draw_8BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *styl if (!gray) continue;
- for (k = 0; k < style->pixel_ymul; k++) - GP_HLine(context, x_start, x_start + style->pixel_xmul - 1, - y - (glyph->bearing_y - style->font->ascend) * y_mul, + int cur_y = y - (glyph->bearing_y - style->font->ascend) * y_mul; + + for (k = 0; k < style->pixel_ymul; k++) { +%% if use_bg + GP_HLine(context, x_start, x_start + style->pixel_xmul - 1, cur_y, GP_MIX_PIXELS_{{ pt.name }}(fg, bg, gray)); +%% else + unsigned int l; + + for (l = x_start; l < x_start + style->pixel_xmul; l++) + GP_MixPixel_Raw_Clipped_{{ pt.name }}(context, l, cur_y, fg, gray); +%% endif + } }
y += style->pixel_ymul + style->pixel_yspace; @@ -134,20 +137,37 @@ static void text_draw_8BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *styl if (p == str) x -= glyph->bearing_x * x_mul; } +%% endmacro + +%% for pt in pixeltypes +%% if not pt.is_unknown() + +static void text_8BPP_bg_{{ pt.name }}(GP_Context *context, GP_TextStyle *style, + GP_Coord x, GP_Coord y, + GP_Pixel fg, GP_Pixel bg, const char *str) +{ +{{ text_8BPP(pt, True) }} +} + +static void text_8BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *style, + GP_Coord x, GP_Coord y, + GP_Pixel fg, const char *str) +{ +{{ text_8BPP(pt, False) }} }
%% endif %% endfor
-static void text_draw_8BPP(GP_Context *context, GP_TextStyle *style, - GP_Coord x, GP_Coord y, - GP_Pixel fg, GP_Pixel bg, const char *str) +static void text_8BPP_bg(GP_Context *context, GP_TextStyle *style, + GP_Coord x, GP_Coord y, + GP_Pixel fg, GP_Pixel bg, const char *str) { switch (context->pixel_type) { %% for pt in pixeltypes %% if not pt.is_unknown() case GP_PIXEL_{{ pt.name }}: - text_draw_8BPP_{{ pt.name }}(context, style, x, y, fg, bg, str); + text_8BPP_bg_{{ pt.name }}(context, style, x, y, fg, bg, str); break; %% endif %% endfor @@ -156,9 +176,25 @@ static void text_draw_8BPP(GP_Context *context, GP_TextStyle *style, } }
+static void text_8BPP(GP_Context *context, GP_TextStyle *style, + GP_Coord x, GP_Coord y, + GP_Pixel fg, const char *str) +{ + switch (context->pixel_type) { +%% for pt in pixeltypes +%% if not pt.is_unknown() + case GP_PIXEL_{{ pt.name }}: + text_8BPP_{{ pt.name }}(context, style, x, y, fg, str); + break; +%% endif +%% endfor + default: + GP_ABORT("Invalid context->pixel_type"); + } +}
void GP_Text_Raw(GP_Context *context, GP_TextStyle *style, - GP_Coord x, GP_Coord y, + GP_Coord x, GP_Coord y, uint8_t flags, GP_Pixel fg, GP_Pixel bg, const char *str) { switch (style->font->glyph_bitmap_format) { @@ -166,7 +202,10 @@ void GP_Text_Raw(GP_Context *context, GP_TextStyle *style, text_draw_1BPP(context, style, x, y, fg, str); break; case GP_FONT_BITMAP_8BPP: - text_draw_8BPP(context, style, x, y, fg, bg, str); + if (flags) + text_8BPP(context, style, x, y, fg, str); + else + text_8BPP_bg(context, style, x, y, fg, bg, str); break; default: GP_ABORT("Invalid font glyph bitmap format");
-----------------------------------------------------------------------
Summary of changes: include/text/GP_Text.h | 9 +++++- libs/text/GP_Text.c | 4 +- libs/text/GP_Text.gen.c.t | 71 ++++++++++++++++++++++++++++++++++---------- 3 files changed, 65 insertions(+), 19 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.