diff options
Diffstat (limited to 'frontends/framebuffer/bitmap.c')
-rw-r--r-- | frontends/framebuffer/bitmap.c | 79 |
1 files changed, 9 insertions, 70 deletions
diff --git a/frontends/framebuffer/bitmap.c b/frontends/framebuffer/bitmap.c index 59f68bba5..c9b58541e 100644 --- a/frontends/framebuffer/bitmap.c +++ b/frontends/framebuffer/bitmap.c @@ -47,19 +47,16 @@ * \param state a flag word indicating the initial state * \return an opaque struct bitmap, or NULL on memory exhaustion */ -static void *bitmap_create(int width, int height, unsigned int state) +static void *bitmap_create(int width, int height, enum gui_bitmap_flags flags) { - nsfb_t *bm; - - NSLOG(netsurf, INFO, "width %d, height %d, state %u", width, height, - state); + nsfb_t *bm; bm = nsfb_new(NSFB_SURFACE_RAM); if (bm == NULL) { return NULL; } - if ((state & BITMAP_OPAQUE) == 0) { + if ((flags & BITMAP_OPAQUE) == 0) { nsfb_set_geometry(bm, width, height, NSFB_FMT_ABGR8888); } else { nsfb_set_geometry(bm, width, height, NSFB_FMT_XBGR8888); @@ -70,9 +67,7 @@ static void *bitmap_create(int width, int height, unsigned int state) return NULL; } - NSLOG(netsurf, INFO, "bitmap %p", bm); - - return bm; + return bm; } @@ -133,20 +128,6 @@ static void bitmap_destroy(void *bitmap) /** - * Save a bitmap in the platform's native format. - * - * \param bitmap a bitmap, as returned by bitmap_create() - * \param path pathname for file - * \param flags flags controlling how the bitmap is saved. - * \return true on success, false on error and error reported - */ -static bool bitmap_save(void *bitmap, const char *path, unsigned flags) -{ - return true; -} - - -/** * The bitmap image has changed, so flush any persistant cache. * * \param bitmap a bitmap, as returned by bitmap_create() @@ -175,39 +156,6 @@ static void bitmap_set_opaque(void *bitmap, bool opaque) /** - * Tests whether a bitmap has an opaque alpha channel - * - * \param bitmap a bitmap, as returned by bitmap_create() - * \return whether the bitmap is opaque - */ -static bool bitmap_test_opaque(void *bitmap) -{ - int tst; - nsfb_t *bm = bitmap; - unsigned char *bmpptr; - int width; - int height; - - assert(bm != NULL); - - nsfb_get_buffer(bm, &bmpptr, NULL); - - nsfb_get_geometry(bm, &width, &height, NULL); - - tst = width * height; - - while (tst-- > 0) { - if (bmpptr[(tst << 2) + 3] != 0xff) { - NSLOG(netsurf, INFO, "bitmap %p has transparency", bm); - return false; - } - } - NSLOG(netsurf, INFO, "bitmap %p is opaque", bm); - return true; -} - - -/** * Gets weather a bitmap should be plotted opaque * * \param bitmap a bitmap, as returned by bitmap_create() @@ -251,12 +199,6 @@ static int bitmap_get_height(void *bitmap) return(height); } -/* get bytes per pixel */ -static size_t bitmap_get_bpp(void *bitmap) -{ - return 4; -} - /** * Render content into a bitmap. * @@ -286,11 +228,11 @@ bitmap_render(struct bitmap *bitmap, NSLOG(netsurf, INFO, "width %d, height %d", width, height); /* Calculate size of buffer to render the content into */ - /* We get the width from the content width, unless it exceeds 1024, - * in which case we use 1024. This means we never create excessively - * large render buffers for huge contents, which would eat memory and - * cripple performance. */ - cwidth = min(content_get_width(content), 1024); + /* We get the width from the largest of the bitmap width and the content + * width, unless it exceeds 1024, in which case we use 1024. This means + * we never create excessively large render buffers for huge contents, + * which would eat memory and cripple performance. */ + cwidth = max(width, min(content_get_width(content), 1024)); /* The height is set in proportion with the width, according to the * aspect ratio of the required thumbnail. */ cheight = ((cwidth * height) + (width / 2)) / width; @@ -332,13 +274,10 @@ static struct gui_bitmap_table bitmap_table = { .destroy = bitmap_destroy, .set_opaque = bitmap_set_opaque, .get_opaque = framebuffer_bitmap_get_opaque, - .test_opaque = bitmap_test_opaque, .get_buffer = bitmap_get_buffer, .get_rowstride = bitmap_get_rowstride, .get_width = bitmap_get_width, .get_height = bitmap_get_height, - .get_bpp = bitmap_get_bpp, - .save = bitmap_save, .modified = bitmap_modified, .render = bitmap_render, }; |