From b9092d6271469e8491ac6bd71991de61353afc4e Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Wed, 14 Mar 2012 22:06:07 +0000 Subject: Restructured the plotter driver struct and declared misc functions static within the vdi driver. svn path=/trunk/netsurf/; revision=13519 --- atari/plot/font_freetype.c | 30 +++-- atari/plot/plotter.c | 271 ++++++++++---------------------------- atari/plot/plotter.h | 110 ++++++---------- atari/plot/plotter_gd.c | 98 ++++++++++---- atari/plot/plotter_gd.h | 10 +- atari/plot/plotter_vdi.c | 318 ++++++++++++++++++++++++++++++++------------- atari/plot/plotter_vdi.h | 31 ++++- 7 files changed, 467 insertions(+), 401 deletions(-) (limited to 'atari/plot') diff --git a/atari/plot/font_freetype.c b/atari/plot/font_freetype.c index 9eba3b48b..e62263ec7 100755 --- a/atari/plot/font_freetype.c +++ b/atari/plot/font_freetype.c @@ -377,17 +377,20 @@ static void draw_glyph8(FONT_PLOTTER self, GRECT * loc, uint8_t * pixdata, int p uint32_t fontpix; size_t bmpstride; int xloop,yloop,xoff,yoff; - int x,y,w,h; + int x,y,w,h; + struct rect clipping; x = loc->g_x; y = loc->g_y; w = loc->g_w; - h = loc->g_h; + h = loc->g_h; + + self->plotter->get_clip( self->plotter, &clipping ); - clip.g_x = self->plotter->clipping.x0; - clip.g_y = self->plotter->clipping.y0; - clip.g_w = (self->plotter->clipping.x1 - self->plotter->clipping.x0)+1; - clip.g_h = (self->plotter->clipping.y1 - self->plotter->clipping.y0)+1; + clip.g_x = clipping.x0; + clip.g_y = clipping.y0; + clip.g_w = (clipping.x1 - clipping.x0)+1; + clip.g_h = (clipping.y1 - clipping.y0)+1; if( !rc_intersect( &clip, loc ) ){ return; @@ -425,17 +428,20 @@ static void draw_glyph1(FONT_PLOTTER self, GRECT * loc, uint8_t * pixdata, int p int xloop,yloop,xoff,yoff; int x,y,w,h; uint8_t bitm; - const uint8_t *fntd; + const uint8_t *fntd; + struct rect clipping; x = loc->g_x; y = loc->g_y; w = loc->g_w; - h = loc->g_h; + h = loc->g_h; + + self->plotter->get_clip( self->plotter, &clipping ); - clip.g_x = self->plotter->clipping.x0; - clip.g_y = self->plotter->clipping.y0; - clip.g_w = (self->plotter->clipping.x1 - self->plotter->clipping.x0)+1; - clip.g_h = (self->plotter->clipping.y1 - self->plotter->clipping.y0)+1; + clip.g_x = clipping.x0; + clip.g_y = clipping.y0; + clip.g_w = (clipping.x1 - clipping.x0)+1; + clip.g_h = (clipping.y1 - clipping.y0)+1; if( !rc_intersect( &clip, loc ) ){ return; diff --git a/atari/plot/plotter.c b/atari/plot/plotter.c index 7a4ff81ea..25d065ec8 100755 --- a/atari/plot/plotter.c +++ b/atari/plot/plotter.c @@ -73,31 +73,18 @@ struct s_driver_table_entry screen_driver_table[] = const struct s_font_driver_table_entry font_driver_table[] = { #ifdef WITH_VDI_FONT_DRIVER - {(char*)"vdi", ctor_font_plotter_vdi, 0}, + {"vdi", ctor_font_plotter_vdi, 0}, #endif #ifdef WITH_FREETYPE_FONT_DRIVER - {(char*)"freetype", ctor_font_plotter_freetype, 0}, + {"freetype", ctor_font_plotter_freetype, 0}, #endif #ifdef WITH_INTERNAL_FONT_DRIVER - {(char*)"internal", ctor_font_plotter_internal, 0}, + {"internal", ctor_font_plotter_internal, 0}, #endif {(char*)NULL, NULL, 0} }; - -/* get index to driver in driver list by name */ -static int drvrname_idx( char * name ); - -/* Error code translations: */ -static const char * plot_error_codes[] = -{ - "None", - "ERR_BUFFERSIZE_EXCEEDS_SCREEN", - "ERR_NO_MEM", - "ERR_PLOTTER_NOT_AVAILABLE" -}; - -#ifdef WITH_8BPP_SUPPORT + unsigned short vdi_web_pal[216][3] = { {0x000,0x000,0x000}, {0x0c8,0x000,0x000}, {0x190,0x000,0x000}, {0x258,0x000,0x000}, {0x320,0x000,0x000}, {0x3e8,0x000,0x000}, {0x000,0x0c8,0x000}, {0x0c8,0x0c8,0x000}, {0x190,0x0c8,0x000}, {0x258,0x0c8,0x000}, {0x320,0x0c8,0x000}, {0x3e8,0x0c8,0x000}, @@ -136,9 +123,20 @@ unsigned short vdi_web_pal[216][3] = { {0x000,0x320,0x3e8}, {0x0c8,0x320,0x3e8}, {0x190,0x320,0x3e8}, {0x258,0x320,0x3e8}, {0x320,0x320,0x3e8}, {0x3e8,0x320,0x3e8}, {0x000,0x3e8,0x3e8}, {0x0c8,0x3e8,0x3e8}, {0x190,0x3e8,0x3e8}, {0x258,0x3e8,0x3e8}, {0x320,0x3e8,0x3e8}, {0x3e8,0x3e8,0x3e8} }; -#endif + + +/* get index to driver in driver list by name */ +static int drvrname_idx( char * name ); + +/* Error code translations: */ +static const char * plot_error_codes[] = +{ + "None", + "ERR_BUFFERSIZE_EXCEEDS_SCREEN", + "ERR_NO_MEM", + "ERR_PLOTTER_NOT_AVAILABLE" +}; -static short prev_vdi_clip[4]; struct s_vdi_sysinfo vdi_sysinfo; struct s_vdi_sysinfo * read_vdi_sysinfo( short vdih, struct s_vdi_sysinfo * info ) { @@ -401,12 +399,6 @@ GEM_PLOTTER new_plotter(int vdihandle, char * name, GRECT * loc_size, gemplotter->flags = 0; gemplotter->font_plotter = fplotter; gemplotter->bpp_virt = virt_bpp; - gemplotter->cfbi = 0; - memset(&gemplotter->fbuf, 0, sizeof(struct s_frame_buf) * MAX_FRAMEBUFS ); - gemplotter->fbuf[0].x = loc_size->g_x; - gemplotter->fbuf[0].y = loc_size->g_y; - gemplotter->fbuf[0].w = loc_size->g_w; - gemplotter->fbuf[0].h = loc_size->g_h; /* request vdi info once, so every plotter is able to access the info */ if( !init ) { @@ -423,7 +415,7 @@ GEM_PLOTTER new_plotter(int vdihandle, char * name, GRECT * loc_size, if( strcmp(name, screen_driver_table[i].name) == 0 ) { if( screen_driver_table[i].ctor ) { gemplotter->flags = (screen_driver_table[i].flags | flags); - res = screen_driver_table[i].ctor( gemplotter ); + res = screen_driver_table[i].ctor( gemplotter, loc_size ); *error = 0; } else { res = 0-ERR_PLOTTER_NOT_AVAILABLE; @@ -501,84 +493,6 @@ int get_pixel_offset( int x, int y, int stride, int bpp ) return( ( (y * stride) + x) * (bpp >> 3) ); } -/* - 1. calculate visible area of framebuffer in coords relative to framebuffer position - - result: - this function should calc offsets into x,y coords of the framebuffer which - can be drawn. If the framebuffer coords do not fall within the screen region, - all values of visible region are set to zero. -*/ -void update_visible_rect( GEM_PLOTTER p ) -{ - 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 = CURFB(p).x; - common.g_y = frame.g_y = CURFB(p).y; - common.g_w = frame.g_w = CURFB(p).w; - common.g_h = frame.g_h = CURFB(p).h; - - if( rc_intersect( &screen, &common ) ) { - CURFB(p).vis_w = common.g_w; - CURFB(p).vis_h = common.g_h; - if( CURFB(p).x < screen.g_x ) - CURFB(p).vis_x = frame.g_w - common.g_w; - else - CURFB(p).vis_x = 0; - if( CURFB(p).y 0 ) { + if( (flags & MFDB_FLAG_NOALLOC) == 0 ) { + out->fd_addr = malloc( size ); + if( out->fd_addr == NULL ){ + return( 0 ); + } + if( (flags & MFDB_FLAG_ZEROMEM) ){ + memset( out->fd_addr, 0, size ); + } + } + out->fd_stand = (flags & MFDB_FLAG_STAND) ? 1 : 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( size ); +} + +void plotter_get_clip_grect( GEM_PLOTTER self, GRECT * out ) +{ + struct rect clip; + self->get_clip( self, &clip ); + out->g_x = clip.x0; + out->g_y = clip.y0; + out->g_w = clip.x1 - clip.x0; + out->g_h = clip.y1 - clip.y0; +} + /* Convert an RGB color to an VDI Color */ void rgb_to_vdi1000( unsigned char * in, unsigned short * out ) { - double r = ((double)in[3]/255); /* prozentsatz red */ + double r = ((double)in[3]/255); /* prozentsatz red */ double g = ((double)in[2]/255); /* prozentsatz green */ - double b = ((double)in[1]/255); /* prozentsatz blue */ + double b = ((double)in[1]/255); /* prozentsatz blue */ out[0] = 1000 * r + 0.5; out[1] = 1000 * g + 0.5; out[2] = 1000 * b + 0.5; @@ -650,17 +605,20 @@ void rgb_to_vdi1000( unsigned char * in, unsigned short * out ) void vdi1000_to_rgb( unsigned short * in, unsigned char * out ) { - double r = ((double)in[0]/1000); /* prozentsatz red */ - double g = ((double)in[1]/1000); /* prozentsatz green */ - double b = ((double)in[2]/1000); /* prozentsatz blue */ + double r = ((double)in[0]/1000); /* prozentsatz red */ + double g = ((double)in[1]/1000); /* prozentsatz green */ + double b = ((double)in[2]/1000); /* prozentsatz blue */ out[2] = 255 * r + 0.5; out[1] = 255 * g + 0.5; out[0] = 255 * b + 0.5; return; -} +} + + +#ifdef WITH_8BPP_SUPPORT -static short web_std_colors[6] = {0, 51, 102, 153, 204, 255}; +short web_std_colors[6] = {0, 51, 102, 153, 204, 255}; /* Convert an RGB color into an index into the 216 colors web pallette @@ -698,94 +656,7 @@ short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b) } } return( tval[2]*36+tval[1]*6+tval[0] ); -} - -/* - bpp: bits per pixel, - -*/ -int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out ) -{ - int dststride; - dststride = MFDB_STRIDE( w ); - int size = MFDB_SIZE( bpp, dststride, h ); - if( bpp > 0 ) { - if( (flags & MFDB_FLAG_NOALLOC) == 0 ) { - out->fd_addr = malloc( size ); - if( out->fd_addr == NULL ){ - return( 0 ); - } - if( (flags & MFDB_FLAG_ZEROMEM) ){ - memset( out->fd_addr, 0, size ); - } - } - out->fd_stand = (flags & MFDB_FLAG_STAND) ? 1 : 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( size ); -} - - -int plotter_get_clip( GEM_PLOTTER self, struct rect * out ) -{ - out->x0 = self->clipping.x0; - out->y0 = self->clipping.y0; - out->x1 = self->clipping.x1; - out->y1 = self->clipping.y1; - return( 1 ); -} - -void plotter_get_clip_grect( GEM_PLOTTER self, GRECT * out ) -{ - out->g_x = self->clipping.x0; - out->g_y = self->clipping.y0; - out->g_w = self->clipping.x1 - self->clipping.x0; - out->g_h = self->clipping.y1 - self->clipping.y0; -} - -void plotter_get_visible_grect( GEM_PLOTTER self, GRECT * out ) -{ - /*todo: !!! */ - out->g_x = self->clipping.x0; - out->g_y = self->clipping.y0; - out->g_w = self->clipping.x1 - self->clipping.x0; - out->g_h = self->clipping.y1 - self->clipping.y0; -} - -int plotter_std_clip(GEM_PLOTTER self, const struct rect * clip) -{ - self->clipping.x0 = clip->x0; - self->clipping.y0 = clip->y0; - self->clipping.x1 = clip->x1; - self->clipping.y1 = clip->y1; - return ( 1 ); -} - +} +#endif -void plotter_vdi_clip( GEM_PLOTTER self, bool set) -{ - if( set == true ) { - struct rect * c = &self->clipping; - short vdiflags[58]; - short newclip[4]; - vq_extnd( self->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] = CURFB(self).x + MAX(c->x0, 0); - newclip[1] = CURFB(self).y + MAX(c->y0, 0); - newclip[2] = MIN(CURFB(self).x+CURFB(self).w, newclip[0] + (c->x1 - c->x0) )-1; - newclip[3] = MIN(CURFB(self).y+CURFB(self).h, newclip[1] + (c->y1 - c->y0) )-1; - vs_clip( self->vdi_handle, 1, (short*)&newclip ); - } else { - vs_clip( self->vdi_handle, 1, (short *)&prev_vdi_clip ); - } -} diff --git a/atari/plot/plotter.h b/atari/plot/plotter.h index 838451572..ebaaec826 100755 --- a/atari/plot/plotter.h +++ b/atari/plot/plotter.h @@ -143,21 +143,6 @@ struct s_vdi_sysinfo { }; -struct s_frame_buf -{ - short x; - short y; - short w; - short h; - short vis_x; /* visible rectangle of the screen buffer */ - short vis_y; /* coords are relative to framebuffer location */ - short vis_w; - short vis_h; - int size; - bool swapped; - void * mem; -}; - /* declaration of plotter member functions ( _pmf_ prefix )*/ typedef int (*_pmf_resize)(GEM_PLOTTER self, int w, int h); typedef int (*_pmf_move)(GEM_PLOTTER self, short x, short y ); @@ -167,7 +152,8 @@ typedef int (*_pmf_lock)(GEM_PLOTTER self); typedef int (*_pmf_unlock)(GEM_PLOTTER self); typedef int (*_pmf_put_pixel)(GEM_PLOTTER self, int x, int y, int color ); typedef int (*_pmf_copy_rect)(GEM_PLOTTER self, GRECT src, GRECT dst ); -typedef int (*_pmf_clip)(GEM_PLOTTER self, const struct rect * clip ); +typedef int (*_pmf_set_clip)(GEM_PLOTTER self, const struct rect * clip ); +typedef int (*_pmf_get_clip)(GEM_PLOTTER self, struct rect * clip_out ); typedef int (*_pmf_arc)(GEM_PLOTTER self, int x, int y, int radius, int angle1, int angle2, const plot_style_t * pstyle); typedef int (*_pmf_disc)(GEM_PLOTTER self, int x, int y, int radius, const plot_style_t * pstyle); typedef int (*_pmf_line)(GEM_PLOTTER self, int x0, int y0, int x1, int y1, const plot_style_t * pstyle); @@ -194,10 +180,6 @@ struct s_gem_plotter void * priv_data; /* bit depth of framebuffers: */ int bpp_virt; - struct rect clipping; - struct s_frame_buf fbuf[MAX_FRAMEBUFS]; - /* current framebuffer index: */ - int cfbi; FONT_PLOTTER font_plotter; /* set new dimensions (realloc memory): */ @@ -210,7 +192,8 @@ struct s_gem_plotter _pmf_switch_to_framebuffer switch_to_framebuffer; _pmf_put_pixel put_pixel; _pmf_copy_rect copy_rect; - _pmf_clip clip; + _pmf_set_clip set_clip; + _pmf_get_clip get_clip; _pmf_arc arc; _pmf_disc disc; _pmf_line line; @@ -233,16 +216,24 @@ struct s_gem_plotter /* these 2 structs hold info about an specific driver. */ /* a table in plotter.c defines all the available plotters */ struct s_driver_table_entry -{ - char * name; /* name (unique) */ - int (*ctor)( GEM_PLOTTER self ); /* pointer to ctor of the plotter */ - int flags; /* a bitmask containing info about supported operations */ - int max_bpp; /* the maximum supported screen depth of the plotter */ +{ + + /* name (unique) */ + char * name; + + /* pointer to ctor of the plotter */ + int (*ctor)( GEM_PLOTTER self, GRECT * log_isze ); + + /* a bitmask containing info about supported operations */ + int flags; + + /* the maximum supported screen depth of the plotter */ + int max_bpp; }; struct s_font_driver_table_entry { - char * name; + const char * name; int (*ctor)( FONT_PLOTTER self ); int flags; }; @@ -290,12 +281,6 @@ int calc_chunked_buffer_size(int x, int y, int stride, int bpp); /* calculates the pixel offset from x,y pos */ int get_pixel_offset( int x, int y, int stride, int bpp ); -/* Recalculate visible parts of the framebuffer */ -void update_visible_rect( GEM_PLOTTER p ); - -/* resolve possible visible parts of the framebuffer in screen coords */ -bool fbrect_to_screen( GEM_PLOTTER self, GRECT box, GRECT * ret ); - /* translate an error number */ const char* plotter_err_str(int i) ; @@ -334,50 +319,39 @@ int plotter_get_clip( GEM_PLOTTER self, struct rect * out ); */ void plotter_get_clip_grect( GEM_PLOTTER self, GRECT * out ); -/* - Get current visible coords -*/ -void plotter_get_visible_grect( GEM_PLOTTER self, GRECT * 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 ) -#define CURFB( p ) \ - p->fbuf[p->cfbi] -#define FIRSTFB( p ) \ - p->fbuf[0] +/* + calculates MFDB compatible rowstride (in number of bits) +*/ +#define MFDB_STRIDE( w ) (((w & 15) != 0) ? (w | 15)+1 : w) +/* +Calculate size of an mfdb, + + params: + + bpp: Bits per pixel, + stride: Word aligned rowstride (width) as returned by MFDB_STRIDE, + h: Height in pixels +*/ +#define MFDB_SIZE( bpp, stride, h ) ( ((stride >> 3) * h) * bpp ) + +#ifdef WITH_8BPP_SUPPORT /* some Well known indexes into the VDI palette */ /* common indexes into the VDI palette */ /* (only used when running with 256 colors or less ) */ #define OFFSET_WEB_PAL 16 -#define OFFSET_CUST_PAL 232 -#define OFFSET_CUSTOM_COLOR 255 /* this one is used by the TC renderer */ -#define RGB_TO_VDI(c) rgb_to_666_index( (c&0xFF),(c&0xFF00)>>8,(c&0xFF0000)>>16)+OFFSET_WEB_PAL -/* the name of this macro is crap - it should be named bgr_to_rgba ... or so */ -#define ABGR_TO_RGB(c) ( ((c&0xFF)<<16) | (c&0xFF00) | ((c&0xFF0000)>>16) ) << 8 - -/* calculate MFDB compatible rowstride (in number of bits) */ -#define MFDB_STRIDE( w ) (((w & 15) != 0) ? (w | 15)+1 : w) +#define OFFSET_CUST_PAL 232 +#define RGB_TO_VDI(c) rgb_to_666_index( (c&0xFF),(c&0xFF00)>>8,(c&0xFF0000)>>16)+OFFSET_WEB_PAL +#endif + +/* the name of this macro is crap - it should be named bgr_to_rgba ... or so */ +#define ABGR_TO_RGB(c) ( ((c&0xFF)<<16) | (c&0xFF00) | ((c&0xFF0000)>>16) ) << 8 +/* this index into the palette is used by the TC renderer to set current draw color: */ +#define OFFSET_CUSTOM_COLOR 255 -/* -Calculate size of an mfdb, params: - Bits per pixel, - Word aligned rowstride (width) as returned by MFDB_STRIDE, - height in pixels -*/ -#define MFDB_SIZE( bpp, stride, h ) ( ((stride >> 3) * h) * bpp ) #endif diff --git a/atari/plot/plotter_gd.c b/atari/plot/plotter_gd.c index 0b29dafd4..39b44be07 100644 --- a/atari/plot/plotter_gd.c +++ b/atari/plot/plotter_gd.c @@ -40,6 +40,8 @@ static int lock( GEM_PLOTTER self ); static int unlock( GEM_PLOTTER self ); static int put_pixel(GEM_PLOTTER self, int x, int y, int color ); static int copy_rect( GEM_PLOTTER self, GRECT src, GRECT dst ); +static int get_clip( GEM_PLOTTER instance, struct rect * clip); +static int set_clip( GEM_PLOTTER instance, const struct rect * clip ); static int arc(GEM_PLOTTER self,int x, int y, int radius, int angle1, int angle2, const plot_style_t * pstyle); static int disc(GEM_PLOTTER self,int x, int y, int radius, const plot_style_t * pstyle); static int line(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plot_style_t * pstyle); @@ -53,8 +55,10 @@ static int bitmap( GEM_PLOTTER self, struct bitmap * bmp, int x, int y, unsigned long bg, unsigned long flags ); static int plot_mfdb( GEM_PLOTTER self, GRECT * where, MFDB * mfdb, unsigned char fgcolor, uint32_t flags); static int text(GEM_PLOTTER self, int x, int y, const char *text,size_t length, const plot_font_style_t *fstyle); +static int clip(GEM_PLOTTER self, const struct rect * clip); -int ctor_plotter_gd( GEM_PLOTTER instance ){ +int ctor_plotter_gd( GEM_PLOTTER instance, GRECT * origin_size ) +{ instance->dtor = dtor; instance->resize= resize; @@ -63,7 +67,8 @@ int ctor_plotter_gd( GEM_PLOTTER instance ){ instance->unlock = unlock; instance->put_pixel = put_pixel; instance->copy_rect = copy_rect; - instance->clip = plotter_std_clip; + instance->get_clip = get_clip; + instance->set_clip = set_clip; instance->arc = arc; instance->disc = disc; instance->line = line; @@ -82,6 +87,11 @@ int ctor_plotter_gd( GEM_PLOTTER instance ){ memset( instance->priv_data, 0, sizeof(struct s_gd_priv_data) ); // allocate framebuffer + THIS(instance)->vbuf = gdImageCreateTrueColor( origin_size->g_w, + origin_size->g_h ); + + THIS(instance)->origin_x = origin_size->g_x; + THIS(instance)->origin_y = origin_size->g_y; return( 1 ); } @@ -89,99 +99,139 @@ int ctor_plotter_gd( GEM_PLOTTER instance ){ static int dtor( GEM_PLOTTER instance ) { int i; - for( i=0; ifbuf[i].mem != NULL ) - free( instance->fbuf[i].mem ); - } free( instance->priv_data ); + gdImageDestroy( THIS(instance)->vbuf ); return( 1 ); } -static int resize( GEM_PLOTTER self, int w, int h ) +static int resize( GEM_PLOTTER instance, int w, int h ) { return( 1 ); } -static int move( GEM_PLOTTER self, short x, short y ) +static int move( GEM_PLOTTER instance, short x, short y ) { + THIS(instance)->origin_x = x; + THIS(instance)->origin_y = y; return( 1 ); } -static int lock( GEM_PLOTTER self ){ +static int lock( GEM_PLOTTER instance ){ + instance->flags |= PLOT_FLAG_LOCKED; return( 1 ); } -static int unlock( GEM_PLOTTER self ) +static int unlock( GEM_PLOTTER instance ) { + instance->flags &= ~PLOT_FLAG_LOCKED; return( 1 ); } -static int put_pixel(GEM_PLOTTER self, int x, int y, int color ) +static int put_pixel(GEM_PLOTTER instance, int x, int y, int color ) { + gdImageSetPixel( THIS(instance)->vbuf, x, y, color ); return( 1 ); - } -static int copy_rect( GEM_PLOTTER self, GRECT src, GRECT dst ) +static int copy_rect( GEM_PLOTTER instance, GRECT src, GRECT dst ) { return( 1 ); } -static int arc(GEM_PLOTTER self,int x, int y, int radius, int angle1, int angle2, const plot_style_t * pstyle) +static int arc(GEM_PLOTTER instance,int x, int y, int radius, int angle1, int angle2, const plot_style_t * pstyle) { return( 1 ); } -static int disc(GEM_PLOTTER self,int x, int y, int radius, const plot_style_t * pstyle) +static int disc(GEM_PLOTTER instance,int x, int y, int radius, const plot_style_t * pstyle) { return( 1 ); } -static int line(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plot_style_t * pstyle) +static int line(GEM_PLOTTER instance,int x0, int y0, int x1, int y1, const plot_style_t * pstyle) { + int w = pstyle->stroke_width; + if( ((w % 2) == 0) || (w < 1) ){ + w++; + } + gdImageSetThickness( THIS(instance)->vbuf, w ); + // FIXME: set stroke style + //gdImageSetStyle( THIS(instance), style, nofpix ); + gdImageLine( THIS(instance)->vbuf, x0, y0, x1, y1, pstyle->stroke_colour ); return( 1 ); } -static int rectangle(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plot_style_t * pstyle) +static int rectangle(GEM_PLOTTER instance,int x0, int y0, int x1, int y1, const plot_style_t * pstyle) { + int lw = pstyle->stroke_width; + + if( pstyle->fill_type != PLOT_OP_TYPE_NONE ){ + gdImageFilledRectangle( THIS(instance)->vbuf, + x0, y0, x1, y1, + pstyle->fill_colour ); + } + + if( pstyle->stroke_type != PLOT_OP_TYPE_NONE ){ + gdImageLine( THIS(instance)->vbuf, + x0, y0, x1, y1, + pstyle->stroke_colour ); + } return( 1 ); } -static int polygon(GEM_PLOTTER self,const int *p, unsigned int n, const plot_style_t * pstyle) +static int polygon(GEM_PLOTTER instance,const int *p, unsigned int n, const plot_style_t * pstyle) { + //gdImagePolygon( THIS(instance).vbuf, points, count, c ); return( 1 ); } -static int path(GEM_PLOTTER self,const float *p, unsigned int n, int fill, float width, int c, const float transform[6]) +static int path(GEM_PLOTTER instance,const float *p, unsigned int n, int fill, float width, int c, const float transform[6]) { return( 1 ); } -static int bitmap_resize( GEM_PLOTTER self, struct bitmap * img, int nw, int nh ) +static int bitmap_resize( GEM_PLOTTER instance, struct bitmap * img, int nw, int nh ) { return( 1 ); } -static int bitmap_convert( GEM_PLOTTER self, struct bitmap * img, int x, int y, +static int bitmap_convert( GEM_PLOTTER instance, struct bitmap * img, int x, int y, GRECT * clip,uint32_t bg,uint32_t flags, MFDB *out ) { return( 1 ); } -static int bitmap( GEM_PLOTTER self, struct bitmap * bmp, int x, int y, +static int bitmap( GEM_PLOTTER instance, struct bitmap * bmp, int x, int y, unsigned long bg, unsigned long flags ) { return( 1 ); } -static int plot_mfdb( GEM_PLOTTER self, GRECT * where, MFDB * mfdb, unsigned char fgcolor, uint32_t flags) +static int plot_mfdb( GEM_PLOTTER instance, GRECT * where, MFDB * mfdb, unsigned char fgcolor, uint32_t flags) { return( 1 ); } -static int text(GEM_PLOTTER self, int x, int y, const char *text,size_t length, const plot_font_style_t *fstyle) +static int text( GEM_PLOTTER instance, int x, int y, const char *text,size_t length, const plot_font_style_t *fstyle) { return( 1 ); } +static int get_clip( GEM_PLOTTER instance, struct rect * clip) +{ + gdImageGetClip( THIS(instance)->vbuf, + &clip->x0, &clip->y0, + &clip->x0, &clip->y0 ); + return( 1 ); +} + +static int set_clip( GEM_PLOTTER instance, const struct rect * clip ) +{ + gdImageSetClip( THIS(instance)->vbuf, clip->x0, + clip->y0, clip->x1, + clip->y1 ); + return ( 1 ); +} + + #endif diff --git a/atari/plot/plotter_gd.h b/atari/plot/plotter_gd.h index da223a565..b449997d8 100644 --- a/atari/plot/plotter_gd.h +++ b/atari/plot/plotter_gd.h @@ -23,15 +23,17 @@ #include #include "plotter.h" -struct s_gd_priv_data { - +struct s_gd_priv_data { + gdImagePtr vbuf; + int origin_x; + int origin_y; }; /* this is an shortcut cast to access the members of the s_gd_priv_data */ -#define THIS(instance) ((struct s_gd_priv_data*)self->priv_data) +#define THIS(instance) ((struct s_gd_priv_data*)instance->priv_data) /* Each driver object must export 1 it's own constructor: */ -int ctor_plotter_gd( GEM_PLOTTER p ); +int ctor_plotter_gd( GEM_PLOTTER p, GRECT * loc_size ); #endif #endif diff --git a/atari/plot/plotter_vdi.c b/atari/plot/plotter_vdi.c index f9b488d71..2a722f5e0 100755 --- a/atari/plot/plotter_vdi.c +++ b/atari/plot/plotter_vdi.c @@ -26,8 +26,9 @@ #include "atari/plot/eddi.h" #include "atari/plot/plotter.h" -#include "atari/plot/plotter_vdi.h" - +#include "atari/plot/plotter_vdi.h" + + /* assign vdi line style to dst ( netsurf type ) */ #define NSLT2VDI(dst, src) \ dst = 0;\ @@ -52,6 +53,8 @@ static int lock( GEM_PLOTTER self ); static int unlock( GEM_PLOTTER self ); static int put_pixel(GEM_PLOTTER self, int x, int y, int color ); static int copy_rect( GEM_PLOTTER self, GRECT src, GRECT dst ); +static int set_clip(GEM_PLOTTER self, const struct rect * clip); +static int get_clip( GEM_PLOTTER self, struct rect * out ); static int arc(GEM_PLOTTER self,int x, int y, int radius, int angle1, int angle2, const plot_style_t * pstyle); static int disc(GEM_PLOTTER self,int x, int y, int radius, const plot_style_t * pstyle); static int line(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plot_style_t * pstyle); @@ -70,20 +73,28 @@ static int text(GEM_PLOTTER self, int x, int y, const char *text,size_t length, static inline void set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned char val ); static inline unsigned char get_stdpx(MFDB * dst, int wdplanesz, int x, int y ); + +/* + Set clipping for current framebuffer +*/ +static int plotter_std_clip(GEM_PLOTTER self, const struct rect * clip); -#ifdef WITH_8BPP_SUPPORT -static unsigned short sys_pal[256][3]; /*RGB*/ -static unsigned short pal[256][3]; /*RGB*/ -static char rgb_lookup[256][4]; -extern unsigned short vdi_web_pal[126][3]; -#endif extern struct s_vdi_sysinfo vdi_sysinfo; 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]; + +#ifdef WITH_8BPP_SUPPORT +static unsigned short sys_pal[256][3]; /*RGB*/ +static unsigned short pal[256][3]; /*RGB*/ +static char rgb_lookup[256][4]; +extern unsigned short vdi_web_pal[216][3]; +#endif + static inline void vsl_rgbcolor( short vdih, uint32_t cin ) { @@ -117,7 +128,143 @@ static inline void vsf_rgbcolor( short vdih, uint32_t cin ) } } -int ctor_plotter_vdi(GEM_PLOTTER self ) +static int set_clip(GEM_PLOTTER self, const struct rect * clip) +{ + VIEW( self ).clipping.x0 = clip->x0; + VIEW( self ).clipping.y0 = clip->y0; + VIEW( self ).clipping.x1 = clip->x1; + VIEW( self ).clipping.y1 = clip->y1; + return ( 1 ); +} + +static int get_clip( GEM_PLOTTER self, struct rect * out ) +{ + out->x0 = VIEW( self ).clipping.x0; + out->y0 = VIEW( self ).clipping.y0; + out->x1 = VIEW( self ).clipping.x1; + out->y1 = VIEW( self ).clipping.y1; + return( 1 ); +} + +/* + Get current visible coords +*/ +static inline void plotter_get_visible_grect( GEM_PLOTTER self, GRECT * out ) +{ + /*todo: !!! */ + out->g_x = VIEW( self ).clipping.x0; + out->g_y = VIEW( self ).clipping.y0; + out->g_w = VIEW( self ).clipping.x1 - VIEW( self ).clipping.x0; + out->g_h = VIEW( self ).clipping.y1 - VIEW( self ).clipping.y0; +} + + +/* + 1. calculate visible area of framebuffer in coords relative to framebuffer position + + result: + this function should calc offsets into x,y coords of the framebuffer which + can be drawn. If the framebuffer coords do not fall within the screen region, + all values of visible region are set to zero. +*/ +static inline void update_visible_rect( GEM_PLOTTER p ) +{ + 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(p).x; + common.g_y = frame.g_y = VIEW(p).y; + common.g_w = frame.g_w = VIEW(p).w; + common.g_h = frame.g_h = VIEW(p).h; + + if( rc_intersect( &screen, &common ) ) { + VIEW(p).vis_w = common.g_w; + VIEW(p).vis_h = common.g_h; + if( VIEW(p).x < screen.g_x ) + VIEW(p).vis_x = frame.g_w - common.g_w; + else + VIEW(p).vis_x = 0; + if( VIEW(p).y get_clip( self, &c ); + vq_extnd( self->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(self).x + MAX(c.x0, 0); + newclip[1] = VIEW(self).y + MAX(c.y0, 0); + newclip[2] = MIN(VIEW(self).x+VIEW(self).w, newclip[0] + (c.x1 - c.x0) )-1; + newclip[3] = MIN(VIEW(self).y+VIEW(self).h, newclip[1] + (c.y1 - c.y0) )-1; + vs_clip( self->vdi_handle, 1, (short*)&newclip ); + } else { + vs_clip( self->vdi_handle, 1, (short *)&prev_vdi_clip ); + } +} + +int ctor_plotter_vdi( GEM_PLOTTER self , GRECT * loc_size ) { int retval = 0; int i; @@ -130,7 +277,8 @@ int ctor_plotter_vdi(GEM_PLOTTER self ) self->unlock = unlock; self->put_pixel = put_pixel; self->copy_rect = copy_rect; - self->clip = plotter_std_clip; + self->set_clip = set_clip; + self->get_clip = get_clip; self->arc = arc; self->disc = disc; self->line = line; @@ -139,12 +287,13 @@ int ctor_plotter_vdi(GEM_PLOTTER self ) self->path = path; self->bitmap = bitmap; self->bitmap_resize = bitmap_resize; + /* override virtual bpp - must be in sync with screen for this driver: */ + self->bpp_virt = app.nplanes; #ifdef WITH_8BPP_SUPPORT self->bitmap_convert =(app.nplanes > 8) ? bitmap_convert : bitmap_convert_8; #else self->bitmap_convert = bitmap_convert; #endif - //self->bitmap_convert =bitmap_convert; self->plot_mfdb = plot_mfdb; self->text = text; LOG(("Screen: x: %d, y: %d\n", vdi_sysinfo.scr_w, vdi_sysinfo.scr_h)); @@ -153,6 +302,11 @@ int ctor_plotter_vdi(GEM_PLOTTER self ) if( self->priv_data == NULL ) return( 0-ERR_NO_MEM ); memset( self->priv_data, 0, sizeof(struct s_vdi_priv_data) ); + memset( &VIEW(self), 0, sizeof( struct s_view) ); + VIEW( self ).x = loc_size->g_x; + VIEW( self ).y = loc_size->g_y; + VIEW( self ).w = loc_size->g_w; + VIEW( self ).h = loc_size->g_h; DUMMY_PRIV(self)->bufops = 0; DUMMY_PRIV(self)->size_buf_packed = 0; DUMMY_PRIV(self)->size_buf_planar = 0; @@ -164,20 +318,15 @@ int ctor_plotter_vdi(GEM_PLOTTER self ) DUMMY_PRIV(self)->bufops = C2P; self->bpp_virt = 8; } - if( FIRSTFB(self).w > vdi_sysinfo.scr_w || FIRSTFB(self).h > vdi_sysinfo.scr_h ){ - return( 0-ERR_BUFFERSIZE_EXCEEDS_SCREEN ); - } - FIRSTFB(self).size = calc_chunked_buffer_size( FIRSTFB(self).w, FIRSTFB(self).h, FIRSTFB(self).w, self->bpp_virt ); - /* offscreen: FIRSTFB(self).mem = malloc( FIRSTFB(self).size ); */ - FIRSTFB(self).mem = NULL; + VIEW(self).mem = NULL; update_visible_rect( self ); clip.x0 = 0; clip.y0 = 0; - clip.x1 = FIRSTFB(self).w; - clip.y1 = FIRSTFB(self).h; - self->clip( self, &clip ); + clip.x1 = VIEW(self).w; + clip.y1 = VIEW(self).h; + self->set_clip( self, &clip ); assert( Hermes_Init() ); /* store system palette & setup the new (web) palette: */ @@ -254,10 +403,9 @@ static int dtor( GEM_PLOTTER self ) { int i=0; LOG(("%s: %s\n", (char*)__FILE__, __FUNCTION__)); - for( i=0; ifbuf[i].mem != NULL ) - free( self->fbuf[i].mem ); - } + + if( VIEW(self).mem ) + free( VIEW(self).mem ); #ifdef WITH_8BPP_SUPPORT for( i=OFFSET_WEB_PAL; ibpp_virt ); - LOG(("%s: %s, oldsize: %d\n", (char*)__FILE__, __FUNCTION__, CURFB(self).size )); - if( newsize > self->screen_buffer_size ) { - self->screen_buffer_size = newsize; - self->screen_buffer =realloc( self->screen_buffer , self->screen_buffer_size ); - } - */ - CURFB(self).w = w; - CURFB(self).h = h; + VIEW(self).w = w; + VIEW(self).h = h; update_visible_rect( self ); - LOG(("%s: %s, newsize: %d\n", (char*)__FILE__, (char*)__FUNCTION__, CURFB(self).size )); + LOG(("%s: %s\n", (char*)__FILE__, (char*)__FUNCTION__)); return( 1 ); } static int move( GEM_PLOTTER self,short x, short y ) { bool upd; - if(x == CURFB(self).x && y == CURFB(self).y ){ + if(x == VIEW(self).x && y == VIEW(self).y ){ return 1; } LOG(("%s: x: %d, y: %d\n",(char*)__FUNCTION__, x, y)); - CURFB(self).x = x; - CURFB(self).y = y; + VIEW(self).x = x; + VIEW(self).y = y; update_visible_rect( self ); return( 1 ); } @@ -364,10 +504,10 @@ static int copy_rect( GEM_PLOTTER self, GRECT src, GRECT dst ) if( !rc_intersect(&vis, &dst) ) return 1; - src.g_x = CURFB(self).x + src.g_x; - src.g_y = CURFB(self).y + src.g_y; - dst.g_x = CURFB(self).x + dst.g_x; - dst.g_y = CURFB(self).y + dst.g_y; + src.g_x = VIEW(self).x + src.g_x; + src.g_y = VIEW(self).y + src.g_y; + dst.g_x = VIEW(self).x + dst.g_x; + dst.g_y = VIEW(self).y + dst.g_y; devmf.fd_addr = NULL; devmf.fd_w = src.g_w; @@ -410,12 +550,12 @@ static int arc(GEM_PLOTTER self,int x, int y, int radius, int angle1, int angle2 vsl_rgbcolor( self->vdi_handle, pstyle->stroke_colour); vsf_perimeter( self->vdi_handle, 1); vsf_interior( self->vdi_handle, 1 ); - v_arc( self->vdi_handle, CURFB(self).x + x, CURFB(self).y + y, radius, angle1*10, angle2*10 ); + v_arc( self->vdi_handle, VIEW(self).x + x, VIEW(self).y + y, radius, angle1*10, angle2*10 ); } else { vsf_rgbcolor( self->vdi_handle, pstyle->fill_colour); vsl_width( self->vdi_handle, 1 ); vsf_perimeter( self->vdi_handle, 1); - v_arc( self->vdi_handle, CURFB(self).x + x, CURFB(self).y + y, radius, angle1*10, angle2*10 ); + v_arc( self->vdi_handle, VIEW(self).x + x, VIEW(self).y + y, radius, angle1*10, angle2*10 ); } //plotter_vdi_clip( self, 0); return ( 1 ); @@ -428,12 +568,12 @@ static int disc(GEM_PLOTTER self,int x, int y, int radius, const plot_style_t * vsf_rgbcolor( self->vdi_handle, pstyle->stroke_colour ); vsf_perimeter( self->vdi_handle, 1); vsf_interior( self->vdi_handle, 0 ); - v_circle( self->vdi_handle, CURFB(self).x + x, CURFB(self).y + y, radius ); + v_circle( self->vdi_handle, VIEW(self).x + x, VIEW(self).y + y, radius ); } else { vsf_rgbcolor( self->vdi_handle, pstyle->fill_colour ); vsf_perimeter( self->vdi_handle, 0); vsf_interior( self->vdi_handle, FIS_SOLID ); - v_circle( self->vdi_handle, CURFB(self).x + x, CURFB(self).y + y, radius ); + v_circle( self->vdi_handle, VIEW(self).x + x, VIEW(self).y + y, radius ); } plotter_vdi_clip( self, 0); return ( 1 ); @@ -446,10 +586,10 @@ static int line(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plot_styl uint32_t lt; int sw = pstyle->stroke_width; - pxy[0] = CURFB(self).x + x0; - pxy[1] = CURFB(self).y + y0; - pxy[2] = CURFB(self).x + x1; - pxy[3] = CURFB(self).y + y1; + pxy[0] = VIEW(self).x + x0; + pxy[1] = VIEW(self).y + y0; + pxy[2] = VIEW(self).x + x1; + pxy[3] = VIEW(self).y + y1; plotter_vdi_clip( self, 1); if( sw == 0) @@ -475,16 +615,16 @@ static int rectangle(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plo uint32_t lt; /* current canvas clip: */ - rclip.g_x = self->clipping.x0; - rclip.g_y = self->clipping.y0; - rclip.g_w = self->clipping.x1 - self->clipping.x0; - rclip.g_h = self->clipping.y1 - self->clipping.y0; + rclip.g_x = VIEW( self ).clipping.x0; + rclip.g_y = VIEW( self ).clipping.y0; + rclip.g_w = VIEW( self ).clipping.x1 - VIEW( self ).clipping.x0; + rclip.g_h = VIEW( self ).clipping.y1 - VIEW( self ).clipping.y0; /* physical clipping: */ sclip.g_x = rclip.g_x; sclip.g_y = rclip.g_y; - sclip.g_w = CURFB(self).vis_w; - sclip.g_h = CURFB(self).vis_h; + sclip.g_w = VIEW(self).vis_w; + sclip.g_h = VIEW(self).vis_h; rc_intersect(&sclip, &rclip); r.g_x = x0; @@ -516,37 +656,37 @@ static int rectangle(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plo vsl_rgbcolor( self->vdi_handle, pstyle->stroke_colour ); /* top border: */ if( r.g_y == y0){ - pxy[0] = CURFB(self).x + r.g_x; - pxy[1] = CURFB(self).y + r.g_y ; - pxy[2] = CURFB(self).x + r.g_x + r.g_w; - pxy[3] = CURFB(self).y + r.g_y; + pxy[0] = VIEW(self).x + r.g_x; + pxy[1] = VIEW(self).y + r.g_y ; + pxy[2] = VIEW(self).x + r.g_x + r.g_w; + pxy[3] = VIEW(self).y + r.g_y; v_pline(self->vdi_handle, 2, (short *)&pxy ); } /* right border: */ if( r.g_x + r.g_w == x1 ){ - pxy[0] = CURFB(self).x + r.g_x + r.g_w; - pxy[1] = CURFB(self).y + r.g_y; - pxy[2] = CURFB(self).x + r.g_x + r.g_w; - pxy[3] = CURFB(self).y + r.g_y + r.g_h; + pxy[0] = VIEW(self).x + r.g_x + r.g_w; + pxy[1] = VIEW(self).y + r.g_y; + pxy[2] = VIEW(self).x + r.g_x + r.g_w; + pxy[3] = VIEW(self).y + r.g_y + r.g_h; v_pline(self->vdi_handle, 2, (short *)&pxy ); } /* bottom border: */ if( r.g_y+r.g_h == y1 ){ - pxy[0] = CURFB(self).x + r.g_x; - pxy[1] = CURFB(self).y + r.g_y+r.g_h; - pxy[2] = CURFB(self).x + r.g_x+r.g_w; - pxy[3] = CURFB(self).y + r.g_y+r.g_h; + pxy[0] = VIEW(self).x + r.g_x; + pxy[1] = VIEW(self).y + r.g_y+r.g_h; + pxy[2] = VIEW(self).x + r.g_x+r.g_w; + pxy[3] = VIEW(self).y + r.g_y+r.g_h; v_pline(self->vdi_handle, 2, (short *)&pxy ); } /* left border: */ if( r.g_x == x0 ){ - pxy[0] = CURFB(self).x + r.g_x; - pxy[1] = CURFB(self).y + r.g_y; - pxy[2] = CURFB(self).x + r.g_x; - pxy[3] = CURFB(self).y + r.g_y + r.g_h; + pxy[0] = VIEW(self).x + r.g_x; + pxy[1] = VIEW(self).y + r.g_y; + pxy[2] = VIEW(self).x + r.g_x; + pxy[3] = VIEW(self).y + r.g_y + r.g_h; v_pline(self->vdi_handle, 2, (short *)&pxy ); } } @@ -561,10 +701,10 @@ static int rectangle(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plo vsf_interior( self->vdi_handle, FIS_SOLID ); - pxy[0] = CURFB(self).x + r.g_x + stroke_width; - pxy[1] = CURFB(self).y + r.g_y + stroke_width; - pxy[2] = CURFB(self).x + r.g_x + r.g_w -1 - stroke_width ; - pxy[3] = CURFB(self).y + r.g_y + r.g_h -1 - stroke_width; + pxy[0] = VIEW(self).x + r.g_x + stroke_width; + pxy[1] = VIEW(self).y + r.g_y + stroke_width; + pxy[2] = VIEW(self).x + r.g_x + r.g_w -1 - stroke_width ; + pxy[3] = VIEW(self).y + r.g_y + r.g_h -1 - stroke_width; vsf_style( self->vdi_handle, 1); v_bar( self->vdi_handle, (short*)&pxy ); @@ -584,8 +724,8 @@ static int polygon(GEM_PLOTTER self,const int *p, unsigned int n, const plot_st vsf_interior( self->vdi_handle, FIS_SOLID ); vsf_style( self->vdi_handle, 1); for( i = 0; ifill_type == PLOT_OP_TYPE_SOLID){ vsf_rgbcolor( self->vdi_handle, pstyle->fill_colour); @@ -1261,10 +1401,10 @@ static int bitmap( GEM_PLOTTER self, struct bitmap * bmp, int x, int y, off.g_h = bmp->height; off.g_w = bmp->width; - clip.g_x = self->clipping.x0; - clip.g_y = self->clipping.y0; - clip.g_w = self->clipping.x1 - self->clipping.x0; - clip.g_h = self->clipping.y1 - self->clipping.y0; + clip.g_x = VIEW( self ).clipping.x0; + clip.g_y = VIEW( self ).clipping.y0; + clip.g_w = VIEW( self ).clipping.x1 - VIEW( self ).clipping.x0; + clip.g_h = VIEW( self ).clipping.y1 - VIEW( self ).clipping.y0; if( !rc_intersect( &clip, &off) ) { return( true ); @@ -1285,10 +1425,10 @@ static int bitmap( GEM_PLOTTER self, struct bitmap * bmp, int x, int y, pxy[1] = 0; pxy[2] = off.g_w-1; pxy[3] = off.g_h-1; - pxy[4] = CURFB(self).x + loc.g_x; - pxy[5] = CURFB(self).y + loc.g_y; - pxy[6] = CURFB(self).x + loc.g_x + off.g_w-1; - pxy[7] = CURFB(self).y + loc.g_y + off.g_h-1; + pxy[4] = VIEW(self).x + loc.g_x; + pxy[5] = VIEW(self).y + loc.g_y; + pxy[6] = VIEW(self).x + loc.g_x + off.g_w-1; + 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 ) { @@ -1342,8 +1482,8 @@ static int plot_mfdb (GEM_PLOTTER self, GRECT * loc, MFDB * insrc, unsigned char 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] = CURFB(self).x + off.g_x; - pxy[5] = CURFB(self).y + off.g_y; + pxy[4] = VIEW(self).x + off.g_x; + pxy[5] = VIEW(self).y + off.g_y; pxy[6] = pxy[4] + off.g_w-1; pxy[7] = pxy[5] + off.g_h-1; diff --git a/atari/plot/plotter_vdi.h b/atari/plot/plotter_vdi.h index 61c49aba1..0dd8dcb17 100755 --- a/atari/plot/plotter_vdi.h +++ b/atari/plot/plotter_vdi.h @@ -19,7 +19,23 @@ #define GEM_PLOTTER_DUMMY_H_INCLUDED #include "plotter.h" -#include +#include + +struct s_view +{ + short x; /* drawing (screen) offset x */ + short y; /* drawing (screen) offset y */ + short w; /* width of buffer, not in sync with vis_w */ + short h; /* height of buffer, not in sync with vis_w */ + short vis_x; /* visible rectangle of the screen buffer */ + short vis_y; /* coords are relative to plot location */ + short vis_w; /* clipped to screen dimensions */ + short vis_h; /* */ + struct rect clipping; + int size; + bool swapped; + void * mem; +}; struct s_vdi_priv_data { short bufops; @@ -48,7 +64,12 @@ struct s_vdi_priv_data { /* no screen format here, hermes may not suitable for it */ /* netsurf source bitmap format */ - HermesFormat nsfmt; + HermesFormat nsfmt; + + /* Some internal structure used everywhere */ + /* trying to describe screen position, plotting origins and maxmimum */ + /* extent. */ + struct s_view view; }; /* how much memory should be kept allocated for temp. conversion bitmaps: */ @@ -57,10 +78,12 @@ struct s_vdi_priv_data { #define CONV_BLOCK_SIZE 32000 /* this is an shortcut cast to access the members of the s_vdi_priv_data */ -#define DUMMY_PRIV(self) ((struct s_vdi_priv_data*)self->priv_data) +#define DUMMY_PRIV(_self) ((struct s_vdi_priv_data*)_self->priv_data) + +#define VIEW( priv ) DUMMY_PRIV( priv )->view /* Each driver object must export 1 it's own constructor: */ -int ctor_plotter_vdi( GEM_PLOTTER p ); +int ctor_plotter_vdi( GEM_PLOTTER p, GRECT * loc_size ); /* * Capture the screen at x,y location -- cgit v1.2.3