27#include <mint/osbind.h>
75#ifdef WITH_8BPP_SUPPORT
76static unsigned short sys_pal[256][3];
77static unsigned short pal[256][3];
78static char rgb_lookup[256][4];
79short web_std_colors[6] = {0, 51, 102, 153, 204, 255};
81unsigned short vdi_web_pal[216][3] = {
82 {0x000,0x000,0x000}, {0x0c8,0x000,0x000}, {0x190,0x000,0x000},
83 {0x258,0x000,0x000}, {0x320,0x000,0x000}, {0x3e8,0x000,0x000},
84 {0x000,0x0c8,0x000}, {0x0c8,0x0c8,0x000}, {0x190,0x0c8,0x000},
85 {0x258,0x0c8,0x000}, {0x320,0x0c8,0x000}, {0x3e8,0x0c8,0x000},
86 {0x000,0x190,0x000}, {0x0c8,0x190,0x000}, {0x190,0x190,0x000},
87 {0x258,0x190,0x000}, {0x320,0x190,0x000}, {0x3e8,0x190,0x000},
88 {0x000,0x258,0x000}, {0x0c8,0x258,0x000}, {0x190,0x258,0x000},
89 {0x258,0x258,0x000}, {0x320,0x258,0x000}, {0x3e8,0x258,0x000},
90 {0x000,0x320,0x000}, {0x0c8,0x320,0x000}, {0x190,0x320,0x000},
91 {0x258,0x320,0x000}, {0x320,0x320,0x000}, {0x3e8,0x320,0x000},
92 {0x000,0x3e8,0x000}, {0x0c8,0x3e8,0x000}, {0x190,0x3e8,0x000},
93 {0x258,0x3e8,0x000}, {0x320,0x3e8,0x000}, {0x3e8,0x3e8,0x000},
94 {0x000,0x000,0x0c8}, {0x0c8,0x000,0x0c8}, {0x190,0x000,0x0c8},
95 {0x258,0x000,0x0c8}, {0x320,0x000,0x0c8}, {0x3e8,0x000,0x0c8},
96 {0x000,0x0c8,0x0c8}, {0x0c8,0x0c8,0x0c8}, {0x190,0x0c8,0x0c8},
97 {0x258,0x0c8,0x0c8}, {0x320,0x0c8,0x0c8}, {0x3e8,0x0c8,0x0c8},
98 {0x000,0x190,0x0c8}, {0x0c8,0x190,0x0c8}, {0x190,0x190,0x0c8},
99 {0x258,0x190,0x0c8}, {0x320,0x190,0x0c8}, {0x3e8,0x190,0x0c8},
100 {0x000,0x258,0x0c8}, {0x0c8,0x258,0x0c8}, {0x190,0x258,0x0c8},
101 {0x258,0x258,0x0c8}, {0x320,0x258,0x0c8}, {0x3e8,0x258,0x0c8},
102 {0x000,0x320,0x0c8}, {0x0c8,0x320,0x0c8}, {0x190,0x320,0x0c8},
103 {0x258,0x320,0x0c8}, {0x320,0x320,0x0c8}, {0x3e8,0x320,0x0c8},
104 {0x000,0x3e8,0x0c8}, {0x0c8,0x3e8,0x0c8}, {0x190,0x3e8,0x0c8},
105 {0x258,0x3e8,0x0c8}, {0x320,0x3e8,0x0c8}, {0x3e8,0x3e8,0x0c8},
106 {0x000,0x000,0x190}, {0x0c8,0x000,0x190}, {0x190,0x000,0x190},
107 {0x258,0x000,0x190}, {0x320,0x000,0x190}, {0x3e8,0x000,0x190},
108 {0x000,0x0c8,0x190}, {0x0c8,0x0c8,0x190}, {0x190,0x0c8,0x190},
109 {0x258,0x0c8,0x190}, {0x320,0x0c8,0x190}, {0x3e8,0x0c8,0x190},
110 {0x000,0x190,0x190}, {0x0c8,0x190,0x190}, {0x190,0x190,0x190},
111 {0x258,0x190,0x190}, {0x320,0x190,0x190}, {0x3e8,0x190,0x190},
112 {0x000,0x258,0x190}, {0x0c8,0x258,0x190}, {0x190,0x258,0x190},
113 {0x258,0x258,0x190}, {0x320,0x258,0x190}, {0x3e8,0x258,0x190},
114 {0x000,0x320,0x190}, {0x0c8,0x320,0x190}, {0x190,0x320,0x190},
115 {0x258,0x320,0x190}, {0x320,0x320,0x190}, {0x3e8,0x320,0x190},
116 {0x000,0x3e8,0x190}, {0x0c8,0x3e8,0x190}, {0x190,0x3e8,0x190},
117 {0x258,0x3e8,0x190}, {0x320,0x3e8,0x190}, {0x3e8,0x3e8,0x190},
118 {0x000,0x000,0x258}, {0x0c8,0x000,0x258}, {0x190,0x000,0x258},
119 {0x258,0x000,0x258}, {0x320,0x000,0x258}, {0x3e8,0x000,0x258},
120 {0x000,0x0c8,0x258}, {0x0c8,0x0c8,0x258}, {0x190,0x0c8,0x258},
121 {0x258,0x0c8,0x258}, {0x320,0x0c8,0x258}, {0x3e8,0x0c8,0x258},
122 {0x000,0x190,0x258}, {0x0c8,0x190,0x258}, {0x190,0x190,0x258},
123 {0x258,0x190,0x258}, {0x320,0x190,0x258}, {0x3e8,0x190,0x258},
124 {0x000,0x258,0x258}, {0x0c8,0x258,0x258}, {0x190,0x258,0x258},
125 {0x258,0x258,0x258}, {0x320,0x258,0x258}, {0x3e8,0x258,0x258},
126 {0x000,0x320,0x258}, {0x0c8,0x320,0x258}, {0x190,0x320,0x258},
127 {0x258,0x320,0x258}, {0x320,0x320,0x258}, {0x3e8,0x320,0x258},
128 {0x000,0x3e8,0x258}, {0x0c8,0x3e8,0x258}, {0x190,0x3e8,0x258},
129 {0x258,0x3e8,0x258}, {0x320,0x3e8,0x258}, {0x3e8,0x3e8,0x258},
130 {0x000,0x000,0x320}, {0x0c8,0x000,0x320}, {0x190,0x000,0x320},
131 {0x258,0x000,0x320}, {0x320,0x000,0x320}, {0x3e8,0x000,0x320},
132 {0x000,0x0c8,0x320}, {0x0c8,0x0c8,0x320}, {0x190,0x0c8,0x320},
133 {0x258,0x0c8,0x320}, {0x320,0x0c8,0x320}, {0x3e8,0x0c8,0x320},
134 {0x000,0x190,0x320}, {0x0c8,0x190,0x320}, {0x190,0x190,0x320},
135 {0x258,0x190,0x320}, {0x320,0x190,0x320}, {0x3e8,0x190,0x320},
136 {0x000,0x258,0x320}, {0x0c8,0x258,0x320}, {0x190,0x258,0x320},
137 {0x258,0x258,0x320}, {0x320,0x258,0x320}, {0x3e8,0x258,0x320},
138 {0x000,0x320,0x320}, {0x0c8,0x320,0x320}, {0x190,0x320,0x320},
139 {0x258,0x320,0x320}, {0x320,0x320,0x320}, {0x3e8,0x320,0x320},
140 {0x000,0x3e8,0x320}, {0x0c8,0x3e8,0x320}, {0x190,0x3e8,0x320},
141 {0x258,0x3e8,0x320}, {0x320,0x3e8,0x320}, {0x3e8,0x3e8,0x320},
142 {0x000,0x000,0x3e8}, {0x0c8,0x000,0x3e8}, {0x190,0x000,0x3e8},
143 {0x258,0x000,0x3e8}, {0x320,0x000,0x3e8}, {0x3e8,0x000,0x3e8},
144 {0x000,0x0c8,0x3e8}, {0x0c8,0x0c8,0x3e8}, {0x190,0x0c8,0x3e8},
145 {0x258,0x0c8,0x3e8}, {0x320,0x0c8,0x3e8}, {0x3e8,0x0c8,0x3e8},
146 {0x000,0x190,0x3e8}, {0x0c8,0x190,0x3e8}, {0x190,0x190,0x3e8},
147 {0x258,0x190,0x3e8}, {0x320,0x190,0x3e8}, {0x3e8,0x190,0x3e8},
148 {0x000,0x258,0x3e8}, {0x0c8,0x258,0x3e8}, {0x190,0x258,0x3e8},
149 {0x258,0x258,0x3e8}, {0x320,0x258,0x3e8}, {0x3e8,0x258,0x3e8},
150 {0x000,0x320,0x3e8}, {0x0c8,0x320,0x3e8}, {0x190,0x320,0x3e8},
151 {0x258,0x320,0x3e8}, {0x320,0x320,0x3e8}, {0x3e8,0x320,0x3e8},
152 {0x000,0x3e8,0x3e8}, {0x0c8,0x3e8,0x3e8}, {0x190,0x3e8,0x3e8},
153 {0x258,0x3e8,0x3e8}, {0x320,0x3e8,0x3e8}, {0x3e8,0x3e8,0x3e8}
160 "ERR_BUFFERSIZE_EXCEEDS_SCREEN",
162 "ERR_PLOTTER_NOT_AVAILABLE"
230#ifdef WITH_8BPP_SUPPORT
237#ifdef WITH_8BPP_SUPPORT
240 vsl_color(
vdih, RGB_TO_VDI(cin));
243 vsl_color(
vdih, BLACK);
257#ifdef WITH_8BPP_SUPPORT
264#ifdef WITH_8BPP_SUPPORT
267 vsf_color(
vdih, RGB_TO_VDI(cin) );
270 vsf_color(
vdih, WHITE );
311 if (rc_intersect(&screen, &
common)) {
314 if (
view.
x < screen.g_x)
318 if (
view.
y <screen.g_y)
337 GRECT out, vis, screen;
350 if ( !rc_intersect( &screen, &vis ) ) {
353 vis.g_x =
view.
w - vis.g_w;
354 vis.g_y =
view.
h - vis.g_h;
357 if( !rc_intersect(&vis, &
box) ) {
384 if( !rc_intersect(&vis, &src) )
386 if( !rc_intersect(&vis, &dst) )
389 src.g_x =
view.
x + src.g_x;
390 src.g_y =
view.
y + src.g_y;
391 dst.g_x =
view.
x + dst.g_x;
392 dst.g_y =
view.
y + dst.g_y;
394 devmf.fd_addr = NULL;
395 devmf.fd_w = src.g_w;
396 devmf.fd_h = src.g_h;
397 devmf.fd_wdwidth = 0;
399 devmf.fd_nplanes = 0;
400 devmf.fd_r1 = devmf.fd_r2 = devmf.fd_r3 = 0;
402 scrmf.fd_addr = NULL;
403 scrmf.fd_w = dst.g_w;
404 scrmf.fd_h = dst.g_h;
405 scrmf.fd_wdwidth = 0 ;
407 scrmf.fd_nplanes = 0;
408 scrmf.fd_r1 = scrmf.fd_r2 = scrmf.fd_r3 = 0;
412 pxy[2] = pxy[0] + src.g_w-1;
413 pxy[3] = pxy[1] + src.g_h-1;
416 pxy[6] = pxy[4] + dst.g_w-1;
417 pxy[7] = pxy[5] + dst.g_h-1;
435 unsigned long cookie_EdDI=0;
440 if (
tos_getcookie(C_EdDI, (
long *)&cookie_EdDI) == C_NOTFOUND ) {
446 memset( &out, 0,
sizeof(
short)*300 );
447 vq_extnd(
vdih, 0, (
short*)&out );
448 info->
scr_w = out[0]+1;
449 info->
scr_h = out[1]+1;
457 memset( &out, 0,
sizeof(
short)*300 );
458 vq_extnd(
vdih, 1, (
short*)&out );
495 memset( &out, 0,
sizeof(
short)*300 );
500 info->
hicolors = *((
unsigned long*) &out[3]);
502 info->
pitch = out[5];
503 info->
screen = (
void *) *((
unsigned long *) &out[6]);
506 switch( info->
clut ) {
515 unsigned short *tmp_p;
518 tmp_p = (
unsigned short *) &out[16];
519 for (component=0; component<5; component++) {
520 for (num_bit=0; num_bit<16; num_bit++) {
548 if ((info->
mask_g == ((7<<13)|3)) ||
549 (info->
mask_g == ((7<<13)|7))) {
566 double r = ((double)in[3]/255);
567 double g = ((double)in[2]/255);
568 double b = ((double)in[1]/255);
569 out->red = 1000 * r + 0.5;
570 out->green = 1000 * g + 0.5;
571 out->blue = 1000 * b + 0.5;
578 double r = ((double)in[0]/1000);
579 double g = ((double)in[1]/1000);
580 double b = ((double)in[2]/1000);
581 out[2] = 255 * r + 0.5;
582 out[1] = 255 * g + 0.5;
583 out[0] = 255 * b + 0.5;
588#ifdef WITH_8BPP_SUPPORT
593set_stdpx( MFDB * dst,
int wdplanesz,
int x,
int y,
unsigned char val )
596 short whichbit = (1<<(15-(x%16)));
599 buf += ((dst->fd_wdwidth*(y))+(x>>4));
601 *buf = (val&1) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
604 *buf = (val&(1<<1)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
607 *buf = (val&(1<<2)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
610 *buf = (val&(1<<3)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
613 *buf = (val&(1<<4)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
616 *buf = (val&(1<<5)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
619 *buf = (val&(1<<6)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
622 *buf = (val&(1<<7)) ? ((*buf)|(whichbit)) : ((*buf)&~(whichbit));
629inline static unsigned char get_stdpx(MFDB * dst,
int wdplanesz,
int x,
int y)
633 short whichbit = (1<<(15-(x%16)));
636 buf += ((dst->fd_wdwidth*(y))+(x>>4));
638 if( *buf & whichbit )
642 if( *buf & whichbit )
646 if( *buf & whichbit )
650 if( *buf & whichbit )
654 if( *buf & whichbit )
658 if( *buf & whichbit )
662 if( *buf & whichbit )
666 if( *buf & whichbit )
675inline short rgb_to_666_index(
unsigned char r,
unsigned char g,
unsigned char b)
678 unsigned char rgb[3] = {r,g,b};
679 unsigned char tval[3];
681 int diff_a, diff_b, diff_c;
685 if( diff_a < 2 && diff_b < 2 && diff_c < 2 ) {
686 if( (r!=0XFF) && (g!=0XFF) && (b!=0XFF) ) {
687 if( ((r&0xF0)>>4) != 0 )
689 return( (OFFSET_CUST_PAL - OFFSET_WEB_PAL) + ((r&0xF0)>>4) );
694 for( i=0; i<3; i++) {
695 if(0 == rgb[i] % web_std_colors[1] ) {
696 tval[i] = rgb[i] / web_std_colors[1];
698 int pos = ((short)rgb[i] / web_std_colors[1]);
699 if( abs(rgb[i] - web_std_colors[pos]) > abs(rgb[i] - web_std_colors[pos+1]) )
705 return(tval[2]*36+tval[1]*6+tval[0]);
714 printf(
"struct s_vdi_sysinfo {\n");
715 printf(
" short vdi_handle: %d\n", temp.
vdi_handle);
716 printf(
" short scr_w: %d \n", temp.
scr_w);
717 printf(
" short scr_h: %d\n", temp.
scr_h);
718 printf(
" short scr_bpp: %d\n", temp.
scr_bpp);
719 printf(
" int colors: %d\n", temp.
colors);
720 printf(
" ulong hicolors: %lu\n", temp.
hicolors);
721 printf(
" short pixelsize: %d\n", temp.
pixelsize);
722 printf(
" unsigned short pitch: %d\n", temp.
pitch);
723 printf(
" unsigned short vdiformat: %d\n", temp.
vdiformat);
724 printf(
" unsigned short clut: %d\n", temp.
clut);
725 printf(
" void * screen: 0x0%p\n", temp.
screen);
726 printf(
" unsigned long screensize: %lu\n", temp.
screensize);
727 printf(
" unsigned long mask_r: 0x0%08lx\n", temp.
mask_r);
728 printf(
" unsigned long mask_g: 0x0%08lx\n", temp.
mask_g);
729 printf(
" unsigned long mask_b: 0x0%08lx\n", temp.
mask_b);
730 printf(
" unsigned long mask_a: 0x0%08lx\n", temp.
mask_a);
731 printf(
" short maxintin: %d\n", temp.
maxintin);
733 printf(
" unsigned long EdDiVersion: 0x0%03lx\n", temp.
EdDiVersion);
734 printf(
" unsigned short rasterscale: 0x%2x\n", temp.
rasterscale);
753 buf_scr.fd_addr = malloc( scr_size );
770 buf_scr.fd_wdwidth = scr_stride >> 4;
771 assert(
buf_scr.fd_addr != NULL );
776 pxy[2] = pxy[0] + w-1;
777 pxy[3] = pxy[1] + h-1;
863 for (row = 0; row<(uint32_t)h; row++) {
865 uint32_t *rowptr = ((uint32_t*)
native->fd_addr + ((row*
native->fd_w)));
866 for (col=0; col<(uint32_t)w; col++) {
867 *(rowptr+col) = (*(rowptr+col)<<8);
890#ifdef WITH_8BPP_SUPPORT
933#ifdef WITH_8BPP_SUPPORT
940inline static uint32_t
ablend(uint32_t pixel, uint32_t scrpixel)
942 int opacity = pixel & 0xFF;
943 int transp = 0x100 - opacity;
947 rb = ((pixel & 0xFF00FF) * opacity +
948 (scrpixel & 0xFF00FF) * transp) >> 8;
949 g = ((pixel & 0x00FF00) * opacity +
950 (scrpixel & 0x00FF00) * transp) >> 8;
952 return ((rb & 0xFF00FF) | (g & 0xFF00)) << 8;
964 int img_x, img_y, img_stride;
968 for( img_y = 0; img_y <
clip->g_h; img_y++) {
969 imgrow = (uint32_t *)(img->
pixdata + (img_stride * img_y));
970 for( img_x = 0; img_x <
clip->g_w; img_x++ ) {
971 imgrow[img_x] =
ablend( imgrow[img_x], bg );
990 uint32_t * screenrow;
991 int img_x, img_y, bg_x, bg_y, img_stride, bg_stride;
997 for( img_y = img_clip->g_y, bg_y = 0; bg_y < img_clip->g_h; bg_y++, img_y++) {
998 imgrow = (uint32_t *)(img->
pixdata + (img_stride * img_y));
999 screenrow = (uint32_t *)(bg->
pixdata + (bg_stride * bg_y));
1000 for( img_x = img_clip->g_x, bg_x = 0; bg_x < img_clip->g_w; bg_x++, img_x++ ) {
1003 if( (imgrow[img_x] & 0x0FF) != 0 ){
1004 screenrow[bg_x] =
ablend( imgrow[img_x], screenrow[bg_x]);
1026#ifdef WITH_8BPP_SUPPORT
1031static MFDB * snapshot_create_std_mfdb(
int x,
int y,
int w,
int h)
1039 buf_std.fd_addr = malloc( scr_size );
1049 if(
buf_std.fd_addr == NULL ) {
1057 buf_std.fd_wdwidth = scr_stride >> 4;
1058 assert(
buf_std.fd_addr != NULL );
1080bitmap_convert_8(
struct bitmap *img,
1093 struct bitmap * scrbuf = NULL;
1105 assert(
clip->g_h > 0 );
1106 assert(
clip->g_w > 0 );
1124 assert(cache ==
false);
1130 if( cache ==
false ){
1155 assert( out->fd_addr == NULL );
1156 native.fd_addr = malloc( dstsize );
1157 if (
native.fd_addr == NULL){
1173 MFDB * bg = snapshot_create_std_mfdb(x, y,
clip->g_w,
clip->g_h);
1174 stdform.fd_addr = bg->fd_addr;
1196 stdform.fd_w = dststride;
1198 stdform.fd_wdwidth = dststride >> 4;
1199 stdform.fd_stand = 1;
1201 stdform.fd_r1 = stdform.fd_r2 = stdform.fd_r3 = 0;
1204 uint32_t prev_pixel = 0x12345678;
1205 unsigned long col = 0;
1206 unsigned char val = 0;
1209 int wdplanesize = stdform.fd_wdwidth*stdform.fd_h;
1213 unsigned long bgcol = 0;
1214 unsigned char prev_col = 0;
1215 for( y=0; y<
clip->g_h; y++ ){
1216 row = (uint32_t *)(img->
pixdata + (img_stride * (y+
clip->g_y)));
1217 for( x=0; x<
clip->g_w; x++ ){
1218 pixel = row[x+
clip->g_x];
1219 if( (pixel&0xFF) == 0 ){
1222 if( (pixel&0xFF) < 0xF0 ){
1223 col = get_stdpx( &stdform, wdplanesize,x,y );
1224 if( (col != prev_col) || (y == 0) )
1225 bgcol = (((rgb_lookup[col][2] << 16) | (rgb_lookup[col][1] << 8) | (rgb_lookup[col][0]))<<8);
1226 if( prev_col != col || prev_pixel != pixel ){
1228 pixel =
ablend( pixel, bgcol );
1232 col = ( ((pixel&0xFF)<<16)
1234 | ((pixel&0xFF0000)>>16) );
1235 val = RGB_TO_VDI( col );
1237 set_stdpx( &stdform, wdplanesize, x, y, val );
1239 if( pixel != prev_pixel ){
1242 col = ( ((pixel&0xFF)<<16)
1244 | ((pixel&0xFF0000)>>16) );
1245 val = RGB_TO_VDI( col );
1248 set_stdpx( &stdform, wdplanesize, x, y, val );
1257 for( y=0; y < bh; y++ ){
1258 row = (uint32_t *)(img->
pixdata + (img_stride * y));
1259 for( x=0; x < bw; x++ ){
1261 if( pixel != prev_pixel ){
1264 col = ( ((pixel&0xFF)<<16)
1266 | ((pixel&0xFF0000)>>16) );
1267 val = RGB_TO_VDI( col );
1270 set_stdpx( &stdform, wdplanesize, x, y, val );
1276 native.fd_w = stdform.fd_w;
1277 native.fd_h = stdform.fd_h;
1278 native.fd_wdwidth = stdform.fd_wdwidth;
1284 if( cache ==
true ){
1320 struct bitmap * scrbuf = NULL;
1321 struct bitmap * source = NULL;
1333 assert(
clip->g_h > 0 );
1334 assert(
clip->g_w > 0 );
1362 if ((
opaque ==
false )) {
1366 if( scrbuf != NULL ) {
1368 assert(
clip->g_w <= bw );
1369 assert(
clip->g_h <= bh );
1387 GRECT region = { 0, 0, bw, bh };
1397 if (cache ==
false) {
1408 if (scrbuf != NULL) {
1418 assert( out->fd_addr == NULL );
1419 out->fd_addr = (
void*)malloc( dstsize );
1420 if( out->fd_addr == NULL ){
1421 if( scrbuf != NULL )
1427 out->fd_w = dststride;
1429 out->fd_wdwidth = dststride >> 4;
1432 out->fd_r1 = out->fd_r2 = out->fd_r3 = 0;
1434 err = Hermes_ConverterRequest(
1459 if( cache ==
true ){
1483 unsigned long bg,
unsigned long flags )
1488 GRECT off,
clip, vis;
1489 int screen_x, screen_y;
1491 src_mf.fd_addr = NULL;
1492 scrmf.fd_addr = NULL;
1497 off.g_w = bmp->
width;
1505 if( !rc_intersect( &
clip, &off) ) {
1513 if( !rc_intersect( &vis, &off) ) {
1517 screen_x =
view.
x + off.g_x;
1518 screen_y =
view.
y + off.g_y;
1521 off.g_x = off.g_x - x;
1522 off.g_y = off.g_y - y;
1523 assert( (off.g_x >= 0) && (off.g_y >= 0) );
1527 if (
bitmap_convert(bmp, screen_x, screen_y, &off, bg, flags, &src_mf)
1535 pxy[2] = off.g_x + off.g_w-1;
1536 pxy[3] = off.g_y + off.g_h-1;
1541 pxy[6] = screen_x + off.g_w-1;
1542 pxy[7] = screen_y + off.g_h-1;
1558 short c[2] = {fgcolor, 0};
1562 if( rc_intersect(loc, &off) == 0 ){
1566 init_mfdb( 0, loc->g_w, loc->g_h, 0, &screen );
1592 pxy[0] = off.g_x - loc->g_x;
1593 pxy[1] = off.g_y - loc->g_y;
1594 pxy[2] = pxy[0] + off.g_w - 1;
1595 pxy[3] = pxy[1] + off.g_h - 1;
1596 pxy[4] =
view.
x + off.g_x;
1597 pxy[5] =
view.
y + off.g_y;
1598 pxy[6] = pxy[4] + off.g_w-1;
1599 pxy[7] = pxy[5] + off.g_h-1;
1614 GRECT loc_pos = { 0, 0, 360, 400 };
1627 short work_in[12] = {Getrez()+2,1,1,1,1,1,1,1,1,1,2,1};
1643 NSLOG(netsurf, INFO,
"Unable to load font plotter %s -> %s",
1645 die(
"font plotter");
1650 view.
x = loc_pos.g_x;
1651 view.
y = loc_pos.g_y;
1652 view.
w = loc_pos.g_w;
1653 view.
h = loc_pos.g_h;
1674 assert(Hermes_Init());
1676#ifdef WITH_8BPP_SUPPORT
1680 unsigned char rgbcol[4];
1682 unsigned char graytone=0;
1684 for( i=0; i<=255; i++ ) {
1688 if( i<OFFSET_WEB_PAL ) {
1689 pal[i][0] = sys_pal[i][0];
1690 pal[i][1] = sys_pal[i][1];
1691 pal[i][2] = sys_pal[i][2];
1693 if ( i < OFFSET_CUST_PAL ){
1694 pal[i][0] = vdi_web_pal[i-OFFSET_WEB_PAL][0];
1695 pal[i][1] = vdi_web_pal[i-OFFSET_WEB_PAL][1];
1696 pal[i][2] = vdi_web_pal[i-OFFSET_WEB_PAL][2];
1700 if( i >= OFFSET_CUST_PAL && i<OFFSET_CUST_PAL+16 ) {
1702 rgbcol[1] = rgbcol[2] = rgbcol[3] = ((graytone&0x0F) << 4);
1729 nsfmt.b = 0x0FF00UL;
1730 nsfmt.g = 0x0FF0000UL;
1731 nsfmt.r = 0x0FF000000UL;
1733 nsfmt.indexed =
false;
1734 nsfmt.has_colorkey =
false;
1742 vfmt.has_colorkey = 0;
1753#ifdef WITH_8BPP_SUPPORT
1756 for (i=OFFSET_WEB_PAL; i<OFFSET_CUST_PAL+16; i++) {
1779 if( !wind_update(BEG_UPDATE|0x100) )
1781 if( !wind_update(BEG_MCTRL|0x100) ){
1782 wind_update(END_UPDATE);
1786 graf_mouse(M_OFF, NULL);
1795 wind_update(END_MCTRL);
1796 wind_update(END_UPDATE);
1797 graf_mouse(M_ON, NULL);
1808 bool doupdate =
false;
1809 struct rect newclip = {0, 0, w, h};
1810 GRECT absclip = {x, y, w, h};
1881 if(!rc_intersect(area, &canvas)){
1976 GRECT canvas, screen, gclip, maxclip;
1993 gclip.g_x += canvas.g_x;
1994 gclip.g_y += canvas.g_y;
1996 rc_intersect(&canvas, &gclip);
2002 if (!rc_intersect(&screen, &gclip)) {
2011 rc_intersect(&maxclip, &gclip);
2017 pxy[2] = pxy[0] + gclip.g_w;
2018 pxy[3] = pxy[1] + gclip.g_h;
2045 int x,
int y,
int radius,
int angle1,
int angle2)
2092 int x,
int y,
int radius)
2129 if (((
line->x0 < 0) && (
line->x1 < 0)) ||
2130 ((
line->y0 < 0) && (
line->y1 < 0))) {
2154 if ((lt&0x0F) == 7 ) {
2185 GRECT r, rclip, sclip;
2196 sclip.g_x = rclip.g_x;
2197 sclip.g_y = rclip.g_y;
2201 rc_intersect(&sclip, &rclip);
2207 if (!rc_intersect(&rclip, &r)) {
2225 if ((lt&0x0F) == 7 ) {
2232 pxy[0] =
view.
x + r.g_x;
2233 pxy[1] =
view.
y + r.g_y ;
2234 pxy[2] =
view.
x + r.g_x + r.g_w;
2235 pxy[3] =
view.
y + r.g_y;
2240 if (r.g_x + r.g_w ==
rect->
x1 ) {
2241 pxy[0] =
view.
x + r.g_x + r.g_w;
2242 pxy[1] =
view.
y + r.g_y;
2243 pxy[2] =
view.
x + r.g_x + r.g_w;
2244 pxy[3] =
view.
y + r.g_y + r.g_h;
2249 if ( r.g_y+r.g_h ==
rect->
y1 ) {
2250 pxy[0] =
view.
x + r.g_x;
2251 pxy[1] =
view.
y + r.g_y+r.g_h;
2252 pxy[2] =
view.
x + r.g_x+r.g_w;
2253 pxy[3] =
view.
y + r.g_y+r.g_h;
2258 if ( r.g_x ==
rect->
x0 ) {
2259 pxy[0] =
view.
x + r.g_x;
2260 pxy[1] =
view.
y + r.g_y;
2261 pxy[2] =
view.
x + r.g_x;
2262 pxy[3] =
view.
y + r.g_y + r.g_h;
2276 pxy[0] =
view.
x + r.g_x + stroke_width;
2277 pxy[1] =
view.
y + r.g_y + stroke_width;
2278 pxy[2] =
view.
x + r.g_x + r.g_w -1 - stroke_width;
2279 pxy[3] =
view.
y + r.g_y + r.g_h -1 - stroke_width;
2317 for (i = 0; i<n*2; i=i+2) {
2318 pxy[i] = (short)
view.
x+p[i];
2319 pxy[i+1] = (
short)
view.
y+p[i+1];
2354 const float transform[6])
2394 struct bitmap * bm = NULL;
2408 if ( repeat_x || repeat_y ) {
2410 if (repeat_x &&
width == 1 && repeat_y &&
height == 1 ) {
2413 }
else if (repeat_x &&
width == 1 ) {
2415 }
else if (repeat_y &&
height == 1) {
2433 printf(
"plot: out of memory! bmp: %p, bmpres: %p\n",
2438 if (!(repeat_x || repeat_y) ) {
2445 if (yoff >
clip.y0) {
2448 if (xoff >
clip.x0) {
2459 for (xf = xoff; xf <
clip.x1; xf +=
width ) {
2460 for (yf = yoff; yf <
clip.y1; yf +=
height ) {
2518 .group_start = NULL,
2520 .option_knockout =
true
void die(const char *error)
Cause an abnormal program termination.
static nserror plot_path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
struct s_vdi_sysinfo vdi_sysinfo
static bool ablend_bitmap(struct bitmap *img, struct bitmap *bg, GRECT *img_clip, GRECT *bg_clip)
Aplha blends the foreground image onto thebackground images.
static void vsf_rgbcolor(short vdih, colour cin)
Set fill color by passing netsurf XBGR "colour" type.
static nserror plot_clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
static struct s_view view
bool plot_blit_mfdb(GRECT *loc, MFDB *insrc, short fgcolor, uint32_t flags)
static void update_visible_rect(void)
static nserror plot_text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
const struct plotter_table atari_plotters
atari plottr operation table
static nserror plot_bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
static nserror plot_rectangle(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *rect)
Plots a rectangle.
static int size_buf_packed
static void snapshot_destroy(void)
destroy memory used by screenshot
unsigned long atari_plot_flags
static nserror plot_disc(const struct redraw_context *ctx, const plot_style_t *pstyle, int x, int y, int radius)
Plots a circle.
static HermesHandle hermes_cnv_h
void plot_get_abs_clipping(struct rect *dst)
Get the maximum clip extent, in absolute screen coords.
bool plot_blit_bitmap(struct bitmap *bmp, int x, int y, unsigned long bg, unsigned long flags)
void plot_set_text_plotter(FONT_PLOTTER font_plotter)
static const char * plot_error_codes[]
static void plot_get_visible_grect(GRECT *out)
Get current visible coords.
static void read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo *info)
Fill the screen info structure.
static void convert_bitmap_done(void)
float plot_get_scale(void)
static void vsl_rgbcolor(short vdih, colour cin)
Set line drawing color by passing netsurf XBGR "colour" type.
void rgb_to_vdi1000(unsigned char *in, RGB1000 *out)
Convert an RGB color to an VDI Color.
static bool fbrect_to_screen(GRECT box, GRECT *ret)
Returns the visible parts of the box.
long plot_get_flags(void)
bool plot_get_clip(struct rect *out)
const char * plot_err_str(int i)
translate an error number
static int atari_plot_bpp_virt
void vdi1000_to_rgb(unsigned short *in, unsigned char *out)
float plot_set_scale(float scale)
set scale of plotter.
VdiHdl plot_get_vdi_handle(void)
void plot_get_clip_grect(GRECT *out)
Get clipping for current framebuffer as GRECT.
static struct bitmap snapshot
bool plot_copy_rect(GRECT src, GRECT dst)
copy an rectangle from the plot buffer to screen
void plot_set_abs_clipping(const GRECT *area)
Subsequent calls to plot_clip will be clipped by the absolute clip.
FONT_PLOTTER plot_get_text_plotter()
static bitmap_convert_fnc bitmap_convert
static bool ablend_pixel(struct bitmap *img, uint32_t bg, GRECT *clip)
Alpha blends an image, using one pixel as the background.
bool plot_set_dimensions(const struct redraw_context *ctx, int x, int y, int w, int h)
Set plot origin and canvas size.
static struct bitmap * snapshot_create(int x, int y, int w, int h)
Create an snapshot of the screen in netsurf ABGR format.
static nserror plot_line(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *line)
Plots a line.
VdiHdl atari_plot_vdi_handle
static void snapshot_suspend(void)
Garbage collection of the snapshot routine.
static nserror plot_polygon(const struct redraw_context *ctx, const plot_style_t *pstyle, const int *p, unsigned int n)
Plot a polygon.
static MFDB * snapshot_create_native_mfdb(int x, int y, int w, int h)
Create an snapshot of the screen image in device format.
unsigned long atari_font_flags
static HermesHandle hermes_res_h
void vq_scrninfo(VdiHdl handle, short *work_out)
static void dump_vdi_info(short vdih)
static uint32_t ablend(uint32_t pixel, uint32_t scrpixel)
static HermesFormat nsfmt
static nserror plot_arc(const struct redraw_context *ctx, const plot_style_t *pstyle, int x, int y, int radius, int angle1, int angle2)
Plots an arc.
void plot_get_abs_clipping_grect(GRECT *dst)
Get the maximum clip extent, in absolute screen coords.
static bool bitmap_convert_tc(struct bitmap *img, int x, int y, GRECT *clip, uint32_t bg, uint32_t flags, MFDB *out)
Convert bitmap to the native screen format.
bool plot_get_dimensions(GRECT *dst)
Get current canvas size.
int plot_init(const struct redraw_context *ctx, char *fdrvrname)
Init screen and font driver objects.
struct bitmap * buf_scr_compat
bool(* bitmap_convert_fnc)(struct bitmap *img, int x, int y, GRECT *clip, uint32_t bg, uint32_t flags, MFDB *out)
#define FONTPLOT_FLAG_MONOGLYPH
#define BITMAPF_MONOGLYPH
The bitmap is an character bitmap.
#define NSLT2VDI(dst, src)
#define PLOT_FLAG_TRANS
set if the plotter supports transparent operations
#define OFFSET_CUSTOM_COLOR
short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b)
#define CONV_BLOCK_SIZE
how much memory to allocate if some is needed:
#define CONV_KEEP_LIMIT
how much memory should be kept allocated for temp.
#define PLOT_FLAG_LOCKED
plotter should set this flag during screen updates
#define BITMAPF_BUFFER_NATIVE
Bitmap shall be kept converted
#define PLOT_FLAG_DITHER
set if the plotter shall dither images
unsigned long EdDI_version(void *function_pointer)
nserror
Enumeration of error codes.
@ NSERROR_NOMEM
Memory exhaustion.
void dump_font_drivers(void)
FONT_PLOTTER new_font_plotter(int vdihandle, char *name, unsigned long flags, int *error)
Create an new text plotter object.
int delete_font_plotter(FONT_PLOTTER p)
bool atari_bitmap_resize(struct bitmap *img, HermesHandle hermes_h, HermesFormat *fmt, int nw, int nh)
size_t atari_bitmap_buffer_size(void *bitmap)
size_t atari_bitmap_get_rowstride(void *bitmap)
Find the width of a pixel row in bytes.
bool atari_bitmap_get_opaque(void *bitmap)
Gets whether a bitmap should be plotted opaque.
void atari_bitmap_destroy(void *bitmap)
Free a bitmap.
void * atari_bitmap_create(int w, int h, enum gui_bitmap_flags flags)
Create a bitmap.
int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB *out)
setup an MFDB struct and allocate memory for it when it is needed.
int atari_bitmap_get_height(void *bitmap)
Get bitmap height.
int atari_bitmap_get_width(void *bitmap)
Get bitmap width.
void * atari_bitmap_realloc(int w, int h, short bpp, int rowstride, unsigned int state, void *bmp)
Atari bitmap handling implementation.
#define MFDB_STRIDE(w)
Calculates MFDB compatible rowstride (in number of bits)
Generic bitmap handling interface.
Core mouse and pointer states.
Target independent plotting interface.
unsigned long bitmap_flags_t
bool verbose_log
flag to enable verbose logging
#define NSLOG(catname, level, logmsg, args...)
int tos_getcookie(long tag, long *value)
#define plot_style_fixed_to_int(v)
@ PLOT_OP_TYPE_NONE
No operation.
@ PLOT_OP_TYPE_SOLID
Solid colour.
Interface to utility string handling.
RISC OS wimp toolkit bitmap.
int height
height of bitmap
bool opaque
Whether the bitmap is opaque.
plot_style_fixed size
Font size, in pt.
Plot style for stroke/fill plotters.
colour fill_colour
Colour of fill.
plot_style_fixed stroke_width
Width of stroke, in pixels.
plot_operation_type_t fill_type
Fill plot type.
colour stroke_colour
Colour of stroke.
plot_operation_type_t stroke_type
Stroke plot type.
Plotter operations table.
nserror(* rectangle)(const struct redraw_context *ctx, const plot_style_t *pstyle, const struct rect *rectangle)
Plots a rectangle.
nserror(* clip)(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
const struct plotter_table * plot
Current plot operation table.
void * screen
pointer to screen, or NULL
short scr_h
resolution vert.
unsigned long screensize
size of screen (in bytes)
short pixelsize
bytes per pixel
unsigned long hicolors
if colors = 0
unsigned long mask_b
blue color mask
int colors
0=hiclor, 2=mono
short vdi_handle
vdi handle
short scr_bpp
bits per pixel
unsigned short pitch
row pitch
unsigned long mask_a
alpha color mask
unsigned long EdDiVersion
unsigned short clut
type of clut support
unsigned short vdiformat
pixel format
unsigned long mask_g
green color mask
short scr_w
resolution horz.
unsigned long mask_r
red color mask
short x
drawing (screen) offset x
struct rect abs_clipping
The toplevel clipping rectangle
short vis_y
coords are relative to plot location
struct rect clipping
actual clipping rectangle
short vis_w
clipped to screen dimensions
short y
drawing (screen) offset y
short vis_x
visible rectangle of the screen buffer
short h
height of buffer, not in sync with vis_w
short w
width of buffer, not in sync with vis_w
uint32_t colour
Colour type: XBGR.
Option reading and saving interface.
#define nsoption_int(OPTION)
Get the value of an integer option.
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.
static nserror bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.