~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to components/aggpas/src/agg_scanline_storage_aa.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
// [Pascal Port History] -----------------------------------------------------
22
 
//
23
 
// 23.06.2006-Milano: ptrcomp adjustments
24
 
// 15.02.2006-Milano: Unit port establishment
25
 
//
26
 
{ agg_scanline_storage_aa.pas }
27
 
unit
28
 
 agg_scanline_storage_aa ;
29
 
 
30
 
INTERFACE
31
 
 
32
 
{$I agg_mode.inc }
33
 
{$Q- }
34
 
{$R- }
35
 
uses
36
 
 agg_basics ,
37
 
 agg_array ,
38
 
 agg_scanline ,
39
 
 agg_renderer_scanline ,
40
 
 agg_render_scanlines ,
41
 
 agg_rasterizer_scanline_aa ;
42
 
 
43
 
{ TYPES DEFINITION }
44
 
type
45
 
//----------------------------------------------scanline_cell_storage
46
 
 extra_span_ptr = ^extra_span;
47
 
 extra_span = record
48
 
   len : unsigned;
49
 
   ptr : pointer;
50
 
 
51
 
  end;
52
 
 
53
 
 scanline_cell_storage_ptr = ^scanline_cell_storage;
54
 
 scanline_cell_storage = object
55
 
   m_cells         ,
56
 
   m_extra_storage : pod_deque;
57
 
 
58
 
   constructor Construct(entry_sz : unsigned ); overload;
59
 
   constructor Construct(v : scanline_cell_storage_ptr ); overload;
60
 
   destructor  Destruct;
61
 
 
62
 
   procedure remove_all;
63
 
   function  add_cells(cells : pointer; num_cells : unsigned ) : int;
64
 
 
65
 
   function  assign_operator(v : scanline_cell_storage_ptr ) : scanline_cell_storage_ptr;
66
 
   function  array_operator (idx : int ) : pointer;
67
 
 
68
 
   procedure copy_extra_storage(v : scanline_cell_storage_ptr );
69
 
 
70
 
  end;
71
 
 
72
 
//-----------------------------------------------scanline_storage_aa
73
 
 span_data_ss_ptr = ^span_data_ss;
74
 
 span_data_ss = record
75
 
   x         ,
76
 
   len       : int32; // If negative, it's a solid span, covers is valid
77
 
   covers_id : int;   // The index of the cells in the scanline_cell_storage
78
 
 
79
 
  end;
80
 
 
81
 
 scanline_data_ss_ptr = ^scanline_data_ss; 
82
 
 scanline_data_ss = record
83
 
   y          : int;
84
 
   num_spans  ,
85
 
   start_span : unsigned;
86
 
 
87
 
  end;
88
 
 
89
 
 span_ss_ptr = ^span_ss;
90
 
 span_ss = record
91
 
   x   ,
92
 
   len : int32; // If negative, it's a solid span, covers is valid
93
 
 
94
 
   covers : pointer;
95
 
 
96
 
  end;
97
 
 
98
 
 scanline_storage_aa_ptr = ^scanline_storage_aa;
99
 
 
100
 
 embedded_scanline_ss_ptr = ^embedded_scanline_ss;
101
 
 
102
 
 const_iterator_ss = object(span_obj )
103
 
   m_storage  : scanline_storage_aa_ptr;
104
 
   m_span_idx : unsigned;
105
 
   m_span     : span_ss;
106
 
 
107
 
   constructor Construct(sl : embedded_scanline_ss_ptr );
108
 
 
109
 
   function  x      : int; virtual;
110
 
   function  len    : int; virtual;
111
 
   function  covers : int8u_ptr; virtual;
112
 
 
113
 
   procedure inc_operator; virtual;
114
 
   procedure init_span;
115
 
 
116
 
  end;
117
 
 
118
 
 embedded_scanline_ss = object(scanline )
119
 
   m_storage      : scanline_storage_aa_ptr;
120
 
   m_scanline     : scanline_data_ss;
121
 
   m_scanline_idx : unsigned;
122
 
 
123
 
   m_result : const_iterator_ss;
124
 
 
125
 
   constructor Construct(storage : scanline_storage_aa_ptr );
126
 
 
127
 
   procedure reset(min_x ,max_x : int ); virtual;
128
 
 
129
 
   function  y : int; virtual;
130
 
   function  num_spans : unsigned; virtual;
131
 
   function  begin_ : pointer; virtual;
132
 
 
133
 
   function  sz_of_span : unsigned; virtual;
134
 
   function  is_plain_span : boolean; virtual;
135
 
   function  is_embedded : boolean; virtual;
136
 
 
137
 
   procedure setup(scanline_idx : unsigned ); virtual;
138
 
 
139
 
  end;
140
 
 
141
 
 scanline_storage_aa = object(renderer_scanline )
142
 
   m_covers    : scanline_cell_storage;
143
 
   m_spans     ,
144
 
   m_scanlines : pod_deque;
145
 
 
146
 
   m_fake_span     : span_data_ss;
147
 
   m_fake_scanline : scanline_data_ss;
148
 
 
149
 
   m_min_x ,
150
 
   m_min_y ,
151
 
   m_max_x ,
152
 
   m_max_y : int;
153
 
 
154
 
   m_cur_scanline : unsigned;
155
 
 
156
 
   constructor Construct;
157
 
   destructor  Destruct;
158
 
 
159
 
  // Renderer Interface
160
 
   procedure prepare(u : unsigned ); virtual;
161
 
   procedure render (sl : scanline_ptr ); virtual;
162
 
 
163
 
  // Iterate scanlines interface
164
 
   function  _min_x : int; virtual;
165
 
   function  _min_y : int; virtual;
166
 
   function  _max_x : int; virtual;
167
 
   function  _max_y : int; virtual;
168
 
 
169
 
   function  rewind_scanlines : boolean; virtual;
170
 
   function  sweep_scanline(sl : scanline_ptr ) : boolean; virtual;
171
 
 
172
 
  // Specialization for embedded_scanline
173
 
   function  sweep_scanline_em(sl : scanline_ptr ) : boolean; virtual;
174
 
 
175
 
   function  byte_size : unsigned; virtual;
176
 
   procedure write_int32(dst : int8u_ptr; val : int32 );
177
 
   procedure serialize  (data : int8u_ptr ); virtual;
178
 
 
179
 
   function  scanline_by_index(i : unsigned ) : scanline_data_ss_ptr;
180
 
   function  span_by_index    (i : unsigned ) : span_data_ss_ptr;
181
 
   function  covers_by_index  (i : int ) : pointer;
182
 
 
183
 
  end;
184
 
 
185
 
 scanline_storage_aa8 = object(scanline_storage_aa )
186
 
  end;
187
 
 
188
 
 scanline_storage_aa16 = object(scanline_storage_aa )
189
 
   constructor Construct;
190
 
 
191
 
   function  sweep_scanline(sl : scanline_ptr ) : boolean; virtual;
192
 
 
193
 
   function  byte_size : unsigned; virtual;
194
 
   procedure serialize(data : int8u_ptr ); virtual;
195
 
 
196
 
  end;
197
 
 
198
 
 scanline_storage_aa32 = object(scanline_storage_aa )
199
 
   constructor Construct;
200
 
 
201
 
   function  sweep_scanline(sl : scanline_ptr ) : boolean; virtual;
202
 
 
203
 
   function  byte_size : unsigned; virtual;
204
 
   procedure serialize(data : int8u_ptr ); virtual;
205
 
 
206
 
  end;
207
 
 
208
 
//------------------------------------------serialized_scanlines_adaptor_aa
209
 
 embedded_scanline_sa_ptr = ^embedded_scanline_sa;
210
 
 
211
 
 const_iterator_sa = object(span_obj )
212
 
   m_ptr  : int8u_ptr;
213
 
   m_span : span_ss;
214
 
 
215
 
   m_dx : int;
216
 
   m_sz : unsigned;
217
 
 
218
 
   constructor Construct(sl : embedded_scanline_sa_ptr; sz : unsigned );
219
 
 
220
 
   function  x      : int; virtual;
221
 
   function  len    : int; virtual;
222
 
   function  covers : int8u_ptr; virtual;
223
 
 
224
 
   procedure inc_operator; virtual;
225
 
   procedure init_span;
226
 
 
227
 
   function  read_int32 : int;
228
 
 
229
 
  end;
230
 
 
231
 
 embedded_scanline_sa = object(scanline )
232
 
   m_ptr : int8u_ptr;
233
 
   m_y   : int;
234
 
 
235
 
   m_num_spans : unsigned;
236
 
 
237
 
   m_dx : int;
238
 
   m_sz : unsigned;
239
 
 
240
 
   m_result : const_iterator_sa;
241
 
 
242
 
   constructor Construct(sz : unsigned );
243
 
 
244
 
   procedure reset(min_x ,max_x : int ); virtual;
245
 
 
246
 
   function  y : int; virtual;
247
 
   function  num_spans : unsigned; virtual;
248
 
   function  begin_ : pointer; virtual;
249
 
 
250
 
   function  sz_of_span : unsigned; virtual;
251
 
   function  is_plain_span : boolean; virtual;
252
 
   function  is_embedded : boolean; virtual;
253
 
 
254
 
   procedure init(ptr : int8u_ptr; dx ,dy : int ); virtual;
255
 
 
256
 
   function  read_int32 : int;
257
 
 
258
 
  end;
259
 
 
260
 
 serialized_scanlines_adaptor_aa = object(rasterizer_scanline )
261
 
   m_data ,
262
 
   m_end  ,
263
 
   m_ptr  : int8u_ptr;
264
 
 
265
 
   m_dx ,
266
 
   m_dy ,
267
 
 
268
 
   m_min_x ,
269
 
   m_min_y ,
270
 
   m_max_x ,
271
 
   m_max_y : int;
272
 
 
273
 
   m_sz : unsigned;
274
 
 
275
 
   constructor Construct(sz : unsigned ); overload;
276
 
   constructor Construct(sz : unsigned; data : int8u_ptr; size : unsigned; dx ,dy : double ); overload;
277
 
 
278
 
   procedure init(data : int8u_ptr; size : unsigned; dx ,dy : double );
279
 
 
280
 
   function  read_int32 : int;
281
 
   function  read_int32u : unsigned;
282
 
 
283
 
  // Iterate scanlines interface
284
 
   function  rewind_scanlines : boolean; virtual;
285
 
 
286
 
   function  _min_x : int; virtual;
287
 
   function  _min_y : int; virtual;
288
 
   function  _max_x : int; virtual;
289
 
   function  _max_y : int; virtual;
290
 
 
291
 
   function  sweep_scanline(sl : scanline_ptr ) : boolean; virtual;
292
 
 
293
 
  // Specialization for embedded_scanline
294
 
   function  sweep_scanline_em(sl : scanline_ptr ) : boolean; virtual;
295
 
 
296
 
  end;
297
 
 
298
 
 serialized_scanlines_adaptor_aa8 = object(serialized_scanlines_adaptor_aa )
299
 
   constructor Construct; overload;
300
 
   constructor Construct(data : int8u_ptr; size : unsigned; dx ,dy : double ); overload;
301
 
 
302
 
  end;
303
 
 
304
 
 serialized_scanlines_adaptor_aa16 = object(serialized_scanlines_adaptor_aa )
305
 
   constructor Construct; overload;
306
 
   constructor Construct(data : int8u_ptr; size : unsigned; dx ,dy : double ); overload;
307
 
 
308
 
  end;
309
 
 
310
 
 serialized_scanlines_adaptor_aa32 = object(serialized_scanlines_adaptor_aa )
311
 
   constructor Construct; overload;
312
 
   constructor Construct(data : int8u_ptr; size : unsigned; dx ,dy : double ); overload;
313
 
 
314
 
  end;
315
 
 
316
 
{ GLOBAL PROCEDURES }
317
 
 
318
 
 
319
 
IMPLEMENTATION
320
 
{ LOCAL VARIABLES & CONSTANTS }
321
 
{ UNIT IMPLEMENTATION }
322
 
{ CONSTRUCT }
323
 
constructor scanline_cell_storage.Construct(entry_sz : unsigned );
324
 
begin
325
 
 m_cells.Construct        (128 - 2 ,entry_sz ,12 );
326
 
 m_extra_storage.Construct(sizeof(extra_span ) ,6 );
327
 
 
328
 
end;
329
 
 
330
 
{ CONSTRUCT }
331
 
constructor scanline_cell_storage.Construct(v : scanline_cell_storage_ptr );
332
 
begin
333
 
 m_cells.Construct        (v.m_cells.m_entry_sz );
334
 
 m_extra_storage.Construct(sizeof(extra_span ) ,6 );
335
 
 
336
 
 assign_operator   (v );
337
 
 copy_extra_storage(v );
338
 
 
339
 
end;
340
 
 
341
 
{ DESTRUCT }
342
 
destructor scanline_cell_storage.Destruct;
343
 
begin
344
 
 remove_all;
345
 
 
346
 
 m_cells.Destruct;
347
 
 m_extra_storage.Destruct;
348
 
 
349
 
end;
350
 
 
351
 
{ REMOVE_ALL }
352
 
procedure scanline_cell_storage.remove_all;
353
 
var
354
 
 i : int;
355
 
 s : extra_span_ptr;
356
 
 
357
 
begin
358
 
 i:=m_extra_storage.size; dec(i );
359
 
 
360
 
 while i >= 0 do
361
 
  begin
362
 
   s:=m_extra_storage.array_operator(i );
363
 
 
364
 
   agg_freemem(s.ptr ,s.len * m_cells.m_entry_sz );
365
 
 
366
 
   dec(i );
367
 
 
368
 
  end;
369
 
 
370
 
 m_extra_storage.remove_all;
371
 
 m_cells.remove_all;
372
 
 
373
 
end;
374
 
 
375
 
{ ADD_CELLS }
376
 
function scanline_cell_storage.add_cells;
377
 
var
378
 
 idx : int;
379
 
 ptr : pointer;
380
 
 
381
 
 s : extra_span;
382
 
 
383
 
begin
384
 
 idx:=m_cells.allocate_continuous_block(num_cells );
385
 
 
386
 
 if idx >= 0 then
387
 
  begin
388
 
   ptr:=m_cells.array_operator(idx );
389
 
 
390
 
   move(cells^ ,ptr^ ,m_cells.m_entry_sz * num_cells );
391
 
 
392
 
   result:=idx;
393
 
 
394
 
   exit;
395
 
 
396
 
  end;
397
 
 
398
 
 s.len:=num_cells;
399
 
 
400
 
 agg_getmem(s.ptr ,s.len * m_cells.m_entry_sz );
401
 
 
402
 
 move(cells^ ,s.ptr^ ,s.len * m_cells.m_entry_sz );
403
 
 
404
 
 m_extra_storage.add(@s );
405
 
 
406
 
 result:=-int(m_extra_storage.size );
407
 
 
408
 
end;
409
 
 
410
 
{ ASSIGN_OPERATOR }
411
 
function scanline_cell_storage.assign_operator;
412
 
begin
413
 
 remove_all;
414
 
 
415
 
 m_cells.assign_operator(@v.m_cells );
416
 
 copy_extra_storage     (v );
417
 
 
418
 
 result:=@self;
419
 
 
420
 
end;
421
 
 
422
 
{ ARRAY_OPERATOR }
423
 
function scanline_cell_storage.array_operator;
424
 
var
425
 
 i : unsigned;
426
 
 
427
 
begin
428
 
 if idx >= 0 then
429
 
  begin
430
 
   if idx >= m_cells.size then
431
 
    begin
432
 
     result:=NIL;
433
 
 
434
 
     exit;
435
 
 
436
 
    end;
437
 
 
438
 
   result:=m_cells.array_operator(idx );
439
 
 
440
 
   exit;
441
 
 
442
 
  end;
443
 
 
444
 
 i:=unsigned(-idx - 1 );
445
 
 
446
 
 if i >= m_extra_storage.size then
447
 
  begin
448
 
   result:=0;
449
 
 
450
 
   exit;
451
 
 
452
 
  end;
453
 
 
454
 
 result:=extra_span_ptr(m_extra_storage.array_operator(i ) ).ptr;
455
 
 
456
 
end;
457
 
 
458
 
{ COPY_EXTRA_STORAGE }
459
 
procedure scanline_cell_storage.copy_extra_storage;
460
 
var
461
 
 i : unsigned;
462
 
 
463
 
 src : extra_span_ptr;
464
 
 dst : extra_span;
465
 
 
466
 
begin
467
 
 i:=0;
468
 
 
469
 
 while i < v.m_extra_storage.size do
470
 
  begin
471
 
   src:=v.m_extra_storage.array_operator(i );
472
 
 
473
 
   dst.len:=src.len;
474
 
 
475
 
   agg_getmem(dst.ptr ,dst.len * v.m_cells.m_entry_sz );
476
 
 
477
 
   move(src.ptr^ ,dst.ptr^ ,dst.len * v.m_cells.m_entry_sz );
478
 
 
479
 
   m_extra_storage.add(@dst );
480
 
 
481
 
   inc(i );
482
 
 
483
 
  end;
484
 
 
485
 
end;
486
 
 
487
 
{ CONSTRUCT }
488
 
constructor const_iterator_ss.Construct;
489
 
begin
490
 
 m_storage :=sl.m_storage;
491
 
 m_span_idx:=sl.m_scanline.start_span;
492
 
 
493
 
 init_span;
494
 
 
495
 
end;
496
 
 
497
 
{ X }
498
 
function const_iterator_ss.x;
499
 
begin
500
 
 result:=m_span.x;
501
 
 
502
 
end;
503
 
 
504
 
{ LEN }
505
 
function const_iterator_ss.len;
506
 
begin
507
 
 result:=m_span.len;
508
 
 
509
 
end;
510
 
 
511
 
{ COVERS }
512
 
function const_iterator_ss.covers;
513
 
begin
514
 
 result:=m_span.covers;
515
 
 
516
 
end;
517
 
 
518
 
{ INC_OPERATOR }
519
 
procedure const_iterator_ss.inc_operator;
520
 
begin
521
 
 inc(m_span_idx );
522
 
 
523
 
 init_span;
524
 
 
525
 
end;
526
 
 
527
 
{ INIT_SPAN }
528
 
procedure const_iterator_ss.init_span;
529
 
var
530
 
 s : span_data_ss_ptr;
531
 
 
532
 
begin
533
 
 s:=m_storage.span_by_index(m_span_idx );
534
 
 
535
 
 m_span.x     :=s.x;
536
 
 m_span.len   :=s.len;
537
 
 m_span.covers:=m_storage.covers_by_index(s.covers_id );
538
 
 
539
 
end;
540
 
 
541
 
{ CONSTRUCT }
542
 
constructor embedded_scanline_ss.Construct;
543
 
begin
544
 
 m_storage:=storage;
545
 
 
546
 
 setup(0 );
547
 
 
548
 
end;
549
 
 
550
 
{ RESET }
551
 
procedure embedded_scanline_ss.reset;
552
 
begin
553
 
end;
554
 
 
555
 
{ Y }
556
 
function embedded_scanline_ss.y;
557
 
begin
558
 
 result:=m_scanline.y;
559
 
 
560
 
end;
561
 
 
562
 
{ NUM_SPANS }
563
 
function embedded_scanline_ss.num_spans;
564
 
begin
565
 
 result:=m_scanline.num_spans;
566
 
 
567
 
end;
568
 
 
569
 
{ BEGIN_ }
570
 
function embedded_scanline_ss.begin_;
571
 
begin
572
 
 m_result.Construct(@self );
573
 
 
574
 
 result:=@m_result;
575
 
 
576
 
end;
577
 
 
578
 
{ SZ_OF_SPAN }
579
 
function embedded_scanline_ss.sz_of_span;
580
 
begin
581
 
 result:=sizeof(span_ss );
582
 
 
583
 
end;
584
 
 
585
 
{ IS_PLAIN_SPAN }
586
 
function embedded_scanline_ss.is_plain_span;
587
 
begin
588
 
 result:=false;
589
 
 
590
 
end;
591
 
 
592
 
{ IS_EMBEDDED }
593
 
function embedded_scanline_ss.is_embedded;
594
 
begin
595
 
 result:=true;
596
 
 
597
 
end;
598
 
 
599
 
{ SETUP }
600
 
procedure embedded_scanline_ss.setup;
601
 
begin
602
 
 m_scanline_idx:=scanline_idx;
603
 
 m_scanline    :=m_storage.scanline_by_index(m_scanline_idx )^;
604
 
 
605
 
end;
606
 
 
607
 
{ CONSTRUCT }
608
 
constructor scanline_storage_aa.Construct;
609
 
begin
610
 
 m_covers.Construct   (sizeof(int8u ) );
611
 
 m_spans.Construct    (256 - 2 ,sizeof(span_data_ss ) ,10 ); // Block increment size
612
 
 m_scanlines.Construct(sizeof(scanline_data_ss ) ,8 );
613
 
 
614
 
 m_min_x:=$7FFFFFFF;
615
 
 m_min_y:=$7FFFFFFF;
616
 
 m_max_x:=-$7FFFFFFF;
617
 
 m_max_y:=-$7FFFFFFF;
618
 
 
619
 
 m_cur_scanline:=0;
620
 
 
621
 
 m_fake_scanline.y         :=0;
622
 
 m_fake_scanline.num_spans :=0;
623
 
 m_fake_scanline.start_span:=0;
624
 
 
625
 
 m_fake_span.x        :=0;
626
 
 m_fake_span.len      :=0;
627
 
 m_fake_span.covers_id:=0;
628
 
 
629
 
end;
630
 
 
631
 
{ DESTRUCT }
632
 
destructor scanline_storage_aa.Destruct;
633
 
begin
634
 
 m_covers.Destruct;
635
 
 m_spans.Destruct;
636
 
 m_scanlines.Destruct;
637
 
 
638
 
end;
639
 
 
640
 
{ PREPARE }
641
 
procedure scanline_storage_aa.prepare;
642
 
begin
643
 
 m_covers.remove_all;
644
 
 m_scanlines.remove_all;
645
 
 m_spans.remove_all;
646
 
 
647
 
 m_min_x:=$7FFFFFFF;
648
 
 m_min_y:=$7FFFFFFF;
649
 
 m_max_x:=-$7FFFFFFF;
650
 
 m_max_y:=-$7FFFFFFF;
651
 
 
652
 
 m_cur_scanline:=0;
653
 
 
654
 
end;
655
 
 
656
 
{ RENDER }
657
 
procedure scanline_storage_aa.render;
658
 
var
659
 
 sl_this : scanline_data_ss;
660
 
 
661
 
 y ,x1 ,x2 ,len : int;
662
 
 
663
 
 num_spans ,ss : unsigned;
664
 
 
665
 
 span_pl  : span_ptr;
666
 
 span_obj : span_obj_ptr;
667
 
 
668
 
 sp : span_data_ss;
669
 
 
670
 
begin
671
 
 y:=sl.y;
672
 
 
673
 
 if y < m_min_y then
674
 
  m_min_y:=y;
675
 
 
676
 
 if y > m_max_y then
677
 
  m_max_y:=y;
678
 
 
679
 
 sl_this.y         :=y;
680
 
 sl_this.num_spans :=sl.num_spans;
681
 
 sl_this.start_span:=m_spans.size;
682
 
 
683
 
 num_spans:=sl_this.num_spans;
684
 
 
685
 
 span_pl :=NIL;
686
 
 span_obj:=NIL;
687
 
 
688
 
 if sl.is_plain_span then
689
 
  begin
690
 
   span_pl:=sl.begin_;
691
 
 
692
 
   ss:=sl.sz_of_span;
693
 
 
694
 
  end
695
 
 else
696
 
  span_obj:=sl.begin_;
697
 
 
698
 
 repeat
699
 
  if span_pl <> NIL then
700
 
   begin
701
 
    sp.x  :=span_pl.x;
702
 
    sp.len:=span_pl.len;
703
 
 
704
 
   end
705
 
  else
706
 
   begin
707
 
    sp.x  :=span_obj.x;
708
 
    sp.len:=span_obj.len;
709
 
 
710
 
   end;
711
 
 
712
 
  len:=Abs(sp.len );
713
 
 
714
 
  if span_pl <> NIL then
715
 
   sp.covers_id:=m_covers.add_cells(span_pl.covers ,unsigned(len ) )
716
 
  else
717
 
   sp.covers_id:=m_covers.add_cells(span_obj.covers ,unsigned(len ) );
718
 
 
719
 
  m_spans.add(@sp );
720
 
 
721
 
  x1:=sp.x;
722
 
  x2:=sp.x + len - 1;
723
 
 
724
 
  if x1 < m_min_x then
725
 
   m_min_x:=x1;
726
 
 
727
 
  if x2 > m_max_x then
728
 
   m_max_x:=x2;
729
 
 
730
 
  dec(num_spans );
731
 
 
732
 
  if num_spans = 0 then
733
 
   break;
734
 
 
735
 
  if span_pl <> NIL then
736
 
   inc(ptrcomp(span_pl ) ,ss )
737
 
  else
738
 
   span_obj.inc_operator;
739
 
 
740
 
 until false;
741
 
 
742
 
 m_scanlines.add(@sl_this );
743
 
 
744
 
end;
745
 
 
746
 
{ _MIN_X }
747
 
function scanline_storage_aa._min_x;
748
 
begin
749
 
 result:=m_min_x;
750
 
 
751
 
end;
752
 
 
753
 
{ _MIN_Y }
754
 
function scanline_storage_aa._min_y;
755
 
begin
756
 
 result:=m_min_y;
757
 
 
758
 
end;
759
 
 
760
 
{ _MAX_X }
761
 
function scanline_storage_aa._max_x;
762
 
begin
763
 
 result:=m_max_x;
764
 
 
765
 
end;
766
 
 
767
 
{ _MAX_Y }
768
 
function scanline_storage_aa._max_y;
769
 
begin
770
 
 result:=m_max_y;
771
 
 
772
 
end;
773
 
 
774
 
{ REWIND_SCANLINES }
775
 
function scanline_storage_aa.rewind_scanlines;
776
 
begin
777
 
 m_cur_scanline:=0;
778
 
 
779
 
 result:=m_scanlines.size > 0;
780
 
 
781
 
end;
782
 
 
783
 
{ SWEEP_SCANLINE }
784
 
function scanline_storage_aa.sweep_scanline;
785
 
var
786
 
 sl_this : scanline_data_ss_ptr;
787
 
 
788
 
 num_spans ,span_idx : unsigned;
789
 
 
790
 
 sp : span_data_ss_ptr;
791
 
 
792
 
 covers : int8u_ptr;
793
 
 
794
 
begin
795
 
 sl.reset_spans;
796
 
 
797
 
 repeat
798
 
  if m_cur_scanline >= m_scanlines.size then
799
 
   begin
800
 
    result:=false;
801
 
 
802
 
    exit;
803
 
 
804
 
   end;
805
 
 
806
 
  sl_this:=m_scanlines.array_operator(m_cur_scanline );
807
 
 
808
 
  num_spans:=sl_this.num_spans;
809
 
  span_idx :=sl_this.start_span;
810
 
 
811
 
  repeat
812
 
   sp:=m_spans.array_operator(span_idx );
813
 
 
814
 
   inc(span_idx );
815
 
 
816
 
   covers:=covers_by_index(sp.covers_id );
817
 
 
818
 
   if sp.len < 0 then
819
 
    sl.add_span(sp.x ,unsigned(-sp.len ) ,covers^ )
820
 
   else
821
 
    sl.add_cells(sp.x ,sp.len ,covers );
822
 
 
823
 
   dec(num_spans );
824
 
 
825
 
  until num_spans = 0;
826
 
 
827
 
  inc(m_cur_scanline );
828
 
 
829
 
  if sl.num_spans <> 0 then
830
 
   begin
831
 
    sl.finalize(sl_this.y );
832
 
 
833
 
    break;
834
 
 
835
 
   end;
836
 
 
837
 
 until false;
838
 
 
839
 
 result:=true;
840
 
 
841
 
end;
842
 
 
843
 
{ SWEEP_SCANLINE }
844
 
function scanline_storage_aa.sweep_scanline_em;
845
 
begin
846
 
 repeat
847
 
  if m_cur_scanline >= m_scanlines.size then
848
 
   begin
849
 
    result:=false;
850
 
 
851
 
    exit;
852
 
 
853
 
   end;
854
 
 
855
 
  sl.setup(m_cur_scanline );
856
 
 
857
 
  inc(m_cur_scanline );
858
 
 
859
 
 until sl.num_spans <> 0;
860
 
 
861
 
 result:=true;
862
 
 
863
 
end;
864
 
 
865
 
{ BYTE_SIZE }
866
 
function scanline_storage_aa.byte_size;
867
 
var
868
 
 i ,size ,num_spans ,span_idx : unsigned;
869
 
 
870
 
 sl_this : scanline_data_ss_ptr;
871
 
 
872
 
 sp : span_data_ss_ptr;
873
 
 
874
 
begin
875
 
 size:=sizeof(int32 ) * 4; // min_x, min_y, max_x, max_y
876
 
 
877
 
 i:=0;
878
 
 
879
 
 while i < m_scanlines.size do
880
 
  begin
881
 
   inc(size ,sizeof(int32 ) * 3 ); // scanline size in bytes, Y, num_spans
882
 
 
883
 
   sl_this:=m_scanlines.array_operator(i );
884
 
 
885
 
   num_spans:=sl_this.num_spans;
886
 
   span_idx :=sl_this.start_span;
887
 
 
888
 
   repeat
889
 
    sp:=m_spans.array_operator(span_idx );
890
 
 
891
 
    inc(span_idx );
892
 
    inc(size ,sizeof(int32 ) * 2 );                  // X, span_len
893
 
 
894
 
    if sp.len < 0 then
895
 
     inc(size ,sizeof(int8u ) )                      // cover
896
 
    else
897
 
     inc(size ,sizeof(int8u ) * unsigned(sp.len ) ); // covers
898
 
 
899
 
    dec(num_spans );
900
 
 
901
 
   until num_spans = 0;
902
 
 
903
 
   inc(i );
904
 
 
905
 
  end;
906
 
 
907
 
 result:=size;
908
 
 
909
 
end;
910
 
 
911
 
{ WRITE_INT32 }
912
 
procedure scanline_storage_aa.write_int32;
913
 
begin
914
 
 int8u_ptr(ptrcomp(dst ) + 0 * sizeof(int8u ) )^:=int32_int8u(val )._0;
915
 
 int8u_ptr(ptrcomp(dst ) + 1 * sizeof(int8u ) )^:=int32_int8u(val )._1;
916
 
 int8u_ptr(ptrcomp(dst ) + 2 * sizeof(int8u ) )^:=int32_int8u(val )._2;
917
 
 int8u_ptr(ptrcomp(dst ) + 3 * sizeof(int8u ) )^:=int32_int8u(val )._3;
918
 
 
919
 
end;
920
 
 
921
 
{ SERIALIZE }
922
 
procedure scanline_storage_aa.serialize;
923
 
var
924
 
 i ,num_spans ,span_idx : unsigned;
925
 
 
926
 
 sl_this : scanline_data_ss_ptr;
927
 
 
928
 
 sp : span_data_ss_ptr;
929
 
 
930
 
 covers : int8u_ptr;
931
 
 
932
 
 size_ptr : int8u_ptr;
933
 
 
934
 
begin
935
 
 write_int32(data ,_min_x ); // min_x
936
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
937
 
 
938
 
 write_int32(data ,_min_y ); // min_y
939
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
940
 
 
941
 
 write_int32(data ,_max_x ); // max_x
942
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
943
 
 
944
 
 write_int32(data ,_max_y ); // max_y
945
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
946
 
 
947
 
 i:=0;
948
 
 
949
 
 while i < m_scanlines.size do
950
 
  begin
951
 
   sl_this :=m_scanlines.array_operator(i );
952
 
   size_ptr:=data;
953
 
 
954
 
   inc(ptrcomp(data ) ,sizeof(int32 ) );     // Reserve space for scanline size in bytes
955
 
 
956
 
   write_int32(data ,sl_this.y );            // Y
957
 
   inc(ptrcomp(data ) ,sizeof(int32 ) );
958
 
 
959
 
   write_int32(data ,sl_this.num_spans );    // num_spans
960
 
   inc(ptrcomp(data ) ,sizeof(int32 ) );
961
 
 
962
 
   num_spans:=sl_this.num_spans;
963
 
   span_idx :=sl_this.start_span;
964
 
 
965
 
   repeat
966
 
    sp:=m_spans.array_operator(span_idx );
967
 
 
968
 
    inc(span_idx );
969
 
 
970
 
    covers:=covers_by_index(sp.covers_id );
971
 
 
972
 
    write_int32(data ,sp.x );                // X
973
 
    inc(ptrcomp(data ) ,sizeof(int32 ) );
974
 
 
975
 
    write_int32(data ,sp.len );              // span_len
976
 
    inc(ptrcomp(data ) ,sizeof(int32 ) );
977
 
 
978
 
    if sp.len < 0 then
979
 
     begin
980
 
      move(covers^ ,data^ ,sizeof(int8u ) );
981
 
      inc (ptrcomp(data ) ,sizeof(int8u ) );
982
 
 
983
 
     end
984
 
    else
985
 
     begin
986
 
      move(covers^ ,data^ ,unsigned(sp.len ) * sizeof(int8u ) );
987
 
      inc (ptrcomp(data ) ,sizeof(int8u ) * unsigned(sp.len ) );
988
 
 
989
 
     end;
990
 
 
991
 
    dec(num_spans );
992
 
 
993
 
   until num_spans = 0;
994
 
 
995
 
   write_int32(size_ptr ,ptrcomp(data ) - ptrcomp(size_ptr ) );
996
 
 
997
 
   inc(i );
998
 
 
999
 
  end;
1000
 
 
1001
 
end;
1002
 
 
1003
 
{ SCANLINE_BY_INDEX }
1004
 
function scanline_storage_aa.scanline_by_index;
1005
 
begin
1006
 
 if i < m_scanlines.size then
1007
 
  result:=m_scanlines.array_operator(i )
1008
 
 else
1009
 
  result:=@m_fake_scanline;
1010
 
 
1011
 
end;
1012
 
 
1013
 
{ SPAN_BY_INDEX }
1014
 
function scanline_storage_aa.span_by_index;
1015
 
begin
1016
 
 if i < m_spans.size then
1017
 
  result:=m_spans.array_operator(i )
1018
 
 else
1019
 
  result:=@m_fake_span;
1020
 
 
1021
 
end;
1022
 
 
1023
 
{ COVERS_BY_INDEX }
1024
 
function scanline_storage_aa.covers_by_index;
1025
 
begin
1026
 
 result:=m_covers.array_operator(i );
1027
 
 
1028
 
end;
1029
 
 
1030
 
{ CONSTRUCT }
1031
 
constructor scanline_storage_aa16.Construct;
1032
 
begin
1033
 
 m_covers.Construct   (sizeof(int16u ) );
1034
 
 m_spans.Construct    (256 - 2 ,sizeof(span_data_ss ) ,10 ); // Block increment size
1035
 
 m_scanlines.Construct(sizeof(scanline_data_ss ) ,8 );
1036
 
 
1037
 
 m_min_x:=$7FFFFFFF;
1038
 
 m_min_y:=$7FFFFFFF;
1039
 
 m_max_x:=-$7FFFFFFF;
1040
 
 m_max_y:=-$7FFFFFFF;
1041
 
 
1042
 
 m_cur_scanline:=0;
1043
 
 
1044
 
 m_fake_scanline.y         :=0;
1045
 
 m_fake_scanline.num_spans :=0;
1046
 
 m_fake_scanline.start_span:=0;
1047
 
 
1048
 
 m_fake_span.x        :=0;
1049
 
 m_fake_span.len      :=0;
1050
 
 m_fake_span.covers_id:=0;
1051
 
 
1052
 
end;
1053
 
 
1054
 
{ SWEEP_SCANLINE }
1055
 
function scanline_storage_aa16.sweep_scanline;
1056
 
var
1057
 
 sl_this : scanline_data_ss_ptr;
1058
 
 
1059
 
 num_spans ,span_idx : unsigned;
1060
 
 
1061
 
 sp : span_data_ss_ptr;
1062
 
 
1063
 
 covers : int16u_ptr;
1064
 
 
1065
 
begin
1066
 
 sl.reset_spans;
1067
 
 
1068
 
 repeat
1069
 
  if m_cur_scanline >= m_scanlines.size then
1070
 
   begin
1071
 
    result:=false;
1072
 
 
1073
 
    exit;
1074
 
 
1075
 
   end;
1076
 
 
1077
 
  sl_this:=m_scanlines.array_operator(m_cur_scanline );
1078
 
 
1079
 
  num_spans:=sl_this.num_spans;
1080
 
  span_idx :=sl_this.start_span;
1081
 
 
1082
 
  repeat
1083
 
   sp:=m_spans.array_operator(span_idx );
1084
 
 
1085
 
   inc(span_idx );
1086
 
 
1087
 
   covers:=covers_by_index(sp.covers_id );
1088
 
 
1089
 
   if sp.len < 0 then
1090
 
    sl.add_span(sp.x ,unsigned(-sp.len ) ,covers^ )
1091
 
   else
1092
 
    sl.add_cells(sp.x ,sp.len ,int8u_ptr(covers ) );
1093
 
 
1094
 
   dec(num_spans );
1095
 
 
1096
 
  until num_spans = 0;
1097
 
 
1098
 
  inc(m_cur_scanline );
1099
 
 
1100
 
  if sl.num_spans <> 0 then
1101
 
   begin
1102
 
    sl.finalize(sl_this.y );
1103
 
 
1104
 
    break;
1105
 
 
1106
 
   end;
1107
 
 
1108
 
 until false;
1109
 
 
1110
 
 result:=true;
1111
 
 
1112
 
end;
1113
 
 
1114
 
{ BYTE_SIZE }
1115
 
function scanline_storage_aa16.byte_size;
1116
 
var
1117
 
 i ,size ,num_spans ,span_idx : unsigned;
1118
 
 
1119
 
 sl_this : scanline_data_ss_ptr;
1120
 
 
1121
 
 sp : span_data_ss_ptr;
1122
 
 
1123
 
begin
1124
 
 size:=sizeof(int32 ) * 4; // min_x, min_y, max_x, max_y
1125
 
 
1126
 
 i:=0;
1127
 
 
1128
 
 while i < m_scanlines.size do
1129
 
  begin
1130
 
   inc(size ,sizeof(int32 ) * 3 ); // scanline size in bytes, Y, num_spans
1131
 
 
1132
 
   sl_this:=m_scanlines.array_operator(i );
1133
 
 
1134
 
   num_spans:=sl_this.num_spans;
1135
 
   span_idx :=sl_this.start_span;
1136
 
 
1137
 
   repeat
1138
 
    sp:=m_spans.array_operator(span_idx );
1139
 
 
1140
 
    inc(span_idx );
1141
 
    inc(size ,sizeof(int32 ) * 2 );                   // X, span_len
1142
 
 
1143
 
    if sp.len < 0 then
1144
 
     inc(size ,sizeof(int16u ) )                      // cover
1145
 
    else
1146
 
     inc(size ,sizeof(int16u ) * unsigned(sp.len ) ); // covers
1147
 
 
1148
 
    dec(num_spans );
1149
 
 
1150
 
   until num_spans = 0;
1151
 
 
1152
 
   inc(i );
1153
 
 
1154
 
  end;
1155
 
 
1156
 
 result:=size;
1157
 
 
1158
 
end;
1159
 
 
1160
 
{ SERIALIZE }
1161
 
procedure scanline_storage_aa16.serialize;
1162
 
var
1163
 
 i ,num_spans ,span_idx : unsigned;
1164
 
 
1165
 
 sl_this : scanline_data_ss_ptr;
1166
 
 
1167
 
 sp : span_data_ss_ptr;
1168
 
 
1169
 
 covers : int16u_ptr;
1170
 
 
1171
 
 size_ptr : int8u_ptr;
1172
 
 
1173
 
begin
1174
 
 write_int32(data ,_min_x ); // min_x
1175
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
1176
 
 
1177
 
 write_int32(data ,_min_y ); // min_y
1178
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
1179
 
 
1180
 
 write_int32(data ,_max_x ); // max_x
1181
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
1182
 
 
1183
 
 write_int32(data ,_max_y ); // max_y
1184
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
1185
 
 
1186
 
 i:=0;
1187
 
 
1188
 
 while i < m_scanlines.size do
1189
 
  begin
1190
 
   sl_this :=m_scanlines.array_operator(i );
1191
 
   size_ptr:=data;
1192
 
 
1193
 
   inc(ptrcomp(data ) ,sizeof(int32 ) );     // Reserve space for scanline size in bytes
1194
 
 
1195
 
   write_int32(data ,sl_this.y );            // Y
1196
 
   inc(ptrcomp(data ) ,sizeof(int32 ) );
1197
 
 
1198
 
   write_int32(data ,sl_this.num_spans );    // num_spans
1199
 
   inc(ptrcomp(data ) ,sizeof(int32 ) );
1200
 
 
1201
 
   num_spans:=sl_this.num_spans;
1202
 
   span_idx :=sl_this.start_span;
1203
 
 
1204
 
   repeat
1205
 
    sp:=m_spans.array_operator(span_idx );
1206
 
 
1207
 
    inc(span_idx );
1208
 
 
1209
 
    covers:=covers_by_index(sp.covers_id );
1210
 
 
1211
 
    write_int32(data ,sp.x );                // X
1212
 
    inc(ptrcomp(data ) ,sizeof(int32 ) );
1213
 
 
1214
 
    write_int32(data ,sp.len );              // span_len
1215
 
    inc(ptrcomp(data ) ,sizeof(int32 ) );
1216
 
 
1217
 
    if sp.len < 0 then
1218
 
     begin
1219
 
      move(covers^ ,data^ ,sizeof(int16u ) );
1220
 
      inc (ptrcomp(data ) ,sizeof(int16u ) );
1221
 
 
1222
 
     end
1223
 
    else
1224
 
     begin
1225
 
      move(covers^ ,data^ ,unsigned(sp.len ) * sizeof(int16u ) );
1226
 
      inc (ptrcomp(data ) ,sizeof(int16u ) * unsigned(sp.len ) );
1227
 
 
1228
 
     end;
1229
 
 
1230
 
    dec(num_spans );
1231
 
 
1232
 
   until num_spans = 0;
1233
 
 
1234
 
   write_int32(size_ptr ,ptrcomp(data ) - ptrcomp(size_ptr ) );
1235
 
 
1236
 
   inc(i );
1237
 
 
1238
 
  end;
1239
 
 
1240
 
end;
1241
 
 
1242
 
{ CONSTRUCT }
1243
 
constructor scanline_storage_aa32.Construct;
1244
 
begin
1245
 
 m_covers.Construct   (sizeof(int32u ) );
1246
 
 m_spans.Construct    (256 - 2 ,sizeof(span_data_ss ) ,10 ); // Block increment size
1247
 
 m_scanlines.Construct(sizeof(scanline_data_ss ) ,8 );
1248
 
 
1249
 
 m_min_x:=$7FFFFFFF;
1250
 
 m_min_y:=$7FFFFFFF;
1251
 
 m_max_x:=-$7FFFFFFF;
1252
 
 m_max_y:=-$7FFFFFFF;
1253
 
 
1254
 
 m_cur_scanline:=0;
1255
 
 
1256
 
 m_fake_scanline.y         :=0;
1257
 
 m_fake_scanline.num_spans :=0;
1258
 
 m_fake_scanline.start_span:=0;
1259
 
 
1260
 
 m_fake_span.x        :=0;
1261
 
 m_fake_span.len      :=0;
1262
 
 m_fake_span.covers_id:=0;
1263
 
 
1264
 
end;
1265
 
 
1266
 
{ SWEEP_SCANLINE }
1267
 
function scanline_storage_aa32.sweep_scanline;
1268
 
var
1269
 
 sl_this : scanline_data_ss_ptr;
1270
 
 
1271
 
 num_spans ,span_idx : unsigned;
1272
 
 
1273
 
 sp : span_data_ss_ptr;
1274
 
 
1275
 
 covers : int32u_ptr;
1276
 
 
1277
 
begin
1278
 
 sl.reset_spans;
1279
 
 
1280
 
 repeat
1281
 
  if m_cur_scanline >= m_scanlines.size then
1282
 
   begin
1283
 
    result:=false;
1284
 
 
1285
 
    exit;
1286
 
 
1287
 
   end;
1288
 
 
1289
 
  sl_this:=m_scanlines.array_operator(m_cur_scanline );
1290
 
 
1291
 
  num_spans:=sl_this.num_spans;
1292
 
  span_idx :=sl_this.start_span;
1293
 
 
1294
 
  repeat
1295
 
   sp:=m_spans.array_operator(span_idx );
1296
 
 
1297
 
   inc(span_idx );
1298
 
 
1299
 
   covers:=covers_by_index(sp.covers_id );
1300
 
 
1301
 
   if sp.len < 0 then
1302
 
    sl.add_span(sp.x ,unsigned(-sp.len ) ,covers^ )
1303
 
   else
1304
 
    sl.add_cells(sp.x ,sp.len ,int8u_ptr(covers ) );
1305
 
 
1306
 
   dec(num_spans );
1307
 
 
1308
 
  until num_spans = 0;
1309
 
 
1310
 
  inc(m_cur_scanline );
1311
 
 
1312
 
  if sl.num_spans <> 0 then
1313
 
   begin
1314
 
    sl.finalize(sl_this.y );
1315
 
 
1316
 
    break;
1317
 
 
1318
 
   end;
1319
 
 
1320
 
 until false;
1321
 
 
1322
 
 result:=true;
1323
 
 
1324
 
end;
1325
 
 
1326
 
{ BYTE_SIZE }
1327
 
function scanline_storage_aa32.byte_size;
1328
 
var
1329
 
 i ,size ,num_spans ,span_idx : unsigned;
1330
 
 
1331
 
 sl_this : scanline_data_ss_ptr;
1332
 
 
1333
 
 sp : span_data_ss_ptr;
1334
 
 
1335
 
begin
1336
 
 size:=sizeof(int32 ) * 4; // min_x, min_y, max_x, max_y
1337
 
 
1338
 
 i:=0;
1339
 
 
1340
 
 while i < m_scanlines.size do
1341
 
  begin
1342
 
   inc(size ,sizeof(int32 ) * 3 ); // scanline size in bytes, Y, num_spans
1343
 
 
1344
 
   sl_this:=m_scanlines.array_operator(i );
1345
 
 
1346
 
   num_spans:=sl_this.num_spans;
1347
 
   span_idx :=sl_this.start_span;
1348
 
 
1349
 
   repeat
1350
 
    sp:=m_spans.array_operator(span_idx );
1351
 
 
1352
 
    inc(span_idx );
1353
 
    inc(size ,sizeof(int32 ) * 2 );                   // X, span_len
1354
 
 
1355
 
    if sp.len < 0 then
1356
 
     inc(size ,sizeof(int32u ) )                      // cover
1357
 
    else
1358
 
     inc(size ,sizeof(int32u ) * unsigned(sp.len ) ); // covers
1359
 
 
1360
 
    dec(num_spans );
1361
 
 
1362
 
   until num_spans = 0;
1363
 
 
1364
 
   inc(i );
1365
 
 
1366
 
  end;
1367
 
 
1368
 
 result:=size;
1369
 
 
1370
 
end;
1371
 
 
1372
 
{ SERIALIZE }
1373
 
procedure scanline_storage_aa32.serialize;
1374
 
var
1375
 
 i ,num_spans ,span_idx : unsigned;
1376
 
 
1377
 
 sl_this : scanline_data_ss_ptr;
1378
 
 
1379
 
 sp : span_data_ss_ptr;
1380
 
 
1381
 
 covers : int32u_ptr;
1382
 
 
1383
 
 size_ptr : int8u_ptr;
1384
 
 
1385
 
begin
1386
 
 write_int32(data ,_min_x ); // min_x
1387
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
1388
 
 
1389
 
 write_int32(data ,_min_y ); // min_y
1390
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
1391
 
 
1392
 
 write_int32(data ,_max_x ); // max_x
1393
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
1394
 
 
1395
 
 write_int32(data ,_max_y ); // max_y
1396
 
 inc(ptrcomp(data ) ,sizeof(int32 ) );
1397
 
 
1398
 
 i:=0;
1399
 
 
1400
 
 while i < m_scanlines.size do
1401
 
  begin
1402
 
   sl_this :=m_scanlines.array_operator(i );
1403
 
   size_ptr:=data;
1404
 
 
1405
 
   inc(ptrcomp(data ) ,sizeof(int32 ) );     // Reserve space for scanline size in bytes
1406
 
 
1407
 
   write_int32(data ,sl_this.y );            // Y
1408
 
   inc(ptrcomp(data ) ,sizeof(int32 ) );
1409
 
 
1410
 
   write_int32(data ,sl_this.num_spans );    // num_spans
1411
 
   inc(ptrcomp(data ) ,sizeof(int32 ) );
1412
 
 
1413
 
   num_spans:=sl_this.num_spans;
1414
 
   span_idx :=sl_this.start_span;
1415
 
 
1416
 
   repeat
1417
 
    sp:=m_spans.array_operator(span_idx );
1418
 
 
1419
 
    inc(span_idx );
1420
 
 
1421
 
    covers:=covers_by_index(sp.covers_id );
1422
 
 
1423
 
    write_int32(data ,sp.x );                // X
1424
 
    inc(ptrcomp(data ) ,sizeof(int32 ) );
1425
 
 
1426
 
    write_int32(data ,sp.len );              // span_len
1427
 
    inc(ptrcomp(data ) ,sizeof(int32 ) );
1428
 
 
1429
 
    if sp.len < 0 then
1430
 
     begin
1431
 
      move(covers^ ,data^ ,sizeof(int32u ) );
1432
 
      inc (ptrcomp(data ) ,sizeof(int32u ) );
1433
 
 
1434
 
     end
1435
 
    else
1436
 
     begin
1437
 
      move(covers^ ,data^ ,unsigned(sp.len ) * sizeof(int32u ) );
1438
 
      inc (ptrcomp(data ) ,sizeof(int32u ) * unsigned(sp.len ) );
1439
 
 
1440
 
     end;
1441
 
 
1442
 
    dec(num_spans );
1443
 
 
1444
 
   until num_spans = 0;
1445
 
 
1446
 
   write_int32(size_ptr ,ptrcomp(data ) - ptrcomp(size_ptr ) );
1447
 
 
1448
 
   inc(i );
1449
 
 
1450
 
  end;
1451
 
 
1452
 
end;
1453
 
 
1454
 
{ CONSTRUCT }
1455
 
constructor const_iterator_sa.Construct;
1456
 
begin
1457
 
 m_ptr:=sl.m_ptr;
1458
 
 m_dx :=sl.m_dx;
1459
 
 m_sz :=sz;
1460
 
 
1461
 
 init_span;
1462
 
 
1463
 
end;
1464
 
 
1465
 
{ X }
1466
 
function const_iterator_sa.x;
1467
 
begin
1468
 
 result:=m_span.x;
1469
 
 
1470
 
end;
1471
 
 
1472
 
{ LEN }
1473
 
function const_iterator_sa.len;
1474
 
begin
1475
 
 result:=m_span.len;
1476
 
 
1477
 
end;
1478
 
 
1479
 
{ COVERS }
1480
 
function const_iterator_sa.covers;
1481
 
begin
1482
 
 result:=m_span.covers;
1483
 
 
1484
 
end;
1485
 
 
1486
 
{ INC_OPERATOR }
1487
 
procedure const_iterator_sa.inc_operator;
1488
 
begin
1489
 
 if m_span.len < 0 then
1490
 
  inc(ptrcomp(m_ptr ) ,m_sz )
1491
 
 else
1492
 
  inc(ptrcomp(m_ptr ) ,m_span.len * m_sz );
1493
 
 
1494
 
 init_span;
1495
 
 
1496
 
end;
1497
 
 
1498
 
{ INIT_SPAN }
1499
 
procedure const_iterator_sa.init_span;
1500
 
begin
1501
 
 m_span.x     :=read_int32 + m_dx;
1502
 
 m_span.len   :=read_int32;
1503
 
 m_span.covers:=m_ptr;
1504
 
 
1505
 
end;
1506
 
 
1507
 
{ READ_INT32 }
1508
 
function const_iterator_sa.read_int32;
1509
 
begin
1510
 
 int32_int8u(result )._0:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1511
 
 int32_int8u(result )._1:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1512
 
 int32_int8u(result )._2:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1513
 
 int32_int8u(result )._3:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1514
 
 
1515
 
end;
1516
 
 
1517
 
{ CONSTRUCT }
1518
 
constructor embedded_scanline_sa.Construct;
1519
 
begin
1520
 
 m_ptr:=NIL;
1521
 
 m_y  :=0;
1522
 
 m_sz :=sz;
1523
 
 
1524
 
 m_num_spans:=0;
1525
 
 
1526
 
end;
1527
 
 
1528
 
{ RESET }
1529
 
procedure embedded_scanline_sa.reset;
1530
 
begin
1531
 
end;
1532
 
 
1533
 
{ Y }
1534
 
function embedded_scanline_sa.y;
1535
 
begin
1536
 
 result:=m_y;
1537
 
 
1538
 
end;
1539
 
 
1540
 
{ NUM_SPANS }
1541
 
function embedded_scanline_sa.num_spans;
1542
 
begin
1543
 
 result:=m_num_spans;
1544
 
 
1545
 
end;
1546
 
 
1547
 
{ BEGIN_ }
1548
 
function embedded_scanline_sa.begin_;
1549
 
begin
1550
 
 m_result.Construct(@self ,m_sz );
1551
 
 
1552
 
 result:=@m_result;
1553
 
 
1554
 
end;
1555
 
 
1556
 
{ SZ_OF_SPAN }
1557
 
function embedded_scanline_sa.sz_of_span;
1558
 
begin
1559
 
 result:=sizeof(span_ss );
1560
 
 
1561
 
end;
1562
 
 
1563
 
{ IS_PLAIN_SPAN }
1564
 
function embedded_scanline_sa.is_plain_span;
1565
 
begin
1566
 
 result:=false;
1567
 
 
1568
 
end;
1569
 
 
1570
 
{ IS_EMBEDDED }
1571
 
function embedded_scanline_sa.is_embedded;
1572
 
begin
1573
 
 result:=true;
1574
 
 
1575
 
end;
1576
 
 
1577
 
{ INIT }
1578
 
procedure embedded_scanline_sa.init;
1579
 
begin
1580
 
 m_ptr      :=ptr;
1581
 
 m_y        :=read_int32 + dy;
1582
 
 m_num_spans:=unsigned(read_int32 );
1583
 
 m_dx       :=dx;
1584
 
 
1585
 
end;
1586
 
 
1587
 
{ READ_INT32 }
1588
 
function embedded_scanline_sa.read_int32;
1589
 
begin
1590
 
 int32_int8u(result )._0:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1591
 
 int32_int8u(result )._1:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1592
 
 int32_int8u(result )._2:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1593
 
 int32_int8u(result )._3:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1594
 
 
1595
 
end;
1596
 
 
1597
 
{ CONSTRUCT }
1598
 
constructor serialized_scanlines_adaptor_aa.Construct(sz : unsigned );
1599
 
begin
1600
 
 m_data:=NIL;
1601
 
 m_end :=NIL;
1602
 
 m_ptr :=NIL;
1603
 
 
1604
 
 m_dx:=0;
1605
 
 m_dy:=0;
1606
 
 
1607
 
 m_min_x:=$7FFFFFFF;
1608
 
 m_min_y:=$7FFFFFFF;
1609
 
 m_max_x:=-$7FFFFFFF;
1610
 
 m_max_y:=-$7FFFFFFF;
1611
 
 
1612
 
 m_sz:=sz;
1613
 
 
1614
 
end;
1615
 
 
1616
 
{ CONSTRUCT }
1617
 
constructor serialized_scanlines_adaptor_aa.Construct(sz : unsigned; data : int8u_ptr; size : unsigned; dx ,dy : double );
1618
 
begin
1619
 
 m_data:=data;
1620
 
 m_end :=int8u_ptr(ptrcomp(data ) + size );
1621
 
 m_ptr :=data;
1622
 
 
1623
 
 m_dx:=trunc(dx + 0.5 );
1624
 
 m_dy:=trunc(dy + 0.5 );
1625
 
 
1626
 
 m_min_x:=$7FFFFFFF;
1627
 
 m_min_y:=$7FFFFFFF;
1628
 
 m_max_x:=-$7FFFFFFF;
1629
 
 m_max_y:=-$7FFFFFFF;
1630
 
 
1631
 
 m_sz:=sz;
1632
 
 
1633
 
end;
1634
 
 
1635
 
{ INIT }
1636
 
procedure serialized_scanlines_adaptor_aa.init;
1637
 
begin
1638
 
 m_data:=data;
1639
 
 m_end :=int8u_ptr(ptrcomp(data ) + size );
1640
 
 m_ptr :=data;
1641
 
 
1642
 
 m_dx:=trunc(dx + 0.5 );
1643
 
 m_dy:=trunc(dy + 0.5 );
1644
 
 
1645
 
 m_min_x:=$7FFFFFFF;
1646
 
 m_min_y:=$7FFFFFFF;
1647
 
 m_max_x:=-$7FFFFFFF;
1648
 
 m_max_y:=-$7FFFFFFF;
1649
 
 
1650
 
end;
1651
 
 
1652
 
{ READ_INT32 }
1653
 
function serialized_scanlines_adaptor_aa.read_int32;
1654
 
begin
1655
 
 int32_int8u(result )._0:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1656
 
 int32_int8u(result )._1:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1657
 
 int32_int8u(result )._2:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1658
 
 int32_int8u(result )._3:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1659
 
 
1660
 
end;
1661
 
 
1662
 
{ READ_INT32U }
1663
 
function serialized_scanlines_adaptor_aa.read_int32u;
1664
 
begin
1665
 
 int32_int8u(result )._0:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1666
 
 int32_int8u(result )._1:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1667
 
 int32_int8u(result )._2:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1668
 
 int32_int8u(result )._3:=m_ptr^; inc(ptrcomp(m_ptr ) ,sizeof(int8u ) );
1669
 
 
1670
 
end;
1671
 
 
1672
 
{ REWIND_SCANLINES }
1673
 
function serialized_scanlines_adaptor_aa.rewind_scanlines;
1674
 
var
1675
 
 x : int;
1676
 
 
1677
 
begin
1678
 
 m_ptr:=m_data;
1679
 
 
1680
 
 if ptrcomp(m_ptr ) < ptrcomp(m_end ) then
1681
 
  begin
1682
 
   m_min_x:=read_int32 + m_dx;
1683
 
   m_min_y:=read_int32 + m_dy;
1684
 
   m_max_x:=read_int32 + m_dx;
1685
 
   m_max_y:=read_int32 + m_dy;
1686
 
 
1687
 
   result:=true;
1688
 
 
1689
 
   exit;
1690
 
 
1691
 
  end;
1692
 
 
1693
 
 result:=false;
1694
 
 
1695
 
end;
1696
 
 
1697
 
{ _MIN_X }
1698
 
function serialized_scanlines_adaptor_aa._min_x;
1699
 
begin
1700
 
 result:=m_min_x;
1701
 
 
1702
 
end;
1703
 
 
1704
 
{ _MIN_Y }
1705
 
function serialized_scanlines_adaptor_aa._min_y;
1706
 
begin
1707
 
 result:=m_min_y;
1708
 
 
1709
 
end;
1710
 
 
1711
 
{ _MAX_X }
1712
 
function serialized_scanlines_adaptor_aa._max_x;
1713
 
begin
1714
 
 result:=m_max_x;
1715
 
 
1716
 
end;
1717
 
 
1718
 
{ _MAX_Y }
1719
 
function serialized_scanlines_adaptor_aa._max_y;
1720
 
begin
1721
 
 result:=m_max_y;
1722
 
 
1723
 
end;
1724
 
 
1725
 
{ SWEEP_SCANLINE }
1726
 
function serialized_scanlines_adaptor_aa.sweep_scanline;
1727
 
var
1728
 
 y ,x ,len : int;
1729
 
 
1730
 
 num_spans : unsigned;
1731
 
 
1732
 
begin
1733
 
 sl.reset_spans;
1734
 
 
1735
 
 repeat
1736
 
  if ptrcomp(m_ptr ) >= ptrcomp(m_end ) then
1737
 
   begin
1738
 
    result:=false;
1739
 
 
1740
 
    exit;
1741
 
 
1742
 
   end;
1743
 
 
1744
 
  read_int32;      // Skip scanline size in bytes
1745
 
 
1746
 
  y        :=read_int32 + m_dy;
1747
 
  num_spans:=read_int32;
1748
 
 
1749
 
  repeat
1750
 
   x  :=read_int32 + m_dx;
1751
 
   len:=read_int32;
1752
 
 
1753
 
   if len < 0 then
1754
 
    begin
1755
 
     sl.add_span(x ,unsigned(-len ) ,m_ptr^ );
1756
 
 
1757
 
     inc(ptrcomp(m_ptr ) ,m_sz );
1758
 
 
1759
 
    end
1760
 
   else
1761
 
    begin
1762
 
     sl.add_cells(x ,len ,m_ptr );
1763
 
 
1764
 
     inc(ptrcomp(m_ptr ) ,len * m_sz );
1765
 
 
1766
 
    end;
1767
 
 
1768
 
   dec(num_spans );
1769
 
 
1770
 
  until num_spans = 0;
1771
 
 
1772
 
  if sl.num_spans <> 0 then
1773
 
   begin
1774
 
    sl.finalize(y );
1775
 
 
1776
 
    break;
1777
 
 
1778
 
   end;
1779
 
 
1780
 
 until false;
1781
 
 
1782
 
 result:=true;
1783
 
 
1784
 
end;
1785
 
 
1786
 
{ SWEEP_SCANLINE }
1787
 
function serialized_scanlines_adaptor_aa.sweep_scanline_em;
1788
 
var
1789
 
 byte_size : unsigned;
1790
 
 
1791
 
begin
1792
 
 repeat
1793
 
  if ptrcomp(m_ptr ) >= ptrcomp(m_end ) then
1794
 
   begin
1795
 
    result:=false;
1796
 
 
1797
 
    exit;
1798
 
 
1799
 
   end;
1800
 
 
1801
 
  byte_size:=read_int32u;
1802
 
 
1803
 
  sl.init(m_ptr ,m_dx ,m_dy );
1804
 
 
1805
 
  inc(ptrcomp(m_ptr ) ,byte_size - sizeof(int32 ) );
1806
 
 
1807
 
 until sl.num_spans <> 0;
1808
 
 
1809
 
 result:=true;
1810
 
 
1811
 
end;
1812
 
 
1813
 
{ CONSTRUCT }
1814
 
constructor serialized_scanlines_adaptor_aa8.Construct;
1815
 
begin
1816
 
 inherited Construct(sizeof(int8u ) );
1817
 
 
1818
 
end;
1819
 
 
1820
 
{ CONSTRUCT }
1821
 
constructor serialized_scanlines_adaptor_aa8.Construct(data : int8u_ptr; size : unsigned; dx ,dy : double );
1822
 
begin
1823
 
 inherited Construct(sizeof(int8u ) ,data ,size ,dx ,dy );
1824
 
 
1825
 
end;
1826
 
 
1827
 
{ CONSTRUCT }
1828
 
constructor serialized_scanlines_adaptor_aa16.Construct;
1829
 
begin
1830
 
 inherited Construct(sizeof(int16u ) );
1831
 
 
1832
 
end;
1833
 
 
1834
 
{ CONSTRUCT }
1835
 
constructor serialized_scanlines_adaptor_aa16.Construct(data : int8u_ptr; size : unsigned; dx ,dy : double );
1836
 
begin
1837
 
 inherited Construct(sizeof(int8u ) ,data ,size ,dx ,dy );
1838
 
 
1839
 
end;
1840
 
 
1841
 
{ CONSTRUCT }
1842
 
constructor serialized_scanlines_adaptor_aa32.Construct;
1843
 
begin
1844
 
 inherited Construct(sizeof(int32u ) );
1845
 
 
1846
 
end;
1847
 
 
1848
 
{ CONSTRUCT }
1849
 
constructor serialized_scanlines_adaptor_aa32.Construct(data : int8u_ptr; size : unsigned; dx ,dy : double );
1850
 
begin
1851
 
 inherited Construct(sizeof(int8u ) ,data ,size ,dx ,dy );
1852
 
 
1853
 
end;
1854
 
 
1855
 
END.
1856
 
 
1857