diff options
author | Ole Loots <ole@monochrom.net> | 2012-03-12 21:24:38 +0000 |
---|---|---|
committer | Ole Loots <ole@monochrom.net> | 2012-03-12 21:24:38 +0000 |
commit | 2e65e51fc5ad3042201988d49ba061a781b70351 (patch) | |
tree | b2dceed93492e87e11a708fe3e3e34aadc47b0d1 | |
parent | 4604f293b768aa806f951e260518c62b3f4367c1 (diff) | |
download | netsurf-2e65e51fc5ad3042201988d49ba061a781b70351.tar.gz netsurf-2e65e51fc5ad3042201988d49ba061a781b70351.tar.bz2 |
Added GD Plotter stub.
svn path=/trunk/netsurf/; revision=13512
-rwxr-xr-x | atari/plot/plotter.c | 64 | ||||
-rw-r--r-- | atari/plot/plotter_gd.c | 187 | ||||
-rw-r--r-- | atari/plot/plotter_gd.h | 37 |
3 files changed, 265 insertions, 23 deletions
diff --git a/atari/plot/plotter.c b/atari/plot/plotter.c index 06632d3ee..7a4ff81ea 100755 --- a/atari/plot/plotter.c +++ b/atari/plot/plotter.c @@ -31,7 +31,11 @@ #include "image/bitmap.h"
#include "atari/plot/eddi.h"
#include "atari/plot/plotter.h" -#include "atari/plot/plotter_vdi.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 @@ -46,6 +50,40 @@ #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
+ {(char*)"vdi", ctor_font_plotter_vdi, 0},
+#endif +#ifdef WITH_FREETYPE_FONT_DRIVER + {(char*)"freetype", ctor_font_plotter_freetype, 0}, +#endif +#ifdef WITH_INTERNAL_FONT_DRIVER
+ {(char*)"internal", ctor_font_plotter_internal, 0}, +#endif
+ {(char*)NULL, NULL, 0}
+}; + /* get index to driver in driver list by name */
static int drvrname_idx( char * name ); @@ -103,26 +141,6 @@ unsigned short vdi_web_pal[216][3] = { static short prev_vdi_clip[4];
struct s_vdi_sysinfo vdi_sysinfo;
-struct s_driver_table_entry screen_driver_table[] =
-{
- {(char*)"vdi", ctor_plotter_vdi, 0, 32},
- {(char*)NULL, NULL, 0, 0 }
-};
-
-const struct s_font_driver_table_entry font_driver_table[] =
-{ -#ifdef WITH_VDI_FONT_DRIVER
- {(char*)"vdi", ctor_font_plotter_vdi, 0},
-#endif -#ifdef WITH_FREETYPE_FONT_DRIVER - {(char*)"freetype", ctor_font_plotter_freetype, 0}, -#endif -#ifdef WITH_INTERNAL_FONT_DRIVER
- {(char*)"internal", ctor_font_plotter_internal, 0}, -#endif
- {(char*)NULL, NULL, 0}
-};
-
struct s_vdi_sysinfo * read_vdi_sysinfo( short vdih, struct s_vdi_sysinfo * info ) {
unsigned long cookie_EdDI=0;
@@ -380,7 +398,7 @@ GEM_PLOTTER new_plotter(int vdihandle, char * name, GRECT * loc_size, gemplotter->name = name;
gemplotter->vdi_handle = vdihandle;
- gemplotter->flags |= flags;
+ gemplotter->flags = 0;
gemplotter->font_plotter = fplotter;
gemplotter->bpp_virt = virt_bpp;
gemplotter->cfbi = 0;
@@ -404,7 +422,7 @@ GEM_PLOTTER new_plotter(int vdihandle, char * name, GRECT * loc_size, else {
if( strcmp(name, screen_driver_table[i].name) == 0 ) {
if( screen_driver_table[i].ctor ) {
- gemplotter->flags |= screen_driver_table[i].flags;
+ gemplotter->flags = (screen_driver_table[i].flags | flags);
res = screen_driver_table[i].ctor( gemplotter );
*error = 0;
} else {
diff --git a/atari/plot/plotter_gd.c b/atari/plot/plotter_gd.c new file mode 100644 index 000000000..0b29dafd4 --- /dev/null +++ b/atari/plot/plotter_gd.c @@ -0,0 +1,187 @@ +/*
+ * 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 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); + +int ctor_plotter_gd( GEM_PLOTTER instance ){ + + 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->clip = plotter_std_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 + + return( 1 ); +} + +static int dtor( GEM_PLOTTER instance ) +{ + int i; + for( i=0; i<MAX_FRAMEBUFS; i++) { + if( instance->fbuf[i].mem != NULL ) + free( instance->fbuf[i].mem ); + } + free( instance->priv_data ); + return( 1 ); +} + +static int resize( GEM_PLOTTER self, int w, int h ) +{ + return( 1 ); +} + +static int move( GEM_PLOTTER self, short x, short y ) +{ + return( 1 ); +} + +static int lock( GEM_PLOTTER self ){ + return( 1 ); +} + +static int unlock( GEM_PLOTTER self ) +{ + return( 1 ); +} + +static int put_pixel(GEM_PLOTTER self, int x, int y, int color ) +{ + return( 1 ); + +} + +static int copy_rect( GEM_PLOTTER self, GRECT src, GRECT dst ) +{ + return( 1 ); +} + +static int arc(GEM_PLOTTER self,int x, int y, int radius, int angle1, int angle2, const plot_style_t * pstyle) +{ + return( 1 ); +} + +static int disc(GEM_PLOTTER self,int x, int y, int radius, const plot_style_t * pstyle) +{ + return( 1 ); +} + +static int line(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plot_style_t * pstyle) +{ + return( 1 ); +} + +static int rectangle(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plot_style_t * pstyle) +{ + return( 1 ); +} + +static int polygon(GEM_PLOTTER self,const int *p, unsigned int n, const plot_style_t * pstyle) +{ + return( 1 ); +} +static int path(GEM_PLOTTER self,const float *p, unsigned int n, int fill, float width, int c, const float transform[6]) +{ + return( 1 ); +} + +static int bitmap_resize( GEM_PLOTTER self, struct bitmap * img, int nw, int nh ) +{ + return( 1 ); +} + +static int bitmap_convert( GEM_PLOTTER self, struct bitmap * img, int x, int y, + GRECT * clip,uint32_t bg,uint32_t flags, MFDB *out ) +{ + return( 1 ); +} + +static int bitmap( GEM_PLOTTER self, struct bitmap * bmp, int x, int y, + unsigned long bg, unsigned long flags ) +{ + return( 1 ); +} + +static int plot_mfdb( GEM_PLOTTER self, GRECT * where, MFDB * mfdb, unsigned char fgcolor, uint32_t flags) +{ + return( 1 ); +} + +static int text(GEM_PLOTTER self, int x, int y, const char *text,size_t length, const plot_font_style_t *fstyle) +{ + return( 1 ); +} + + +#endif diff --git a/atari/plot/plotter_gd.h b/atari/plot/plotter_gd.h new file mode 100644 index 000000000..da223a565 --- /dev/null +++ b/atari/plot/plotter_gd.h @@ -0,0 +1,37 @@ +/*
+ * 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 {
+
+};
+
+/* this is an shortcut cast to access the members of the s_gd_priv_data */
+#define THIS(instance) ((struct s_gd_priv_data*)self->priv_data)
+
+/* Each driver object must export 1 it's own constructor: */
+int ctor_plotter_gd( GEM_PLOTTER p );
+
+#endif
+#endif |