1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4 (Public License)
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4 //
5 // Anti-Grain Geometry - Version 2.4 Release Milano 3 (AggPas 2.4 RM3)
6 // Pascal Port By: Milan Marusinec alias Milano
7 // milan@marusinec.sk
8 // http://www.aggpas.org
9 // Copyright (c) 2005-2006
10 //
11 // Permission to copy, use, modify, sell and distribute this software
12 // is granted provided this copyright notice appears in all copies.
13 // This software is provided "as is" without express or implied
14 // warranty, and with no claim as to its suitability for any purpose.
15 //
16 //----------------------------------------------------------------------------
17 // Contact: mcseem@antigrain.com
18 // mcseemagg@yahoo.com
19 // http://www.antigrain.com
20 //
21 //----------------------------------------------------------------------------
22 //
23 // class renderer_mclip
24 //
25 // [Pascal Port History] -----------------------------------------------------
26 //
27 // 11.02.2006-Milano: Unit port establishment
28 //
29 { agg_renderer_mclip.pas }
30 unit
31 agg_renderer_mclip ;
32
33 INTERFACE
34
35 {$I agg_mode.inc }
36
37 uses
38 agg_basics ,
39 agg_array ,
40 agg_color ,
41 agg_rendering_buffer ,
42 agg_renderer_base ,
43 agg_pixfmt ;
44
45 { TYPES DEFINITION }
46 type
47 renderer_mclip = object(renderer_base )
48 m_clip : pod_deque;
49 m_curr_cb : unsigned;
50 m_bounds : rect;
51
52 constructor Construct(ren_ : pixel_formats_ptr );
53 destructor Destruct;
54
bounding_clip_boxnull55 function bounding_clip_box : rect_ptr; virtual;
bounding_xminnull56 function bounding_xmin : int; virtual;
bounding_yminnull57 function bounding_ymin : int; virtual;
bounding_xmaxnull58 function bounding_xmax : int; virtual;
bounding_ymaxnull59 function bounding_ymax : int; virtual;
60
61 procedure first_clip_box; virtual;
next_clip_boxnull62 function next_clip_box : boolean; virtual;
63
64 procedure reset_clipping(visibility : boolean ); virtual;
65
66 procedure add_clip_box(x1 ,y1 ,x2 ,y2 : int );
67
68 procedure copy_pixel (x ,y : int; c : aggclr_ptr ); virtual;
69 procedure blend_pixel(x ,y : int; c : aggclr_ptr; cover : int8u ); virtual;
pixelnull70 function pixel (x ,y : int ) : aggclr; virtual;
71
72 procedure copy_hline(x1 ,y ,x2 : int; c : aggclr_ptr ); virtual;
73 procedure copy_vline(x ,y1 ,y2 : int; c : aggclr_ptr ); virtual;
74
75 procedure blend_hline(x1 ,y ,x2 : int; c : aggclr_ptr; cover : int8u ); virtual;
76 procedure blend_vline(x ,y1 ,y2 : int; c : aggclr_ptr; cover : int8u ); virtual;
77
78 procedure copy_bar (x1 ,y1 ,x2 ,y2 : int; c : aggclr_ptr ); virtual;
79 procedure blend_bar(x1 ,y1 ,x2 ,y2 : int; c : aggclr_ptr; cover : int8u ); virtual;
80
81 procedure blend_solid_hspan(x ,y ,len : int; c : aggclr_ptr; covers : int8u_ptr ); virtual;
82 procedure blend_solid_vspan(x ,y ,len : int; c : aggclr_ptr; covers : int8u_ptr ); virtual;
83
84 procedure copy_color_hspan (x ,y ,len : int; colors : aggclr_ptr ); virtual;
85 procedure blend_color_hspan(x ,y ,len : int; colors : aggclr_ptr; covers : int8u_ptr; cover : int8u = cover_full ); virtual;
86 procedure blend_color_vspan(x ,y ,len : int; colors : aggclr_ptr; covers : int8u_ptr; cover : int8u = cover_full ); virtual;
87
88 procedure copy_from(from : rendering_buffer_ptr; rc : rect_ptr = NIL; x_to : int = 0; y_to : int = 0 ); virtual;
89
90 end;
91
92 { GLOBAL PROCEDURES }
93
94
95 IMPLEMENTATION
96 { LOCAL VARIABLES & CONSTANTS }
97 { UNIT IMPLEMENTATION }
98 { CONSTRUCT }
99 constructor renderer_mclip.Construct;
100 begin
101 inherited Construct(ren_ );
102
103 m_clip.Construct (sizeof(rect ) ,4 );
104 m_bounds.Construct(_xmin ,_ymin ,_xmax ,_ymax );
105
106 m_curr_cb:=0;
107
108 end;
109
110 { DESTRUCT }
111 destructor renderer_mclip.Destruct;
112 begin
113 m_clip.Destruct;
114
115 end;
116
117 { BOUNDING_CLIP_BOX }
renderer_mclip.bounding_clip_boxnull118 function renderer_mclip.bounding_clip_box;
119 begin
120 result:=@m_bounds;
121
122 end;
123
124 { BOUNDING_XMIN }
renderer_mclip.bounding_xminnull125 function renderer_mclip.bounding_xmin;
126 begin
127 result:=m_bounds.x1;
128
129 end;
130
131 { BOUNDING_YMIN }
renderer_mclip.bounding_yminnull132 function renderer_mclip.bounding_ymin;
133 begin
134 result:=m_bounds.y1;
135
136 end;
137
138 { BOUNDING_XMAX }
renderer_mclip.bounding_xmaxnull139 function renderer_mclip.bounding_xmax;
140 begin
141 result:=m_bounds.x2;
142
143 end;
144
145 { BOUNDING_YMAX }
renderer_mclip.bounding_ymaxnull146 function renderer_mclip.bounding_ymax;
147 begin
148 result:=m_bounds.y2;
149
150 end;
151
152 { FIRST_CLIP_BOX }
153 procedure renderer_mclip.first_clip_box;
154 var
155 cb : rect_ptr;
156
157 begin
158 m_curr_cb:=0;
159
160 if m_clip.size <> 0 then
161 begin
162 cb:=m_clip.array_operator(0 );
163
164 clip_box_naked(cb.x1 ,cb.y1 ,cb.x2 ,cb.y2 );
165
166 end;
167
168 end;
169
170 { NEXT_CLIP_BOX }
renderer_mclip.next_clip_boxnull171 function renderer_mclip.next_clip_box;
172 var
173 cb : rect_ptr;
174
175 begin
176 inc(m_curr_cb );
177
178 if m_curr_cb < m_clip.size then
179 begin
180 cb:=m_clip.array_operator(m_curr_cb );
181
182 clip_box_naked(cb.x1 ,cb.y1 ,cb.x2 ,cb.y2 );
183
184 result:=true;
185
186 exit;
187
188 end;
189
190 result:=false;
191
192 end;
193
194 { RESET_CLIPPING }
195 procedure renderer_mclip.reset_clipping;
196 begin
197 inherited reset_clipping(visibility );
198
199 m_clip.remove_all;
200
201 m_curr_cb:=0;
202
203 m_bounds.Construct(_clip_box );
204
205 end;
206
207 { ADD_CLIP_BOX }
208 procedure renderer_mclip.add_clip_box;
209 var
210 cb ,
211 rc : rect;
212
213 begin
214 cb.Construct(x1 ,y1 ,x2 ,y2 );
215 cb.normalize;
216 rc.Construct(0 ,0 ,width - 1 ,height - 1 );
217
218 if cb.clip(@rc ) then
219 begin
220 m_clip.add(@cb );
221
222 if cb.x1 < m_bounds.x1 then
223 m_bounds.x1:=cb.x1;
224
225 if cb.y1 < m_bounds.y1 then
226 m_bounds.y1:=cb.y1;
227
228 if cb.x2 > m_bounds.x2 then
229 m_bounds.x2:=cb.x2;
230
231 if cb.y2 > m_bounds.y2 then
232 m_bounds.y2:=cb.y2;
233
234 end;
235
236 end;
237
238 { COPY_PIXEL }
239 procedure renderer_mclip.copy_pixel;
240 begin
241 first_clip_box;
242
243 repeat
244 if inbox(x ,y ) then
245 begin
246 m_ren.copy_pixel(m_ren ,x ,y ,c );
247
248 break;
249
250 end;
251
252 until not next_clip_box;
253
254 end;
255
256 { BLEND_PIXEL }
257 procedure renderer_mclip.blend_pixel;
258 begin
259 first_clip_box;
260
261 repeat
262 if inbox(x ,y ) then
263 begin
264 m_ren.blend_pixel(m_ren ,x ,y ,c ,cover );
265
266 break;
267
268 end;
269
270 until not next_clip_box;
271
272 end;
273
274 { PIXEL }
renderer_mclip.pixelnull275 function renderer_mclip.pixel;
276 begin
277 first_clip_box;
278
279 repeat
280 if inbox(x ,y ) then
281 begin
282 result:=m_ren.pixel(m_ren ,x ,y );
283
284 exit;
285
286 end;
287
288 until not next_clip_box;
289
290 result.clear;
291
292 end;
293
294 { COPY_HLINE }
295 procedure renderer_mclip.copy_hline;
296 begin
297 first_clip_box;
298
299 repeat
300 inherited copy_hline(x1 ,y ,x2 ,c );
301
302 until not next_clip_box;
303
304 end;
305
306 { COPY_VLINE }
307 procedure renderer_mclip.copy_vline;
308 begin
309 first_clip_box;
310
311 repeat
312 inherited copy_vline(x ,y1 ,y2 ,c );
313
314 until not next_clip_box;
315
316 end;
317
318 { BLEND_HLINE }
319 procedure renderer_mclip.blend_hline;
320 begin
321 first_clip_box;
322
323 repeat
324 inherited blend_hline(x1 ,y ,x2 ,c ,cover );
325
326 until not next_clip_box;
327
328 end;
329
330 { BLEND_VLINE }
331 procedure renderer_mclip.blend_vline;
332 begin
333 first_clip_box;
334
335 repeat
336 inherited blend_vline(x ,y1 ,y2 ,c ,cover );
337
338 until not next_clip_box;
339
340 end;
341
342 { COPY_BAR }
343 procedure renderer_mclip.copy_bar;
344 begin
345 first_clip_box;
346
347 repeat
348 inherited copy_bar(x1 ,y1 ,x2 ,y2 ,c );
349
350 until not next_clip_box;
351
352 end;
353
354 { BLEND_BAR }
355 procedure renderer_mclip.blend_bar;
356 begin
357 first_clip_box;
358
359 repeat
360 inherited blend_bar(x1 ,y1 ,x2 ,y2 ,c ,cover );
361
362 until not next_clip_box;
363
364 end;
365
366 { BLEND_SOLID_HSPAN }
367 procedure renderer_mclip.blend_solid_hspan;
368 begin
369 first_clip_box;
370
371 repeat
372 inherited blend_solid_hspan(x ,y ,len ,c ,covers );
373
374 until not next_clip_box;
375
376 end;
377
378 { BLEND_SOLID_VSPAN }
379 procedure renderer_mclip.blend_solid_vspan;
380 begin
381 first_clip_box;
382
383 repeat
384 inherited blend_solid_vspan(x ,y ,len ,c ,covers );
385
386 until not next_clip_box;
387
388 end;
389
390 { COPY_COLOR_HSPAN }
391 procedure renderer_mclip.copy_color_hspan;
392 begin
393 first_clip_box;
394
395 repeat
396 inherited copy_color_hspan(x ,y ,len ,colors );
397
398 until not next_clip_box;
399
400 end;
401
402 { BLEND_COLOR_HSPAN }
403 procedure renderer_mclip.blend_color_hspan;
404 begin
405 first_clip_box;
406
407 repeat
408 inherited blend_color_hspan(x ,y ,len ,colors ,covers ,cover );
409
410 until not next_clip_box;
411
412 end;
413
414 { BLEND_COLOR_VSPAN }
415 procedure renderer_mclip.blend_color_vspan;
416 begin
417 first_clip_box;
418
419 repeat
420 inherited blend_color_vspan(x ,y ,len ,colors ,covers ,cover );
421
422 until not next_clip_box;
423
424 end;
425
426 { COPY_FROM }
427 procedure renderer_mclip.copy_from;
428 begin
429 first_clip_box;
430
431 repeat
432 inherited copy_from(from ,rc ,x_to ,y_to );
433
434 until not next_clip_box;
435
436 end;
437
438 END.
439
440