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
|
#include "fitz.h"
fz_shade *
fz_keepshade(fz_shade *shade)
{
shade->refs ++;
return shade;
}
void
fz_dropshade(fz_shade *shade)
{
if (shade && --shade->refs == 0)
{
if (shade->cs)
fz_dropcolorspace(shade->cs);
fz_free(shade->mesh);
fz_free(shade);
}
}
fz_rect
fz_boundshade(fz_shade *shade, fz_matrix ctm)
{
ctm = fz_concat(shade->matrix, ctm);
return fz_transformrect(ctm, shade->bbox);
}
void
fz_debugshade(fz_shade *shade)
{
int i, j, n;
float *vertex;
int triangle;
printf("shade {\n");
printf(" bbox [%g %g %g %g]\n",
shade->bbox.x0, shade->bbox.y0,
shade->bbox.x1, shade->bbox.y1);
printf(" colorspace %s\n", shade->cs->name);
printf(" matrix [%g %g %g %g %g %g]\n",
shade->matrix.a, shade->matrix.b, shade->matrix.c,
shade->matrix.d, shade->matrix.e, shade->matrix.f);
if (shade->usebackground)
{
printf(" background [");
for (i = 0; i < shade->cs->n; i++)
printf("%s%g", i == 0 ? "" : " ", shade->background[i]);
printf("]\n");
}
if (shade->usefunction)
{
printf(" function\n");
n = 3;
}
else
n = 2 + shade->cs->n;
printf(" triangles: %d\n", shade->meshlen);
vertex = shade->mesh;
triangle = 0;
i = 0;
while (i < shade->meshlen * 3)
{
printf(" %d:(%g, %g): ", triangle, vertex[0], vertex[1]);
for (j = 2; j < n; j++)
printf("%s%g", j == 2 ? "" : " ", vertex[j]);
printf("\n");
vertex += n;
i++;
if (i % 3 == 0)
triangle++;
}
printf("}\n");
}
|