From c59b173d21074474b5267f3d39c56302855367df Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Tue, 1 Feb 2011 21:27:29 +0000 Subject: Improved drawing primitives for true color systems. svn path=/trunk/netsurf/; revision=11592 --- atari/plot/plotter.c | 7 ++- atari/plot/plotter.h | 27 +----------- atari/plot/plotter_vdi.c | 110 ++++++++++++++++++++++++++++++++--------------- 3 files changed, 80 insertions(+), 64 deletions(-) diff --git a/atari/plot/plotter.c b/atari/plot/plotter.c index 712499a77..6f9ba750e 100755 --- a/atari/plot/plotter.c +++ b/atari/plot/plotter.c @@ -642,10 +642,9 @@ void dump_font_drivers(void) */ void rgb_to_vdi1000( unsigned char * in, unsigned short * out ) { - - double r = ((double)in[0]/255); /* prozentsatz red */ - double g = ((double)in[1]/255); /* prozentsatz green */ - double b = ((double)in[2]/255); /* prozentsatz blue */ + double r = ((double)in[3]/255); /* prozentsatz red */ + double g = ((double)in[2]/255); /* prozentsatz green */ + 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; diff --git a/atari/plot/plotter.h b/atari/plot/plotter.h index 7f4794086..7bca2c200 100755 --- a/atari/plot/plotter.h +++ b/atari/plot/plotter.h @@ -212,30 +212,6 @@ struct s_gem_plotter _pmf_bitmap bitmap; _pmf_text text; _pmf_dtor dtor; -/* - int (*move)(GEM_PLOTTER self, short x, short y ); - void * (*lock)(GEM_PLOTTER self); - void * (*create_framebuffer)(GEM_PLOTTER self); - void * (*switch_to_framebuffer)(GEM_PLOTTER self); - int (*unlock)(GEM_PLOTTER self); - int (*update_region)(GEM_PLOTTER self, GRECT region); - int (*update_screen_region)( GEM_PLOTTER self, GRECT region ); - int (*update_screen)(GEM_PLOTTER self); - int (*put_pixel)(GEM_PLOTTER self, int x, int y, int color ); - int (*copy_rect)(GEM_PLOTTER self, GRECT src, GRECT dst ); - int (*clip)(GEM_PLOTTER self, int x0, int y0, int x1, int y1); - int (*arc)(GEM_PLOTTER self, int x, int y, int radius, int angle1, int angle2, const plot_style_t * pstyle); - int (*disc)(GEM_PLOTTER self, int x, int y, int radius, const plot_style_t * pstyle); - int (*line)(GEM_PLOTTER self, int x0, int y0, int x1, int y1, const plot_style_t * pstyle); - int (*rectangle)(GEM_PLOTTER self, int x0, int y0, int x1, int y1, const plot_style_t * pstyle); - int (*polygon)(GEM_PLOTTER self, const int *p, unsigned int n, const plot_style_t * pstyle); - int (*path)(GEM_PLOTTER self, const float *p, unsigned int n, int fill, float width, int c, const float transform[6]); - int (*bitmap_resize) ( GEM_PLOTTER self, struct bitmap * bm, int nw, int nh ); - int (*bitmap)(GEM_PLOTTER self, struct bitmap * bmp, int x, int y, - unsigned long bg, unsigned long flags ); - int (*text)(GEM_PLOTTER self, int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle); - int (*dtor)(GEM_PLOTTER self); -*/ }; @@ -361,7 +337,8 @@ void plotter_vdi_clip( GEM_PLOTTER self, bool set); p->fbuf[0] #define OFFSET_WEB_PAL 16 -#define OFFSET_FONT_PAL 232 +#define OFFSET_CUST_PAL 232 +#define OFFSET_CUSTOM_COLOR 255 #define RGB_TO_VDI(c) rgb_to_666_index( (c&0xFF),(c&0xFF00)>>8,(c&0xFF0000)>>16)+OFFSET_WEB_PAL #define ABGR_TO_RGB(c) ( ((c&0xFF)<<16) | (c&0xFF00) | ((c&0xFF0000)>>16) ) << 8 diff --git a/atari/plot/plotter_vdi.c b/atari/plot/plotter_vdi.c index 45640df57..b2e85fe63 100755 --- a/atari/plot/plotter_vdi.c +++ b/atari/plot/plotter_vdi.c @@ -78,6 +78,45 @@ static HermesHandle hermes_cnv_h; /* hermes converter instance handle */ static HermesHandle hermes_res_h; int32 * hermes_pal_p; +/* +static inline void vs_rgbcolor(short vdih, uint32_t cin ) +{ + unsigned short c[4]; + rgb_to_vdi1000( &cin, &c ); + vs_color( vdih, OFFSET_CUST_PAL, &c[0] ); +} +*/ + +static inline void vsl_rgbcolor( short vdih, uint32_t cin ) +{ + if( vdi_sysinfo.scr_bpp > 8 ) { + unsigned short c[4]; + rgb_to_vdi1000( (unsigned char*)&cin, (unsigned short*)&c ); + vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c[0] ); + vsl_color( vdih, OFFSET_CUSTOM_COLOR ); + } else { + if( vdi_sysinfo.scr_bpp >= 4 ) + vsl_color( vdih, RGB_TO_VDI(cin) ); + else + vsl_color( vdih, BLACK ); + } +} + +static inline void vsf_rgbcolor( short vdih, uint32_t cin ) +{ + if( vdi_sysinfo.scr_bpp > 8 ) { + unsigned short c[4]; + rgb_to_vdi1000( (unsigned char*)&cin, (unsigned short*)&c ); + vs_color( vdih, OFFSET_CUSTOM_COLOR, &c[0] ); + vsf_color( vdih, OFFSET_CUSTOM_COLOR ); + } else { + if( vdi_sysinfo.scr_bpp >= 4 ) + vsf_color( vdih, RGB_TO_VDI(cin) ); + else + vsf_color( vdih, WHITE ); + } +} + int ctor_plotter_vdi(GEM_PLOTTER self ) { int retval = 0; @@ -130,24 +169,28 @@ int ctor_plotter_vdi(GEM_PLOTTER self ) self->clip( self, 0, 0, FIRSTFB(self).w, FIRSTFB(self).h ); /* store system palette & setup the new (web) palette: */ i = 0; - for( i=0; i<=255; i++ ) { - vq_color(self->vdi_handle, i, 1, (unsigned short*)&sys_pal[i][0] ); - if( i= OFFSET_FONT_PAL ) { - /* here we could define some additional colors... */ - /* rgb_to_vdi1000( &rgb_font_pal[i-OFFSET_FONT_PAL], &pal[i] ); */ + if( app.nplanes <= 8 ){ + for( i=0; i<=255; i++ ) { + vq_color(self->vdi_handle, i, 1, (unsigned short*)&sys_pal[i][0] ); + if( i= 8 ) { + if ( i < OFFSET_CUST_PAL ){ + pal[i][0] = vdi_web_pal[i-OFFSET_WEB_PAL][0]; + pal[i][1] = vdi_web_pal[i-OFFSET_WEB_PAL][1]; + pal[i][2] = vdi_web_pal[i-OFFSET_WEB_PAL][2]; + } + if( i >= OFFSET_CUST_PAL ) { + /* here we could define 22 additional colors... */ + /* rgb_to_vdi1000( &rgb_font_pal[i-OFFSET_FONT_PAL], &pal[i] ); */ + } + vs_color( self->vdi_handle, i, &pal[i][0] ); } - vs_color( self->vdi_handle, i, &pal[i][0] ); } + } else { + /* no need to change the palette - its application specific */ } unsigned char * col; @@ -156,7 +199,7 @@ int ctor_plotter_vdi(GEM_PLOTTER self ) hermes_pal_p = Hermes_PaletteGet(hermes_pal_h); assert(hermes_pal_p); - for( i = 0; ifbuf[i].mem ); } - /* restore system palette */ - for( i=0; i<=255; i++ ) { - vs_color( self->vdi_handle, i, &sys_pal[i][0] ); + if( app.nplanes <= 8 ){ + /* restore system palette */ + for( i=0; i<=255; i++ ) { + vs_color( self->vdi_handle, i, &sys_pal[i][0] ); + } } /* close Hermes stuff: */ @@ -453,12 +498,12 @@ static int arc(GEM_PLOTTER self,int x, int y, int radius, int angle1, int angle2 if( pstyle->fill_type == PLOT_OP_TYPE_NONE ) return 1; if( pstyle->fill_type != PLOT_OP_TYPE_SOLID) { - vsl_color( self->vdi_handle, RGB_TO_VDI(pstyle->stroke_colour) ); + 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 ); } else { - vsl_color( self->vdi_handle, RGB_TO_VDI(pstyle->fill_colour) ); + 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 ); @@ -471,12 +516,12 @@ static int disc(GEM_PLOTTER self,int x, int y, int radius, const plot_style_t * { plotter_vdi_clip( self, 1); if( pstyle->fill_type != PLOT_OP_TYPE_SOLID) { - vsf_color( self->vdi_handle, RGB_TO_VDI(pstyle->stroke_colour) ); + 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 ); } else { - vsf_color( self->vdi_handle, RGB_TO_VDI(pstyle->fill_colour) ); + 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 ); @@ -485,6 +530,7 @@ static int disc(GEM_PLOTTER self,int x, int y, int radius, const plot_style_t * return ( 1 ); } + static int line(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plot_style_t * pstyle) { short pxy[4]; @@ -500,10 +546,7 @@ static int line(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plot_styl NSLT2VDI(lt, pstyle) vsl_type( self->vdi_handle, lt ); vsl_width( self->vdi_handle, (short)sw ); - if( vdi_sysinfo.scr_bpp > 4) - vsl_color( self->vdi_handle, RGB_TO_VDI(pstyle->stroke_colour) ); - else - vsl_color( self->vdi_handle, BLACK ); + vsl_rgbcolor( self->vdi_handle, pstyle->stroke_colour ); v_pline(self->vdi_handle, 2, (short *)&pxy ); /* plotter_vdi_clip( self, 0); */ return ( 1 ); @@ -534,10 +577,7 @@ static int rectangle(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plo if( !rc_intersect( &rclip, &r ) ) { return( 1 ); } - if( vdi_sysinfo.scr_bpp > 4) - vsf_color( self->vdi_handle, RGB_TO_VDI(pstyle->fill_colour) ); - else - vsf_color( self->vdi_handle, WHITE ); + vsf_rgbcolor( self->vdi_handle, pstyle->fill_colour ); vsf_perimeter( self->vdi_handle, 0); vsf_interior( self->vdi_handle, FIS_SOLID ); @@ -555,7 +595,7 @@ static int rectangle(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plo static int polygon(GEM_PLOTTER self,const int *p, unsigned int n, const plot_style_t * pstyle) { - short pxy[n+2]; + short pxy[n*2]; unsigned int i=0; short d[4]; if( vdi_sysinfo.maxpolycoords > 0 ) @@ -574,13 +614,13 @@ static int polygon(GEM_PLOTTER self,const int *p, unsigned int n, const plot_st pxy[i+1] = (short)CURFB(self).y+p[i+1]; } if( pstyle->fill_type == PLOT_OP_TYPE_SOLID){ - vsf_color( self->vdi_handle, BLACK); + vsf_rgbcolor( self->vdi_handle, pstyle->fill_colour); v_fillarea(self->vdi_handle, n, (short*)&pxy); } else { pxy[n*2]=pxy[0]; pxy[n*2+1]=pxy[1]; - vsl_color( self->vdi_handle, BLACK ); + vsl_rgbcolor( self->vdi_handle, pstyle->stroke_colour); v_pline(self->vdi_handle, n+1, (short *)&pxy ); } /* plotter_vdi_clip( self, 0); */ -- cgit v1.2.3