summaryrefslogtreecommitdiff
path: root/atari
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2012-04-10 23:06:21 +0000
committerOle Loots <ole@monochrom.net>2012-04-10 23:06:21 +0000
commitb400b7c22bb56c943225b08e4146192aae7aaa5f (patch)
tree2bf534f7d46502e6fedbca4c918f43e02ae62375 /atari
parent65b128b0881c647451182ac3c17992df5f482367 (diff)
downloadnetsurf-b400b7c22bb56c943225b08e4146192aae7aaa5f.tar.gz
netsurf-b400b7c22bb56c943225b08e4146192aae7aaa5f.tar.bz2
Introduced BITMAPF_BUFFER_NATIVE, for fast redraw of bitmaps.
svn path=/trunk/netsurf/; revision=13845
Diffstat (limited to 'atari')
-rw-r--r--atari/plot/font_internal.c2
-rwxr-xr-xatari/plot/plotter.h15
-rwxr-xr-xatari/plot/plotter_vdi.c99
3 files changed, 77 insertions, 39 deletions
diff --git a/atari/plot/font_internal.c b/atari/plot/font_internal.c
index 1f9f1301c..e8ddc5ae1 100644
--- a/atari/plot/font_internal.c
+++ b/atari/plot/font_internal.c
@@ -162,7 +162,7 @@ static void draw_glyph1(FONT_PLOTTER self, GRECT *inloc, uint8_t *chrp, int pitc
pixmask = (pixmask << 1);
}
}
- self->plotter->bitmap( self->plotter, fontbmp, loc.g_x, loc.g_y, 0, BITMAP_MONOGLYPH );
+ self->plotter->bitmap( self->plotter, fontbmp, loc.g_x, loc.g_y, 0, BITMAPF_MONOGLYPH );
}
static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length,
diff --git a/atari/plot/plotter.h b/atari/plot/plotter.h
index 9ec4d2d64..c77457aa6 100755
--- a/atari/plot/plotter.h
+++ b/atari/plot/plotter.h
@@ -69,8 +69,12 @@
/* Flags for init_mfdb function: */
#define MFDB_FLAG_STAND 0x01
#define MFDB_FLAG_ZEROMEM 0x02
-#define MFDB_FLAG_NOALLOC 0x04
-
+#define MFDB_FLAG_NOALLOC 0x04
+
+/* Flags for blit functions: */
+#define BITMAPF_MONOGLYPH 4096 /* The bitmap is an character bitmap */
+#define BITMAPF_BUFFER_NATIVE 8192 /* Bitmap shall be kept converted */
+
/* Error codes: */
#define ERR_BUFFERSIZE_EXCEEDS_SCREEN 1 /* The buffer allocated is larger than the screen */
#define ERR_NO_MEM 2 /* Not enough memory for requested operation */
@@ -166,7 +170,8 @@ typedef int (*_pmf_bitmap_convert)( GEM_PLOTTER self, struct bitmap * img, int x
typedef int (*_pmf_bitmap)(GEM_PLOTTER self, struct bitmap * bmp, int x, int y,
unsigned long bg, unsigned long flags );
typedef int (*_pmf_plot_mfdb)(GEM_PLOTTER self, GRECT * loc, MFDB * mfdb, unsigned char fgcolor, uint32_t flags);
-typedef int (*_pmf_text)(GEM_PLOTTER self, int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle);
+typedef int (*_pmf_text)(GEM_PLOTTER self, int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle);
+typedef int (*_pmf_blit)(GEM_PLOTTER self, GRECT * region);
typedef int (*_pmf_dtor)(GEM_PLOTTER self);
@@ -207,7 +212,9 @@ struct s_gem_plotter
/* plot an netsurf bitmap into the buffer / screen: */
_pmf_bitmap bitmap;
/* plot an mfdb into the buffer / screen: */
- _pmf_plot_mfdb plot_mfdb;
+ _pmf_plot_mfdb plot_mfdb;
+ /* draw to screen, only valid for offscreen plotters: */
+ _pmf_blit blit;
_pmf_text text;
_pmf_dtor dtor;
};
diff --git a/atari/plot/plotter_vdi.c b/atari/plot/plotter_vdi.c
index c2de42cf8..92731719d 100755
--- a/atari/plot/plotter_vdi.c
+++ b/atari/plot/plotter_vdi.c
@@ -433,9 +433,11 @@ static int resize( GEM_PLOTTER self, int w, int h )
{
if( w == VIEW(self).w && h == VIEW(self).h )
return( 1 );
+ struct rect newclip = { 0, 0, w-1, h-1 };
VIEW(self).w = w;
VIEW(self).h = h;
update_visible_rect( self );
+ set_clip( self, &newclip);
LOG(("%s: %s\n", (char*)__FILE__, (char*)__FUNCTION__));
return( 1 );
}
@@ -1002,6 +1004,9 @@ static void snapshot_destroy( GEM_PLOTTER self )
}
}
+
+#ifdef WITH_8BPP_SUPPORT
+
static inline void set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned char val )
{
short * buf;
@@ -1077,7 +1082,6 @@ static inline unsigned char get_stdpx(MFDB * dst, int wdplanesz, int x, int y )
return( ret );
}
-#ifdef WITH_8BPP_SUPPORT
static int bitmap_convert_8( GEM_PLOTTER self,
struct bitmap * img,
int x,
@@ -1094,7 +1098,7 @@ static int bitmap_convert_8( GEM_PLOTTER self,
int bw;
struct bitmap * scrbuf = NULL;
struct bitmap * bm;
- bool transp = ( ( (img->opaque == false) || ( (flags & BITMAP_MONOGLYPH) != 0) )
+ bool transp = ( ( (img->opaque == false) || ( (flags & BITMAPF_MONOGLYPH) != 0) )
&& ((self->flags & PLOT_FLAG_TRANS) != 0) );
assert( clip->g_h > 0 );
@@ -1135,7 +1139,7 @@ static int bitmap_convert_8( GEM_PLOTTER self,
// realloc mem for stdform
MFDB stdform;
if( transp ){
- if( ((self->flags & PLOT_FLAG_TRANS) != 0) || ( (flags & BITMAP_MONOGLYPH) != 0) ) {
+ if( ((self->flags & PLOT_FLAG_TRANS) != 0) || ( (flags & BITMAPF_MONOGLYPH) != 0) ) {
// point image to snapshot buffer, otherwise allocate mem
MFDB * bg = snapshot_create_std_mfdb( self, x+clip->g_x,y+clip->g_y, clip->g_w, clip->g_h );
stdform.fd_addr = bg->fd_addr;
@@ -1260,7 +1264,11 @@ static int bitmap_convert_8( GEM_PLOTTER self,
}
#endif
-/* convert bitmap to the virutal (chunked) framebuffer format */
+/*
+*
+* Convert bitmap to the virutal (chunked) framebuffer format
+*
+*/
static int bitmap_convert( GEM_PLOTTER self,
struct bitmap * img,
int x,
@@ -1273,24 +1281,34 @@ static int bitmap_convert( GEM_PLOTTER self,
int dststride; /* stride of dest. image */
int dstsize; /* size of dest. in byte */
int err;
- int bw;
+ int bw, bh;
struct bitmap * scrbuf = NULL;
- struct bitmap * bm;
+ struct bitmap * bm;
+ bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
assert( clip->g_h > 0 );
- assert( clip->g_w > 0 );
-
+ assert( clip->g_w > 0 );
+
bm = img;
- bw = bitmap_get_width( img );
+ bw = bitmap_get_width( img );
+ bh = bitmap_get_height( img );
+
+ if( cache ){
+ assert( clip->g_w >= bw && clip->g_h >= bh );
+ if( img->native.fd_addr != NULL ){
+ *out = img->native;
+ return( 0 );
+ }
+ }
/* rem. if eddi xy is installed, we could directly access the screen! */
/* apply transparency to the image: */
- if( (img->opaque == false)
+ if( ( img->opaque == false )
&& ( (self->flags & PLOT_FLAG_TRANS) != 0)
&& (
(vdi_sysinfo.vdiformat == VDI_FORMAT_PACK )
||
- ( (flags & BITMAP_MONOGLYPH) != 0)
+ ( (flags & BITMAPF_MONOGLYPH) != 0)
) ) {
uint32_t * imgpixel;
uint32_t * screenpixel;
@@ -1320,28 +1338,38 @@ static int bitmap_convert( GEM_PLOTTER self,
bm = scrbuf;
}
}
-
/* (re)allocate buffer for framebuffer image: */
dststride = MFDB_STRIDE( clip->g_w );
- 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 )
- DUMMY_PRIV(self)->buf_packed =(void*)malloc( blocks * CONV_BLOCK_SIZE );
- else
- DUMMY_PRIV(self)->buf_packed =(void*)realloc(
- DUMMY_PRIV(self)->buf_packed,
- blocks * CONV_BLOCK_SIZE
- );
- assert( DUMMY_PRIV(self)->buf_packed );
- if( DUMMY_PRIV(self)->buf_packed == NULL ) {
+ dstsize = ( ((dststride >> 3) * clip->g_h) * self->bpp_virt);
+ if( cache == false ){
+ if( dstsize > DUMMY_PRIV(self)->size_buf_packed) {
+ int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
+ if( DUMMY_PRIV(self)->buf_packed == NULL )
+ DUMMY_PRIV(self)->buf_packed =(void*)malloc( blocks * CONV_BLOCK_SIZE );
+ else
+ DUMMY_PRIV(self)->buf_packed =(void*)realloc(
+ DUMMY_PRIV(self)->buf_packed,
+ blocks * CONV_BLOCK_SIZE
+ );
+ assert( DUMMY_PRIV(self)->buf_packed );
+ if( DUMMY_PRIV(self)->buf_packed == NULL ) {
+ if( scrbuf != NULL )
+ bitmap_destroy( scrbuf );
+ return( 0-ERR_NO_MEM );
+ }
+ DUMMY_PRIV(self)->size_buf_packed = blocks * CONV_BLOCK_SIZE;
+ }
+ out->fd_addr = DUMMY_PRIV(self)->buf_packed;
+ } else {
+ assert( out->fd_addr == NULL );
+ out->fd_addr = (void*)malloc( dstsize );
+ if( out->fd_addr == NULL ){
if( scrbuf != NULL )
- bitmap_destroy( scrbuf );
- return( 0-ERR_NO_MEM );
- }
- DUMMY_PRIV(self)->size_buf_packed = blocks * CONV_BLOCK_SIZE;
+ bitmap_destroy( scrbuf );
+ return( 0-ERR_NO_MEM );
+ }
}
- out->fd_addr = DUMMY_PRIV(self)->buf_packed;
+
out->fd_w = dststride;
out->fd_h = clip->g_h;
out->fd_wdwidth = dststride >> 4;
@@ -1368,8 +1396,10 @@ static int bitmap_convert( GEM_PLOTTER self,
clip->g_w, clip->g_h,
(dststride >> 3) * self->bpp_virt /* stride as bytes */
);
- assert( err != 0 );
-
+ assert( err != 0 );
+ if( cache == true ){
+ img->native = *out;
+ }
return( 0 );
}
@@ -1399,7 +1429,7 @@ static int bitmap( GEM_PLOTTER self, struct bitmap * bmp, int x, int y,
off.g_x = x;
off.g_y = y;
off.g_h = bmp->height;
- off.g_w = bmp->width;
+ off.g_w = bmp->width;
clip.g_x = VIEW( self ).clipping.x0;
clip.g_y = VIEW( self ).clipping.y0;
@@ -1408,7 +1438,7 @@ static int bitmap( GEM_PLOTTER self, struct bitmap * bmp, int x, int y,
if( !rc_intersect( &clip, &off) ) {
return( true );
- }
+ }
plotter_get_visible_grect( self, &vis );
if( !rc_intersect( &vis, &off) ) {
@@ -1419,7 +1449,7 @@ static int bitmap( GEM_PLOTTER self, struct bitmap * bmp, int x, int y,
off.g_x = MAX(0, off.g_x - x);
off.g_y = MAX(0, off.g_y - y);
loc.g_x = MAX(0, loc.g_x);
- loc.g_y = MAX(0, loc.g_y);
+ loc.g_y = MAX(0, loc.g_y);
pxy[0] = 0;
pxy[1] = 0;
@@ -1431,6 +1461,7 @@ static int bitmap( GEM_PLOTTER self, struct bitmap * bmp, int x, int y,
pxy[7] = VIEW(self).y + loc.g_y + off.g_h-1;
/* Convert the Bitmap to native screen format - ready for output*/
/* This includes blending transparent pixels */
+
if( self->bitmap_convert( self, bmp, pxy[4], pxy[5], &off, bg, flags, &src_mf) != 0 ) {
return( true );
}