1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
Copyright (C) 2009 Red Hat, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _H_GL_CANVASE
#define _H_GL_CANVASE
#include <stdint.h>
typedef void * GLCCtx;
typedef void * GLCPattern;
typedef void * GLCPath;
typedef struct GLCRect {
double x;
double y;
double width;
double height;
} GLCRect;
typedef struct GLCRecti {
int x;
int y;
int width;
int height;
} GLCRecti;
typedef enum {
GLC_IMAGE_RGB32,
GLC_IMAGE_ARGB32,
} GLCImageFormat;
typedef struct GLCPImage {
GLCImageFormat format;
int width;
int height;
int stride;
uint8_t *pixels;
uint32_t *pallet;
} GLCImage;
GLCPattern glc_pattern_create(GLCCtx glc, int x_orign, int y_orign, const GLCImage *image);
void glc_pattern_set(GLCPattern pattern, int x_orign, int y_orign, const GLCImage *image);
void glc_pattern_destroy(GLCPattern pattern);
void glc_path_move_to(GLCPath path, double x, double y);
void glc_path_line_to(GLCPath path, double x, double y);
void glc_path_curve_to(GLCPath path, double p1_x, double p1_y, double p2_x, double p2_y,
double p3_x, double p3_y);
void glc_path_rel_move_to(GLCPath path, double x, double y);
void glc_path_rel_line_to(GLCPath path, double x, double y);
void glc_path_rel_curve_to(GLCPath path, double p1_x, double p1_y, double p2_x, double p2_y,
double p3_x, double p3_y);
void glc_path_close(GLCPath path);
void glc_path_cleare(GLCPath);
GLCPath glc_path_create(GLCCtx glc);
void glc_path_destroy(GLCPath path);
void glc_set_rgb(GLCCtx glc, double red, double green, double blue);
void glc_set_rgba(GLCCtx glc, double red, double green, double blue, double alpha);
void glc_set_pattern(GLCCtx glc, GLCPattern pattern);
typedef enum {
GLC_OP_CLEAR = 0x1500,
GLC_OP_SET = 0x150F,
GLC_OP_COPY = 0x1503,
GLC_OP_COPY_INVERTED = 0x150C,
GLC_OP_NOOP = 0x1505,
GLC_OP_INVERT = 0x150A,
GLC_OP_AND = 0x1501,
GLC_OP_NAND = 0x150E,
GLC_OP_OR = 0x1507,
GLC_OP_NOR = 0x1508,
GLC_OP_XOR = 0x1506,
GLC_OP_EQUIV = 0x1509,
GLC_OP_AND_REVERSE = 0x1502,
GLC_OP_AND_INVERTED = 0x1504,
GLC_OP_OR_REVERSE = 0x150B,
GLC_OP_OR_INVERTED = 0x150D,
} GLCOp;
void glc_set_op(GLCCtx glc, GLCOp op);
void glc_set_alpha_factor(GLCCtx glc, double alpah);
typedef enum {
GLC_FILL_MODE_WINDING_ODD,
GLC_FILL_MODE_WINDING_NONZERO,
} GLCFillMode;
void glc_set_fill_mode(GLCCtx glc, GLCFillMode mode);
void glc_set_line_width(GLCCtx glc, double width);
void glc_set_line_end_cap(GLCCtx glc, int style);
void glc_set_line_join(GLCCtx glc, int style);
void glc_set_miter_limit(GLCCtx glc, int limit);
void glc_set_line_dash(GLCCtx glc, const double *dashes, int num_dashes, double offset);
typedef enum {
GLC_MASK_A,
GLC_MASK_B,
} GLCMaskID;
void glc_set_mask(GLCCtx glc, int x_dest, int y_dest, int width, int height,
int stride, const uint8_t *bitmap, GLCMaskID id);
void glc_mask_rects(GLCCtx glc, int num_rect, GLCRect *rects, GLCMaskID id);
void glc_clear_mask(GLCCtx glc, GLCMaskID id);
typedef enum {
GLC_CLIP_OP_SET,
GLC_CLIP_OP_OR,
GLC_CLIP_OP_AND,
GLC_CLIP_OP_EXCLUDE,
} GLCClipOp;
void glc_clip_rect(GLCCtx glc, const GLCRect *rect, GLCClipOp op);
void glc_clip_path(GLCCtx glc, GLCPath path, GLCClipOp op);
void glc_clip_mask(GLCCtx glc, int x_dest, int y_dest, int width, int height, int stride,
const uint8_t *bitmap, GLCClipOp op);
void glc_clip_reset(GLCCtx glc);
void glc_fill_rect(GLCCtx glc, const GLCRect *rect);
void glc_fill_path(GLCCtx glc, GLCPath path);
void _glc_fill_mask(GLCCtx glc, int x_dest, int y_dest, int width, int height, int stride,
const uint8_t *bitmap);
void glc_fill_alpha(GLCCtx glc, int x_dest, int y_dest, int width, int height, int stride,
const uint8_t *alpha_mask);
void glc_stroke_rect(GLCCtx glc, const GLCRect *rect);
void glc_stroke_path(GLCCtx glc, GLCPath path);
void glc_draw_image(GLCCtx glc, const GLCRecti *dest, const GLCRecti *src, const GLCImage *image,
int scale_mode, double alpha);
void glc_copy_pixels(GLCCtx glc, int x_dest, int y_dest, int x_src, int y_src, int width,
int height);
void glc_read_pixels(GLCCtx glc, int x, int y, GLCImage *image);
void glc_flush(GLCCtx glc);
void glc_clear(GLCCtx glc);
GLCCtx glc_create(int width, int height);
void glc_destroy(GLCCtx glc, int textures_lost);
#endif
|