Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
20 | pmbaty | 1 | #include "genclip.h" |
2 | #include "harness/trace.h" |
||
3 | |||
4 | // IDA: br_clip_result __cdecl PixelmapPointClip(br_point *out, br_point *in, br_pixelmap *pm) |
||
5 | br_clip_result PixelmapPointClip(br_point* out, br_point* in, br_pixelmap* pm) { |
||
6 | LOG_TRACE("(%p, %p, %p)", out, in, pm); |
||
7 | |||
8 | out->x = in->x + pm->origin_x; |
||
9 | out->y = in->y + pm->origin_y; |
||
10 | |||
11 | if (out->x < 0) { |
||
12 | return BR_CLIP_REJECT; |
||
13 | } |
||
14 | if (out->y < 0) { |
||
15 | return BR_CLIP_REJECT; |
||
16 | } |
||
17 | if (out->x >= pm->width) { |
||
18 | return BR_CLIP_REJECT; |
||
19 | } |
||
20 | if (out->y >= pm->height) { |
||
21 | return BR_CLIP_REJECT; |
||
22 | } |
||
23 | return BR_CLIP_ACCEPT; |
||
24 | } |
||
25 | |||
26 | // IDA: br_clip_result __cdecl PixelmapLineClip(br_point *s_out, br_point *e_out, br_point *s_in, br_point *e_in, br_pixelmap *pm) |
||
27 | br_clip_result PixelmapLineClip(br_point* s_out, br_point* e_out, br_point* s_in, br_point* e_in, br_pixelmap* pm) { |
||
28 | int temp; |
||
29 | br_int_32 w; |
||
30 | br_int_32 h; |
||
31 | br_int_32 x1; |
||
32 | br_int_32 x2; |
||
33 | br_int_32 y1; |
||
34 | br_int_32 y2; |
||
35 | LOG_TRACE("(%p, %p, %p, %p, %p)", s_out, e_out, s_in, e_in, pm); |
||
36 | |||
37 | x1 = s_in->x + pm->origin_x; |
||
38 | x2 = e_in->x + pm->origin_x; |
||
39 | y1 = s_in->y + pm->origin_y; |
||
40 | y2 = e_in->y + pm->origin_y; |
||
41 | w = pm->width - 1; |
||
42 | h = pm->height - 1; |
||
43 | if (x2 < x1) { |
||
44 | temp = x2; |
||
45 | x2 = x1; |
||
46 | x1 = temp; |
||
47 | temp = y2; |
||
48 | y2 = y1; |
||
49 | y1 = temp; |
||
50 | } |
||
51 | if (x2 >= 0 && x1 <= w) { |
||
52 | if (y1 < y2) { |
||
53 | if (y2 >= 0 && y1 <= h) { |
||
54 | if (y1 < 0) { |
||
55 | x1 -= (x2 - x1) * y1 / (y2 - y1); |
||
56 | if (w < x1) { |
||
57 | return BR_CLIP_REJECT; |
||
58 | } |
||
59 | y1 = 0; |
||
60 | } |
||
61 | if (y2 <= h) { |
||
62 | incr_p2: |
||
63 | if (x1 < 0) { |
||
64 | y1 -= (y2 - y1) * x1 / (x2 - x1); |
||
65 | x1 = 0; |
||
66 | } |
||
67 | if (w < x2) { |
||
68 | y2 -= (x2 - w) * (y2 - y1) / (x2 - x1); |
||
69 | x2 = w; |
||
70 | } |
||
71 | s_out->x = x1; |
||
72 | s_out->y = y1; |
||
73 | e_out->x = x2; |
||
74 | e_out->y = y2; |
||
75 | return BR_CLIP_PARTIAL; |
||
76 | } else { |
||
77 | x2 -= (y2 - h) * (x2 - x1) / (y2 - y1); |
||
78 | y2 = h; |
||
79 | if (0 <= x2) { |
||
80 | goto incr_p2; |
||
81 | } |
||
82 | } |
||
83 | } |
||
84 | } else { |
||
85 | if (0 <= y1 && y2 <= h) { |
||
86 | if (y1 <= h) { |
||
87 | decr_p1: |
||
88 | if (y2 < 0) { |
||
89 | x2 -= (x2 - x1) * y2 / (y2 - y1); |
||
90 | if (x2 < 0) { |
||
91 | return BR_CLIP_REJECT; |
||
92 | } |
||
93 | y2 = 0; |
||
94 | } |
||
95 | if (x1 < 0) { |
||
96 | y1 -= (y2 - y1) * x1 / (x2 - x1); |
||
97 | x1 = 0; |
||
98 | } |
||
99 | if (w < x2) { |
||
100 | y2 -= (x2 - w) * (y2 - y1) / (x2 - x1); |
||
101 | x2 = w; |
||
102 | } |
||
103 | s_out->x = x1; |
||
104 | s_out->y = y1; |
||
105 | e_out->x = x2; |
||
106 | e_out->y = y2; |
||
107 | return BR_CLIP_PARTIAL; |
||
108 | } else { |
||
109 | x1 += (h - y1) * (x2 - x1) / (y2 - y1); |
||
110 | y1 = h; |
||
111 | if (x1 <= w) { |
||
112 | goto decr_p1; |
||
113 | } |
||
114 | } |
||
115 | } |
||
116 | } |
||
117 | } |
||
118 | return BR_CLIP_REJECT; |
||
119 | } |
||
120 | |||
121 | // IDA: br_clip_result __cdecl PixelmapRectangleClip(br_rectangle *out, br_rectangle *in, br_pixelmap *pm) |
||
122 | br_clip_result PixelmapRectangleClip(br_rectangle* out, br_rectangle* in, br_pixelmap* pm) { |
||
123 | LOG_TRACE("(%p, %p, %p)", out, in, pm); |
||
124 | |||
125 | out->x = pm->origin_x + in->x; |
||
126 | out->y = pm->origin_y + in->y; |
||
127 | out->w = in->w; |
||
128 | out->h = in->h; |
||
129 | if (pm->width > out->x && pm->height > out->y) { |
||
130 | if ((out->x + out->w) > 0 && (out->y + out->h) > 0) { |
||
131 | if (out->x < 0) { |
||
132 | out->x = 0; |
||
133 | out->w += out->x; |
||
134 | } |
||
135 | if (out->y < 0) { |
||
136 | out->y = 0; |
||
137 | out->h += out->y; |
||
138 | } |
||
139 | if ((out->x + out->w) > pm->width) |
||
140 | out->w = pm->width - out->x; |
||
141 | if ((out->y + out->h) > pm->height) { |
||
142 | out->h = pm->height - out->y; |
||
143 | } |
||
144 | if (out->w != 0 && out->h != 0) { |
||
145 | return BR_CLIP_PARTIAL; |
||
146 | } |
||
147 | } |
||
148 | } |
||
149 | return BR_CLIP_REJECT; |
||
150 | } |
||
151 | |||
152 | // IDA: br_clip_result __cdecl PixelmapRectangleClipTwo(br_rectangle *r_out, br_point *p_out, br_rectangle *r_in, br_point *p_in, br_pixelmap *pm_dst, br_pixelmap *pm_src) |
||
153 | br_clip_result PixelmapRectangleClipTwo(br_rectangle* r_out, br_point* p_out, br_rectangle* r_in, br_point* p_in, br_pixelmap* pm_dst, br_pixelmap* pm_src) { |
||
154 | LOG_TRACE("(%p, %p, %p, %p, %p, %p)", r_out, p_out, r_in, p_in, pm_dst, pm_src); |
||
155 | |||
156 | r_out->x = pm_src->origin_x + r_in->x; |
||
157 | r_out->y = pm_src->origin_y + r_in->y; |
||
158 | r_out->w = r_in->w; |
||
159 | r_out->h = r_in->h; |
||
160 | p_out->x = pm_dst->origin_x + p_in->x; |
||
161 | p_out->y = pm_dst->origin_y + p_in->y; |
||
162 | |||
163 | if (p_out->x >= pm_dst->width) { |
||
164 | return BR_CLIP_REJECT; |
||
165 | } |
||
166 | if (p_out->y >= pm_dst->height) { |
||
167 | return BR_CLIP_REJECT; |
||
168 | } |
||
169 | if (r_out->x >= pm_src->width) { |
||
170 | return BR_CLIP_REJECT; |
||
171 | } |
||
172 | if (r_out->y >= pm_src->height) { |
||
173 | return BR_CLIP_REJECT; |
||
174 | } |
||
175 | if (p_out->x + r_out->w <= 0) { |
||
176 | return BR_CLIP_REJECT; |
||
177 | } |
||
178 | if (p_out->y + r_out->h <= 0) { |
||
179 | return BR_CLIP_REJECT; |
||
180 | } |
||
181 | if (r_out->x + r_out->w <= 0) { |
||
182 | return BR_CLIP_REJECT; |
||
183 | } |
||
184 | if (r_out->y + r_out->h <= 0) { |
||
185 | return BR_CLIP_REJECT; |
||
186 | } |
||
187 | if (p_out->x < 0) { |
||
188 | r_out->w += p_out->x; |
||
189 | r_out->x -= p_out->x; |
||
190 | p_out->x = 0; |
||
191 | } |
||
192 | if (p_out->y < 0) { |
||
193 | r_out->h += p_out->y; |
||
194 | r_out->y -= p_out->y; |
||
195 | p_out->y = 0; |
||
196 | } |
||
197 | if (p_out->x + r_out->w > pm_dst->width) { |
||
198 | r_out->w = pm_dst->width - p_out->x; |
||
199 | } |
||
200 | if (p_out->y + r_out->h > pm_dst->height) { |
||
201 | r_out->h = pm_dst->height - p_out->y; |
||
202 | } |
||
203 | if (r_out->x < 0) { |
||
204 | r_out->w += r_out->x; |
||
205 | p_out->x -= r_out->x; |
||
206 | r_out->x = 0; |
||
207 | } |
||
208 | if (r_out->y < 0) { |
||
209 | r_out->h += r_out->y; |
||
210 | p_out->y -= r_out->y; |
||
211 | r_out->y = 0; |
||
212 | } |
||
213 | if (r_out->x + r_out->w > pm_src->width) { |
||
214 | r_out->w = pm_src->width - r_out->x; |
||
215 | } |
||
216 | if (r_out->y + r_out->h > pm_src->height) { |
||
217 | r_out->h = pm_src->height - r_out->y; |
||
218 | } |
||
219 | if (r_out->w == 0 || r_out->h == 0) { |
||
220 | return BR_CLIP_REJECT; |
||
221 | } |
||
222 | return BR_CLIP_PARTIAL; |
||
223 | } |
||
224 | |||
225 | // IDA: br_clip_result __cdecl PixelmapCopyBitsClip(br_rectangle *r_out, br_point *p_out, br_rectangle *r_in, br_point *p_in, br_pixelmap *pm) |
||
226 | br_clip_result PixelmapCopyBitsClip(br_rectangle* r_out, br_point* p_out, br_rectangle* r_in, br_point* p_in, br_pixelmap* pm) { |
||
227 | LOG_TRACE("(%p, %p, %p, %p, %p)", r_out, p_out, r_in, p_in, pm); |
||
228 | |||
229 | r_out->x = r_in->x; |
||
230 | r_out->y = r_in->y; |
||
231 | r_out->w = r_in->w; |
||
232 | r_out->h = r_in->h; |
||
233 | p_out->x = pm->origin_x + p_in->x; |
||
234 | p_out->y = pm->origin_y + p_in->y; |
||
235 | |||
236 | if (p_out->x >= pm->width) { |
||
237 | return BR_CLIP_REJECT; |
||
238 | } |
||
239 | if (p_out->y >= pm->height) { |
||
240 | return BR_CLIP_REJECT; |
||
241 | } |
||
242 | if (p_out->x + r_out->w <= 0) { |
||
243 | return BR_CLIP_REJECT; |
||
244 | } |
||
245 | if (p_out->y + r_out->h <= 0) { |
||
246 | return BR_CLIP_REJECT; |
||
247 | } |
||
248 | if (p_out->x < 0) { |
||
249 | r_out->w += p_out->x; |
||
250 | r_out->x -= p_out->x; |
||
251 | p_out->x = 0; |
||
252 | } |
||
253 | if (p_out->y < 0) { |
||
254 | r_out->h += p_out->y; |
||
255 | r_out->y -= p_out->y; |
||
256 | p_out->y = 0; |
||
257 | } |
||
258 | if (p_out->x + r_out->w > pm->width) { |
||
259 | r_out->w = pm->width - p_out->x; |
||
260 | } |
||
261 | if (p_out->y + r_out->h > pm->height) { |
||
262 | r_out->h = pm->height - p_out->y; |
||
263 | } |
||
264 | if (r_out->w == 0 || r_out->h == 0) { |
||
265 | return BR_CLIP_REJECT; |
||
266 | } |
||
267 | return BR_CLIP_PARTIAL; |
||
268 | } |