NetSurf
Functions | Variables
bitmap.c File Reference
#include <sys/types.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include "netsurf/inttypes.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "netsurf/bitmap.h"
#include "netsurf/mouse.h"
#include "atari/bitmap.h"
#include "atari/plot/plot.h"
Include dependency graph for bitmap.c:

Go to the source code of this file.

Functions

int init_mfdb (int bpp, int w, int h, uint32_t flags, MFDB *out)
 setup an MFDB struct and allocate memory for it when it is needed. More...
 
static void * atari_bitmap_create_ex (int w, int h, short bpp, int rowstride, enum gui_bitmap_flags flags, void *pixdata)
 Create a bitmap. More...
 
void * atari_bitmap_create (int w, int h, enum gui_bitmap_flags flags)
 Create a bitmap. More...
 
static void bitmap_modified (void *bitmap)
 The bitmap image has changed, so flush any persistant cache. More...
 
void * atari_bitmap_realloc (int w, int h, short bpp, int rowstride, unsigned int state, void *bmp)
 
static unsigned char * bitmap_get_buffer (void *bitmap)
 Return a pointer to the pixel data in a bitmap. More...
 
size_t atari_bitmap_buffer_size (void *bitmap)
 
size_t atari_bitmap_get_rowstride (void *bitmap)
 Find the width of a pixel row in bytes. More...
 
void atari_bitmap_destroy (void *bitmap)
 Free a bitmap. More...
 
static void bitmap_set_opaque (void *bitmap, bool opaque)
 Sets whether a bitmap should be plotted opaque. More...
 
bool atari_bitmap_get_opaque (void *bitmap)
 Gets whether a bitmap should be plotted opaque. More...
 
int atari_bitmap_get_width (void *bitmap)
 Get bitmap width. More...
 
int atari_bitmap_get_height (void *bitmap)
 Get bitmap height. More...
 
bool atari_bitmap_resize (struct bitmap *img, HermesHandle hermes_h, HermesFormat *fmt, int nw, int nh)
 
static nserror bitmap_render (struct bitmap *bitmap, struct hlcache_handle *content)
 

Variables

static struct gui_bitmap_table bitmap_table
 
struct gui_bitmap_tableatari_bitmap_table = &bitmap_table
 

Function Documentation

◆ atari_bitmap_buffer_size()

size_t atari_bitmap_buffer_size ( void *  bitmap)

Definition at line 208 of file bitmap.c.

References bitmap(), bitmap::height, and bitmap::rowstride.

Referenced by snapshot_suspend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ atari_bitmap_create()

void * atari_bitmap_create ( int  w,
int  h,
enum gui_bitmap_flags  flags 
)

Create a bitmap.

Parameters
wwidth of image in pixels
hwidth of image in pixels
statea flag word indicating the initial state
Returns
an opaque struct bitmap, or NULL on memory exhaustion

Definition at line 121 of file bitmap.c.

References atari_bitmap_create_ex(), and NS_BMP_DEFAULT_BPP.

Referenced by snapshot_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ atari_bitmap_create_ex()

static void * atari_bitmap_create_ex ( int  w,
int  h,
short  bpp,
int  rowstride,
enum gui_bitmap_flags  flags,
void *  pixdata 
)
static

Create a bitmap.

Parameters
wwidth of image in pixels
hheight of image in pixels
bppnumber of BYTES per pixel
rowstridelinewidth in bytes
statea flag word indicating the initial state
pixdataNULL or an memory address to use as the bitmap pixdata
Returns
an opaque struct bitmap, or NULL on memory exhaustion

Definition at line 80 of file bitmap.c.

References bitmap(), BITMAP_OPAQUE, bitmap::bpp, bitmap::height, NSLOG, bitmap::opaque, bitmap::pixdata, bitmap::resized, bitmap::rowstride, and bitmap::width.

Referenced by atari_bitmap_create(), and atari_bitmap_resize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ atari_bitmap_destroy()

void atari_bitmap_destroy ( void *  bitmap)

Free a bitmap.

Parameters
bitmapa bitmap, as returned by bitmap_create()

Definition at line 231 of file bitmap.c.

References atari_bitmap_destroy(), bitmap(), bitmap::converted, bitmap::native, NSLOG, bitmap::pixdata, and bitmap::resized.

Referenced by atari_bitmap_destroy(), atari_bitmap_resize(), bitmap_convert_tc(), bitmap_modified(), and snapshot_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ atari_bitmap_get_height()

int atari_bitmap_get_height ( void *  bitmap)

Get bitmap height.

Parameters
bitmapa bitmap, as returned by bitmap_create()

Definition at line 301 of file bitmap.c.

References bitmap(), bitmap::height, and NSLOG.

Referenced by atari_bitmap_resize(), bitmap_convert_tc(), and plot_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ atari_bitmap_get_opaque()

bool atari_bitmap_get_opaque ( void *  bitmap)

Gets whether a bitmap should be plotted opaque.

Parameters
bitmapa bitmap, as returned by bitmap_create()

Definition at line 273 of file bitmap.c.

References bitmap(), NSLOG, and bitmap::opaque.

Referenced by bitmap_convert_tc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ atari_bitmap_get_rowstride()

size_t atari_bitmap_get_rowstride ( void *  bitmap)

Find the width of a pixel row in bytes.

Parameters
bitmapa bitmap, as returned by bitmap_create()
Returns
width of a pixel row in the bitmap

Definition at line 218 of file bitmap.c.

References bitmap(), NSLOG, and bitmap::rowstride.

Referenced by ablend_bitmap(), ablend_pixel(), atari_bitmap_resize(), and snapshot_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ atari_bitmap_get_width()

int atari_bitmap_get_width ( void *  bitmap)

Get bitmap width.

Parameters
bitmapa bitmap, as returned by bitmap_create()

Definition at line 287 of file bitmap.c.

References bitmap(), NSLOG, and bitmap::width.

Referenced by atari_bitmap_resize(), bitmap_convert_tc(), and plot_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ atari_bitmap_realloc()

void * atari_bitmap_realloc ( int  w,
int  h,
short  bpp,
int  rowstride,
unsigned int  state,
void *  bmp 
)

Definition at line 149 of file bitmap.c.

References BITMAP_CLEAR, BITMAP_GROW, bitmap_modified(), bitmap::bpp, bitmap::height, bitmap::pixdata, bitmap::resized, bitmap::rowstride, and bitmap::width.

Referenced by snapshot_create(), and snapshot_suspend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ atari_bitmap_resize()

bool atari_bitmap_resize ( struct bitmap img,
HermesHandle  hermes_h,
HermesFormat *  fmt,
int  nw,
int  nh 
)

Definition at line 313 of file bitmap.c.

References atari_bitmap_create_ex(), atari_bitmap_destroy(), atari_bitmap_get_height(), atari_bitmap_get_rowstride(), atari_bitmap_get_width(), BITMAP_OPAQUE, bitmap::bpp, bitmap::height, bitmap::opaque, bitmap::pixdata, bitmap::resized, and bitmap::width.

Referenced by plot_bitmap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bitmap_get_buffer()

static unsigned char * bitmap_get_buffer ( void *  bitmap)
static

Return a pointer to the pixel data in a bitmap.

Parameters
bitmapa bitmap, as returned by bitmap_create()
Returns
pointer to the pixel buffer

The pixel data is packed as BITMAP_FORMAT, possibly with padding at the end of rows. The width of a row in bytes is given by bitmap_get_rowstride().

Definition at line 194 of file bitmap.c.

References bitmap(), NSLOG, and bitmap::pixdata.

Here is the call graph for this function:

◆ bitmap_modified()

static void bitmap_modified ( void *  bitmap)
static

The bitmap image has changed, so flush any persistant cache.

Parameters
bitmapa bitmap, as returned by bitmap_create()

Definition at line 131 of file bitmap.c.

References atari_bitmap_destroy(), bitmap(), bitmap::converted, bitmap::native, bitmap::pixdata, and bitmap::resized.

Referenced by atari_bitmap_realloc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bitmap_render()

static nserror bitmap_render ( struct bitmap bitmap,
struct hlcache_handle content 
)
static

Definition at line 373 of file bitmap.c.

References NSERROR_NOT_IMPLEMENTED.

◆ bitmap_set_opaque()

static void bitmap_set_opaque ( void *  bitmap,
bool  opaque 
)
static

Sets whether a bitmap should be plotted opaque.

Parameters
bitmapa bitmap, as returned by bitmap_create()
opaquewhether the bitmap should be plotted opaque

Definition at line 257 of file bitmap.c.

References bitmap(), NSLOG, and bitmap::opaque.

Here is the call graph for this function:

◆ init_mfdb()

int init_mfdb ( int  bpp,
int  w,
int  h,
uint32_t  flags,
MFDB *  out 
)

setup an MFDB struct and allocate memory for it when it is needed.

If bpp == 0, this function assumes that the MFDB shall point to the screen and will not allocate any memory (mfdb.fd_addr == 0).

Returns
0 when the memory allocation fails (out of memory), otherwise it returns the size of the mfdb.fd_addr as number of bytes.

Definition at line 41 of file bitmap.c.

References MFDB_FLAG_NOALLOC, MFDB_FLAG_STAND, MFDB_FLAG_ZEROMEM, MFDB_SIZE, and MFDB_STRIDE.

Referenced by plot_blit_mfdb(), snapshot_create_native_mfdb(), and window_place_caret().

Here is the caller graph for this function:

Variable Documentation

◆ atari_bitmap_table

struct gui_bitmap_table* atari_bitmap_table = &bitmap_table

Definition at line 391 of file bitmap.c.

Referenced by main().

◆ bitmap_table

struct gui_bitmap_table bitmap_table
static
Initial value:
= {
.set_opaque = bitmap_set_opaque,
.get_opaque = atari_bitmap_get_opaque,
.get_buffer = bitmap_get_buffer,
.get_rowstride = atari_bitmap_get_rowstride,
.get_width = atari_bitmap_get_width,
.get_height = atari_bitmap_get_height,
.modified = bitmap_modified,
.render = bitmap_render,
}
static void bitmap_modified(void *bitmap)
The bitmap image has changed, so flush any persistant cache.
Definition: bitmap.c:131
static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content)
Definition: bitmap.c:373
size_t atari_bitmap_get_rowstride(void *bitmap)
Find the width of a pixel row in bytes.
Definition: bitmap.c:218
bool atari_bitmap_get_opaque(void *bitmap)
Gets whether a bitmap should be plotted opaque.
Definition: bitmap.c:273
static unsigned char * bitmap_get_buffer(void *bitmap)
Return a pointer to the pixel data in a bitmap.
Definition: bitmap.c:194
void atari_bitmap_destroy(void *bitmap)
Free a bitmap.
Definition: bitmap.c:231
static void bitmap_set_opaque(void *bitmap, bool opaque)
Sets whether a bitmap should be plotted opaque.
Definition: bitmap.c:257
void * atari_bitmap_create(int w, int h, enum gui_bitmap_flags flags)
Create a bitmap.
Definition: bitmap.c:121
int atari_bitmap_get_height(void *bitmap)
Get bitmap height.
Definition: bitmap.c:301
int atari_bitmap_get_width(void *bitmap)
Get bitmap width.
Definition: bitmap.c:287

Definition at line 378 of file bitmap.c.