summaryrefslogtreecommitdiff
path: root/atari/plot
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2012-11-07 23:35:43 +0100
committerOle Loots <ole@monochrom.net>2012-11-07 23:35:43 +0100
commit5242cd00a4b9ddc6364e107519f1e674e716bc77 (patch)
treec229b2b1b662d94c8016a129b9a47cb3180075fb /atari/plot
parent1e4b78af56dfb969e10af4b7b07e1aeb8ddd3f8f (diff)
downloadnetsurf-5242cd00a4b9ddc6364e107519f1e674e716bc77.tar.gz
netsurf-5242cd00a4b9ddc6364e107519f1e674e716bc77.tar.bz2
Fixed syntax error caused by search&replace?
Diffstat (limited to 'atari/plot')
-rwxr-xr-xatari/plot/plot.c693
1 files changed, 347 insertions, 346 deletions
diff --git a/atari/plot/plot.c b/atari/plot/plot.c
index 66407ffa6..ca3f2b726 100755
--- a/atari/plot/plot.c
+++ b/atari/plot/plot.c
@@ -159,8 +159,8 @@ static struct s_vdi_sysinfo vdi_sysinfo;
static int atari_plot_bpp_virt;
static struct s_view view;
-static HermesHandle hermes_pal_h; /* hermes palette handle */
-static HermesHandle hermes_cnv_h; /* hermes converter instance handle */
+static HermesHandle hermes_pal_h; /* hermes palette handle */
+static HermesHandle hermes_cnv_h; /* hermes converter instance handle */
static HermesHandle hermes_res_h;
static short prev_vdi_clip[4];
@@ -232,118 +232,118 @@ inline static void vsf_rgbcolor(short vdih, colour cin)
}
-
+
/**
- * Get current visible coords
+ * Get current visible coords
*/
-inline static void plot_get_visible_grect(GRECT * out)
-{
- out->g_x = view.vis_x;
- out->g_y = view.vis_y;
- out->g_w = view.vis_w;
- out->g_h = view.vis_h;
+inline static void plot_get_visible_grect(GRECT * out)
+{
+ out->g_x = view.vis_x;
+ out->g_y = view.vis_y;
+ out->g_w = view.vis_w;
+ out->g_h = view.vis_h;
}
-
-
+
+
/* calculate visible area of framebuffer in coords relative to framebuffer */
/* position */
-/* result: */
+/* result: */
/* this function should calculates an rectangle relative to the plot origin*/
/* and size. */
-/* If the ploter coords do not fall within the screen region, */
-/* all values of the region are set to zero. */
-inline static void update_visible_rect(void)
-{
- GRECT screen;
- GRECT common;
- GRECT frame;
-
- screen.g_x = 0;
- screen.g_y = 0;
- screen.g_w = vdi_sysinfo.scr_w;
+/* If the ploter coords do not fall within the screen region, */
+/* all values of the region are set to zero. */
+inline static void update_visible_rect(void)
+{
+ GRECT screen;
+ GRECT common;
+ GRECT frame;
+
+ screen.g_x = 0;
+ screen.g_y = 0;
+ screen.g_w = vdi_sysinfo.scr_w;
screen.g_h = vdi_sysinfo.scr_h;
-
- common.g_x = frame.g_x = view.x;
- common.g_y = frame.g_y = view.y;
- common.g_w = frame.g_w = view.w;
+
+ common.g_x = frame.g_x = view.x;
+ common.g_y = frame.g_y = view.y;
+ common.g_w = frame.g_w = view.w;
common.g_h = frame.g_h = view.h;
-
- if( rc_intersect( &screen, &common ) ) {
- view.vis_w = common.g_w;
- view.vis_h = common.g_h;
- if( view.x < screen.g_x )
- view.vis_x = frame.g_w - common.g_w;
- else
- view.vis_x = 0;
- if( view.y <screen.g_y )
- view.vis_y = frame.g_h - common.g_h;
- else
- view.vis_y = 0;
- } else {
- view.vis_w = view.vis_h = 0;
- view.vis_x = view.vis_y = 0;
- }
-}
-
-/* Returns the visible parts of the box (relative coords within framebuffer),*/
-/* relative to screen coords (normally starting at 0,0 ) */
-inline static bool fbrect_to_screen(GRECT box, GRECT * ret)
-{
- GRECT out, vis, screen;
-
- screen.g_x = 0;
- screen.g_y = 0;
- screen.g_w = vdi_sysinfo.scr_w;
- screen.g_h = vdi_sysinfo.scr_h;
-
- /* get visible region: */
- vis.g_x = view.x;
- vis.g_y = view.y;
- vis.g_w = view.w;
- vis.g_h = view.h;
-
- if ( !rc_intersect( &screen, &vis ) ) {
- return( false );
- }
- vis.g_x = view.w - vis.g_w;
- vis.g_y = view.h - vis.g_h;
-
- /* clip box to visible region: */
- if( !rc_intersect(&vis, &box) ) {
- return( false );
- }
- out.g_x = box.g_x + view.x;
- out.g_y = box.g_y + view.y;
- out.g_w = box.g_w;
- out.g_h = box.g_h;
- *ret = out;
- return ( true );
+
+ if( rc_intersect( &screen, &common ) ) {
+ view.vis_w = common.g_w;
+ view.vis_h = common.g_h;
+ if( view.x < screen.g_x )
+ view.vis_x = frame.g_w - common.g_w;
+ else
+ view.vis_x = 0;
+ if( view.y <screen.g_y )
+ view.vis_y = frame.g_h - common.g_h;
+ else
+ view.vis_y = 0;
+ } else {
+ view.vis_w = view.vis_h = 0;
+ view.vis_x = view.vis_y = 0;
+ }
+}
+
+/* Returns the visible parts of the box (relative coords within framebuffer),*/
+/* relative to screen coords (normally starting at 0,0 ) */
+inline static bool fbrect_to_screen(GRECT box, GRECT * ret)
+{
+ GRECT out, vis, screen;
+
+ screen.g_x = 0;
+ screen.g_y = 0;
+ screen.g_w = vdi_sysinfo.scr_w;
+ screen.g_h = vdi_sysinfo.scr_h;
+
+ /* get visible region: */
+ vis.g_x = view.x;
+ vis.g_y = view.y;
+ vis.g_w = view.w;
+ vis.g_h = view.h;
+
+ if ( !rc_intersect( &screen, &vis ) ) {
+ return( false );
+ }
+ vis.g_x = view.w - vis.g_w;
+ vis.g_y = view.h - vis.g_h;
+
+ /* clip box to visible region: */
+ if( !rc_intersect(&vis, &box) ) {
+ return( false );
+ }
+ out.g_x = box.g_x + view.x;
+ out.g_y = box.g_y + view.y;
+ out.g_w = box.g_w;
+ out.g_h = box.g_h;
+ *ret = out;
+ return ( true );
}
/* convert framebuffer clipping to vdi clipping and activates it */
-inline static void plot_vdi_clip(bool set)
+inline static void plot_vdi_clip(bool set)
{
// TODO : check this
- return;
- if( set == true ) {
- struct rect c;
- short vdiflags[58];
+ return;
+ if( set == true ) {
+ struct rect c;
+ short vdiflags[58];
short newclip[4];
- plot_get_clip(&c);
- vq_extnd(atari_plot_vdi_handle, 1, (short*)&vdiflags);
- prev_vdi_clip[0] = vdiflags[45];
- prev_vdi_clip[1] = vdiflags[46];
- prev_vdi_clip[2] = vdiflags[47];
- prev_vdi_clip[3] = vdiflags[48];
- newclip[0] = view.x + MAX(c.x0, 0);
- newclip[1] = view.y + MAX(c.y0, 0);
- newclip[2] = MIN(view.x+view.w, newclip[0] + (c.x1 - c.x0) )-1;
- newclip[3] = MIN(view.y+view.h, newclip[1] + (c.y1 - c.y0) )-1;
- vs_clip(atari_plot_vdi_handle, 1, (short*)&newclip );
- } else {
- vs_clip(atari_plot_vdi_handle, 1, (short *)&prev_vdi_clip );
- }
+ plot_get_clip(&c);
+ vq_extnd(atari_plot_vdi_handle, 1, (short*)&vdiflags);
+ prev_vdi_clip[0] = vdiflags[45];
+ prev_vdi_clip[1] = vdiflags[46];
+ prev_vdi_clip[2] = vdiflags[47];
+ prev_vdi_clip[3] = vdiflags[48];
+ newclip[0] = view.x + MAX(c.x0, 0);
+ newclip[1] = view.y + MAX(c.y0, 0);
+ newclip[2] = MIN(view.x+view.w, newclip[0] + (c.x1 - c.x0) )-1;
+ newclip[3] = MIN(view.y+view.h, newclip[1] + (c.y1 - c.y0) )-1;
+ vs_clip(atari_plot_vdi_handle, 1, (short*)&newclip );
+ } else {
+ vs_clip(atari_plot_vdi_handle, 1, (short *)&prev_vdi_clip );
+ }
}
@@ -562,12 +562,12 @@ inline void vdi1000_to_rgb(unsigned short * in, unsigned char * out)
/**
* Set pixel within an 8 bit VDI standard bitmap.
*/
-inline static void set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned char val )
-{
- short * buf;
- short whichbit = (1<<(15-(x%16)));
-
- buf = dst->fd_addr;
+inline static void set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned char val )
+{
+ short * buf;
+ short whichbit = (1<<(15-(x%16)));
+
+ buf = dst->fd_addr;
buf += ((dst->fd_wdwidth*(y))+(x>>4));
*buf = (val&1) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
@@ -591,7 +591,7 @@ inline static void set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned
*buf = (val&(1<<6)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
buf += wdplanesz;
- *buf = (val&(1<<7)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
+ *buf = (val&(1<<7)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
}
/**
@@ -600,10 +600,10 @@ inline static void set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned
inline static unsigned char get_stdpx(MFDB * dst, int wdplanesz, int x, int y)
{
unsigned char ret=0;
- short * buf;
- short whichbit = (1<<(15-(x%16)));
-
- buf = dst->fd_addr;
+ short * buf;
+ short whichbit = (1<<(15-(x%16)));
+
+ buf = dst->fd_addr;
buf += ((dst->fd_wdwidth*(y))+(x>>4));
if( *buf & whichbit )
@@ -933,19 +933,19 @@ static void snapshot_destroy(void)
}
-inline static uint32_t ablend(uint32_t pixel, uint32_t scrpixel)
-{
- int opacity = pixel & 0xFF;
- int transp = 0x100 - opacity;
- uint32_t rb, g;
- pixel >>= 8;
- scrpixel >>= 8;
- rb = ((pixel & 0xFF00FF) * opacity +
- (scrpixel & 0xFF00FF) * transp) >> 8;
- g = ((pixel & 0x00FF00) * opacity +
- (scrpixel & 0x00FF00) * transp) >> 8;
-
- return ((rb & 0xFF00FF) | (g & 0xFF00)) << 8;
+inline static uint32_t ablend(uint32_t pixel, uint32_t scrpixel)
+{
+ int opacity = pixel & 0xFF;
+ int transp = 0x100 - opacity;
+ uint32_t rb, g;
+ pixel >>= 8;
+ scrpixel >>= 8;
+ rb = ((pixel & 0xFF00FF) * opacity +
+ (scrpixel & 0xFF00FF) * transp) >> 8;
+ g = ((pixel & 0x00FF00) * opacity +
+ (scrpixel & 0x00FF00) * transp) >> 8;
+
+ return ((rb & 0xFF00FF) | (g & 0xFF00)) << 8;
}
/*
@@ -959,11 +959,11 @@ inline static bool ablend_pixel(struct bitmap * img, uint32_t bg, GRECT * clip)
img_stride= bitmap_get_rowstride(img);
- for( img_y = 0; img_y < clip->g_h; img_y++) {
- imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
+ for( img_y = 0; img_y < clip->g_h; img_y++) {
+ imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
for( img_x = 0; img_x < clip->g_w; img_x++ ) {
- imgrow[img_x] = ablend( imgrow[img_x], bg );
- }
+ imgrow[img_x] = ablend( imgrow[img_x], bg );
+ }
}
return(true);
}
@@ -977,38 +977,38 @@ inline static bool ablend_pixel(struct bitmap * img, uint32_t bg, GRECT * clip)
inline static bool ablend_bitmap( struct bitmap * img, struct bitmap * bg,
GRECT * img_clip, GRECT * bg_clip )
{
- uint32_t * imgrow;
- uint32_t * screenrow;
+ uint32_t * imgrow;
+ uint32_t * screenrow;
int img_x, img_y, bg_x, bg_y, img_stride, bg_stride;
bg_clip = bg_clip;
img_stride= bitmap_get_rowstride(img);
bg_stride = bitmap_get_rowstride(bg);
- for( img_y = img_clip->g_y, bg_y = 0; bg_y < img_clip->g_h; bg_y++, img_y++) {
- imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
- screenrow = (uint32_t *)(bg->pixdata + (bg_stride * bg_y));
+ for( img_y = img_clip->g_y, bg_y = 0; bg_y < img_clip->g_h; bg_y++, img_y++) {
+ imgrow = (uint32_t *)(img->pixdata + (img_stride * img_y));
+ screenrow = (uint32_t *)(bg->pixdata + (bg_stride * bg_y));
for( img_x = img_clip->g_x, bg_x = 0; bg_x < img_clip->g_w; bg_x++, img_x++ ) {
// when the pixel isn't fully transparent,...:
- if( (imgrow[img_x] & 0x0FF) != 0 ){
- screenrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]);
+ if( (imgrow[img_x] & 0x0FF) != 0 ){
+ screenrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]);
}
// FIXME, maybe this loop would be faster??:
// ---
- //if( (imgrow[img_x] & 0x0FF) != 0xFF ){
- // imgrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]);
+ //if( (imgrow[img_x] & 0x0FF) != 0xFF ){
+ // imgrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]);
//}
// or maybe even this???
// ---
//if( (imgrow[img_x] & 0x0FF) == 0xFF ){
- // screenrow[bg_x] = imgrow[img_x];
+ // screenrow[bg_x] = imgrow[img_x];
//} else if( (imgrow[img_x] & 0x0FF) != 0x00 ) {
// screenrow[bg_x] = ablend( imgrow[img_x], screenrow[bg_x]);
- //}
- }
+ //}
+ }
}
return(false);
}
@@ -1021,13 +1021,13 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
{
MFDB native;
MFDB stdform;
- int dststride; /* stride of dest. image */
- int dstsize; /* size of dest. in byte */
- int err;
+ int dststride; /* stride of dest. image */
+ int dstsize; /* size of dest. in byte */
+ int err;
int bw, bh;
int process_w, process_h;
struct bitmap * scrbuf = NULL;
- struct bitmap * source;
+ struct bitmap * source;
bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
bool opaque = bitmap_get_opaque( img );
@@ -1090,7 +1090,7 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
assert( out->fd_addr == NULL );
native.fd_addr = (void*)malloc( dstsize );
if (native.fd_addr == NULL){
- if (scrbuf != NULL)
+ if (scrbuf != NULL)
bitmap_destroy(scrbuf);
return( 0-ERR_NO_MEM );
}
@@ -1233,16 +1233,16 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
* bg: background color
* flags: blit flags
* out: the result MFDB
-*/
+*/
static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
- GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out )
-{
- int dststride; /* stride of dest. image */
- int dstsize; /* size of dest. in byte */
- int err;
+ GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out )
+{
+ int dststride; /* stride of dest. image */
+ int dstsize; /* size of dest. in byte */
+ int err;
int bw, bh;
struct bitmap * scrbuf = NULL;
- struct bitmap * source = NULL;
+ struct bitmap * source = NULL;
bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
bool opaque = bitmap_get_opaque( img );
@@ -1253,9 +1253,9 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
opaque = true;
}
}
-
-
- assert( clip->g_h > 0 );
+
+
+ assert( clip->g_h > 0 );
assert( clip->g_w > 0 );
bw = bitmap_get_width( img );
@@ -1282,13 +1282,13 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
}
}
- /* rem. if eddi xy is installed, we could directly access the screen! */
- /* apply transparency to the image: */
+ /* rem. if eddi xy is installed, we could directly access the screen! */
+ /* apply transparency to the image: */
if (( opaque == false )) {
/* copy the screen to an temp buffer: */
if ((flags & BITMAPF_BUFFER_NATIVE) == 0) {
- scrbuf = snapshot_create(x, y, clip->g_w, clip->g_h);
- if( scrbuf != NULL ) {
+ scrbuf = snapshot_create(x, y, clip->g_w, clip->g_h);
+ if( scrbuf != NULL ) {
assert( clip->g_w <= bw );
assert( clip->g_h <= bh );
@@ -1302,7 +1302,7 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
clip->g_x = 0;
clip->g_y = 0;
/* set the source of conversion: */
- source = scrbuf;
+ source = scrbuf;
}
} else {
/*
@@ -1315,213 +1315,213 @@ static bool bitmap_convert_tc(struct bitmap * img, int x, int y,
}
} else {
source = img;
- }
- /* (re)allocate buffer for converted image: */
- dststride = MFDB_STRIDE(bw);
+ }
+ /* (re)allocate buffer for converted image: */
+ dststride = MFDB_STRIDE(bw);
dstsize = ( ((dststride >> 3) * bh) * atari_plot_bpp_virt );
- if (cache == false) {
- if (dstsize > size_buf_packed) {
- int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
- if( buf_packed == NULL )
- buf_packed =(void*)malloc( blocks * CONV_BLOCK_SIZE );
- else
+ if (cache == false) {
+ if (dstsize > size_buf_packed) {
+ int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
+ if( buf_packed == NULL )
+ buf_packed =(void*)malloc( blocks * CONV_BLOCK_SIZE );
+ else
buf_packed =(void*)realloc(buf_packed,
- blocks * CONV_BLOCK_SIZE);
- assert( buf_packed );
- if( buf_packed == NULL ) {
- if( scrbuf != NULL )
- bitmap_destroy( scrbuf );
- return( 0-ERR_NO_MEM );
- }
- size_buf_packed = blocks * CONV_BLOCK_SIZE;
+ blocks * CONV_BLOCK_SIZE);
+ assert( buf_packed );
+ if( buf_packed == NULL ) {
+ if( scrbuf != NULL )
+ bitmap_destroy( scrbuf );
+ return( 0-ERR_NO_MEM );
+ }
+ size_buf_packed = blocks * CONV_BLOCK_SIZE;
}
out->fd_addr = buf_packed;
} else {
assert( out->fd_addr == NULL );
out->fd_addr = (void*)malloc( dstsize );
if( out->fd_addr == NULL ){
- if( scrbuf != NULL )
+ if( scrbuf != NULL )
bitmap_destroy( scrbuf );
return( 0-ERR_NO_MEM );
}
- }
-
- out->fd_w = dststride;
- out->fd_h = bh;
- out->fd_wdwidth = dststride >> 4;
- out->fd_stand = 0;
- out->fd_nplanes = (short)atari_plot_bpp_virt;
- out->fd_r1 = out->fd_r2 = out->fd_r3 = 0;
-
- err = Hermes_ConverterRequest(
- hermes_cnv_h,
- &nsfmt,
- &vfmt
- );
+ }
+
+ out->fd_w = dststride;
+ out->fd_h = bh;
+ out->fd_wdwidth = dststride >> 4;
+ out->fd_stand = 0;
+ out->fd_nplanes = (short)atari_plot_bpp_virt;
+ out->fd_r1 = out->fd_r2 = out->fd_r3 = 0;
+
+ err = Hermes_ConverterRequest(
+ hermes_cnv_h,
+ &nsfmt,
+ &vfmt
+ );
assert( err != 0 );
// FIXME: here we can use the same optimization which is used for
// the snapshot creation.
- /* convert image to virtual format: */
- err = Hermes_ConverterCopy( hermes_cnv_h,
- source->pixdata,
- 0, /* x src coord of top left in pixel coords */
- 0, /* y src coord of top left in pixel coords */
- bw, bh,
- source->rowstride, /* stride as bytes */
- out->fd_addr,
- 0, /* x dst coord of top left in pixel coords */
- 0, /* y dst coord of top left in pixel coords */
- bw, bh,
- (dststride >> 3) * atari_plot_bpp_virt /* stride as bytes */
+ /* convert image to virtual format: */
+ err = Hermes_ConverterCopy( hermes_cnv_h,
+ source->pixdata,
+ 0, /* x src coord of top left in pixel coords */
+ 0, /* y src coord of top left in pixel coords */
+ bw, bh,
+ source->rowstride, /* stride as bytes */
+ out->fd_addr,
+ 0, /* x dst coord of top left in pixel coords */
+ 0, /* y dst coord of top left in pixel coords */
+ bw, bh,
+ (dststride >> 3) * atari_plot_bpp_virt /* stride as bytes */
);
assert( err != 0 );
if( cache == true ){
img->native = *out;
img->converted = true;
- }
- return( 0 );
-
-}
-
- inline static void convert_bitmap_done(void)
-{
- if (size_buf_packed > CONV_KEEP_LIMIT) {
- /* free the mem if it was an large allocation ... */
- buf_packed = realloc(buf_packed, CONV_KEEP_LIMIT);
- size_buf_packed = CONV_KEEP_LIMIT;
- }
-}
-
-
-bool plot_blit_bitmap(struct bitmap * bmp, int x, int y,
- unsigned long bg, unsigned long flags )
-{
- MFDB src_mf;
- MFDB scrmf;
- short pxy[8];
+ }
+ return( 0 );
+
+}
+
+ inline static void convert_bitmap_done(void)
+{
+ if (size_buf_packed > CONV_KEEP_LIMIT) {
+ /* free the mem if it was an large allocation ... */
+ buf_packed = realloc(buf_packed, CONV_KEEP_LIMIT);
+ size_buf_packed = CONV_KEEP_LIMIT;
+ }
+}
+
+
+bool plot_blit_bitmap(struct bitmap * bmp, int x, int y,
+ unsigned long bg, unsigned long flags )
+{
+ MFDB src_mf;
+ MFDB scrmf;
+ short pxy[8];
GRECT off, clip, vis;
- int screen_x, screen_y;
-
- src_mf.fd_addr = NULL;
- scrmf.fd_addr = NULL;
-
- off.g_x = x;
- off.g_y = y;
- off.g_h = bmp->height;
+ int screen_x, screen_y;
+
+ src_mf.fd_addr = NULL;
+ scrmf.fd_addr = NULL;
+
+ off.g_x = x;
+ off.g_y = y;
+ off.g_h = bmp->height;
off.g_w = bmp->width;
- // clip plotter clip rectangle:
- clip.g_x = view.clipping.x0;
- clip.g_y = view.clipping.y0;
- clip.g_w = view.clipping.x1 - view.clipping.x0;
- clip.g_h = view.clipping.y1 - view.clipping.y0;
-
- if( !rc_intersect( &clip, &off) ) {
- return(true);
+ // clip plotter clip rectangle:
+ clip.g_x = view.clipping.x0;
+ clip.g_y = view.clipping.y0;
+ clip.g_w = view.clipping.x1 - view.clipping.x0;
+ clip.g_h = view.clipping.y1 - view.clipping.y0;
+
+ if( !rc_intersect( &clip, &off) ) {
+ return(true);
}
// clip the visible rectangle of the plot area
// this is the area of the plotter which falls into
- // screen region:
+ // screen region:
plot_get_visible_grect(&vis);
- if( !rc_intersect( &vis, &off) ) {
- return(true);
- }
+ if( !rc_intersect( &vis, &off) ) {
+ return(true);
+ }
screen_x = view.x + off.g_x;
screen_y = view.y + off.g_y;
- // convert the clipping relative to bitmap:
- off.g_x = off.g_x - x;
+ // convert the clipping relative to bitmap:
+ off.g_x = off.g_x - x;
off.g_y = off.g_y - y;
assert( (off.g_x >= 0) && (off.g_y >= 0) );
/* Convert the Bitmap to native screen format - ready for output. */
/* This includes blending transparent pixels: */
if (bitmap_convert(bmp, screen_x, screen_y, &off, bg, flags, &src_mf)
- != 0 ) {
- return(true);
+ != 0 ) {
+ return(true);
}
-
- // setup the src region:
- pxy[0] = off.g_x;
- pxy[1] = off.g_y;
- pxy[2] = off.g_x + off.g_w-1;
+
+ // setup the src region:
+ pxy[0] = off.g_x;
+ pxy[1] = off.g_y;
+ pxy[2] = off.g_x + off.g_w-1;
pxy[3] = off.g_y + off.g_h-1;
- // setup the target region:
- pxy[4] = screen_x;
- pxy[5] = screen_y;
- pxy[6] = screen_x + off.g_w-1;
+ // setup the target region:
+ pxy[4] = screen_x;
+ pxy[5] = screen_y;
+ pxy[6] = screen_x + off.g_w-1;
pxy[7] = screen_y + off.g_h-1;
- vro_cpyfm(atari_plot_vdi_handle, S_ONLY, (short*)&pxy, &src_mf, &scrmf);
+ vro_cpyfm(atari_plot_vdi_handle, S_ONLY, (short*)&pxy, &src_mf, &scrmf);
convert_bitmap_done();
- snapshot_suspend();
- return(true);
-}
-
+ snapshot_suspend();
+ return(true);
+}
+
bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, unsigned char fgcolor,
- uint32_t flags)
-{
-
- MFDB screen, tran;
- MFDB * src;
- short pxy[8];
- short c[2] = {fgcolor, WHITE};
- GRECT off;
-
- plot_get_clip_grect(&off);
- if( rc_intersect(loc, &off) == 0 ){
- return( 1 );
- }
-
- init_mfdb( 0, loc->g_w, loc->g_h, 0, &screen );
-
- if( insrc->fd_stand ){
- int size = init_mfdb( insrc->fd_nplanes, loc->g_w, loc->g_h,
- MFDB_FLAG_NOALLOC,
- &tran
- );
- if( size_buf_scr == 0 ){
- buf_scr.fd_addr = malloc( size );
- size_buf_scr = size;
- } else {
- if( size > size_buf_scr ) {
- buf_scr.fd_addr = realloc(
- buf_scr.fd_addr, size
- );
- size_buf_scr = size;
- }
- }
- tran.fd_addr = buf_scr.fd_addr;
- vr_trnfm(atari_plot_vdi_handle, insrc, &tran );
- src = &tran;
- } else {
- src = insrc;
- }
-
- pxy[0] = off.g_x - loc->g_x;
- pxy[1] = off.g_y - loc->g_y;
- pxy[2] = pxy[0] + off.g_w - 1;
- pxy[3] = pxy[1] + off.g_h - 1;
- pxy[4] = view.x + off.g_x;
- pxy[5] = view.y + off.g_y;
- pxy[6] = pxy[4] + off.g_w-1;
- pxy[7] = pxy[5] + off.g_h-1;
-
-
- if( flags & PLOT_FLAG_TRANS && src->fd_nplanes == 1){
- vrt_cpyfm(atari_plot_vdi_handle, MD_TRANS, (short*)pxy, src, &screen, (short*)&c );
- } else {
- /* this method only plots transparent bitmaps, right now... */
- }
- return( 1 );
-}
-
+ uint32_t flags)
+{
+
+ MFDB screen, tran;
+ MFDB * src;
+ short pxy[8];
+ short c[2] = {fgcolor, WHITE};
+ GRECT off;
+
+ plot_get_clip_grect(&off);
+ if( rc_intersect(loc, &off) == 0 ){
+ return( 1 );
+ }
+
+ init_mfdb( 0, loc->g_w, loc->g_h, 0, &screen );
+
+ if( insrc->fd_stand ){
+ int size = init_mfdb( insrc->fd_nplanes, loc->g_w, loc->g_h,
+ MFDB_FLAG_NOALLOC,
+ &tran
+ );
+ if( size_buf_scr == 0 ){
+ buf_scr.fd_addr = malloc( size );
+ size_buf_scr = size;
+ } else {
+ if( size > size_buf_scr ) {
+ buf_scr.fd_addr = realloc(
+ buf_scr.fd_addr, size
+ );
+ size_buf_scr = size;
+ }
+ }
+ tran.fd_addr = buf_scr.fd_addr;
+ vr_trnfm(atari_plot_vdi_handle, insrc, &tran );
+ src = &tran;
+ } else {
+ src = insrc;
+ }
+
+ pxy[0] = off.g_x - loc->g_x;
+ pxy[1] = off.g_y - loc->g_y;
+ pxy[2] = pxy[0] + off.g_w - 1;
+ pxy[3] = pxy[1] + off.g_h - 1;
+ pxy[4] = view.x + off.g_x;
+ pxy[5] = view.y + off.g_y;
+ pxy[6] = pxy[4] + off.g_w-1;
+ pxy[7] = pxy[5] + off.g_h-1;
+
+
+ if( flags & PLOT_FLAG_TRANS && src->fd_nplanes == 1){
+ vrt_cpyfm(atari_plot_vdi_handle, MD_TRANS, (short*)pxy, src, &screen, (short*)&c );
+ } else {
+ /* this method only plots transparent bitmaps, right now... */
+ }
+ return( 1 );
+}
+
/*
Init screen and font driver objects.
Returns non-zero value > -1 when the objects could be succesfully created.
@@ -1543,8 +1543,8 @@ int plot_init(char * fdrvrname)
atari_plot_vdi_handle = app.graf.handle;
read_vdi_sysinfo(atari_plot_vdi_handle, &vdi_sysinfo);
- if( verbose_log ) {
- dump_vdi_info( atari_plot_vdi_handle ) ;
+ if(verbose_log) {
+ dump_vdi_info(atari_plot_vdi_handle) ;
dump_font_drivers();
}
@@ -1840,27 +1840,27 @@ bool plot_line(int x0, int y0, int x1, int y1,
static bool plot_polygon(const int *p, unsigned int n,
const plot_style_t *pstyle)
{
- short pxy[n*2];
- unsigned int i=0;
- short d[4];
- if (vdi_sysinfo.maxpolycoords > 0)
- assert( (signed int)n < vdi_sysinfo.maxpolycoords);
- plot_vdi_clip(true);
- vsf_interior(atari_plot_vdi_handle, FIS_SOLID);
- vsf_style(atari_plot_vdi_handle, 1);
- for (i = 0; i<n*2; i=i+2) {
- pxy[i] = (short)view.x+p[i];
- pxy[i+1] = (short)view.y+p[i+1];
- }
- if (pstyle->fill_type == PLOT_OP_TYPE_SOLID) {
- vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour);
- v_fillarea(atari_plot_vdi_handle, n, (short*)&pxy);
- } else {
- pxy[n*2]=pxy[0];
- pxy[n*2+1]=pxy[1];
- vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
- v_pline(atari_plot_vdi_handle, n+1, (short *)&pxy);
- }
+ short pxy[n*2];
+ unsigned int i=0;
+ short d[4];
+ if (vdi_sysinfo.maxpolycoords > 0)
+ assert( (signed int)n < vdi_sysinfo.maxpolycoords);
+ plot_vdi_clip(true);
+ vsf_interior(atari_plot_vdi_handle, FIS_SOLID);
+ vsf_style(atari_plot_vdi_handle, 1);
+ for (i = 0; i<n*2; i=i+2) {
+ pxy[i] = (short)view.x+p[i];
+ pxy[i+1] = (short)view.y+p[i+1];
+ }
+ if (pstyle->fill_type == PLOT_OP_TYPE_SOLID) {
+ vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour);
+ v_fillarea(atari_plot_vdi_handle, n, (short*)&pxy);
+ } else {
+ pxy[n*2]=pxy[0];
+ pxy[n*2+1]=pxy[1];
+ vsl_rgbcolor(atari_plot_vdi_handle, pstyle->stroke_colour);
+ v_pline(atari_plot_vdi_handle, n+1, (short *)&pxy);
+ }
plot_vdi_clip(false);
return ( true );
}
@@ -1891,19 +1891,20 @@ bool plot_set_dimensions(int x, int y, int w, int h)
bool plot_clip(const struct rect *clip)
{
// FIXME: consider the canvas size
- view.clipping.x0 = clip->x0;
- view.clipping.y0 = clip->y0;
- view.clipping.x1 = clip->x1;
+ view.clipping.x0 = clip->x0;
+ view.clipping.y0 = clip->y0;
+ view.clipping.x1 = clip->x1;
view.clipping.y1 = clip->y1;
+
return ( true );
}
bool plot_get_clip(struct rect * out)
{
- out->x0 = view.clipping.x0;
+ out->x0 = view.clipping.x0;
out->y0 = view.clipping.y0;
- out->x1 = view.clipping.x1;
+ out->x1 = view.clipping.x1;
out->y1 = view.clipping.y1;
return( true );
}