From f2c97c39200d0d167e17d41f703bb91732901302 Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Sun, 13 Mar 2011 21:46:59 +0000 Subject: init_mfdb() is now able to handle bitmaps with less than 8 bits per pixel. (needed for monochrom glyph rendering) svn path=/trunk/netsurf/; revision=12038 --- atari/plot/plotter.c | 27 +++++++++++++++++++++++++-- atari/plot/plotter.h | 23 ++++++++++++++++++++++- atari/plot/plotter_vdi.c | 34 ++++------------------------------ 3 files changed, 51 insertions(+), 33 deletions(-) (limited to 'atari') diff --git a/atari/plot/plotter.c b/atari/plot/plotter.c index 62fb10918..d9f46e8a8 100755 --- a/atari/plot/plotter.c +++ b/atari/plot/plotter.c @@ -682,7 +682,29 @@ short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b) return( tval[2]*36+tval[1]*6+tval[0] ); } -/* Shared (static in object oriented slang) plotter functions: */ + +int init_mfdb(int bpp, int w, int h, bool stand, MFDB * out ) +{ + int dststride; + dststride = MFDB_STRIDE( w ); + if( bpp > 0 ) { + out->fd_addr = malloc( ((dststride >> 3) * h) * bpp ); + if( out->fd_addr == NULL ){ + return( 0 ); + } + out->fd_stand = stand; + out->fd_nplanes = (short)bpp; + out->fd_r1 = out->fd_r2 = out->fd_r3 = 0; + } else { + memset( out, 0, sizeof(MFDB) ); + } + out->fd_w = dststride; + out->fd_h = h; + out->fd_wdwidth = dststride >> 4; + return( 1 ); +} + + int plotter_get_clip( GEM_PLOTTER self, struct rect * out ) { out->x0 = self->clipping.x0; @@ -692,6 +714,7 @@ int plotter_get_clip( GEM_PLOTTER self, struct rect * out ) return( 1 ); } + int plotter_std_clip(GEM_PLOTTER self, const struct rect * clip) { self->clipping.x0 = clip->x0; @@ -701,7 +724,7 @@ int plotter_std_clip(GEM_PLOTTER self, const struct rect * clip) return ( 1 ); } -/* this converts framebuffer clipping to vdi clipping and sets it */ + void plotter_vdi_clip( GEM_PLOTTER self, bool set) { return; diff --git a/atari/plot/plotter.h b/atari/plot/plotter.h index 78f75d7da..af3bce45e 100755 --- a/atari/plot/plotter.h +++ b/atari/plot/plotter.h @@ -291,9 +291,30 @@ void rgb_to_vdi1000( unsigned char * in, unsigned short * out ); /* convert an rgb color to an index into the web palette */ short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b); -/* shared / static methods ... */ +/* + 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). + The function will return 0 when the memory allocation fails + ( out of memory). +*/ +int init_mfdb(int bpp, int w, int h, bool stand, MFDB * out ); + +/* shared / static methods follows */ + +/* + Get clipping for current framebuffer +*/ int plotter_get_clip( GEM_PLOTTER self, struct rect * out ); + +/* + Set clipping for current framebuffer +*/ int plotter_std_clip(GEM_PLOTTER self, const struct rect * clip); + +/* + convert framebuffer clipping to vdi clipping and activates it +*/ void plotter_vdi_clip( GEM_PLOTTER self, bool set); #define PLOTTER_IS_LOCKED(plotter) ( plotter->private_flags & PLOTTER_FLAG_LOCKED ) diff --git a/atari/plot/plotter_vdi.c b/atari/plot/plotter_vdi.c index 380584817..39cb406ab 100755 --- a/atari/plot/plotter_vdi.c +++ b/atari/plot/plotter_vdi.c @@ -713,30 +713,6 @@ static int bitmap_resize( GEM_PLOTTER self, struct bitmap * img, int nw, int nh return( 0 ); } -/* - fuellt ein mfdb, wenn bpp==null wird angenommen das ein MFDB fr - den Bildschirm initialisiert werden soll, der Speicher fuer das Bild - wird daher nicht alloziert ( fd_addr == 0 ) -*/ -static int init_mfdb(int bpp, int w, int h, MFDB * out ) -{ - int pxsize = bpp >> 3; - int dststride; - dststride = MFDB_STRIDE( w ); - if( bpp > 0 ) { - out->fd_addr = malloc( dststride * pxsize * h ); - out->fd_stand = 0; - out->fd_nplanes = (short)bpp; - out->fd_r1 = out->fd_r2 = out->fd_r3 = 0; - } else { - memset( out, 0, sizeof(MFDB) ); - } - out->fd_w = dststride; - out->fd_h = h; - out->fd_wdwidth = dststride >> 4; - return( 1 ); -} - /* * Capture the screen at x,y location * param self instance @@ -756,9 +732,8 @@ static struct bitmap * snapshot_create(GEM_PLOTTER self, int x, int y, int w, in assert( vdi_sysinfo.vdiformat == VDI_FORMAT_PACK ); { - int pxsize = vdi_sysinfo.scr_bpp >> 3; int scr_stride = MFDB_STRIDE( w ); - int scr_size = scr_stride * pxsize * h; + int scr_size = ( ((scr_stride >> 3) * h) * vdi_sysinfo.scr_bpp ); if( DUMMY_PRIV(self)->size_buf_scr == 0 ){ /* init screen mfdb */ DUMMY_PRIV(self)->buf_scr.fd_addr = malloc( scr_size ); @@ -782,7 +757,7 @@ static struct bitmap * snapshot_create(GEM_PLOTTER self, int x, int y, int w, in assert( DUMMY_PRIV(self)->buf_scr.fd_addr != NULL ); } - init_mfdb( 0, w, h, &scr ); + init_mfdb( 0, w, h, 0, &scr ); pxy[0] = x; pxy[1] = y; pxy[2] = pxy[0] + w-1; @@ -875,7 +850,6 @@ static int convert_bitmap( GEM_PLOTTER self, uint32_t flags, MFDB *out ) { - short vpxsize = self->bpp_virt >> 3; /* / 8 */ int dststride; /* stride of dest. image */ int dstsize; /* size of dest. in byte */ int err; @@ -929,7 +903,7 @@ static int convert_bitmap( GEM_PLOTTER self, /* (re)allocate buffer for framebuffer image: */ dststride = MFDB_STRIDE( clip->g_w ); - dstsize = dststride * vpxsize * clip->g_h; + dstsize = ( ((dststride >> 3) * clip->g_h) * self->bpp_virt); if( dstsize > DUMMY_PRIV(self)->size_buf_packed) { int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1; if( DUMMY_PRIV(self)->buf_packed == NULL ) @@ -972,7 +946,7 @@ static int convert_bitmap( GEM_PLOTTER self, 0, /* x dst coord of top left in pixel coords */ 0, /* y dst coord of top left in pixel coords */ clip->g_w, clip->g_h, - dststride * vpxsize /* stride as bytes */ + (dststride >> 3) * self->bpp_virt /* stride as bytes */ ); assert( err != 0 ); -- cgit v1.2.3