GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
cairodriver.h
Go to the documentation of this file.
1 /*!
2  \file cairodriver/cairodriver.h
3 
4  \brief GRASS cairo display driver - header file
5 
6  (C) 2007-2008 by Lars Ahlzen and the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Lars Ahlzen <lars ahlzen.com> (original contibutor)
12  \author Glynn Clements
13 */
14 
15 #ifndef __CAIRODRIVER_H__
16 #define __CAIRODRIVER_H__
17 
18 #include <grass/config.h>
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 
24 #include <cairo.h>
25 
26 #if !defined(USE_X11) || !CAIRO_HAS_XLIB_SURFACE || CAIRO_VERSION < CAIRO_VERSION_ENCODE(1,6,0)
27 #undef CAIRO_HAS_XLIB_XRENDER_SURFACE
28 #define CAIRO_HAS_XLIB_XRENDER_SURFACE 0
29 #endif
30 
31 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
32 #include <X11/X.h>
33 #include <X11/Xlib.h>
34 #include <X11/Xutil.h>
35 #include <X11/extensions/Xrender.h>
36 #endif
37 
38 #include <grass/gis.h>
39 
40 #include "driver.h"
41 #include "driverlib.h"
42 
43 #define DEFAULT_FILE_NAME "map.png"
44 
45 #define HEADER_SIZE 64
46 
47 /* Scale for converting colors from [0..255] to cairo's [0.0..1.0] */
48 #define COLORSCALE (1.0/255.0)
49 #define CAIROCOLOR(a) (((double)(a))*COLORSCALE)
50 
51 /* File types */
52 #define FTYPE_UNKNOWN 0
53 #define FTYPE_PPM 1
54 #define FTYPE_BMP 2
55 #define FTYPE_PNG 3
56 #define FTYPE_PDF 4
57 #define FTYPE_PS 5
58 #define FTYPE_SVG 6
59 #define FTYPE_X11 7
60 
61 extern cairo_surface_t *surface;
62 extern cairo_t *cairo;
63 
64 struct cairo_state {
65  char *file_name;
66  int file_type;
68  unsigned char *grid;
70  int modified;
71  int mapped;
72 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
73  Display *dpy;
74  Drawable win;
75  Screen *screen;
76  XRenderPictFormat *format;
77  int depth;
78 #endif
79 };
80 
81 extern struct cairo_state ca;
82 
83 extern const struct driver *Cairo_Driver(void);
84 
85 extern void Cairo_Client_Close(void);
86 extern int Cairo_Graph_set(void);
87 extern const char *Cairo_Graph_get_file(void);
88 extern void Cairo_Graph_close(void);
89 extern void Cairo_Box(double, double, double, double);
90 extern void Cairo_Set_window(double, double, double, double);
91 extern void Cairo_Bitmap(int, int, int, const unsigned char *);
92 extern void Cairo_Color(int, int, int);
93 extern void Cairo_Erase(void);
94 extern void Cairo_begin_raster(int, int[2][2], double[2][2]);
95 extern int Cairo_raster(int, int,
96  const unsigned char *, const unsigned char *,
97  const unsigned char *, const unsigned char *);
98 extern void Cairo_end_raster(void);
99 extern void Cairo_Begin(void);
100 extern void Cairo_Move(double, double);
101 extern void Cairo_Cont(double, double);
102 extern void Cairo_Close(void);
103 extern void Cairo_Stroke(void);
104 extern void Cairo_Fill(void);
105 extern void Cairo_Point(double, double);
106 extern void Cairo_Line_width(double);
107 extern void Cairo_Text(const char *);
108 extern void Cairo_text_box(const char *, double *, double *, double *, double *);
109 extern void Cairo_set_font(const char *);
110 extern void Cairo_font_list(char ***, int *);
111 extern void Cairo_font_info(char ***, int *);
112 
113 /* read.c */
114 extern void cairo_read_image(void);
115 extern void cairo_read_ppm(void);
116 extern void cairo_read_bmp(void);
117 extern void cairo_read_xid(void);
118 
119 /* write.c */
120 extern void cairo_write_image(void);
121 extern void cairo_write_ppm(void);
122 extern void cairo_write_bmp(void);
123 extern void cairo_write_xid(void);
124 
125 #endif /* __CAIRODRIVER_H__ */
void cairo_read_xid(void)
Definition: read_xid.c:5
double bgcolor_a
Definition: cairodriver.h:69
void Cairo_Color(int, int, int)
Set source color (opaque)
void Cairo_begin_raster(int, int[2][2], double[2][2])
Start drawing raster.
void Cairo_Bitmap(int, int, int, const unsigned char *)
Draw bitmap.
const char * Cairo_Graph_get_file(void)
Get render file.
void cairo_read_ppm(void)
void Cairo_Graph_close(void)
Close driver.
struct cairo_state ca
void Cairo_Text(const char *)
Draw text.
void Cairo_Set_window(double, double, double, double)
Set window.
void Cairo_Close(void)
char * file_name
Definition: cairodriver.h:65
int Cairo_Graph_set(void)
Initialize driver.
void Cairo_Begin(void)
void Cairo_Fill(void)
double bgcolor_r
Definition: cairodriver.h:69
void Cairo_font_info(char ***, int *)
Get fonts into.
void Cairo_set_font(const char *)
Set font.
void Cairo_Client_Close(void)
double bgcolor_b
Definition: cairodriver.h:69
cairo_t * cairo
void cairo_write_ppm(void)
void cairo_write_bmp(void)
int Cairo_raster(int, int, const unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *)
Draw raster row.
unsigned char * grid
Definition: cairodriver.h:68
void cairo_write_image(void)
void cairo_read_bmp(void)
const struct driver * Cairo_Driver(void)
Initialize display driver.
void Cairo_font_list(char ***, int *)
Get list of fonts.
void Cairo_Line_width(double)
Set line width.
void cairo_read_image(void)
Definition: driver.h:22
cairo_surface_t * surface
void Cairo_end_raster(void)
Finish drawing raster.
void Cairo_Move(double, double)
void cairo_write_xid(void)
Definition: write_xid.c:6
void Cairo_Cont(double, double)
void Cairo_Box(double, double, double, double)
Draw a (filled) rectangle.
void Cairo_Erase(void)
Erase screen.
void Cairo_Point(double, double)
double bgcolor_g
Definition: cairodriver.h:69
void Cairo_Stroke(void)
void Cairo_text_box(const char *, double *, double *, double *, double *)