summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--framebuffer/fb_32bpp_plotters.c47
-rw-r--r--framebuffer/fb_bitmap.c27
-rw-r--r--framebuffer/fb_bitmap.h2
-rw-r--r--framebuffer/fb_convert_image.c1
4 files changed, 43 insertions, 34 deletions
diff --git a/framebuffer/fb_32bpp_plotters.c b/framebuffer/fb_32bpp_plotters.c
index dcaa6b82f..39d2a87e1 100644
--- a/framebuffer/fb_32bpp_plotters.c
+++ b/framebuffer/fb_32bpp_plotters.c
@@ -542,41 +542,30 @@ static bool fb_32bpp_bitmap(int x, int y, int width, int height,
/* plot the image */
pvideo = fb_32bpp_get_xy_loc(x0, y0);
- for (yloop = yoff; yloop < height; yloop += bitmap->width) {
-#if 1
- for (xloop = 0; xloop < width; xloop++) {
- abpixel = pixel[yloop + xloop + xoff];
- if ((abpixel & 0xFF000000) != 0) {
- if ((abpixel & 0xFF000000) != 0xFF000000) {
- abpixel = fb_plotters_ablend(abpixel,
- fb_32bpp_to_colour(*(pvideo + xloop)));
- }
-
+ if (bitmap->opaque) {
+ for (yloop = yoff; yloop < height; yloop += bitmap->width) {
+ for (xloop = 0; xloop < width; xloop++) {
+ abpixel = pixel[yloop + xloop + xoff];
*(pvideo + xloop) = fb_colour_to_pixel(abpixel);
}
+ pvideo += (framebuffer->linelen >> 2);
}
-#else
- uint32_t *pvid = pvideo;
- colour *pix = &pixel[yloop + xoff];
- colour *epix = pix + width;
- do {
- colour *spix = pix;
- while (pix < epix && !((abpixel = *pix) & 0xFF000000U)) pix++;
- if (pix < epix) {
- pvid += pix++ - spix;
- do {
+ } else {
+ for (yloop = yoff; yloop < height; yloop += bitmap->width) {
+ for (xloop = 0; xloop < width; xloop++) {
+ abpixel = pixel[yloop + xloop + xoff];
+ if ((abpixel & 0xFF000000) != 0) {
if ((abpixel & 0xFF000000) != 0xFF000000) {
- abpixel = fb_plotters_ablend(abpixel,
- fb_32bpp_to_colour(*pvid));
+ abpixel = fb_plotters_ablend(abpixel,
+ fb_32bpp_to_colour(*(pvideo + xloop)));
}
- *pvid++ = fb_colour_to_pixel(abpixel);
- } while (pix < epix && ((abpixel = *pix++) & 0xFF000000U));
- }
- } while (pix < epix);
-#endif
- pvideo += (framebuffer->linelen >> 2);
- }
+ *(pvideo + xloop) = fb_colour_to_pixel(abpixel);
+ }
+ }
+ pvideo += (framebuffer->linelen >> 2);
+ }
+ }
return true;
}
diff --git a/framebuffer/fb_bitmap.c b/framebuffer/fb_bitmap.c
index 41860e4e2..1c62898a3 100644
--- a/framebuffer/fb_bitmap.c
+++ b/framebuffer/fb_bitmap.c
@@ -46,6 +46,7 @@ void *bitmap_create(int width, int height, unsigned int state)
if (bitmap->pixdata != NULL) {
bitmap->width = width;
bitmap->height = height;
+ bitmap->opaque = false;
} else {
free(bitmap);
bitmap=NULL;
@@ -164,11 +165,15 @@ void bitmap_set_suspendable(void *bitmap, void *private_word,
*/
void bitmap_set_opaque(void *bitmap, bool opaque)
{
+ struct bitmap *bm = bitmap;
+
if (bitmap == NULL) {
LOG(("NULL bitmap!"));
return;
}
- /* todo: set bitmap as opaque */
+
+ LOG(("setting bitmap %p to %s", bm, opaque?"opaque":"transparent"));
+ bm->opaque = opaque;
}
@@ -180,13 +185,24 @@ void bitmap_set_opaque(void *bitmap, bool opaque)
*/
bool bitmap_test_opaque(void *bitmap)
{
+ int tst;
+ struct bitmap *bm = bitmap;
+
if (bitmap == NULL) {
LOG(("NULL bitmap!"));
return false;
}
- /* todo: test if bitmap as opaque */
- return false;
+ tst = bm->width * bm->height;
+
+ while (tst-- > 0) {
+ if (bm->pixdata[(tst << 2) + 3] != 0xff) {
+ LOG(("bitmap %p has transparency",bm));
+ return false;
+ }
+ }
+ LOG(("bitmap %p is opaque", bm));
+ return true;
}
@@ -197,13 +213,14 @@ bool bitmap_test_opaque(void *bitmap)
*/
bool bitmap_get_opaque(void *bitmap)
{
+ struct bitmap *bm = bitmap;
+
if (bitmap == NULL) {
LOG(("NULL bitmap!"));
return false;
}
-/* todo: get whether bitmap is opaque */
- return false;
+ return bm->opaque;
}
int bitmap_get_width(void *bitmap)
diff --git a/framebuffer/fb_bitmap.h b/framebuffer/fb_bitmap.h
index cbe7ed6b1..9a75b0b13 100644
--- a/framebuffer/fb_bitmap.h
+++ b/framebuffer/fb_bitmap.h
@@ -23,6 +23,8 @@ struct bitmap {
int width;
int height;
uint8_t *pixdata;
+ bool opaque;
+
/* The following two are only used for cursors */
int hot_x;
int hot_y;
diff --git a/framebuffer/fb_convert_image.c b/framebuffer/fb_convert_image.c
index 4fe4c8269..4fb40a933 100644
--- a/framebuffer/fb_convert_image.c
+++ b/framebuffer/fb_convert_image.c
@@ -172,6 +172,7 @@ main(int argc, char **argv)
fprintf(f, " *\n * Do not edit this file directly.\n */\n\n");
fprintf(f, "#include <sys/types.h>\n\n");
fprintf(f, "#include <stdint.h>\n\n");
+ fprintf(f, "#include <stdbool.h>\n\n");
fprintf(f, "#include \"framebuffer/fb_bitmap.h\"\n\n");
fprintf(f, "static uint8_t %s_pixdata[] = {\n", argv[3]);