mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-24 23:39:51 +03:00
Bitmap API: Clean up creation flags.
This commit is contained in:
parent
c2d72d1e93
commit
002c3c1a7c
@ -57,12 +57,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);
|
||||
|
@ -88,7 +88,7 @@ static inline nserror gif__nsgif_error_to_ns(nsgif_error gif_res)
|
||||
*/
|
||||
static void *gif_bitmap_create(int width, int height)
|
||||
{
|
||||
return guit->bitmap->create(width, height, BITMAP_NEW);
|
||||
return guit->bitmap->create(width, height, BITMAP_NONE);
|
||||
}
|
||||
|
||||
static nserror gif_create_gif_data(gif_content *c)
|
||||
|
@ -54,12 +54,12 @@ typedef struct nsico_content {
|
||||
*/
|
||||
static void *nsico_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);
|
||||
|
@ -235,7 +235,7 @@ jpeg_cache_convert(struct content *c)
|
||||
height = cinfo.output_height;
|
||||
|
||||
/* create opaque bitmap (jpegs cannot be transparent) */
|
||||
bitmap = guit->bitmap->create(width, height, BITMAP_NEW | BITMAP_OPAQUE);
|
||||
bitmap = guit->bitmap->create(width, height, BITMAP_OPAQUE);
|
||||
if (bitmap == NULL) {
|
||||
/* empty bitmap could not be created */
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
|
@ -116,7 +116,7 @@ static bool nssprite_convert(struct content *c)
|
||||
|
||||
struct rosprite* sprite = sprite_area->sprites[0];
|
||||
|
||||
nssprite->bitmap = guit->bitmap->create(sprite->width, sprite->height, BITMAP_NEW);
|
||||
nssprite->bitmap = guit->bitmap->create(sprite->width, sprite->height, BITMAP_NONE);
|
||||
if (!nssprite->bitmap) {
|
||||
content_broadcast_error(c, NSERROR_NOMEM, NULL);
|
||||
return false;
|
||||
|
@ -163,7 +163,7 @@ static void info_callback(png_structp png_s, png_infop info)
|
||||
}
|
||||
|
||||
/* Claim the required memory for the converted PNG */
|
||||
png_c->bitmap = guit->bitmap->create(width, height, BITMAP_NEW);
|
||||
png_c->bitmap = guit->bitmap->create(width, height, BITMAP_NONE);
|
||||
if (png_c->bitmap == NULL) {
|
||||
/* Failed to create bitmap skip pre-conversion */
|
||||
longjmp(png_jmpbuf(png_s), CBERR_NOPRE);
|
||||
@ -483,7 +483,7 @@ png_cache_convert(struct content *c)
|
||||
height = png_get_image_height(png_ptr, info_ptr);
|
||||
|
||||
/* Claim the required memory for the converted PNG */
|
||||
bitmap = guit->bitmap->create(width, height, BITMAP_NEW);
|
||||
bitmap = guit->bitmap->create(width, height, BITMAP_NONE);
|
||||
if (bitmap == NULL) {
|
||||
/* cleanup and bail */
|
||||
goto png_cache_convert_error;
|
||||
|
@ -187,7 +187,7 @@ static bool rsvg_convert(struct content *c)
|
||||
c->height = rsvgsize.height;
|
||||
|
||||
if ((d->bitmap = guit->bitmap->create(c->width, c->height,
|
||||
BITMAP_NEW)) == NULL) {
|
||||
BITMAP_NONE)) == NULL) {
|
||||
NSLOG(netsurf, INFO,
|
||||
"Failed to create bitmap for rsvg render.");
|
||||
content_broadcast_error(c, NSERROR_NOMEM, NULL);
|
||||
|
@ -107,9 +107,9 @@ webp_cache_convert(struct content *c)
|
||||
}
|
||||
|
||||
if (webpfeatures.has_alpha == 0) {
|
||||
bmap_flags = BITMAP_NEW | BITMAP_OPAQUE;
|
||||
bmap_flags = BITMAP_OPAQUE;
|
||||
} else {
|
||||
bmap_flags = BITMAP_NEW;
|
||||
bmap_flags = BITMAP_NONE;
|
||||
}
|
||||
|
||||
/* create bitmap */
|
||||
|
@ -90,7 +90,7 @@ canvas2d_user_data_handler(dom_node_operation operation,
|
||||
height = guit->bitmap->get_height(bitmap);
|
||||
stride = guit->bitmap->get_rowstride(bitmap);
|
||||
newbitmap = guit->bitmap->create(width, height,
|
||||
BITMAP_NEW);
|
||||
BITMAP_NONE);
|
||||
if (newbitmap != NULL) {
|
||||
if (guit->bitmap->get_rowstride(newbitmap) == stride) {
|
||||
// Compatible bitmap, bung the data over
|
||||
@ -173,7 +173,7 @@ static nserror canvas2d_create_bitmap(dom_node *node, struct bitmap **bitmap_out
|
||||
|
||||
bitmap = guit->bitmap->create(
|
||||
(int)width, (int)height,
|
||||
BITMAP_NEW);
|
||||
BITMAP_NONE);
|
||||
|
||||
if (bitmap == NULL) {
|
||||
return NSERROR_NOMEM;
|
||||
@ -242,7 +242,7 @@ canvas2d__handle_dom_event(dom_event *evt, void *pw)
|
||||
|
||||
/* Okay, we need to reallocate our bitmap and re-cache values */
|
||||
|
||||
newbitmap = guit->bitmap->create(width, height, BITMAP_NEW);
|
||||
newbitmap = guit->bitmap->create(width, height, BITMAP_NONE);
|
||||
stride = guit->bitmap->get_rowstride(newbitmap);
|
||||
|
||||
if (newbitmap != NULL) {
|
||||
|
@ -106,7 +106,7 @@ browser_window_history__clone_entry(struct history *history,
|
||||
new_entry->page.bitmap = guit->bitmap->create(
|
||||
LOCAL_HISTORY_WIDTH,
|
||||
LOCAL_HISTORY_HEIGHT,
|
||||
BITMAP_NEW | BITMAP_OPAQUE);
|
||||
BITMAP_OPAQUE);
|
||||
|
||||
if (new_entry->page.bitmap != NULL) {
|
||||
bmsrc_data = guit->bitmap->get_buffer(entry->page.bitmap);
|
||||
@ -388,7 +388,7 @@ browser_window_history_add(struct browser_window *bw,
|
||||
|
||||
entry->page.bitmap = guit->bitmap->create(
|
||||
LOCAL_HISTORY_WIDTH, LOCAL_HISTORY_HEIGHT,
|
||||
BITMAP_NEW | BITMAP_CLEAR_MEMORY | BITMAP_OPAQUE);
|
||||
BITMAP_CLEAR | BITMAP_OPAQUE);
|
||||
if (entry->page.bitmap != NULL) {
|
||||
ret = guit->bitmap->render(entry->page.bitmap, content);
|
||||
if (ret != NSERROR_OK) {
|
||||
|
@ -5077,7 +5077,7 @@ treeview_generate_triangle_bitmap(colour bg, colour fg, int size)
|
||||
colour colour4 = fg;
|
||||
|
||||
/* Create the bitmap */
|
||||
b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
|
||||
b = guit->bitmap->create(size, size, BITMAP_OPAQUE);
|
||||
if (b == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -5176,7 +5176,7 @@ treeview_generate_copy_bitmap(struct bitmap *orig, int size)
|
||||
assert(size == guit->bitmap->get_height(orig));
|
||||
|
||||
/* Create the bitmap */
|
||||
b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
|
||||
b = guit->bitmap->create(size, size, BITMAP_OPAQUE);
|
||||
if (b == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -5224,7 +5224,7 @@ treeview_generate_rotate_bitmap(struct bitmap *orig, int size)
|
||||
assert(size == guit->bitmap->get_height(orig));
|
||||
|
||||
/* Create the bitmap */
|
||||
b = guit->bitmap->create(size, size, BITMAP_NEW | BITMAP_OPAQUE);
|
||||
b = guit->bitmap->create(size, size, BITMAP_OPAQUE);
|
||||
if (b == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -108,7 +108,7 @@ static APTR pool_bitmap = NULL;
|
||||
static bool guigfx_warned = false;
|
||||
|
||||
/* exported function documented in amiga/bitmap.h */
|
||||
void *amiga_bitmap_create(int width, int height, unsigned int state)
|
||||
void *amiga_bitmap_create(int width, int height, enum gui_bitmap_flags flags)
|
||||
{
|
||||
struct bitmap *bitmap;
|
||||
|
||||
@ -139,8 +139,7 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
|
||||
bitmap->width = width;
|
||||
bitmap->height = height;
|
||||
|
||||
if(state & BITMAP_OPAQUE) bitmap->opaque = true;
|
||||
else bitmap->opaque = false;
|
||||
bitmap->opaque = (flags & BITMAP_OPAQUE) == BITMAP_OPAQUE;
|
||||
|
||||
bitmap->nativebm = NULL;
|
||||
bitmap->nativebmwidth = 0;
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <intuition/classusr.h>
|
||||
#include <libraries/Picasso96.h>
|
||||
|
||||
#include "netsurf/bitmap.h"
|
||||
|
||||
#define AMI_BITMAP_FORMAT RGBFB_R8G8B8A8
|
||||
#define AMI_BITMAP_SCALE_ICON 0xFF
|
||||
|
||||
@ -101,10 +103,10 @@ void ami_bitmap_fini(void);
|
||||
*
|
||||
* \param width width of image in pixels
|
||||
* \param height width of image in pixels
|
||||
* \param state a flag word indicating the initial state
|
||||
* \param flags flags for bitmap creation
|
||||
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
||||
*/
|
||||
void *amiga_bitmap_create(int width, int height, unsigned int state);
|
||||
void *amiga_bitmap_create(int width, int height, enum gui_bitmap_flags flags);
|
||||
|
||||
/**
|
||||
* Return a pointer to the pixel data in a bitmap.
|
||||
|
@ -173,7 +173,7 @@ bool amiga_dt_anim_convert(struct content *c)
|
||||
size_t size;
|
||||
UBYTE *bm_buffer;
|
||||
struct BitMapHeader *bmh;
|
||||
unsigned int bm_flags = BITMAP_NEW | BITMAP_OPAQUE;
|
||||
unsigned int bm_flags = BITMAP_OPAQUE;
|
||||
struct adtFrame adt_frame;
|
||||
APTR clut;
|
||||
|
||||
|
@ -187,7 +187,7 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c)
|
||||
|
||||
if((dto = amiga_dt_picture_newdtobject(adt)))
|
||||
{
|
||||
bitmap = amiga_bitmap_create(c->width, c->height, BITMAP_NEW);
|
||||
bitmap = amiga_bitmap_create(c->width, c->height, BITMAP_NONE);
|
||||
if (!bitmap) {
|
||||
msg_data.errordata.errorcode = NSERROR_NOMEM;
|
||||
msg_data.errordata.errormsg = messages_get("NoMemory");
|
||||
|
@ -201,7 +201,7 @@ bool amiga_icon_convert(struct content *c)
|
||||
return false;
|
||||
}
|
||||
|
||||
icon_c->bitmap = amiga_bitmap_create(width, height, BITMAP_NEW);
|
||||
icon_c->bitmap = amiga_bitmap_create(width, height, BITMAP_NONE);
|
||||
if (!icon_c->bitmap) {
|
||||
msg_data.errordata.errorcode = NSERROR_NOMEM;
|
||||
msg_data.errordata.errormsg = messages_get("NoMemory");
|
||||
|
@ -77,13 +77,13 @@ int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out )
|
||||
* \param pixdata NULL or an memory address to use as the bitmap pixdata
|
||||
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
||||
*/
|
||||
static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, unsigned int state, void * pixdata )
|
||||
static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, enum gui_bitmap_flags flags, void * pixdata )
|
||||
{
|
||||
struct bitmap * bitmap;
|
||||
|
||||
NSLOG(netsurf, INFO,
|
||||
"width %d (rowstride: %d, bpp: %d), height %d, state %u", w,
|
||||
rowstride, bpp, h, state);
|
||||
"width %d (rowstride: %d, bpp: %d), height %d, flags %u", w,
|
||||
rowstride, bpp, h, (unsigned)flags);
|
||||
|
||||
if( rowstride == 0) {
|
||||
rowstride = bpp * w;
|
||||
@ -102,7 +102,7 @@ static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, uns
|
||||
if (bitmap->pixdata != NULL) {
|
||||
bitmap->width = w;
|
||||
bitmap->height = h;
|
||||
bitmap->opaque = (state & BITMAP_OPAQUE) ? true : false;
|
||||
bitmap->opaque = (flags & BITMAP_OPAQUE) ? true : false;
|
||||
bitmap->bpp = bpp;
|
||||
bitmap->resized = NULL;
|
||||
bitmap->rowstride = rowstride;
|
||||
@ -118,9 +118,9 @@ static void *atari_bitmap_create_ex( int w, int h, short bpp, int rowstride, uns
|
||||
|
||||
|
||||
/* exported interface documented in atari/bitmap.h */
|
||||
void *atari_bitmap_create(int w, int h, unsigned int state)
|
||||
void *atari_bitmap_create(int w, int h, enum gui_bitmap_flags flags)
|
||||
{
|
||||
return atari_bitmap_create_ex( w, h, NS_BMP_DEFAULT_BPP, w * NS_BMP_DEFAULT_BPP, state, NULL );
|
||||
return atari_bitmap_create_ex( w, h, NS_BMP_DEFAULT_BPP, w * NS_BMP_DEFAULT_BPP, flags, NULL );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -347,7 +347,7 @@ int atari_bitmap_get_height(void *bitmap)
|
||||
bool atari_bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
|
||||
HermesFormat *fmt, int nw, int nh)
|
||||
{
|
||||
unsigned int state = 0;
|
||||
enum gui_bitmap_flags flags = 0;
|
||||
short bpp = img->bpp;
|
||||
int stride = atari_bitmap_get_rowstride( img );
|
||||
int err;
|
||||
@ -364,9 +364,9 @@ bool atari_bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
|
||||
|
||||
/* allocate the mem for resized bitmap */
|
||||
if (img->opaque == true) {
|
||||
state |= BITMAP_OPAQUE;
|
||||
flags |= BITMAP_OPAQUE;
|
||||
}
|
||||
img->resized = atari_bitmap_create_ex( nw, nh, bpp, nw*bpp, state, NULL );
|
||||
img->resized = atari_bitmap_create_ex( nw, nh, bpp, nw*bpp, flags, NULL );
|
||||
if( img->resized == NULL ) {
|
||||
printf("W: %d, H: %d, bpp: %d\n", nw, nh, bpp);
|
||||
assert(img->resized);
|
||||
|
@ -90,7 +90,7 @@ int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out );
|
||||
* \param state a flag word indicating the initial state
|
||||
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
||||
*/
|
||||
void *atari_bitmap_create(int w, int h, unsigned int state);
|
||||
void *atari_bitmap_create(int w, int h, enum gui_bitmap_flags flags);
|
||||
|
||||
/**
|
||||
* Find the width of a pixel row in bytes.
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "utils/log.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "netsurf/mouse.h"
|
||||
#include "netsurf/bitmap.h"
|
||||
#include "netsurf/plot_style.h"
|
||||
|
||||
#include "atari/gui.h"
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/log.h"
|
||||
#include "netsurf/mouse.h"
|
||||
#include "netsurf/bitmap.h"
|
||||
#include "netsurf/plot_style.h"
|
||||
|
||||
#include "atari/gui.h"
|
||||
|
@ -114,28 +114,28 @@ static inline void nsbeos_rgba_to_bgra(void *src,
|
||||
* Create a bitmap.
|
||||
*
|
||||
* \param width width of image in pixels
|
||||
* \param height width of image in pixels
|
||||
* \param state a flag word indicating the initial state
|
||||
* \param height height of image in pixels
|
||||
* \param bflags flags for bitmap creation
|
||||
* \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)
|
||||
{
|
||||
struct bitmap *bmp = (struct bitmap *)malloc(sizeof(struct bitmap));
|
||||
if (bmp == NULL)
|
||||
return NULL;
|
||||
|
||||
int32 flags = 0;
|
||||
if (state & BITMAP_CLEAR_MEMORY)
|
||||
flags |= B_BITMAP_CLEAR_TO_WHITE;
|
||||
int32 Bflags = 0;
|
||||
if (flags & BITMAP_CLEAR)
|
||||
Bflags |= B_BITMAP_CLEAR_TO_WHITE;
|
||||
|
||||
BRect frame(0, 0, width - 1, height - 1);
|
||||
//XXX: bytes per row ?
|
||||
bmp->primary = new BBitmap(frame, flags, B_RGBA32);
|
||||
bmp->shadow = new BBitmap(frame, flags, B_RGBA32);
|
||||
bmp->primary = new BBitmap(frame, Bflags, B_RGBA32);
|
||||
bmp->shadow = new BBitmap(frame, Bflags, B_RGBA32);
|
||||
|
||||
bmp->pretile_x = bmp->pretile_y = bmp->pretile_xy = NULL;
|
||||
|
||||
bmp->opaque = (state & BITMAP_OPAQUE) != 0;
|
||||
bmp->opaque = (flags & BITMAP_OPAQUE) != 0;
|
||||
|
||||
return bmp;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
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,8 +67,6 @@ static void *bitmap_create(int width, int height, unsigned int state)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NSLOG(netsurf, INFO, "bitmap %p", bm);
|
||||
|
||||
return bm;
|
||||
}
|
||||
|
||||
|
@ -45,17 +45,17 @@
|
||||
* Create a bitmap.
|
||||
*
|
||||
* \param width width of image in pixels
|
||||
* \param height width of image in pixels
|
||||
* \param state a flag word indicating the initial state
|
||||
* \param height height of image in pixels
|
||||
* \param flags flags for bitmap creation
|
||||
* \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)
|
||||
{
|
||||
struct bitmap *gbitmap;
|
||||
|
||||
gbitmap = calloc(1, sizeof(struct bitmap));
|
||||
if (gbitmap != NULL) {
|
||||
if ((state & BITMAP_OPAQUE) != 0) {
|
||||
if ((flags & BITMAP_OPAQUE) != 0) {
|
||||
gbitmap->surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
|
||||
} else {
|
||||
gbitmap->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
|
||||
|
@ -31,10 +31,10 @@ struct bitmap {
|
||||
size_t rowstride;
|
||||
int width;
|
||||
int height;
|
||||
unsigned int state;
|
||||
bool opaque;
|
||||
};
|
||||
|
||||
static void *bitmap_create(int width, int height, unsigned int state)
|
||||
static void *bitmap_create(int width, int height, enum gui_bitmap_flags flags)
|
||||
{
|
||||
struct bitmap *ret = calloc(sizeof(*ret), 1);
|
||||
if (ret == NULL)
|
||||
@ -42,7 +42,7 @@ static void *bitmap_create(int width, int height, unsigned int state)
|
||||
|
||||
ret->width = width;
|
||||
ret->height = height;
|
||||
ret->state = state;
|
||||
ret->opaque = (flags & BITMAP_OPAQUE) == BITMAP_OPAQUE;
|
||||
|
||||
ret->ptr = calloc(width, height * 4);
|
||||
|
||||
@ -65,10 +65,7 @@ static void bitmap_set_opaque(void *bitmap, bool opaque)
|
||||
{
|
||||
struct bitmap *bmap = bitmap;
|
||||
|
||||
if (opaque)
|
||||
bmap->state |= (BITMAP_OPAQUE);
|
||||
else
|
||||
bmap->state &= ~(BITMAP_OPAQUE);
|
||||
bmap->opaque = opaque;
|
||||
}
|
||||
|
||||
static bool bitmap_test_opaque(void *bitmap)
|
||||
@ -80,7 +77,7 @@ static bool bitmap_get_opaque(void *bitmap)
|
||||
{
|
||||
struct bitmap *bmap = bitmap;
|
||||
|
||||
return (bmap->state & BITMAP_OPAQUE) == BITMAP_OPAQUE;
|
||||
return bmap->opaque;
|
||||
}
|
||||
|
||||
static unsigned char *bitmap_get_buffer(void *bitmap)
|
||||
@ -98,7 +95,7 @@ static size_t bitmap_get_rowstride(void *bitmap)
|
||||
|
||||
static void bitmap_modified(void *bitmap)
|
||||
{
|
||||
struct bitmap *bmap = bitmap;
|
||||
return;
|
||||
}
|
||||
|
||||
static int bitmap_get_width(void *bitmap)
|
||||
|
@ -91,7 +91,7 @@ static bool bitmap_initialise(struct bitmap *bitmap)
|
||||
assert(!bitmap->sprite_area);
|
||||
|
||||
area_size = 16 + 44 + bitmap->width * bitmap->height * 4;
|
||||
if (bitmap->state & BITMAP_CLEAR_MEMORY)
|
||||
if (bitmap->clear)
|
||||
bitmap->sprite_area = calloc(1, area_size);
|
||||
else
|
||||
bitmap->sprite_area = malloc(area_size);
|
||||
@ -123,7 +123,7 @@ static bool bitmap_initialise(struct bitmap *bitmap)
|
||||
|
||||
|
||||
/* exported interface documented in riscos/bitmap.h */
|
||||
void *riscos_bitmap_create(int width, int height, unsigned int state)
|
||||
void *riscos_bitmap_create(int width, int height, enum gui_bitmap_flags flags)
|
||||
{
|
||||
struct bitmap *bitmap;
|
||||
|
||||
@ -135,7 +135,8 @@ void *riscos_bitmap_create(int width, int height, unsigned int state)
|
||||
return NULL;
|
||||
bitmap->width = width;
|
||||
bitmap->height = height;
|
||||
bitmap->state = state;
|
||||
bitmap->opaque = (flags & BITMAP_OPAQUE) == BITMAP_OPAQUE;
|
||||
bitmap->clear = (flags & BITMAP_CLEAR) == BITMAP_CLEAR;
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
@ -172,10 +173,7 @@ static void bitmap_set_opaque(void *vbitmap, bool opaque)
|
||||
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
||||
assert(bitmap);
|
||||
|
||||
if (opaque)
|
||||
bitmap->state |= BITMAP_OPAQUE;
|
||||
else
|
||||
bitmap->state &= ~BITMAP_OPAQUE;
|
||||
bitmap->opaque = opaque;
|
||||
}
|
||||
|
||||
|
||||
@ -246,7 +244,7 @@ bool riscos_bitmap_get_opaque(void *vbitmap)
|
||||
{
|
||||
struct bitmap *bitmap = (struct bitmap *) vbitmap;
|
||||
assert(bitmap);
|
||||
return (bitmap->state & BITMAP_OPAQUE);
|
||||
return bitmap->opaque;
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,7 +37,8 @@ struct bitmap {
|
||||
int width; /**< width of bitmap */
|
||||
int height; /**< height of bitmap */
|
||||
|
||||
unsigned int state; /**< The bitmap attributes (opaque/dirty etc.) */
|
||||
bool opaque; /**< Whether the bitmap is opaque. */
|
||||
bool clear; /**< Whether the bitmap should be initialised to zeros. */
|
||||
|
||||
struct osspriteop_area *sprite_area; /**< Uncompressed data, or NULL */
|
||||
};
|
||||
@ -71,11 +72,11 @@ void riscos_bitmap_overlay_sprite(struct bitmap *bitmap, const struct osspriteop
|
||||
* Create a bitmap.
|
||||
*
|
||||
* \param width width of image in pixels
|
||||
* \param height width of image in pixels
|
||||
* \param state the state to create the bitmap in.
|
||||
* \param height height of image in pixels
|
||||
* \param flags flags for bitmap creation.
|
||||
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
||||
*/
|
||||
void *riscos_bitmap_create(int width, int height, unsigned int state);
|
||||
void *riscos_bitmap_create(int width, int height, enum gui_bitmap_flags flags);
|
||||
|
||||
/**
|
||||
* Free a bitmap.
|
||||
|
@ -243,7 +243,7 @@ ro_gui_save_create_thumbnail(struct hlcache_handle *h, const char *name)
|
||||
struct bitmap *bitmap;
|
||||
osspriteop_area *area;
|
||||
|
||||
bitmap = riscos_bitmap_create(34, 34, BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY);
|
||||
bitmap = riscos_bitmap_create(34, 34, BITMAP_OPAQUE | BITMAP_CLEAR);
|
||||
if (!bitmap) {
|
||||
NSLOG(netsurf, INFO, "Thumbnail initialisation failed.");
|
||||
return false;
|
||||
|
@ -4568,7 +4568,7 @@ ro_gui_window_iconise(struct gui_window *g, wimp_full_message_window_info *wi)
|
||||
|
||||
/* create the thumbnail sprite */
|
||||
bitmap = riscos_bitmap_create(width, height,
|
||||
BITMAP_NEW | BITMAP_OPAQUE | BITMAP_CLEAR_MEMORY);
|
||||
BITMAP_OPAQUE | BITMAP_CLEAR);
|
||||
if (!bitmap) {
|
||||
NSLOG(netsurf, INFO, "Thumbnail initialisation failed.");
|
||||
return;
|
||||
|
@ -41,19 +41,19 @@
|
||||
* Create a bitmap.
|
||||
*
|
||||
* \param width width of image in pixels
|
||||
* \param height width of image in pixels
|
||||
* \param state a flag word indicating the initial state
|
||||
* \param height height of image in pixels
|
||||
* \param state flags flags for bitmap creation
|
||||
* \return an opaque struct bitmap, or NULL on memory exhaustion
|
||||
*/
|
||||
void *win32_bitmap_create(int width, int height, unsigned int state)
|
||||
static void *win32_bitmap_create(int width, int height, enum gui_bitmap_flags flags)
|
||||
{
|
||||
struct bitmap *bitmap;
|
||||
BITMAPV5HEADER *pbmi;
|
||||
HBITMAP windib;
|
||||
uint8_t *pixdata;
|
||||
|
||||
NSLOG(netsurf, INFO, "width %d, height %d, state %u", width, height,
|
||||
state);
|
||||
NSLOG(netsurf, INFO, "width %d, height %d, flags %u", width, height,
|
||||
(unsigned)flags);
|
||||
|
||||
pbmi = calloc(1, sizeof(BITMAPV5HEADER));
|
||||
if (pbmi == NULL) {
|
||||
@ -91,7 +91,7 @@ void *win32_bitmap_create(int width, int height, unsigned int state)
|
||||
bitmap->windib = windib;
|
||||
bitmap->pbmi = pbmi;
|
||||
bitmap->pixdata = pixdata;
|
||||
if ((state & BITMAP_OPAQUE) != 0) {
|
||||
if ((flags & BITMAP_OPAQUE) != 0) {
|
||||
bitmap->opaque = true;
|
||||
} else {
|
||||
bitmap->opaque = false;
|
||||
@ -327,7 +327,7 @@ bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content)
|
||||
}
|
||||
|
||||
/* create a full size bitmap and plot into it */
|
||||
fsbitmap = win32_bitmap_create(width, height, BITMAP_NEW | BITMAP_CLEAR_MEMORY | BITMAP_OPAQUE);
|
||||
fsbitmap = win32_bitmap_create(width, height, BITMAP_CLEAR | BITMAP_OPAQUE);
|
||||
|
||||
SelectObject(bufferdc, fsbitmap->windib);
|
||||
|
||||
|
@ -33,8 +33,6 @@ struct bitmap {
|
||||
|
||||
struct bitmap *bitmap_scale(struct bitmap *prescale, int width, int height);
|
||||
|
||||
void *win32_bitmap_create(int width, int height, unsigned int state);
|
||||
|
||||
void win32_bitmap_destroy(void *bitmap);
|
||||
|
||||
#endif
|
||||
|
@ -54,9 +54,12 @@
|
||||
#ifndef _NETSURF_BITMAP_H_
|
||||
#define _NETSURF_BITMAP_H_
|
||||
|
||||
#define BITMAP_NEW 0
|
||||
#define BITMAP_OPAQUE (1 << 0) /**< image is opaque */
|
||||
#define BITMAP_CLEAR_MEMORY (1 << 2) /**< memory should be wiped */
|
||||
/** Bitmap creation flags. */
|
||||
enum gui_bitmap_flags {
|
||||
BITMAP_NONE = 0,
|
||||
BITMAP_OPAQUE = (1 << 0), /**< image is opaque */
|
||||
BITMAP_CLEAR = (1 << 1), /**< memory should be wiped to 0 */
|
||||
};
|
||||
|
||||
struct content;
|
||||
struct bitmap;
|
||||
@ -72,11 +75,11 @@ struct gui_bitmap_table {
|
||||
* Create a new bitmap.
|
||||
*
|
||||
* \param width width of image in pixels
|
||||
* \param height width of image in pixels
|
||||
* \param state The state to create the bitmap in.
|
||||
* \param height height of image in pixels
|
||||
* \param flags flags for bitmap creation
|
||||
* \return A bitmap structure or NULL on error.
|
||||
*/
|
||||
void *(*create)(int width, int height, unsigned int state);
|
||||
void *(*create)(int width, int height, enum gui_bitmap_flags flags);
|
||||
|
||||
/**
|
||||
* Destroy a bitmap.
|
||||
|
Loading…
Reference in New Issue
Block a user