summaryrefslogtreecommitdiff
path: root/framebuffer/fb_32bpp_plotters.c
diff options
context:
space:
mode:
Diffstat (limited to 'framebuffer/fb_32bpp_plotters.c')
-rw-r--r--framebuffer/fb_32bpp_plotters.c98
1 files changed, 84 insertions, 14 deletions
diff --git a/framebuffer/fb_32bpp_plotters.c b/framebuffer/fb_32bpp_plotters.c
index c5bf45968..11268d40a 100644
--- a/framebuffer/fb_32bpp_plotters.c
+++ b/framebuffer/fb_32bpp_plotters.c
@@ -38,6 +38,13 @@ fb_32bpp_get_xy_loc(int x, int y)
(x << 2));
}
+static inline colour fb_32bpp_to_colour(uint32_t pixel)
+{
+ return ((pixel & 0xFF) << 16) |
+ ((pixel & 0xFF00)) |
+ ((pixel & 0xFF0000) >> 16);
+}
+
#define SIGN(x) ((x<0) ? -1 : ((x>0) ? 1 : 0))
static bool fb_32bpp_line(int x0, int y0, int x1, int y1, int width,
@@ -182,7 +189,7 @@ static bool fb_32bpp_clg(colour c)
static bool
-fb_32bpp_draw_ft_bitmap(FT_Bitmap *bp, int x, int y, colour c)
+fb_32bpp_draw_ft_monobitmap(FT_Bitmap *bp, int x, int y, colour c)
{
int height = bp->rows;
int width = bp->width;
@@ -252,6 +259,66 @@ fb_32bpp_draw_ft_bitmap(FT_Bitmap *bp, int x, int y, colour c)
return true;
}
+static bool
+fb_32bpp_draw_ft_bitmap(FT_Bitmap *bp, int x, int y, colour c)
+{
+ uint32_t *pvideo;
+ uint8_t *pixel = (uint8_t *)bp->buffer;
+ colour abpixel; /* alphablended pixel */
+ int xloop, yloop;
+ int x0,y0,x1,y1;
+ int xoff, yoff; /* x and y offset into image */
+ int height = bp->rows;
+ int width = bp->width;
+ uint32_t fgcol;
+
+ /* The part of the scaled image actually displayed is cropped to the
+ * current context.
+ */
+ x0 = x;
+ y0 = y;
+ x1 = x + width;
+ y1 = y + height;
+
+ if (!fb_plotters_clip_rect_ctx(&x0, &y0, &x1, &y1))
+ return true;
+
+ if (height > (y1 - y0))
+ height = (y1 - y0);
+
+ if (width > (x1 - x0))
+ width = (x1 - x0);
+
+ xoff = x0 - x;
+ yoff = y0 - y;
+
+ /* plot the image */
+ pvideo = fb_32bpp_get_xy_loc(x0, y0);
+
+ fgcol = c & 0xFFFFFF;
+
+ for (yloop = 0; yloop < height; yloop++) {
+ for (xloop = 0; xloop < width; xloop++) {
+ abpixel = (pixel[((yoff + yloop) * bp->pitch) + xloop + xoff] << 24) | fgcol;
+ if ((abpixel & 0xFF000000) != 0) {
+ /* pixel is not transparent */
+ if ((abpixel & 0xFF000000) != 0xFF) {
+ abpixel = fb_plotters_ablend(abpixel,
+ fb_32bpp_to_colour(*(pvideo + xloop)));
+ }
+
+ *(pvideo + xloop) = ((abpixel & 0xFF) << 16) |
+ ((abpixel & 0xFF00)) |
+ ((abpixel & 0xFF0000) >> 16);
+
+ }
+ }
+ pvideo += (framebuffer->linelen >> 2);
+ }
+
+ return true;
+}
+
static bool fb_32bpp_text(int x, int y, const struct css_style *style,
const char *text, size_t length, colour bg, colour c)
{
@@ -266,17 +333,26 @@ static bool fb_32bpp_text(int x, int y, const struct css_style *style,
nxtchr = utf8_next(text, length, nxtchr);
glyph_index = FT_Get_Char_Index(face, ucs4);
- error = FT_Load_Glyph(face, glyph_index, FT_LOAD_RENDER |
- FT_LOAD_MONOCHROME |
- FT_LOAD_FORCE_AUTOHINT);
+ error = FT_Load_Glyph(face,
+ glyph_index,
+ FT_LOAD_RENDER |
+ FT_LOAD_FORCE_AUTOHINT |
+ ft_load_type);
if (error)
continue;
/* now, draw to our target surface */
- fb_32bpp_draw_ft_bitmap( &face->glyph->bitmap,
- x + face->glyph->bitmap_left,
- y - face->glyph->bitmap_top,
- c);
+ if (face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
+ fb_32bpp_draw_ft_monobitmap( &face->glyph->bitmap,
+ x + face->glyph->bitmap_left,
+ y - face->glyph->bitmap_top,
+ c);
+ } else {
+ fb_32bpp_draw_ft_bitmap( &face->glyph->bitmap,
+ x + face->glyph->bitmap_left,
+ y - face->glyph->bitmap_top,
+ c);
+ }
x += face->glyph->advance.x >> 6;
@@ -384,12 +460,6 @@ static inline colour ablend(colour pixel)
return pixel;
}
-static inline colour fb_32bpp_to_colour(uint32_t pixel)
-{
- return ((pixel & 0xFF) << 16) |
- ((pixel & 0xFF00)) |
- ((pixel & 0xFF0000) >> 16);
-}
static bool fb_32bpp_bitmap(int x, int y, int width, int height,
struct bitmap *bitmap, colour bg,