NetSurf
plot.h
Go to the documentation of this file.
1/*
2 * Copyright 2010 Ole Loots <ole@monochrom.net>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef NS_ATARI_PLOT_H
20#define NS_ATARI_PLOT_H
21
22/** how much memory should be kept allocated for temp. conversion bitmaps: */
23#define CONV_KEEP_LIMIT 512000
24
25/** how much memory to allocate if some is needed: */
26#define CONV_BLOCK_SIZE 32000
27
28/* Plotter Option Flags: */
29#define PLOT_FLAG_DITHER 0x04 /**< set if the plotter shall dither images */
30#define PLOT_FLAG_TRANS 0x08 /**< set if the plotter supports transparent operations */
31
32/* Plotter "feature" flags */
33#define PLOT_FLAG_HAS_DITHER 0x0400
34#define PLOT_FLAG_HAS_ALPHA 0x0800
35#define PLOT_FLAG_OFFSCREEN 0x1000 /**< offscreen plotter should set this flag */
36
37/* Plotter "internal" flags */
38#define PLOT_FLAG_LOCKED 0x08000 /**< plotter should set this flag during screen updates */
39
40/* Font Plotter flags: */
41#define FONTPLOT_FLAG_MONOGLYPH 0x01
42
43/* Flags for init_mfdb function: */
44#define MFDB_FLAG_STAND 0x01
45#define MFDB_FLAG_ZEROMEM 0x02
46#define MFDB_FLAG_NOALLOC 0x04
47
48/* Flags for blit functions: */
49#define BITMAPF_MONOGLYPH 4096 /**< The bitmap is an character bitmap */
50#define BITMAPF_BUFFER_NATIVE 8192 /**< Bitmap shall be kept converted */
51
52/* Error codes: */
53#define ERR_BUFFERSIZE_EXCEEDS_SCREEN 1 /* The buffer allocated is larger than the screen */
54#define ERR_NO_MEM 2 /* Not enough memory for requested operation */
55#define ERR_PLOTTER_NOT_AVAILABLE 3 /* invalid plotter driver name passed */
56
57struct plot_style_s;
58struct redraw_context;
59
61 short vdi_handle; /**< vdi handle */
62 short scr_w; /**< resolution horz. */
63 short scr_h; /**< resolution vert. */
64 short scr_bpp; /**< bits per pixel */
65 int colors; /**< 0=hiclor, 2=mono */
66 unsigned long hicolors; /**< if colors = 0 */
67 short pixelsize; /**< bytes per pixel */
68 unsigned short pitch; /**< row pitch */
69 unsigned short vdiformat; /**< pixel format */
70 unsigned short clut; /**< type of clut support */
71 void *screen; /**< pointer to screen, or NULL */
72 unsigned long screensize; /**< size of screen (in bytes) */
73 unsigned long mask_r; /**< red color mask */
74 unsigned long mask_g; /**< green color mask */
75 unsigned long mask_b; /**< blue color mask */
76 unsigned long mask_a; /**< alpha color mask */
77 short maxintin; /* maximum pxy items */
78 short maxpolycoords; /* max coords for p_line etc. */
79 unsigned long EdDiVersion; /* EdDi Version or 0 */
80 bool rasterscale; /* raster scaling support */
81};
82
83struct rect;
84
85extern const struct plotter_table atari_plotters;
86
87/**
88 * Init screen and font driver objects.
89 *
90 * \param ctx The current redraw context.
91 * \param fdrvrname font driver name.
92 * \return value > 1 when the objects could be succesfully created or
93 * <= 0 to indicate an error.
94 */
95int plot_init(const struct redraw_context *ctx, char *fdrvrname);
96
97int plot_finalise(void);
98
99/**
100 * translate an error number
101 */
102const char* plot_err_str(int i) ;
103
104bool plot_lock(void);
105bool plot_unlock(void);
106
107/**
108 * Set plot origin and canvas size
109 *
110 * \param ctx The current redraw context.
111 * \param x the x origin
112 * \param y the y origin
113 * \param w the width of the plot area
114 * \param h the height of the plot area
115 */
116bool plot_set_dimensions(const struct redraw_context *ctx, int x, int y, int w, int h );
117bool plot_get_dimensions(GRECT *dst);
118float plot_get_scale(void);
119float plot_set_scale(float);
120void plot_set_abs_clipping(const GRECT *area);
121void plot_get_abs_clipping(struct rect *dst);
122void plot_get_abs_clipping_grect(GRECT *dst);
123bool plot_get_clip(struct rect * out);
124/** Get clipping for current framebuffer as GRECT */
125void plot_get_clip_grect(GRECT * out);
126VdiHdl plot_get_vdi_handle(void);
127long plot_get_flags(void);
128bool plot_blit_bitmap(struct bitmap * bmp, int x, int y,
129 unsigned long bg, unsigned long flags);
130bool plot_blit_mfdb(GRECT * loc, MFDB * insrc, short fgcolor, uint32_t flags);
131bool plot_copy_rect(GRECT src, GRECT dst);
132
133/* convert an vdi color to bgra */
134void vdi1000_to_rgb( unsigned short * in, unsigned char * out );
135
136/* convert an bgra color to vdi1000 color */
137void rgb_to_vdi1000( unsigned char * in, RGB1000 *out);
138
139/* convert an rgb color to an index into the web palette */
140short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b);
141
142/* assign vdi line style to dst ( netsurf type ) */
143#define NSLT2VDI(dst, src) \
144 dst = 0; \
145 switch( src->stroke_type ) { \
146 case PLOT_OP_TYPE_DOT: \
147 dst = (0xAAAA00 | 7); \
148 break; \
149 case PLOT_OP_TYPE_DASH: \
150 dst = 3; \
151 break; \
152 case PLOT_OP_TYPE_SOLID: \
153 case PLOT_OP_TYPE_NONE: \
154 default: \
155 dst = 1; \
156 break; \
157 }
158
159
160#ifdef WITH_8BPP_SUPPORT
161/* some Well known indexes into the VDI palette */
162/* common indexes into the VDI palette */
163/* (only used when running with 256 colors or less ) */
164#define OFFSET_WEB_PAL 16
165#define OFFSET_CUST_PAL 232
166#define RGB_TO_VDI(c) rgb_to_666_index( (c&0xFF),(c&0xFF00)>>8,(c&0xFF0000)>>16)+OFFSET_WEB_PAL
167#endif /* WITH_8BPP_SUPPORT*/
168
169/* the name of this macro is crap - it should be named bgr_to_rgba ... or so */
170#define ABGR_TO_RGB(c) ( ((c&0xFF)<<16) | (c&0xFF00) | ((c&0xFF0000)>>16) ) << 8
171
172/* this index into the palette is used by the TC renderer to set
173 * current draw color.
174 */
175#define OFFSET_CUSTOM_COLOR 255
176
177#endif
bool plot_blit_mfdb(GRECT *loc, MFDB *insrc, short fgcolor, uint32_t flags)
Definition: plot.c:1551
const struct plotter_table atari_plotters
atari plottr operation table
Definition: plot.c:2507
void plot_get_abs_clipping(struct rect *dst)
Get the maximum clip extent, in absolute screen coords.
Definition: plot.c:1899
bool plot_blit_bitmap(struct bitmap *bmp, int x, int y, unsigned long bg, unsigned long flags)
Definition: plot.c:1482
float plot_get_scale(void)
Definition: plot.c:1864
void rgb_to_vdi1000(unsigned char *in, RGB1000 *out)
Convert an RGB color to an VDI Color.
Definition: plot.c:564
bool plot_lock(void)
Definition: plot.c:1775
long plot_get_flags(void)
Definition: plot.c:1924
bool plot_get_clip(struct rect *out)
Definition: plot.c:1930
const char * plot_err_str(int i)
translate an error number
Definition: plot.c:216
short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b)
void vdi1000_to_rgb(unsigned short *in, unsigned char *out)
Definition: plot.c:576
VdiHdl plot_get_vdi_handle(void)
Definition: plot.c:1918
void plot_get_clip_grect(GRECT *out)
Get clipping for current framebuffer as GRECT.
Definition: plot.c:1940
float plot_set_scale(float)
set scale of plotter.
Definition: plot.c:1854
bool plot_copy_rect(GRECT src, GRECT dst)
copy an rectangle from the plot buffer to screen
Definition: plot.c:374
void plot_set_abs_clipping(const GRECT *area)
Subsequent calls to plot_clip will be clipped by the absolute clip.
Definition: plot.c:1875
bool plot_set_dimensions(const struct redraw_context *ctx, int x, int y, int w, int h)
Set plot origin and canvas size.
Definition: plot.c:1806
void plot_get_abs_clipping_grect(GRECT *dst)
Get the maximum clip extent, in absolute screen coords.
Definition: plot.c:1909
bool plot_get_dimensions(GRECT *dst)
Get current canvas size.
Definition: plot.c:1838
int plot_finalise(void)
Definition: plot.c:1748
int plot_init(const struct redraw_context *ctx, char *fdrvrname)
Init screen and font driver objects.
Definition: plot.c:1612
bool plot_unlock(void)
Definition: plot.c:1791
RISC OS wimp toolkit bitmap.
Definition: bitmap.c:68
Plot style for stroke/fill plotters.
Definition: plot_style.h:76
Plotter operations table.
Definition: plotters.h:102
Rectangle coordinates.
Definition: types.h:40
Redraw context.
Definition: plotters.h:51
bool rasterscale
Definition: plot.h:80
void * screen
pointer to screen, or NULL
Definition: plot.h:71
short scr_h
resolution vert.
Definition: plot.h:63
unsigned long screensize
size of screen (in bytes)
Definition: plot.h:72
short pixelsize
bytes per pixel
Definition: plot.h:67
unsigned long hicolors
if colors = 0
Definition: plot.h:66
unsigned long mask_b
blue color mask
Definition: plot.h:75
int colors
0=hiclor, 2=mono
Definition: plot.h:65
short vdi_handle
vdi handle
Definition: plot.h:61
short scr_bpp
bits per pixel
Definition: plot.h:64
unsigned short pitch
row pitch
Definition: plot.h:68
short maxintin
Definition: plot.h:77
unsigned long mask_a
alpha color mask
Definition: plot.h:76
short maxpolycoords
Definition: plot.h:78
unsigned long EdDiVersion
Definition: plot.h:79
unsigned short clut
type of clut support
Definition: plot.h:70
unsigned short vdiformat
pixel format
Definition: plot.h:69
unsigned long mask_g
green color mask
Definition: plot.h:74
short scr_w
resolution horz.
Definition: plot.h:62
unsigned long mask_r
red color mask
Definition: plot.h:73