summaryrefslogtreecommitdiff
path: root/atari/plot
diff options
context:
space:
mode:
Diffstat (limited to 'atari/plot')
-rwxr-xr-xatari/plot/font_freetype.c1
-rw-r--r--atari/plot/font_internal.c2
-rwxr-xr-xatari/plot/font_vdi.c460
-rwxr-xr-xatari/plot/plot.c21
4 files changed, 238 insertions, 246 deletions
diff --git a/atari/plot/font_freetype.c b/atari/plot/font_freetype.c
index 49e46c857..7ca2d8aba 100755
--- a/atari/plot/font_freetype.c
+++ b/atari/plot/font_freetype.c
@@ -23,6 +23,7 @@
#include FT_CACHE_H
#include "utils/nsoption.h"
+#include "css/css.h"
#include "atari/plot/plot.h"
#include "atari/plot/font_freetype.h"
#include "atari/findfile.h"
diff --git a/atari/plot/font_internal.c b/atari/plot/font_internal.c
index 2b0025a71..e3c806cfe 100644
--- a/atari/plot/font_internal.c
+++ b/atari/plot/font_internal.c
@@ -72,7 +72,7 @@ fb_get_font(const plot_font_style_t *fstyle)
}
}
-static utf8_convert_ret utf8_to_font_encoding(const struct fb_font_desc* font,
+static nserror utf8_to_font_encoding(const struct fb_font_desc* font,
const char *string,
size_t len,
char **result)
diff --git a/atari/plot/font_vdi.c b/atari/plot/font_vdi.c
index 340759f02..7f3dacf63 100755
--- a/atari/plot/font_vdi.c
+++ b/atari/plot/font_vdi.c
@@ -1,49 +1,51 @@
-/*
- * Copyright 2010 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
+/*
+ * Copyright 2010 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifdef WITH_VDI_FONT_DRIVER
#include <mt_gemx.h>
-#include "atari/plot/plot.h"
-#include "atari/plot/font_vdi.h"
-
-#include "utils/utf8.h"
+#include "atari/plot/plot.h"
+#include "atari/plot/font_vdi.h"
+
+#include "utils/utf8.h"
#include "utils/log.h"
-
-
-
-//static char * lstr = NULL;
-
-
-static int dtor( FONT_PLOTTER self );
-static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const char * str, size_t length, int * width );
-static int str_split( FONT_PLOTTER self, const plot_font_style_t *fstyle,const char *string,
- size_t length,int x, size_t *char_offset, int *actual_x );
-static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t *fstyle,const char *string,
- size_t length,int x, size_t *char_offset, int *actual_x );
-static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle );
-
-static bool init = false;
-static int vdih;
-
-extern struct s_vdi_sysinfo vdi_sysinfo;
+#include "atari/encoding.h"
+
+
+
+
+//static char * lstr = NULL;
+
+
+static int dtor( FONT_PLOTTER self );
+static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const char * str, size_t length, int * width );
+static int str_split( FONT_PLOTTER self, const plot_font_style_t *fstyle,const char *string,
+ size_t length,int x, size_t *char_offset, int *actual_x );
+static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t *fstyle,const char *string,
+ size_t length,int x, size_t *char_offset, int *actual_x );
+static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle );
+
+static bool init = false;
+static int vdih;
+
+extern struct s_vdi_sysinfo vdi_sysinfo;
static inline void atari_to_vdi_str(char *lstr, int length)
{
@@ -63,53 +65,53 @@ static inline void atari_to_vdi_str(char *lstr, int length)
}
}
}
-
-int ctor_font_plotter_vdi( FONT_PLOTTER self )
-{
- self->dtor = dtor;
- self->str_width = str_width;
- self->str_split = str_split;
- self->pixel_pos = pixel_pos;
- self->text = text;
- LOG(("%s: %s\n", (char*)__FILE__, __FUNCTION__));
- if( !init ) {
- vdih = self->vdi_handle;
- }
- init = true;
- return( 1 );
-}
-
-static int dtor( FONT_PLOTTER self )
-{
- return( 1 );
-}
-
-static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const char * str,
- size_t length, int * width )
-{
- short cw, ch, cellw, cellh;
- short pxsize;
+
+int ctor_font_plotter_vdi( FONT_PLOTTER self )
+{
+ self->dtor = dtor;
+ self->str_width = str_width;
+ self->str_split = str_split;
+ self->pixel_pos = pixel_pos;
+ self->text = text;
+ LOG(("%s: %s\n", (char*)__FILE__, __FUNCTION__));
+ if( !init ) {
+ vdih = self->vdi_handle;
+ }
+ init = true;
+ return( 1 );
+}
+
+static int dtor( FONT_PLOTTER self )
+{
+ return( 1 );
+}
+
+static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const char * str,
+ size_t length, int * width )
+{
+ short cw, ch, cellw, cellh;
+ short pxsize;
short fx=0;
char * lstr = NULL;
-
- utf8_to_local_encoding(str, length, &lstr);
- assert( lstr != NULL );
+
+ utf8_to_local_encoding(str, length, &lstr);
+ assert( lstr != NULL );
int slen = strlen(lstr);
- atari_to_vdi_str(lstr, slen);
-
- if( fstyle->flags & FONTF_ITALIC )
- fx |= 4;
- if( fstyle->flags & FONTF_OBLIQUE )
- fx |= 16;
- if( fstyle->weight > 450 )
- fx |= 1;
- vst_effects( self->vdi_handle, fx );
- /* TODO: replace 90 with global dpi setting */
+ atari_to_vdi_str(lstr, slen);
+
+ if( fstyle->flags & FONTF_ITALIC )
+ fx |= 4;
+ if( fstyle->flags & FONTF_OBLIQUE )
+ fx |= 16;
+ if( fstyle->weight > 450 )
+ fx |= 1;
+ vst_effects( self->vdi_handle, fx );
+ /* TODO: replace 90 with global dpi setting */
//pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
//vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
+ pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
/*
if(slen != utf8_bounded_length(str, length)){
@@ -117,51 +119,49 @@ static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const c
printf("s: %s // %s\n", str, lstr );
}*/
-
- *width = slen * cellw;
- free((void*)lstr);
- return( 0 );
-}
-
-static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const char *string,
- size_t length,int x, size_t *char_offset, int *actual_x )
-{
- short cw, ch, cellw, cellh;
- short pxsize;
- short fx=0;
- int i;
- char *lstr = NULL;
- size_t slen = 0;
- int last_space_x = 0;
+
+ *width = slen * cellw;
+ free((void*)lstr);
+ return( 0 );
+}
+
+static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const char *string,
+ size_t length,int x, size_t *char_offset, int *actual_x )
+{
+ short cw, ch, cellw, cellh;
+ short pxsize;
+ short fx=0;
+ char *lstr = NULL;
+ size_t slen = 0;
+ int last_space_x = 0;
int last_space_idx = 0;
- size_t nxtchr = 0;
-
- utf8_to_local_encoding(string, length, &lstr );
- assert( lstr != NULL );
+ size_t nxtchr = 0;
+
+ utf8_to_local_encoding(string, length, &lstr );
+ assert( lstr != NULL );
slen = strlen(lstr);
atari_to_vdi_str(lstr, slen);
-
- if( fstyle->flags & FONTF_ITALIC )
- fx |= 4;
- if( fstyle->flags & FONTF_OBLIQUE )
- fx |= 16;
- if( fstyle->weight > 450 )
- fx |= 1;
- vst_effects( self->vdi_handle, fx );
- //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+
+ if( fstyle->flags & FONTF_ITALIC )
+ fx |= 4;
+ if( fstyle->flags & FONTF_OBLIQUE )
+ fx |= 16;
+ if( fstyle->weight > 450 )
+ fx |= 1;
+ vst_effects( self->vdi_handle, fx );
+ //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
//vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
- vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
- *actual_x = 0;
- //*char_offset = 0;
- int cpos=0;
+ pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
+ vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
+ *actual_x = 0;
+ //*char_offset = 0;
while (nxtchr < slen) {
- if( lstr[nxtchr] == ' ' ) {
- last_space_x = *actual_x;
- last_space_idx = nxtchr;
+ if( lstr[nxtchr] == ' ' ) {
+ last_space_x = *actual_x;
+ last_space_idx = nxtchr;
}
*actual_x += cellw;
if (*actual_x > x && last_space_idx != 0) {
@@ -178,138 +178,136 @@ static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const
}
*char_offset = nxtchr;
-
-// for( i=0; i<slen; i++) {
-// if( lstr[i] == ' ' ) {
-// last_space_x = *actual_x;
-// last_space_idx = cpos;
-// }
-// if( *actual_x > x ) {
-// *actual_x = last_space_x;
-// *char_offset = last_space_idx;
-// return true;
-// }
-// *actual_x += cellw;
-// cpos++;
-// }
-// *char_offset = cpos;
- free( (void*)lstr );
- return( 0 );
-}
-
-static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t * fstyle,const char *string,
- size_t length,int x, size_t *char_offset, int *actual_x )
-{
- short cw, ch, cellw, cellh;
- short pxsize=0;
- short fx=0;
-
- char *lstr = NULL;
- int i=0;
- int curpx=0;
- utf8_to_local_encoding(string, length, &lstr );
- assert( lstr != NULL );
+
+// for( i=0; i<slen; i++) {
+// if( lstr[i] == ' ' ) {
+// last_space_x = *actual_x;
+// last_space_idx = cpos;
+// }
+// if( *actual_x > x ) {
+// *actual_x = last_space_x;
+// *char_offset = last_space_idx;
+// return true;
+// }
+// *actual_x += cellw;
+// cpos++;
+// }
+// *char_offset = cpos;
+ free( (void*)lstr );
+ return( 0 );
+}
+
+static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t * fstyle,const char *string,
+ size_t length,int x, size_t *char_offset, int *actual_x )
+{
+ short cw, ch, cellw, cellh;
+ short pxsize=0;
+ short fx=0;
+
+ char *lstr = NULL;
+ int i=0;
+ utf8_to_local_encoding(string, length, &lstr );
+ assert( lstr != NULL );
int slen = strlen(lstr);
atari_to_vdi_str(lstr, slen);
-
- if( fstyle->flags & FONTF_ITALIC )
- fx |= 4;
- if( fstyle->flags & FONTF_OBLIQUE )
- fx |= 16;
- if( fstyle->weight > 450 )
- fx |= 1;
- vst_effects(self->vdi_handle, fx);
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
- vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
- *actual_x = 0;
- *char_offset = 0;
- for( i=0; i<slen; i++) {
- *actual_x += cellw;
- if( *actual_x > x) {
- *actual_x -= cellw;
- *char_offset = i;
- break;
- }
- }
- free((void*)lstr);
- lstr = NULL;
- return( 0 );
-}
-
-static inline void vst_rgbcolor( short vdih, uint32_t cin )
-{
+
+ if( fstyle->flags & FONTF_ITALIC )
+ fx |= 4;
+ if( fstyle->flags & FONTF_OBLIQUE )
+ fx |= 16;
+ if( fstyle->weight > 450 )
+ fx |= 1;
+ vst_effects(self->vdi_handle, fx);
+ pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+ vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
+ *actual_x = 0;
+ *char_offset = 0;
+ for( i=0; i<slen; i++) {
+ *actual_x += cellw;
+ if( *actual_x > x) {
+ *actual_x -= cellw;
+ *char_offset = i;
+ break;
+ }
+ }
+ free((void*)lstr);
+ lstr = NULL;
+ return( 0 );
+}
+
+static inline void vst_rgbcolor( short vdih, uint32_t cin )
+{
#ifdef WITH_8BPP_SUPPORT
if( vdi_sysinfo.scr_bpp > 8 ) {
-#endif
+#endif
//unsigned short c[4];
RGB1000 c;
-
- rgb_to_vdi1000( (unsigned char*)&cin, &c );
- vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
- vst_color( vdih, OFFSET_CUSTOM_COLOR );
+
+ rgb_to_vdi1000( (unsigned char*)&cin, &c );
+ vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
+ vst_color( vdih, OFFSET_CUSTOM_COLOR );
#ifdef WITH_8BPP_SUPPORT
- } else {
- if( vdi_sysinfo.scr_bpp >= 4 )
- vst_color( vdih, RGB_TO_VDI(cin) );
- else
- vst_color( vdih, BLACK );
+ } else {
+ if( vdi_sysinfo.scr_bpp >= 4 )
+ vst_color( vdih, RGB_TO_VDI(cin) );
+ else
+ vst_color( vdih, BLACK );
}
-#endif
-}
-
-static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle )
-{
- /* todo: either limit the string to max 80 chars, or use v_ftext instead of v_gtext */
- short cw, ch, cellw, cellh;
- short pxsize=8;
+#endif
+}
+
+static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length,
+ const plot_font_style_t *fstyle )
+{
+ /* todo: either limit the string to max 80 chars, or use v_ftext instead of v_gtext */
+ short cw, ch, cellw, cellh;
+ short pxsize=8;
short fx=0;
- GRECT canvas;
+ GRECT canvas;
char *lstr = NULL;
- assert( utf8_to_local_encoding(text, length, &lstr) == UTF8_CONVERT_OK);
+ assert( utf8_to_local_encoding(text, length, &lstr) == NSERROR_OK);
assert( lstr != NULL );
-
+
int slen = strlen(lstr);
if(slen > 800){
lstr[800]=0;
}
- atari_to_vdi_str(lstr, slen);
-
- if( fstyle != NULL){
- if( fstyle->flags & FONTF_ITALIC )
- fx |= 4;
- if( fstyle->flags & FONTF_OBLIQUE )
- fx |= 4;
- if( fstyle->weight > 450 )
- fx |= 1;
-
- /* TODO: netsurf uses 90 as default dpi ( somewhere defined in libcss),
- use that value or pass it as arg, to reduce netsurf dependency */
- //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
- }
- plot_get_dimensions(&canvas);
- x += canvas.g_x;
- y += canvas.g_y;
- vst_effects( self->vdi_handle, fx );
+ atari_to_vdi_str(lstr, slen);
+
+ if( fstyle->flags & FONTF_ITALIC )
+ fx |= 4;
+ if( fstyle->flags & FONTF_OBLIQUE )
+ fx |= 4;
+ if( fstyle->weight > 450 )
+ fx |= 1;
+
+ /* TODO: netsurf uses 90 as default dpi ( somewhere defined in libcss),
+ use that value or pass it as arg, to reduce netsurf dependency */
+ //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+ pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+
+ plot_get_dimensions(&canvas);
+ x += canvas.g_x;
+ y += canvas.g_y;
+ vst_effects( self->vdi_handle, fx );
vst_alignment(vdih, 0, 0, &cw, &ch );
- vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
- //vst_height( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
- vswr_mode( self->vdi_handle, MD_TRANS );
- vst_rgbcolor(self->vdi_handle, fstyle->foreground);
-
+ vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
+ //vst_height( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
+ vswr_mode( self->vdi_handle, MD_TRANS );
+ vst_rgbcolor(self->vdi_handle, fstyle->foreground);
+
if( atari_sysinfo.gdos_FSMC ){
- //printf("\nftext\n");
- v_ftext( self->vdi_handle, x, y, (char*)lstr );
+ //printf("\nftext\n");
+ v_ftext( self->vdi_handle, x, y, (char*)lstr );
} else {
- //printf("\ngtext\n");
- v_gtext( self->vdi_handle, x, y, (char*)lstr );
- }
- free( lstr );
- return( 0 );
-}
-
-#endif
+ //printf("\ngtext\n");
+ v_gtext( self->vdi_handle, x, y, (char*)lstr );
+ }
+ free( lstr );
+ return( 0 );
+}
+
+#endif
diff --git a/atari/plot/plot.c b/atari/plot/plot.c
index 2c75db335..cfec7b424 100755
--- a/atari/plot/plot.c
+++ b/atari/plot/plot.c
@@ -625,7 +625,6 @@ inline static unsigned char get_stdpx(MFDB * dst, int wdplanesz, int x, int y)
*/
inline 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];
@@ -635,7 +634,7 @@ inline short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b)
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!=0XFF) && (g!=0XFF) && (b!=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) );
@@ -1016,11 +1015,8 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
MFDB stdform;
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;
bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
bool opaque = bitmap_get_opaque( img );
@@ -1035,8 +1031,8 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
assert( clip->g_h > 0 );
assert( clip->g_w > 0 );
- process_w = bw = bitmap_get_width( img );
- process_h = bh = bitmap_get_height( img );
+ bw = bitmap_get_width( img );
+ bh = bitmap_get_height( img );
// The converted bitmap can be saved for subsequent blits, when
// the bitmap is fully opaque
@@ -1526,7 +1522,7 @@ int plot_init(char * fdrvrname)
{
GRECT loc_pos= {0,0,360,400};
- int err=0,i;
+ int err=0;
if( nsoption_int(atari_dither) == 1)
atari_plot_flags |= PLOT_FLAG_DITHER;
@@ -1589,11 +1585,10 @@ int plot_init(char * fdrvrname)
bitmap_convert = (vdi_sysinfo.scr_bpp > 8) ? bitmap_convert_tc : bitmap_convert_8;
/* Setup color lookup tables and palette */
- i = 0;
- unsigned char * col;
unsigned char rgbcol[4];
- unsigned char graytone=0;
if( vdi_sysinfo.scr_bpp <= 8 ){
+ unsigned char graytone=0;
+ int i;
for( i=0; i<=255; i++ ) {
// get the current color and save it for restore:
@@ -1659,12 +1654,12 @@ int plot_init(char * fdrvrname)
int plot_finalise( void )
{
- int i=0;
delete_font_plotter(fplotter);
#ifdef WITH_8BPP_SUPPORT
if (vfmt.indexed) {
+ int i;
for (i=OFFSET_WEB_PAL; i<OFFSET_CUST_PAL+16; i++) {
vs_color(atari_plot_vdi_handle, i, &sys_pal[i][0]);
}
@@ -1857,7 +1852,6 @@ static bool plot_polygon(const int *p, unsigned int n,
{
short pxy[n*2];
unsigned int i=0;
- short d[4];
if (vdi_sysinfo.maxpolycoords > 0)
assert( (signed int)n < vdi_sysinfo.maxpolycoords);
@@ -1894,7 +1888,6 @@ bool plot_set_dimensions(int x, int y, int w, int h)
GRECT absclip = {x, y, w, h};
if (!(w == view.w && h == view.h)) {
- struct rect newclip = { 0, 0, w-1, h-1 };
view.w = (short)w;
view.h = (short)h;
doupdate = true;