mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-13 14:29:20 +03:00
Refactor plot implementation (removed old files)
This commit is contained in:
parent
37b8c5d83d
commit
f2aa118025
255
atari/plot.c
255
atari/plot.c
@ -1,255 +0,0 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <windom.h>
|
||||
|
||||
#include "image/bitmap.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/utils.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/plotters.h"
|
||||
|
||||
#include "atari/bitmap.h"
|
||||
#include "atari/gui.h"
|
||||
#include "atari/plot.h"
|
||||
#include "desktop/options.h"
|
||||
#include "atari/plot.h"
|
||||
|
||||
GEM_PLOTTER plotter = NULL;
|
||||
GEM_FONT_PLOTTER fplotter = NULL;
|
||||
|
||||
extern short vdih;
|
||||
|
||||
/*
|
||||
Init screen and font driver objects.
|
||||
Returns non-zero value > -1 when the objects could be succesfully created.
|
||||
Returns value < 0 to indicate an error
|
||||
*/
|
||||
|
||||
int atari_plotter_init( char* drvrname, char * fdrvrname )
|
||||
{
|
||||
GRECT loc_pos={0,0,360,400};
|
||||
int err=0;
|
||||
struct s_driver_table_entry * drvinfo;
|
||||
int flags = 0;
|
||||
unsigned long font_flags = 0;
|
||||
|
||||
if( nsoption_int(atari_dither) == 1)
|
||||
flags |= PLOT_FLAG_DITHER;
|
||||
if( nsoption_int(atari_transparency) == 1 )
|
||||
flags |= PLOT_FLAG_TRANS;
|
||||
if( nsoption_int(atari_font_monochrom) == 1 )
|
||||
font_flags |= FONTPLOT_FLAG_MONOGLYPH;
|
||||
|
||||
vdih = app.graf.handle;
|
||||
if( verbose_log ) {
|
||||
dump_vdi_info( vdih ) ;
|
||||
dump_plot_drivers();
|
||||
dump_font_drivers();
|
||||
}
|
||||
drvinfo = get_screen_driver_entry( drvrname );
|
||||
|
||||
LOG(("using plotters: %s, %s", drvrname, fdrvrname));
|
||||
fplotter = new_font_plotter(vdih, fdrvrname, font_flags, &err );
|
||||
if(err){
|
||||
const char * desc = plotter_err_str(err);
|
||||
die(("Unable to load font plotter %s -> %s", fdrvrname, desc ));
|
||||
}
|
||||
|
||||
plotter = new_plotter( vdih, drvrname, &loc_pos, drvinfo->max_bpp,
|
||||
flags, fplotter, &err );
|
||||
if(err){
|
||||
const char * desc = plotter_err_str(err);
|
||||
die(("Unable to load graphics plotter %s -> %s", drvrname, desc ));
|
||||
}
|
||||
|
||||
return( err );
|
||||
}
|
||||
|
||||
int atari_plotter_finalise( void )
|
||||
{
|
||||
delete_plotter( plotter );
|
||||
delete_font_plotter( fplotter );
|
||||
}
|
||||
|
||||
bool plot_rectangle( int x0, int y0, int x1, int y1,
|
||||
const plot_style_t *style )
|
||||
{
|
||||
plotter->rectangle( plotter, x0, y0, x1, y1, style );
|
||||
return ( true );
|
||||
}
|
||||
|
||||
bool plot_line( int x0, int y0, int x1, int y1,
|
||||
const plot_style_t *style )
|
||||
{
|
||||
plotter->line( plotter, x0, y0, x1, y1, style );
|
||||
return ( true );
|
||||
}
|
||||
|
||||
static bool plot_polygon(const int *p, unsigned int n,
|
||||
const plot_style_t *style)
|
||||
{
|
||||
plotter->polygon( plotter, p, n, style );
|
||||
return ( true );
|
||||
}
|
||||
|
||||
bool plot_set_dimensions( int x, int y, int w, int h )
|
||||
{
|
||||
plotter->resize( plotter, w, h );
|
||||
plotter->move( plotter, x, y );
|
||||
}
|
||||
|
||||
bool plot_clip(const struct rect *clip)
|
||||
{
|
||||
plotter->set_clip( plotter, clip );
|
||||
return ( true );
|
||||
}
|
||||
|
||||
|
||||
bool plot_get_clip(struct rect * out)
|
||||
{
|
||||
plotter->get_clip( plotter, out );
|
||||
return( true );
|
||||
}
|
||||
|
||||
|
||||
static bool plot_text(int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle )
|
||||
{
|
||||
plotter->text( plotter, x, y, text, length, fstyle );
|
||||
return ( true );
|
||||
}
|
||||
|
||||
static bool plot_disc(int x, int y, int radius, const plot_style_t *style)
|
||||
{
|
||||
plotter->disc(plotter, x, y, radius, style );
|
||||
return ( true );
|
||||
}
|
||||
|
||||
static bool plot_arc(int x, int y, int radius, int angle1, int angle2,
|
||||
const plot_style_t *style)
|
||||
{
|
||||
plotter->arc( plotter, x, y, radius, angle1, angle2, style );
|
||||
return ( true );
|
||||
}
|
||||
|
||||
static bool plot_bitmap(int x, int y, int width, int height,
|
||||
struct bitmap *bitmap, colour bg,
|
||||
bitmap_flags_t flags)
|
||||
{
|
||||
struct bitmap * bm = NULL;
|
||||
bool repeat_x = (flags & BITMAPF_REPEAT_X);
|
||||
bool repeat_y = (flags & BITMAPF_REPEAT_Y);
|
||||
int bmpw,bmph;
|
||||
struct rect clip;
|
||||
|
||||
bmpw = bitmap_get_width(bitmap);
|
||||
bmph = bitmap_get_height(bitmap);
|
||||
|
||||
if ( repeat_x || repeat_y ) {
|
||||
plotter->get_clip( plotter, &clip );
|
||||
if( repeat_x && width == 1 && repeat_y && height == 1 ){
|
||||
width = MAX( width, clip.x1 - x );
|
||||
height = MAX( height, clip.y1 - y );
|
||||
}
|
||||
else if( repeat_x && width == 1 ){
|
||||
width = MAX( width, clip.x1 - x);
|
||||
}
|
||||
else if( repeat_y && height == 1){
|
||||
height = MAX( height, clip.y1 - y );
|
||||
}
|
||||
}
|
||||
|
||||
if( width != bmpw || height != bmph ) {
|
||||
plotter->bitmap_resize(plotter, bitmap, width, height );
|
||||
if( bitmap->resized )
|
||||
bm = bitmap->resized;
|
||||
else
|
||||
bm = bitmap;
|
||||
} else {
|
||||
bm = bitmap;
|
||||
}
|
||||
|
||||
/* out of memory? */
|
||||
if( bm == NULL ) {
|
||||
printf("plot: out of memory! bmp: %p, bmpres: %p\n", bitmap, bitmap->resized );
|
||||
return( true );
|
||||
}
|
||||
|
||||
if (!(repeat_x || repeat_y) ) {
|
||||
plotter->bitmap( plotter, bm, x, y, bg, flags );
|
||||
} else {
|
||||
int xf,yf;
|
||||
int xoff = x;
|
||||
int yoff = y;
|
||||
|
||||
if (yoff > clip.y0 )
|
||||
yoff = (clip.y0 - height) + ((yoff - clip.y0) % height);
|
||||
if (xoff > clip.x0 )
|
||||
xoff = (clip.x0 - width) + ((xoff - clip.x0) % width);
|
||||
/* for now, repeating just works in the rigth / down direction */
|
||||
/*
|
||||
if( repeat_x == true )
|
||||
xoff = clip.x0;
|
||||
if(repeat_y == true )
|
||||
yoff = clip.y0;
|
||||
*/
|
||||
|
||||
for( xf = xoff; xf < clip.x1; xf += width ) {
|
||||
for( yf = yoff; yf < clip.y1; yf += height ) {
|
||||
plotter->bitmap( plotter, bm, xf, yf, bg, flags );
|
||||
if (!repeat_y)
|
||||
break;
|
||||
}
|
||||
if (!repeat_x)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ( true );
|
||||
}
|
||||
|
||||
static bool plot_path(const float *p, unsigned int n, colour fill, float width,
|
||||
colour c, const float transform[6])
|
||||
{
|
||||
plotter->path( plotter, p, n, fill, width, c, transform );
|
||||
return ( true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
const struct plotter_table atari_plotters = {
|
||||
.rectangle = plot_rectangle,
|
||||
.line = plot_line,
|
||||
.polygon = plot_polygon,
|
||||
.clip = plot_clip,
|
||||
.text = plot_text,
|
||||
.disc = plot_disc,
|
||||
.arc = plot_arc,
|
||||
.bitmap = plot_bitmap,
|
||||
.path = plot_path,
|
||||
.flush = NULL,
|
||||
.group_start = NULL,
|
||||
.group_end = NULL,
|
||||
.option_knockout = true
|
||||
};
|
37
atari/plot.h
37
atari/plot.h
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef NS_ATARI_PLOT_H
|
||||
#define NS_ATARI_PLOT_H
|
||||
|
||||
#include "desktop/plotters.h"
|
||||
#include "atari/plot/plotter.h"
|
||||
|
||||
struct rect;
|
||||
|
||||
extern const struct plotter_table atari_plotters;
|
||||
|
||||
int atari_plotter_init( char*, char * );
|
||||
int atari_plotter_finalise( void );
|
||||
bool plot_set_dimensions( int x, int y, int w, int h );
|
||||
bool plot_get_clip(struct rect * out);
|
||||
bool plot_clip(const struct rect *clip);
|
||||
bool plot_rectangle( int x0, int y0, int x1, int y1,const plot_style_t *style );
|
||||
bool plot_line( int x0, int y0, int x1, int y1, const plot_style_t *style );
|
||||
|
||||
#endif
|
@ -1,662 +0,0 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <windom.h>
|
||||
#include <assert.h>
|
||||
#include <mint/osbind.h>
|
||||
#include <mint/cookie.h>
|
||||
#include <Hermes/Hermes.h>
|
||||
|
||||
#include "desktop/plot_style.h"
|
||||
#include "atari/bitmap.h"
|
||||
#include "image/bitmap.h"
|
||||
#include "atari/plot/eddi.h"
|
||||
#include "atari/plot/plotter.h"
|
||||
#include "atari/plot/plotter_vdi.h"
|
||||
#ifdef WITH_GD_PLOTTER
|
||||
#include "atari/plot/plotter_gd.h"
|
||||
#endif
|
||||
|
||||
#ifdef WITH_VDI_FONT_DRIVER
|
||||
#include "atari/plot/font_vdi.h"
|
||||
#endif
|
||||
#ifdef WITH_INTERNAL_FONT_DRIVER
|
||||
#include "atari/plot/font_internal.h"
|
||||
#endif
|
||||
#ifdef WITH_FREETYPE_FONT_DRIVER
|
||||
#include "atari/plot/font_freetype.h"
|
||||
#endif
|
||||
#include "atari/gui.h"
|
||||
#include "utils/log.h"
|
||||
#include "atari/misc.h"
|
||||
#include "atari/osspec.h"
|
||||
|
||||
|
||||
struct s_driver_table_entry screen_driver_table[] =
|
||||
{
|
||||
{
|
||||
(char*)"vdi",
|
||||
ctor_plotter_vdi,
|
||||
PLOT_FLAG_HAS_ALPHA,
|
||||
32
|
||||
},
|
||||
#ifdef WITH_GD_PLOTTER
|
||||
{
|
||||
(char*)"gd",
|
||||
ctor_plotter_gd,
|
||||
PLOT_FLAG_OFFSCREEN | PLOT_FLAG_HAS_ALPHA,
|
||||
32
|
||||
},
|
||||
#endif
|
||||
{(char*)NULL, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
const struct s_font_driver_table_entry font_driver_table[] =
|
||||
{
|
||||
#ifdef WITH_VDI_FONT_DRIVER
|
||||
{"vdi", ctor_font_plotter_vdi, 0},
|
||||
#endif
|
||||
#ifdef WITH_FREETYPE_FONT_DRIVER
|
||||
{"freetype", ctor_font_plotter_freetype, 0},
|
||||
#endif
|
||||
#ifdef WITH_INTERNAL_FONT_DRIVER
|
||||
{"internal", ctor_font_plotter_internal, 0},
|
||||
#endif
|
||||
{(char*)NULL, NULL, 0}
|
||||
};
|
||||
|
||||
|
||||
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},
|
||||
{0x000,0x190,0x000}, {0x0c8,0x190,0x000}, {0x190,0x190,0x000}, {0x258,0x190,0x000}, {0x320,0x190,0x000}, {0x3e8,0x190,0x000},
|
||||
{0x000,0x258,0x000}, {0x0c8,0x258,0x000}, {0x190,0x258,0x000}, {0x258,0x258,0x000}, {0x320,0x258,0x000}, {0x3e8,0x258,0x000},
|
||||
{0x000,0x320,0x000}, {0x0c8,0x320,0x000}, {0x190,0x320,0x000}, {0x258,0x320,0x000}, {0x320,0x320,0x000}, {0x3e8,0x320,0x000},
|
||||
{0x000,0x3e8,0x000}, {0x0c8,0x3e8,0x000}, {0x190,0x3e8,0x000}, {0x258,0x3e8,0x000}, {0x320,0x3e8,0x000}, {0x3e8,0x3e8,0x000},
|
||||
{0x000,0x000,0x0c8}, {0x0c8,0x000,0x0c8}, {0x190,0x000,0x0c8}, {0x258,0x000,0x0c8}, {0x320,0x000,0x0c8}, {0x3e8,0x000,0x0c8},
|
||||
{0x000,0x0c8,0x0c8}, {0x0c8,0x0c8,0x0c8}, {0x190,0x0c8,0x0c8}, {0x258,0x0c8,0x0c8}, {0x320,0x0c8,0x0c8}, {0x3e8,0x0c8,0x0c8},
|
||||
{0x000,0x190,0x0c8}, {0x0c8,0x190,0x0c8}, {0x190,0x190,0x0c8}, {0x258,0x190,0x0c8}, {0x320,0x190,0x0c8}, {0x3e8,0x190,0x0c8},
|
||||
{0x000,0x258,0x0c8}, {0x0c8,0x258,0x0c8}, {0x190,0x258,0x0c8}, {0x258,0x258,0x0c8}, {0x320,0x258,0x0c8}, {0x3e8,0x258,0x0c8},
|
||||
{0x000,0x320,0x0c8}, {0x0c8,0x320,0x0c8}, {0x190,0x320,0x0c8}, {0x258,0x320,0x0c8}, {0x320,0x320,0x0c8}, {0x3e8,0x320,0x0c8},
|
||||
{0x000,0x3e8,0x0c8}, {0x0c8,0x3e8,0x0c8}, {0x190,0x3e8,0x0c8}, {0x258,0x3e8,0x0c8}, {0x320,0x3e8,0x0c8}, {0x3e8,0x3e8,0x0c8},
|
||||
{0x000,0x000,0x190}, {0x0c8,0x000,0x190}, {0x190,0x000,0x190}, {0x258,0x000,0x190}, {0x320,0x000,0x190}, {0x3e8,0x000,0x190},
|
||||
{0x000,0x0c8,0x190}, {0x0c8,0x0c8,0x190}, {0x190,0x0c8,0x190}, {0x258,0x0c8,0x190}, {0x320,0x0c8,0x190}, {0x3e8,0x0c8,0x190},
|
||||
{0x000,0x190,0x190}, {0x0c8,0x190,0x190}, {0x190,0x190,0x190}, {0x258,0x190,0x190}, {0x320,0x190,0x190}, {0x3e8,0x190,0x190},
|
||||
{0x000,0x258,0x190}, {0x0c8,0x258,0x190}, {0x190,0x258,0x190}, {0x258,0x258,0x190}, {0x320,0x258,0x190}, {0x3e8,0x258,0x190},
|
||||
{0x000,0x320,0x190}, {0x0c8,0x320,0x190}, {0x190,0x320,0x190}, {0x258,0x320,0x190}, {0x320,0x320,0x190}, {0x3e8,0x320,0x190},
|
||||
{0x000,0x3e8,0x190}, {0x0c8,0x3e8,0x190}, {0x190,0x3e8,0x190}, {0x258,0x3e8,0x190}, {0x320,0x3e8,0x190}, {0x3e8,0x3e8,0x190},
|
||||
{0x000,0x000,0x258}, {0x0c8,0x000,0x258}, {0x190,0x000,0x258}, {0x258,0x000,0x258}, {0x320,0x000,0x258}, {0x3e8,0x000,0x258},
|
||||
{0x000,0x0c8,0x258}, {0x0c8,0x0c8,0x258}, {0x190,0x0c8,0x258}, {0x258,0x0c8,0x258}, {0x320,0x0c8,0x258}, {0x3e8,0x0c8,0x258},
|
||||
{0x000,0x190,0x258}, {0x0c8,0x190,0x258}, {0x190,0x190,0x258}, {0x258,0x190,0x258}, {0x320,0x190,0x258}, {0x3e8,0x190,0x258},
|
||||
{0x000,0x258,0x258}, {0x0c8,0x258,0x258}, {0x190,0x258,0x258}, {0x258,0x258,0x258}, {0x320,0x258,0x258}, {0x3e8,0x258,0x258},
|
||||
{0x000,0x320,0x258}, {0x0c8,0x320,0x258}, {0x190,0x320,0x258}, {0x258,0x320,0x258}, {0x320,0x320,0x258}, {0x3e8,0x320,0x258},
|
||||
{0x000,0x3e8,0x258}, {0x0c8,0x3e8,0x258}, {0x190,0x3e8,0x258}, {0x258,0x3e8,0x258}, {0x320,0x3e8,0x258}, {0x3e8,0x3e8,0x258},
|
||||
{0x000,0x000,0x320}, {0x0c8,0x000,0x320}, {0x190,0x000,0x320}, {0x258,0x000,0x320}, {0x320,0x000,0x320}, {0x3e8,0x000,0x320},
|
||||
{0x000,0x0c8,0x320}, {0x0c8,0x0c8,0x320}, {0x190,0x0c8,0x320}, {0x258,0x0c8,0x320}, {0x320,0x0c8,0x320}, {0x3e8,0x0c8,0x320},
|
||||
{0x000,0x190,0x320}, {0x0c8,0x190,0x320}, {0x190,0x190,0x320}, {0x258,0x190,0x320}, {0x320,0x190,0x320}, {0x3e8,0x190,0x320},
|
||||
{0x000,0x258,0x320}, {0x0c8,0x258,0x320}, {0x190,0x258,0x320}, {0x258,0x258,0x320}, {0x320,0x258,0x320}, {0x3e8,0x258,0x320},
|
||||
{0x000,0x320,0x320}, {0x0c8,0x320,0x320}, {0x190,0x320,0x320}, {0x258,0x320,0x320}, {0x320,0x320,0x320}, {0x3e8,0x320,0x320},
|
||||
{0x000,0x3e8,0x320}, {0x0c8,0x3e8,0x320}, {0x190,0x3e8,0x320}, {0x258,0x3e8,0x320}, {0x320,0x3e8,0x320}, {0x3e8,0x3e8,0x320},
|
||||
{0x000,0x000,0x3e8}, {0x0c8,0x000,0x3e8}, {0x190,0x000,0x3e8}, {0x258,0x000,0x3e8}, {0x320,0x000,0x3e8}, {0x3e8,0x000,0x3e8},
|
||||
{0x000,0x0c8,0x3e8}, {0x0c8,0x0c8,0x3e8}, {0x190,0x0c8,0x3e8}, {0x258,0x0c8,0x3e8}, {0x320,0x0c8,0x3e8}, {0x3e8,0x0c8,0x3e8},
|
||||
{0x000,0x190,0x3e8}, {0x0c8,0x190,0x3e8}, {0x190,0x190,0x3e8}, {0x258,0x190,0x3e8}, {0x320,0x190,0x3e8}, {0x3e8,0x190,0x3e8},
|
||||
{0x000,0x258,0x3e8}, {0x0c8,0x258,0x3e8}, {0x190,0x258,0x3e8}, {0x258,0x258,0x3e8}, {0x320,0x258,0x3e8}, {0x3e8,0x258,0x3e8},
|
||||
{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}
|
||||
};
|
||||
|
||||
|
||||
/* 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"
|
||||
};
|
||||
|
||||
struct s_vdi_sysinfo vdi_sysinfo;
|
||||
|
||||
struct s_vdi_sysinfo * read_vdi_sysinfo( short vdih, struct s_vdi_sysinfo * info ) {
|
||||
|
||||
unsigned long cookie_EdDI=0;
|
||||
short out[300];
|
||||
memset( info, 0, sizeof(struct s_vdi_sysinfo) );
|
||||
|
||||
info->vdi_handle = vdih;
|
||||
if ( tos_getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND ) {
|
||||
info->EdDiVersion = 0;
|
||||
} else {
|
||||
info->EdDiVersion = EdDI_version( (void *)cookie_EdDI );
|
||||
}
|
||||
|
||||
memset( &out, 0, sizeof(short)*300 );
|
||||
vq_extnd( vdih, 0, (short*)&out );
|
||||
info->scr_w = out[0]+1;
|
||||
info->scr_h = out[1]+1;
|
||||
if( out[39] == 2 ) {
|
||||
info->scr_bpp = 1;
|
||||
info->colors = out[39];
|
||||
} else {
|
||||
info->colors = out[39];
|
||||
}
|
||||
|
||||
memset( &out, 0, sizeof(short)*300 );
|
||||
vq_extnd( vdih, 1, (short*)&out );
|
||||
info->scr_bpp = out[4];
|
||||
info->maxpolycoords = out[14];
|
||||
info->maxintin = out[15];
|
||||
if( out[30] & 1 ) {
|
||||
info->rasterscale = true;
|
||||
} else {
|
||||
info->rasterscale = false;
|
||||
}
|
||||
|
||||
switch( info->scr_bpp ) {
|
||||
case 8:
|
||||
info->pixelsize=1;
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
info->pixelsize=2;
|
||||
break;
|
||||
case 24:
|
||||
info->pixelsize=3;
|
||||
break;
|
||||
case 32:
|
||||
info->pixelsize=4;
|
||||
break;
|
||||
case 64:
|
||||
info->pixelsize=8;
|
||||
break;
|
||||
default:
|
||||
info->pixelsize=1;
|
||||
break;
|
||||
|
||||
}
|
||||
info->pitch = info->scr_w * info->pixelsize;
|
||||
info->vdiformat = ( (info->scr_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK);
|
||||
info->screensize = ( info->scr_w * info->pixelsize ) * info->scr_h;
|
||||
|
||||
if( info->EdDiVersion >= EDDI_10 ) {
|
||||
memset( &out, 0, sizeof(short)*300 );
|
||||
vq_scrninfo(vdih, (short*)&out);
|
||||
info->vdiformat = out[0];
|
||||
info->clut = out[1];
|
||||
info->scr_bpp = out[2];
|
||||
info->hicolors = *((unsigned long*) &out[3]);
|
||||
if( info->EdDiVersion >= EDDI_11 ) {
|
||||
info->pitch = out[5];
|
||||
info->screen = (void *) *((unsigned long *) &out[6]);
|
||||
}
|
||||
|
||||
switch( info->clut ) {
|
||||
|
||||
case VDI_CLUT_HARDWARE:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case VDI_CLUT_SOFTWARE:
|
||||
{
|
||||
int component; /* red, green, blue, alpha, overlay */
|
||||
int num_bit;
|
||||
unsigned short *tmp_p;
|
||||
|
||||
/* We can build masks with info here */
|
||||
tmp_p = (unsigned short *) &out[16];
|
||||
for (component=0;component<5;component++) {
|
||||
for (num_bit=0;num_bit<16;num_bit++) {
|
||||
unsigned short val;
|
||||
|
||||
val = *tmp_p++;
|
||||
|
||||
if (val == 0xffff) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(component) {
|
||||
case 0:
|
||||
info->mask_r |= 1<< val;
|
||||
break;
|
||||
case 1:
|
||||
info->mask_g |= 1<< val;
|
||||
break;
|
||||
case 2:
|
||||
info->mask_b |= 1<< val;
|
||||
break;
|
||||
case 3:
|
||||
info->mask_a |= 1<< val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove lower green bits for Intel endian screen */
|
||||
if ((info->mask_g == ((7<<13)|3)) || (info->mask_g == ((7<<13)|7))) {
|
||||
info->mask_g &= ~(7<<13);
|
||||
}
|
||||
break;
|
||||
|
||||
case VDI_CLUT_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
lookup an plotter ID by name
|
||||
*/
|
||||
static int drvrname_idx( char * name )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; ; i++) {
|
||||
if( screen_driver_table[i].name == NULL ) {
|
||||
return( -1 );
|
||||
}
|
||||
else {
|
||||
if( strcmp(name, screen_driver_table[i].name) == 0 ) {
|
||||
return( i );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
lookup of font plotter ID by name
|
||||
*/
|
||||
static int font_drvrname_idx( char * name )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; ; i++) {
|
||||
if( font_driver_table[i].name == NULL ) {
|
||||
return( -1 );
|
||||
}
|
||||
else {
|
||||
if( strcmp(name, font_driver_table[i].name) == 0 ) {
|
||||
return( i );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Get an plotter info entry, the entry contains an pointer to ctor
|
||||
*/
|
||||
struct s_driver_table_entry * get_screen_driver_entry( char * name )
|
||||
{
|
||||
int idx = drvrname_idx( name );
|
||||
if( idx < 0 )
|
||||
return( 0 );
|
||||
else
|
||||
return( &screen_driver_table[idx] );
|
||||
}
|
||||
|
||||
/*
|
||||
Get an font plotter info entry, the entry contains an pointer to ctor.
|
||||
*/
|
||||
struct s_font_driver_table_entry * get_font_driver_entry( char * name )
|
||||
{
|
||||
int idx = font_drvrname_idx( name );
|
||||
if( idx < 0 )
|
||||
return( 0 );
|
||||
else
|
||||
return( (struct s_font_driver_table_entry *)&font_driver_table[idx] );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Create an new text plotter object
|
||||
*/
|
||||
FONT_PLOTTER new_font_plotter( int vdihandle, char * name, unsigned long flags, int * error)
|
||||
{
|
||||
int i=0;
|
||||
int res = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
||||
FONT_PLOTTER fplotter = (FONT_PLOTTER)malloc( sizeof(struct s_font_plotter) );
|
||||
if( fplotter == NULL ) {
|
||||
*error = 0-ERR_NO_MEM;
|
||||
return( NULL );
|
||||
}
|
||||
memset( fplotter, 0, sizeof(FONT_PLOTTER));
|
||||
fplotter->vdi_handle = vdihandle;
|
||||
fplotter->name = name;
|
||||
fplotter->flags = 0;
|
||||
fplotter->flags |= flags;
|
||||
for( i = 0; ; i++) {
|
||||
if( font_driver_table[i].name == NULL ) {
|
||||
res = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
||||
break;
|
||||
} else {
|
||||
if( strcmp(name, font_driver_table[i].name) == 0 ) {
|
||||
if( font_driver_table[i].ctor ) {
|
||||
res = font_driver_table[i].ctor( fplotter );
|
||||
*error = 0;
|
||||
} else {
|
||||
res = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
||||
*error = res;
|
||||
return (NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( res < 0 ) {
|
||||
free( fplotter );
|
||||
*error = res;
|
||||
return( NULL );
|
||||
}
|
||||
fplotter->plotter = NULL;
|
||||
return( fplotter );
|
||||
}
|
||||
|
||||
static bool init=false;
|
||||
static int inst=0;
|
||||
|
||||
/*
|
||||
Create an new plotter object
|
||||
*/
|
||||
GEM_PLOTTER new_plotter(int vdihandle, char * name, GRECT * loc_size,
|
||||
int virt_bpp, unsigned long flags, FONT_PLOTTER fplotter, int * error )
|
||||
{
|
||||
int res = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
||||
int i;
|
||||
assert( fplotter != NULL );
|
||||
|
||||
GEM_PLOTTER gemplotter = (GEM_PLOTTER)malloc( sizeof(struct s_gem_plotter) );
|
||||
if( !gemplotter ) {
|
||||
*error = 0-ERR_NO_MEM;
|
||||
return( NULL );
|
||||
}
|
||||
memset( gemplotter, 0, sizeof(struct s_gem_plotter));
|
||||
|
||||
gemplotter->name = name;
|
||||
gemplotter->vdi_handle = vdihandle;
|
||||
gemplotter->flags = 0;
|
||||
gemplotter->font_plotter = fplotter;
|
||||
gemplotter->bpp_virt = virt_bpp;
|
||||
|
||||
/* request vdi info once, so every plotter is able to access the info */
|
||||
if( !init ) {
|
||||
/* vdi_sysinfo */
|
||||
read_vdi_sysinfo( vdihandle, &vdi_sysinfo );
|
||||
init = true;
|
||||
}
|
||||
for( i = 0; ; i++) {
|
||||
if( screen_driver_table[i].name == NULL ) {
|
||||
res = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
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, loc_size );
|
||||
*error = 0;
|
||||
} else {
|
||||
res = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
||||
*error = res;
|
||||
return (NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( res < 0 ) {
|
||||
free( gemplotter );
|
||||
*error = res;
|
||||
return( NULL );
|
||||
}
|
||||
inst++;
|
||||
gemplotter->font_plotter->plotter = gemplotter;
|
||||
return( gemplotter );
|
||||
}
|
||||
|
||||
/*
|
||||
Free an plotter
|
||||
*/
|
||||
int delete_plotter( GEM_PLOTTER p )
|
||||
{
|
||||
if( p ) {
|
||||
p->dtor( p );
|
||||
free( p );
|
||||
p = NULL;
|
||||
inst--;
|
||||
if( inst == 0 ){
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
return( -1 );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
Free an font plotter
|
||||
*/
|
||||
int delete_font_plotter( FONT_PLOTTER p )
|
||||
{
|
||||
if( p ) {
|
||||
p->dtor(p);
|
||||
free( p );
|
||||
p = NULL;
|
||||
}
|
||||
else
|
||||
return( -1 );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
x - x coord
|
||||
y - y coord
|
||||
stride - stride in bytes
|
||||
bpp - bits per pixel
|
||||
*/
|
||||
int calc_chunked_buffer_size(int x, int y, int stride, int bpp)
|
||||
{
|
||||
return( (x * (bpp >> 3)) * y );
|
||||
}
|
||||
|
||||
/*
|
||||
x - x coord
|
||||
y - y coord
|
||||
stride - stride in bytes
|
||||
bpp - bits per pixel
|
||||
*/
|
||||
int get_pixel_offset( int x, int y, int stride, int bpp )
|
||||
{
|
||||
LOG(("byte_pp: %d, pure: %d, result: %d\n",(bpp >> 3),(y * stride + x), (y * stride + x) * (bpp >> 3)));
|
||||
return( ( (y * stride) + x) * (bpp >> 3) );
|
||||
}
|
||||
|
||||
const char* plotter_err_str(int i) { return(plot_error_codes[abs(i)]); }
|
||||
|
||||
void dump_vdi_info( short vdih )
|
||||
{
|
||||
struct s_vdi_sysinfo temp;
|
||||
read_vdi_sysinfo( vdih, &temp );
|
||||
printf("struct s_vdi_sysinfo {\n");
|
||||
printf(" short vdi_handle: %d\n", temp.vdi_handle);
|
||||
printf(" short scr_w: %d \n", temp.scr_w);
|
||||
printf(" short scr_h: %d\n", temp.scr_h);
|
||||
printf(" short scr_bpp: %d\n", temp.scr_bpp);
|
||||
printf(" int colors: %d\n", temp.colors);
|
||||
printf(" ulong hicolors: %d\n", temp.hicolors);
|
||||
printf(" short pixelsize: %d\n", temp.pixelsize);
|
||||
printf(" unsigned short pitch: %d\n", temp.pitch);
|
||||
printf(" unsigned short vdiformat: %d\n", temp.vdiformat);
|
||||
printf(" unsigned short clut: %d\n", temp.clut);
|
||||
printf(" void * screen: 0x0%p\n", temp.screen);
|
||||
printf(" unsigned long screensize: %d\n", temp.screensize);
|
||||
printf(" unsigned long mask_r: 0x0%08x\n", temp.mask_r);
|
||||
printf(" unsigned long mask_g: 0x0%08x\n", temp.mask_g);
|
||||
printf(" unsigned long mask_b: 0x0%08x\n", temp.mask_b);
|
||||
printf(" unsigned long mask_a: 0x0%08x\n", temp.mask_a);
|
||||
printf(" short maxintin: %d\n", temp.maxintin);
|
||||
printf(" short maxpolycoords: %d\n", temp.maxpolycoords);
|
||||
printf(" unsigned long EdDiVersion: 0x0%03x\n", temp.EdDiVersion);
|
||||
printf(" unsigned short rasterscale: 0x%2x\n", temp.rasterscale);
|
||||
printf("};\n");
|
||||
}
|
||||
|
||||
void dump_plot_drivers(void)
|
||||
{
|
||||
int i = 0;
|
||||
while( screen_driver_table[i].name != NULL ) {
|
||||
printf("%s -> max_bpp: %d, flags: %d\n",
|
||||
screen_driver_table[i].name,
|
||||
screen_driver_table[i].max_bpp,
|
||||
screen_driver_table[i].flags
|
||||
);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void dump_font_drivers(void)
|
||||
{
|
||||
int i = 0;
|
||||
while( font_driver_table[i].name != NULL ) {
|
||||
printf("%s -> flags: %d\n",
|
||||
font_driver_table[i].name,
|
||||
font_driver_table[i].flags
|
||||
);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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 );
|
||||
}
|
||||
|
||||
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 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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
#ifdef WITH_8BPP_SUPPORT
|
||||
|
||||
|
||||
short web_std_colors[6] = {0, 51, 102, 153, 204, 255};
|
||||
|
||||
/*
|
||||
Convert an RGB color into an index into the 216 colors web pallette
|
||||
*/
|
||||
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];
|
||||
|
||||
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] ) {
|
||||
tval[i] = rgb[i] / web_std_colors[1];
|
||||
}
|
||||
else {
|
||||
int pos = ((short)rgb[i] / web_std_colors[1]);
|
||||
if( abs(rgb[i] - web_std_colors[pos]) > abs(rgb[i] - web_std_colors[pos+1]) )
|
||||
tval[i] = pos+1;
|
||||
else
|
||||
tval[i] = pos;
|
||||
}
|
||||
}
|
||||
return( tval[2]*36+tval[1]*6+tval[0] );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,364 +0,0 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#ifndef _GEM_PLOTTER_API_H_
|
||||
#define _GEM_PLOTTER_API_H_
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <windom.h>
|
||||
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/plot_style.h"
|
||||
#include "image/bitmap.h"
|
||||
#include "atari/bitmap.h"
|
||||
#include "atari/osspec.h"
|
||||
#include "atari/gui.h"
|
||||
#include "atari/font.h"
|
||||
#include "desktop/options.h"
|
||||
#include "atari/findfile.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
#ifndef ceilf
|
||||
#warning "ceilf emulation"
|
||||
#define ceilf(x) (float)ceil((double)x)
|
||||
#endif
|
||||
|
||||
#ifdef TEST_PLOTTER
|
||||
#define verbose_log 1
|
||||
#define LOG(x) do { if (verbose_log) (printf(__FILE__ " %s %i: ", __PRETTY_FUNCTION__, __LINE__), printf x, fputc('\n', stdout)); } while (0)
|
||||
#endif
|
||||
|
||||
#define MAX_FRAMEBUFS 0x010
|
||||
#define C2P (1<<0) /* C2P convert buffer 1 to buffer 2 */
|
||||
/* TODO: implement offscreen buffer switch */
|
||||
|
||||
/* Plotter Option Flags: */
|
||||
#define PLOT_FLAG_DITHER 0x04 /* true if the plotter shall dither images */
|
||||
#define PLOT_FLAG_TRANS 0x08 /* true if the plotter supports transparent operations */
|
||||
|
||||
/* Plotter "feature" flags */
|
||||
#define PLOT_FLAG_HAS_DITHER 0x0400
|
||||
#define PLOT_FLAG_HAS_ALPHA 0x0800
|
||||
#define PLOT_FLAG_OFFSCREEN 0x1000 /* offsreen plotter should set this flag */
|
||||
|
||||
/* Plotter "internal" flags */
|
||||
#define PLOT_FLAG_LOCKED 0x08000 /* plotter should set this flag during screen updates */
|
||||
|
||||
/* Font Plotter flags: */
|
||||
#define FONTPLOT_FLAG_MONOGLYPH 0x01
|
||||
|
||||
/* Flags for init_mfdb function: */
|
||||
#define MFDB_FLAG_STAND 0x01
|
||||
#define MFDB_FLAG_ZEROMEM 0x02
|
||||
#define MFDB_FLAG_NOALLOC 0x04
|
||||
|
||||
/* Flags for blit functions: */
|
||||
#define BITMAPF_MONOGLYPH 4096 /* The bitmap is an character bitmap */
|
||||
#define BITMAPF_BUFFER_NATIVE 8192 /* Bitmap shall be kept converted */
|
||||
|
||||
/* Error codes: */
|
||||
#define ERR_BUFFERSIZE_EXCEEDS_SCREEN 1 /* The buffer allocated is larger than the screen */
|
||||
#define ERR_NO_MEM 2 /* Not enough memory for requested operation */
|
||||
#define ERR_PLOTTER_NOT_AVAILABLE 3 /* invalid plotter driver name passed */
|
||||
|
||||
/* Grapics & Font Plotter "Objects": */
|
||||
typedef struct s_font_plotter * FONT_PLOTTER;
|
||||
typedef struct s_gem_plotter * GEM_PLOTTER;
|
||||
typedef struct s_font_plotter * GEM_FONT_PLOTTER; /* for public use ... */
|
||||
|
||||
|
||||
/* declaration of font plotter member functions: (_fpmf_ prefix) */
|
||||
typedef int (*_fpmf_str_width)( FONT_PLOTTER self, const plot_font_style_t *fstyle,
|
||||
const char * str, size_t length, int * width);
|
||||
typedef int (*_fpmf_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);
|
||||
typedef int (*_fpmf_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);
|
||||
typedef int (*_fpmf_text)( FONT_PLOTTER self, int x, int y, const char *text,
|
||||
size_t length, const plot_font_style_t *fstyle);
|
||||
|
||||
typedef void (*_fpmf_draw_glyph)(FONT_PLOTTER self, GRECT * clip, GRECT * loc,
|
||||
uint8_t * pixdata, int pitch, uint32_t colour);
|
||||
typedef int (*_fpmf_dtor)( FONT_PLOTTER self );
|
||||
|
||||
|
||||
/* prototype of the font plotter "object" */
|
||||
struct s_font_plotter
|
||||
{
|
||||
char * name;
|
||||
int flags;
|
||||
int vdi_handle;
|
||||
void * priv_data;
|
||||
GEM_PLOTTER plotter;
|
||||
|
||||
_fpmf_str_width str_width;
|
||||
_fpmf_str_split str_split;
|
||||
_fpmf_pixel_pos pixel_pos;
|
||||
_fpmf_text text;
|
||||
_fpmf_draw_glyph draw_glyph;
|
||||
_fpmf_dtor dtor;
|
||||
};
|
||||
|
||||
|
||||
struct rect;
|
||||
|
||||
struct s_vdi_sysinfo {
|
||||
short vdi_handle; /* vdi handle */
|
||||
short scr_w; /* resolution horz. */
|
||||
short scr_h; /* resolution vert. */
|
||||
short scr_bpp; /* bits per pixel */
|
||||
int colors; /* 0=hiclor, 2=mono */
|
||||
unsigned long hicolors; /* if colors = 0 */
|
||||
short pixelsize; /* bytes per pixel */
|
||||
unsigned short pitch; /* row pitch */
|
||||
unsigned short vdiformat; /* pixel format */
|
||||
unsigned short clut; /* type of clut support */
|
||||
void * screen; /* pointer to screen, or NULL */
|
||||
unsigned long screensize;/* size of screen (in bytes) */
|
||||
unsigned long mask_r; /* color masks */
|
||||
unsigned long mask_g;
|
||||
unsigned long mask_b;
|
||||
unsigned long mask_a;
|
||||
short maxintin; /* maximum pxy items */
|
||||
short maxpolycoords; /* max coords for p_line etc. */
|
||||
unsigned long EdDiVersion;/* EdDi Version or 0 */
|
||||
bool rasterscale; /* raster scaling support */
|
||||
};
|
||||
|
||||
|
||||
/* 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 );
|
||||
typedef void * (*_pmf_create_framebuffer)(GEM_PLOTTER self);
|
||||
typedef void * (*_pmf_switch_to_framebuffer)(GEM_PLOTTER self);
|
||||
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_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);
|
||||
typedef int (*_pmf_rectangle)(GEM_PLOTTER self, int x0, int y0, int x1, int y1, const plot_style_t * pstyle);
|
||||
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, unsigned char fgcolor, uint32_t flags);
|
||||
typedef int (*_pmf_text)(GEM_PLOTTER self, int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle);
|
||||
typedef int (*_pmf_blit)(GEM_PLOTTER self, GRECT * region);
|
||||
typedef int (*_pmf_dtor)(GEM_PLOTTER self);
|
||||
|
||||
|
||||
/* this is the prototype of an plotter "object" */
|
||||
struct s_gem_plotter
|
||||
{
|
||||
char * name; /* name that identifies the Plotter */
|
||||
unsigned long flags;
|
||||
int vdi_handle;
|
||||
struct s_vdi_sysinfo * scr;
|
||||
void * priv_data;
|
||||
/* bit depth of framebuffers: */
|
||||
int bpp_virt;
|
||||
|
||||
FONT_PLOTTER font_plotter;
|
||||
/* set new dimensions (realloc memory): */
|
||||
_pmf_resize resize;
|
||||
/* set drawing origin: */
|
||||
_pmf_move move;
|
||||
_pmf_lock lock;
|
||||
_pmf_unlock unlock;
|
||||
_pmf_create_framebuffer create_framebuffer;
|
||||
_pmf_switch_to_framebuffer switch_to_framebuffer;
|
||||
_pmf_put_pixel put_pixel;
|
||||
_pmf_copy_rect copy_rect;
|
||||
_pmf_set_clip set_clip;
|
||||
_pmf_get_clip get_clip;
|
||||
_pmf_arc arc;
|
||||
_pmf_disc disc;
|
||||
_pmf_line line;
|
||||
_pmf_rectangle rectangle;
|
||||
_pmf_polygon polygon;
|
||||
_pmf_path path;
|
||||
/* scale an netsurf bitmap: */
|
||||
_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: */
|
||||
_pmf_plot_mfdb plot_mfdb;
|
||||
/* draw to screen, only valid for offscreen plotters: */
|
||||
_pmf_blit blit;
|
||||
_pmf_text text;
|
||||
_pmf_dtor dtor;
|
||||
};
|
||||
|
||||
|
||||
/* these 2 structs hold info about an specific driver. */
|
||||
/* a table in plotter.c defines all the available plotters */
|
||||
struct s_driver_table_entry
|
||||
{
|
||||
|
||||
/* 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
|
||||
{
|
||||
const char * name;
|
||||
int (*ctor)( FONT_PLOTTER self );
|
||||
int flags;
|
||||
};
|
||||
|
||||
typedef struct s_driver_table_entry * PLOTTER_INFO;
|
||||
typedef struct s_font_driver_table_entry * FONT_PLOTTER_INFO;
|
||||
|
||||
/* get s_driver_table_entry from driver table */
|
||||
struct s_driver_table_entry * get_screen_driver_entry(char * name);
|
||||
|
||||
/* get s_font_driver_table_entry from driver table */
|
||||
struct s_font_driver_table_entry * get_font_driver_entry(char * name);
|
||||
|
||||
/* fill screen / sys info */
|
||||
struct s_vdi_sysinfo * read_vdi_sysinfo(short vdih, struct s_vdi_sysinfo * info );
|
||||
|
||||
/*
|
||||
Create an new plotter object
|
||||
Error Values:
|
||||
-1 no mem
|
||||
-2 error configuring plotter
|
||||
-3 Plotter not available
|
||||
*/
|
||||
GEM_PLOTTER new_plotter(int vdihandle, char * name,
|
||||
GRECT *, int virt_bpp, unsigned long flags, FONT_PLOTTER font_renderer,
|
||||
int * error);
|
||||
|
||||
/*
|
||||
Create an new font plotter object
|
||||
Error Values:
|
||||
-1 no mem
|
||||
-2 error configuring font plotter
|
||||
-3 Font Plotter not available
|
||||
*/
|
||||
FONT_PLOTTER new_font_plotter(int vdihandle, char * name, unsigned long flags, int * error );
|
||||
|
||||
/* free the plotter resources */
|
||||
int delete_plotter( GEM_PLOTTER p );
|
||||
int delete_font_plotter( FONT_PLOTTER p );
|
||||
|
||||
|
||||
/* calculate size of intermediate buffer */
|
||||
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 );
|
||||
|
||||
/* translate an error number */
|
||||
const char* plotter_err_str(int i) ;
|
||||
|
||||
void dump_font_drivers(void);
|
||||
void dump_plot_drivers(void);
|
||||
void dump_vdi_info(short);
|
||||
|
||||
/* convert an vdi color to bgra */
|
||||
void vdi1000_to_rgb( unsigned short * in, unsigned char * out );
|
||||
|
||||
/* convert an bgra color to vdi1000 color */
|
||||
void rgb_to_vdi1000( unsigned char * in, unsigned short * out );
|
||||
|
||||
/* convert an rgb color to an index into the web palette */
|
||||
short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b);
|
||||
|
||||
/*
|
||||
setup an MFDB struct and allocate memory for it when it is needed.
|
||||
If bpp == 0, this function assumes that the MFDB shall point to the screen
|
||||
and will not allocate any memory (mfdb.fd_addr == 0).
|
||||
The function will return 0 when the memory allocation fails
|
||||
( out of memory), otherwise it returns the size of the mfdb.fd_addr
|
||||
as number of bytes.
|
||||
*/
|
||||
int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out );
|
||||
|
||||
/* shared / static methods follows */
|
||||
|
||||
/*
|
||||
Get clipping for current framebuffer
|
||||
*/
|
||||
int plotter_get_clip( GEM_PLOTTER self, struct rect * out );
|
||||
|
||||
/*
|
||||
Get clipping for current framebuffer as GRECT
|
||||
*/
|
||||
void plotter_get_clip_grect( GEM_PLOTTER self, GRECT * out );
|
||||
|
||||
|
||||
#define PLOTTER_IS_LOCKED(plotter) ( plotter->private_flags & PLOTTER_FLAG_LOCKED )
|
||||
|
||||
|
||||
/*
|
||||
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 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
|
||||
|
||||
|
||||
#endif
|
@ -1,237 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 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_GD_PLOTTER
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <windom.h>
|
||||
#include <gd.h>
|
||||
|
||||
#include "atari/plot/eddi.h"
|
||||
#include "atari/plot/plotter.h"
|
||||
#include "atari/plot/plotter_gd.h"
|
||||
|
||||
#include "plotter.h"
|
||||
|
||||
static int dtor( GEM_PLOTTER self );
|
||||
static int resize( GEM_PLOTTER self, int w, int h );
|
||||
static int move( GEM_PLOTTER self, short x, short y );
|
||||
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);
|
||||
static int rectangle(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plot_style_t * pstyle);
|
||||
static int polygon(GEM_PLOTTER self,const int *p, unsigned int n, const plot_style_t * pstyle);
|
||||
static int path(GEM_PLOTTER self,const float *p, unsigned int n, int fill, float width, int c, const float transform[6]);
|
||||
static int bitmap_resize( GEM_PLOTTER self, struct bitmap * img, int nw, int nh );
|
||||
static int bitmap_convert( GEM_PLOTTER self, struct bitmap * img, int x, int y,
|
||||
GRECT * clip,uint32_t bg,uint32_t flags, MFDB *out );
|
||||
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, GRECT * origin_size )
|
||||
{
|
||||
|
||||
instance->dtor = dtor;
|
||||
instance->resize= resize;
|
||||
instance->move = move;
|
||||
instance->lock = lock;
|
||||
instance->unlock = unlock;
|
||||
instance->put_pixel = put_pixel;
|
||||
instance->copy_rect = copy_rect;
|
||||
instance->get_clip = get_clip;
|
||||
instance->set_clip = set_clip;
|
||||
instance->arc = arc;
|
||||
instance->disc = disc;
|
||||
instance->line = line;
|
||||
instance->rectangle = rectangle;
|
||||
instance->polygon = polygon;
|
||||
instance->path = path;
|
||||
instance->bitmap = bitmap;
|
||||
instance->bitmap_resize = bitmap_resize;
|
||||
instance->bitmap_convert = bitmap_convert;
|
||||
instance->plot_mfdb = NULL;
|
||||
instance->text = text;
|
||||
|
||||
instance->priv_data = malloc( sizeof(struct s_gd_priv_data) );
|
||||
if( instance->priv_data == NULL )
|
||||
return( 0-ERR_NO_MEM );
|
||||
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 );
|
||||
}
|
||||
|
||||
static int dtor( GEM_PLOTTER instance )
|
||||
{
|
||||
int i;
|
||||
free( instance->priv_data );
|
||||
gdImageDestroy( THIS(instance)->vbuf );
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
static int resize( GEM_PLOTTER instance, int w, int h )
|
||||
{
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
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 instance ){
|
||||
instance->flags |= PLOT_FLAG_LOCKED;
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
static int unlock( GEM_PLOTTER instance )
|
||||
{
|
||||
instance->flags &= ~PLOT_FLAG_LOCKED;
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
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 instance, GRECT src, GRECT dst )
|
||||
{
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
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 instance,int x, int y, int radius, const plot_style_t * pstyle)
|
||||
{
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
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 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 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 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 instance, struct bitmap * img, int nw, int nh )
|
||||
{
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
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 instance, struct bitmap * bmp, int x, int y,
|
||||
unsigned long bg, unsigned long flags )
|
||||
{
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
static int plot_mfdb( GEM_PLOTTER instance, GRECT * where, MFDB * mfdb, unsigned char fgcolor, uint32_t flags)
|
||||
{
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
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
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 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_GD_PLOTTER
|
||||
#ifndef GEM_PLOTTER_GD_H_INCLUDED
|
||||
#define GEM_PLOTTER_GD_H_INCLUDED
|
||||
|
||||
|
||||
#include <gd.h>
|
||||
#include "plotter.h"
|
||||
|
||||
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*)instance->priv_data)
|
||||
|
||||
/* Each driver object must export 1 it's own constructor: */
|
||||
int ctor_plotter_gd( GEM_PLOTTER p, GRECT * loc_size );
|
||||
|
||||
#endif
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,109 +0,0 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#ifndef GEM_PLOTTER_DUMMY_H_INCLUDED
|
||||
#define GEM_PLOTTER_DUMMY_H_INCLUDED
|
||||
|
||||
#include "plotter.h"
|
||||
#include <Hermes/Hermes.h>
|
||||
|
||||
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;
|
||||
/* temp buffer for bitmap conversion: */
|
||||
void * buf_packed;
|
||||
int size_buf_packed;
|
||||
|
||||
/* temp buffer for bitmap conversion: */
|
||||
void * buf_planar;
|
||||
int size_buf_planar;
|
||||
|
||||
/* buffer for plot operations that require device format, */
|
||||
/* currently used for transparent mfdb blits and snapshots: */
|
||||
MFDB 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 */
|
||||
HermesFormat vfmt;
|
||||
|
||||
/* no screen format here, hermes may not suitable for it */
|
||||
|
||||
/* netsurf source bitmap format */
|
||||
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: */
|
||||
#define CONV_KEEP_LIMIT 512000
|
||||
/* how much memory to allocate if some is needed: */
|
||||
#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 VIEW( priv ) DUMMY_PRIV( priv )->view
|
||||
|
||||
/* Each driver object must export 1 it's own constructor: */
|
||||
int ctor_plotter_vdi( GEM_PLOTTER p, GRECT * loc_size );
|
||||
|
||||
/*
|
||||
* Capture the screen at x,y location
|
||||
* param self instance
|
||||
* param x absolute screen coords
|
||||
* param y absolute screen coords
|
||||
* param w width
|
||||
* param h height
|
||||
*
|
||||
* This creates an snapshot in RGBA format (NetSurf's native format)
|
||||
*
|
||||
*/
|
||||
static struct bitmap * snapshot_create(GEM_PLOTTER self, int x, int y, int w, int h);
|
||||
|
||||
/* Garbage collection of the snapshot routine */
|
||||
/* this should be called after you are done with the data returned by snapshot_create */
|
||||
/* don't access the screenshot after you called this function */
|
||||
static void snapshot_suspend(GEM_PLOTTER self );
|
||||
|
||||
/* destroy memory used by screenshot */
|
||||
static void snapshot_destroy( GEM_PLOTTER self );
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user