GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
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 contributor)
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 || \
27  CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 6, 0)
28 #undef CAIRO_HAS_XLIB_XRENDER_SURFACE
29 #define CAIRO_HAS_XLIB_XRENDER_SURFACE 0
30 #endif
31 
32 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
33 #include <X11/X.h>
34 #include <X11/Xlib.h>
35 #include <X11/Xutil.h>
36 #include <X11/extensions/Xrender.h>
37 #endif
38 
39 #include <grass/gis.h>
40 
41 #include "driver.h"
42 #include "driverlib.h"
43 
44 #define DEFAULT_FILE_NAME "map.png"
45 
46 #define HEADER_SIZE 64
47 
48 /* Scale for converting colors from [0..255] to cairo's [0.0..1.0] */
49 #define COLORSCALE (1.0 / 255.0)
50 #define CAIROCOLOR(a) (((double)(a)) * COLORSCALE)
51 
52 /* File types */
53 #define FTYPE_UNKNOWN 0
54 #define FTYPE_PPM 1
55 #define FTYPE_BMP 2
56 #define FTYPE_PNG 3
57 #define FTYPE_PDF 4
58 #define FTYPE_PS 5
59 #define FTYPE_SVG 6
60 #define FTYPE_X11 7
61 
62 extern cairo_surface_t *surface;
63 extern cairo_t *cairo;
64 
65 struct cairo_state {
66  char *file_name;
67  int file_type;
69  unsigned char *grid;
71  int modified;
72  int mapped;
73 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
74  Display *dpy;
75  Drawable win;
76  Screen *screen;
77  XRenderPictFormat *format;
78  int depth;
79 #endif
80 };
81 
82 extern struct cairo_state ca;
83 
84 extern const struct driver *Cairo_Driver(void);
85 
86 extern void Cairo_Client_Close(void);
87 extern int Cairo_Graph_set(void);
88 extern const char *Cairo_Graph_get_file(void);
89 extern void Cairo_Graph_close(void);
90 extern void Cairo_Box(double, double, double, double);
91 extern void Cairo_Set_window(double, double, double, double);
92 extern void Cairo_Bitmap(int, int, int, const unsigned char *);
93 extern void Cairo_Color(int, int, int);
94 extern void Cairo_Erase(void);
95 extern void Cairo_begin_raster(int, int[2][2], double[2][2]);
96 extern int Cairo_raster(int, int, 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 *,
109  double *);
110 extern void Cairo_set_font(const char *);
111 extern void Cairo_font_list(char ***, int *);
112 extern void Cairo_font_info(char ***, int *);
113 
114 /* read.c */
115 extern void cairo_read_image(void);
116 extern void cairo_read_ppm(void);
117 extern void cairo_read_bmp(void);
118 extern void cairo_read_xid(void);
119 
120 /* write.c */
121 extern void cairo_write_image(void);
122 extern void cairo_write_ppm(void);
123 extern void cairo_write_bmp(void);
124 extern void cairo_write_xid(void);
125 
126 #endif /* __CAIRODRIVER_H__ */
void Cairo_Point(double, double)
void Cairo_Color(int, int, int)
Set source color (opaque)
void cairo_write_ppm(void)
void cairo_write_bmp(void)
const struct driver * Cairo_Driver(void)
Initialize display driver.
void Cairo_Begin(void)
void Cairo_Erase(void)
Erase screen.
void Cairo_Move(double, double)
void Cairo_Close(void)
void Cairo_Stroke(void)
int Cairo_raster(int, int, const unsigned char *, const unsigned char *, const unsigned char *, const unsigned char *)
Draw raster row.
void cairo_read_bmp(void)
void cairo_read_xid(void)
Definition: read_xid.c:5
void Cairo_Fill(void)
void cairo_read_image(void)
void Cairo_font_info(char ***, int *)
Get fonts into.
void Cairo_Line_width(double)
Set line width.
void Cairo_font_list(char ***, int *)
Get list of fonts.
cairo_surface_t * surface
void Cairo_Cont(double, double)
void cairo_write_image(void)
void Cairo_end_raster(void)
Finish drawing raster.
void Cairo_Box(double, double, double, double)
Draw a (filled) rectangle.
struct cairo_state ca
const char * Cairo_Graph_get_file(void)
Get render file.
void Cairo_set_font(const char *)
Set font.
int Cairo_Graph_set(void)
Initialize driver.
void cairo_write_xid(void)
Definition: write_xid.c:5
void Cairo_Client_Close(void)
void Cairo_Graph_close(void)
Close driver.
void Cairo_Text(const char *)
Draw text.
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.
cairo_t * cairo
void Cairo_Set_window(double, double, double, double)
Set window.
void cairo_read_ppm(void)
void Cairo_text_box(const char *, double *, double *, double *, double *)
double bgcolor_r
Definition: cairodriver.h:70
unsigned char * grid
Definition: cairodriver.h:69
double bgcolor_a
Definition: cairodriver.h:70
double bgcolor_g
Definition: cairodriver.h:70
char * file_name
Definition: cairodriver.h:66
double bgcolor_b
Definition: cairodriver.h:70
Definition: driver.h:21