diff options
Diffstat (limited to 'content/handlers/image/bmp.c')
-rw-r--r-- | content/handlers/image/bmp.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/content/handlers/image/bmp.c b/content/handlers/image/bmp.c index 448728ede..7139d86b4 100644 --- a/content/handlers/image/bmp.c +++ b/content/handlers/image/bmp.c @@ -33,7 +33,9 @@ #include "netsurf/content.h" #include "content/llcache.h" #include "content/content_protected.h" +#include "content/content_factory.h" #include "desktop/gui_internal.h" +#include "desktop/bitmap.h" #include "image/bmp.h" @@ -56,12 +58,12 @@ typedef struct nsbmp_content { */ static void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state) { - unsigned int bitmap_state = BITMAP_NEW; + unsigned int bitmap_state = BITMAP_NONE; /* set bitmap state based on bmp state */ bitmap_state |= (bmp_state & BMP_OPAQUE) ? BITMAP_OPAQUE : 0; bitmap_state |= (bmp_state & BMP_CLEAR_MEMORY) ? - BITMAP_CLEAR_MEMORY : 0; + BITMAP_CLEAR : 0; /* return the created bitmap */ return guit->bitmap->create(width, height, bitmap_state); @@ -73,10 +75,9 @@ static nserror nsbmp_create_bmp_data(nsbmp_content *bmp) .bitmap_create = nsbmp_bitmap_create, .bitmap_destroy = guit->bitmap->destroy, .bitmap_get_buffer = guit->bitmap->get_buffer, - .bitmap_get_bpp = guit->bitmap->get_bpp }; - bmp->bmp = calloc(sizeof(struct bmp_image), 1); + bmp->bmp = calloc(1, sizeof(struct bmp_image)); if (bmp->bmp == NULL) { content_broadcast_error(&bmp->base, NSERROR_NOMEM, NULL); return NSERROR_NOMEM; @@ -87,10 +88,14 @@ static nserror nsbmp_create_bmp_data(nsbmp_content *bmp) return NSERROR_OK; } -static nserror nsbmp_create(const content_handler *handler, - lwc_string *imime_type, const struct http_parameter *params, - llcache_handle *llcache, const char *fallback_charset, - bool quirks, struct content **c) +static nserror +nsbmp_create(const struct content_handler *handler, + lwc_string *imime_type, + const struct http_parameter *params, + llcache_handle *llcache, + const char *fallback_charset, + bool quirks, + struct content **c) { nsbmp_content *bmp; nserror error; @@ -146,8 +151,7 @@ static bool nsbmp_convert(struct content *c) /* Store our content width and description */ c->width = bmp->bmp->width; c->height = bmp->bmp->height; - swidth = bmp->bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bmp->bitmap) * - bmp->bmp->width; + swidth = sizeof(uint32_t) * bmp->bmp->width; c->size += (swidth * bmp->bmp->height) + 16 + 44; /* set title text */ @@ -186,6 +190,9 @@ static bool nsbmp_redraw(struct content *c, struct content_redraw_data *data, return false; } + bitmap_format_to_client(bmp->bitmap, &(bitmap_fmt_t) { + .layout = BITMAP_LAYOUT_R8G8B8A8, + }); guit->bitmap->modified(bmp->bitmap); } @@ -259,6 +266,16 @@ static content_type nsbmp_content_type(void) return CONTENT_IMAGE; } +static bool nsbmp_content_is_opaque(struct content *c) +{ + nsbmp_content *bmp = (nsbmp_content *)c; + + if (bmp->bitmap != NULL) { + return guit->bitmap->get_opaque(bmp->bitmap); + } + + return false; +} static const content_handler nsbmp_content_handler = { .create = nsbmp_create, @@ -268,6 +285,7 @@ static const content_handler nsbmp_content_handler = { .clone = nsbmp_clone, .get_internal = nsbmp_get_internal, .type = nsbmp_content_type, + .is_opaque = nsbmp_content_is_opaque, .no_share = false, }; |