Added support for 8bit displays, having big problems with transparent plots ( snapshot of background isn't always taken from correct position, maybe a bug in fvdi)

svn path=/trunk/netsurf/; revision=13359
This commit is contained in:
Ole Loots 2011-12-31 15:21:49 +00:00
parent 7124d96b1f
commit a195728c51
4 changed files with 963 additions and 688 deletions

View File

@ -627,10 +627,20 @@ void rgb_to_vdi1000( unsigned char * in, unsigned short * out )
out[2] = 1000 * b + 0.5;
return;
}
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 */
out[2] = 255 * r + 0.5;
out[1] = 255 * g + 0.5;
out[0] = 255 * b + 0.5;
return;
}
static short web_std_colors[6] = {0, 51, 102, 153, 204, 255};
static short web_std_colors[6] = {0, 51, 102, 153, 204, 255};
/*
Convert an RGB color into an index into the 216 colors web pallette
@ -640,7 +650,20 @@ short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b)
short ret = 0;
short i;
unsigned char rgb[3] = {r,g,b};
unsigned char tval[3];
unsigned char tval[3];
int diff_a, diff_b, diff_c;
diff_a = abs(r-g);
diff_b = abs(r-b);
diff_c = abs(r-b);
if( diff_a < 2 && diff_b < 2 && diff_c < 2 ){
if( (r!=0XFF) && (g!=0XFF) && (g!=0XFF) ){
if( ((r&0xF0)>>4) != 0 )
//printf("conv gray: %x -> %d\n", ((r&0xF0)>>4) , (OFFSET_CUST_PAL) + ((r&0xF0)>>4) );
return( (OFFSET_CUST_PAL - OFFSET_WEB_PAL) + ((r&0xF0)>>4) );
}
}
/* convert each 8bit color to 6bit web color: */
for( i=0; i<3; i++) {
if(0 == rgb[i] % web_std_colors[1] ) {

View File

@ -164,6 +164,8 @@ typedef int (*_pmf_rectangle)(GEM_PLOTTER self, int x0, int y0, int x1, int y1,
typedef int (*_pmf_polygon)(GEM_PLOTTER self, const int *p, unsigned int n, const plot_style_t * pstyle);
typedef int (*_pmf_path)(GEM_PLOTTER self, const float *p, unsigned int n, int fill, float width, int c, const float transform[6]);
typedef int (*_pmf_bitmap_resize) ( GEM_PLOTTER self, struct bitmap * bm, int nw, int nh );
typedef int (*_pmf_bitmap_convert)( GEM_PLOTTER self, struct bitmap * img, int x, int y,
GRECT * clip, uint32_t bg, uint32_t flags, MFDB *out );
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, uint32_t flags);
@ -208,7 +210,9 @@ struct s_gem_plotter
_pmf_polygon polygon;
_pmf_path path;
/* scale an netsurf bitmap: */
_pmf_bitmap_resize bitmap_resize;
_pmf_bitmap_resize bitmap_resize;
/* convert an ABGR (netsurf) bitmap to screen format, ready for vro_cpyfm */
_pmf_bitmap_convert bitmap_convert;
/* plot an netsurf bitmap into the buffer / screen: */
_pmf_bitmap bitmap;
/* plot an mfdb into the buffer / screen: */
@ -290,6 +294,7 @@ const char* plotter_err_str(int i) ;
void dump_font_drivers(void);
void dump_plot_drivers(void);
void dump_vdi_info(short);
/* convert an rgb color to vdi1000 color */
void rgb_to_vdi1000( unsigned char * in, unsigned short * out );
@ -351,6 +356,7 @@ void plotter_vdi_clip( GEM_PLOTTER self, bool set);
#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) */

File diff suppressed because it is too large Load Diff

View File

@ -32,9 +32,14 @@ struct s_vdi_priv_data {
int size_buf_planar;
/* buffer for plot operations that require device format, */
/* currently used for transparent mfdb blits: */
/* currently used for transparent mfdb blits and snapshots: */
MFDB buf_scr;
int size_buf_scr;
int size_buf_scr;
/* buffer for std form, used during 8bpp snapshot */
MFDB buf_std;
int size_buf_std;
struct bitmap * buf_scr_compat;
/* intermediate bitmap format */