21#define MAX_IMAGE_SIZE 32767
23static int src_t, src_b, src_l, src_r, src_w, src_h;
24static int dst_t, dst_b, dst_l, dst_r, dst_w, dst_h;
29static unsigned char *src_data;
30static int src_stride, ca_row;
39static int scale_fwd_y(
int sy)
41 return (
int)
floor(scale(sy, src_t, src_b, dst_t, dst_b) + 0.5);
44static int scale_rev_x(
int dx)
46 return (
int)
floor(scale(dx + 0.5, dst_l, dst_r, src_l, src_r));
49static int next_row(
int sy,
int dy)
54 int y = scale_fwd_y(sy);
83 src_w = src_r - src_l;
84 src_h = src_b - src_t;
91 dst_w = dst_r - dst_l;
92 dst_h = dst_b - dst_t;
96 "Cairo_begin_raster(): masked=%d, src_lrtb=%d %d %d %d -> w/h=%d %d, "
97 "dst_lrtb=%d %d %d %d -> w/h=%d %d",
98 masked, src_l, src_r, src_t, src_b, src_w, src_h, dst_l, dst_r, dst_t,
107 _(
"Failed to create cairo surface"),
116 trans =
G_malloc(dst_w *
sizeof(
int));
117 for (i = 0; i < dst_w; i++)
118 trans[i] = scale_rev_x(dst_l + i);
131 const unsigned char *grn,
const unsigned char *blu,
132 const unsigned char *
nul)
134 int d_y0 = scale_fwd_y(row + 0);
135 int d_y1 = scale_fwd_y(row + 1);
137 int x0 =
MAX(0 - dst_l, 0);
138 int x1 =
MIN(
ca.width - dst_l, dst_w);
144 return next_row(row,
d_y1);
146 G_debug(3,
"Cairo_raster(): n=%d row=%d", n, row);
148 for (
x = x0;
x < x1;
x++) {
156 unsigned int r = red[
j];
157 unsigned int g = grn[
j];
158 unsigned int b = blu[
j];
159 unsigned int a = 0xFF;
161 c = (a << 24) + (
r << 16) + (
g << 8) + (
b << 0);
164 for (y =
y0; y < y1; y++) {
167 *(
unsigned int *)(src_data +
yy * src_stride +
xx * 4) = c;
174 return next_row(row,
d_y1);
182 G_debug(1,
"Cairo_end_raster()");
void Cairo_begin_raster(int mask, int s[2][2], double d[2][2])
Start drawing raster.
void Cairo_end_raster(void)
Finish drawing raster.
int Cairo_raster(int n, int row, const unsigned char *red, const unsigned char *grn, const unsigned char *blu, const unsigned char *nul)
Draw raster row.
GRASS cairo display driver - header file.
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf