… | |
… | |
40 | |
40 | |
41 | if (SvTYPE (sv) != SVt_PV) |
41 | if (SvTYPE (sv) != SVt_PV) |
42 | { |
42 | { |
43 | sv_upgrade (sv, SVt_PV); |
43 | sv_upgrade (sv, SVt_PV); |
44 | SvPOK_only (sv); |
44 | SvPOK_only (sv); |
|
|
45 | sv_grow (sv, 512); |
45 | } |
46 | } |
46 | |
47 | |
47 | return sv; |
48 | return sv; |
48 | } |
49 | } |
49 | |
50 | |
50 | static void |
51 | static void |
51 | rc_v2f (rc_array_t *arr, float x, float y) |
52 | rc_v2f (rc_array_t *arr, float x, float y) |
52 | { |
53 | { |
53 | STRLEN len = SvCUR (arr) + sizeof (float) * 2; |
54 | char *end = fast_sv_grow (arr, sizeof (float) * 2); |
54 | SvGROW (arr, len); |
|
|
55 | |
55 | |
56 | ((float *)SvEND (arr))[0] = x; |
56 | ((float *)end)[0] = x; |
57 | ((float *)SvEND (arr))[1] = y; |
57 | ((float *)end)[1] = y; |
58 | |
|
|
59 | SvCUR_set (arr, len); |
|
|
60 | } |
58 | } |
61 | |
59 | |
62 | static void |
60 | static void |
63 | rc_t2f_v3f (rc_array_t *arr, float u, float v, float x, float y, float z) |
61 | rc_t2f_v3f (rc_array_t *arr, float u, float v, float x, float y, float z) |
64 | { |
62 | { |
65 | STRLEN len = SvCUR (arr) + sizeof (float) * 5; |
63 | char *end = fast_sv_grow (arr, sizeof (float) * 5); |
66 | SvGROW (arr, len); |
|
|
67 | |
64 | |
68 | ((float *)SvEND (arr))[0] = u; |
65 | ((float *)end)[0] = u; |
69 | ((float *)SvEND (arr))[1] = v; |
66 | ((float *)end)[1] = v; |
70 | |
67 | |
71 | ((float *)SvEND (arr))[2] = x; |
68 | ((float *)end)[2] = x; |
72 | ((float *)SvEND (arr))[3] = y; |
69 | ((float *)end)[3] = y; |
73 | ((float *)SvEND (arr))[4] = z; |
70 | ((float *)end)[4] = z; |
74 | |
|
|
75 | SvCUR_set (arr, len); |
|
|
76 | } |
71 | } |
77 | |
72 | |
78 | static void |
73 | static void |
79 | rc_glyph (rc_array_t *arr, int u, int v, int w, int h, int x, int y) |
74 | rc_glyph (rc_array_t *arr, int u, int v, int w, int h, int x, int y) |
80 | { |
75 | { |
81 | U8 *c; |
76 | if (w && h) |
82 | STRLEN len = SvCUR (arr); |
77 | { |
83 | SvGROW (arr, len + 2 * 2 + 1 * 4); |
78 | U8 *c = (U8 *)fast_sv_grow (arr, 4 + 4); |
84 | c = (U8 *)SvEND (arr); |
|
|
85 | |
79 | |
86 | x += w; |
80 | x += w; |
87 | y += h; |
81 | y += h; |
88 | |
82 | |
89 | *c++ = u; |
83 | *c++ = u; |
90 | *c++ = v; |
84 | *c++ = v; |
91 | *c++ = w; |
85 | *c++ = w; |
92 | *c++ = h; |
86 | *c++ = h; |
93 | |
87 | |
94 | // use ber-encoding for up to 14 bits (16k) |
88 | // use ber-encoding for up to 14 bits (16k) |
95 | *c = 0x80 | (x >> 7); c += (x >> 7) ? 1 : 0; *c++ = x & 0x7f; |
89 | *c = 0x80 | (x >> 7); c += (x >> 7) ? 1 : 0; *c++ = x & 0x7f; |
96 | *c = 0x80 | (y >> 7); c += (y >> 7) ? 1 : 0; *c++ = y & 0x7f; |
90 | *c = 0x80 | (y >> 7); c += (y >> 7) ? 1 : 0; *c++ = y & 0x7f; |
97 | |
91 | |
98 | SvCUR_set (arr, c - (U8 *)SvPVX (arr)); |
92 | SvCUR_set (arr, c - (U8 *)SvPVX (arr)); |
|
|
93 | } |
99 | } |
94 | } |
100 | |
95 | |
101 | static void |
96 | static void |
102 | rc_draw (rc_t *rc) |
97 | rc_draw (rc_t *rc) |
103 | { |
98 | { |