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

« back to all changes in this revision

Viewing changes to components/aggpas/src/agg_renderer_primitives.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
 
//----------------------------------------------------------------------------
22
 
//
23
 
// class renderer_primitives
24
 
//
25
 
// [Pascal Port History] -----------------------------------------------------
26
 
//
27
 
// 15.01.2006-Milano: Unit port establishment
28
 
//
29
 
{ agg_renderer_primitives.pas }
30
 
unit
31
 
 agg_renderer_primitives ;
32
 
 
33
 
INTERFACE
34
 
 
35
 
{$I agg_mode.inc }
36
 
 
37
 
uses
38
 
 agg_basics ,
39
 
 agg_renderer_base ,
40
 
 agg_color ,
41
 
 agg_dda_line ,
42
 
 agg_ellipse_bresenham ;
43
 
 
44
 
{ TYPES DEFINITION }
45
 
type
46
 
 renderer_primitives_ptr = ^renderer_primitives;
47
 
 renderer_primitives = object
48
 
   m_ren : renderer_base_ptr;
49
 
 
50
 
   m_fill_color ,
51
 
   m_line_color : aggclr;
52
 
 
53
 
   m_curr_x ,
54
 
   m_curr_y : int;
55
 
 
56
 
   constructor Construct(ren_ : renderer_base_ptr );
57
 
 
58
 
   function  coord(c : double ) : int;
59
 
 
60
 
   procedure fill_color_(c : aggclr_ptr );
61
 
   procedure line_color_(c : aggclr_ptr );
62
 
 
63
 
   function  _fill_color : aggclr_ptr;
64
 
   function  _line_color : aggclr_ptr;
65
 
 
66
 
   procedure rectangle         (x1 ,y1 ,x2 ,y2 : int );
67
 
   procedure solid_rectangle   (x1 ,y1 ,x2 ,y2 : int );
68
 
   procedure outlined_rectangle(x1 ,y1 ,x2 ,y2 : int );
69
 
 
70
 
   procedure ellipse         (x ,y ,rx ,ry : int );
71
 
   procedure solid_ellipse   (x ,y ,rx ,ry : int );
72
 
   procedure outlined_ellipse(x ,y ,rx ,ry : int );
73
 
 
74
 
   procedure line(x1 ,y1 ,x2 ,y2 : int; last : boolean = false );
75
 
 
76
 
   procedure move_to(x ,y : int );
77
 
   procedure line_to(x ,y : int; last : boolean = false );
78
 
 
79
 
   function  ren : renderer_base_ptr;
80
 
 
81
 
  end;
82
 
 
83
 
{ GLOBAL PROCEDURES }
84
 
 
85
 
 
86
 
IMPLEMENTATION
87
 
{ LOCAL VARIABLES & CONSTANTS }
88
 
{ UNIT IMPLEMENTATION }
89
 
{ CONSTRUCT }
90
 
constructor renderer_primitives.Construct;
91
 
begin
92
 
 m_fill_color.Construct;
93
 
 m_line_color.Construct;
94
 
 
95
 
 m_ren:=ren_;
96
 
 
97
 
 m_curr_x:=0;
98
 
 m_curr_y:=0;
99
 
 
100
 
end;
101
 
 
102
 
{ COORD }
103
 
function renderer_primitives.coord;
104
 
begin
105
 
 result:=trunc(c * subpixel_size );
106
 
 
107
 
end;
108
 
 
109
 
{ FILL_COLOR_ }
110
 
procedure renderer_primitives.fill_color_;
111
 
begin
112
 
 m_fill_color:=c^;
113
 
 
114
 
end;
115
 
 
116
 
{ LINE_COLOR_ }
117
 
procedure renderer_primitives.line_color_;
118
 
begin
119
 
 m_line_color:=c^;
120
 
 
121
 
end;
122
 
 
123
 
{ _FILL_COLOR }
124
 
function renderer_primitives._fill_color;
125
 
begin
126
 
 result:=@m_fill_color;
127
 
 
128
 
end;
129
 
 
130
 
{ _LINE_COLOR }
131
 
function renderer_primitives._line_color;
132
 
begin
133
 
 result:=@m_line_color;
134
 
 
135
 
end;
136
 
 
137
 
{ RECTANGLE }
138
 
procedure renderer_primitives.rectangle;
139
 
begin
140
 
 m_ren.blend_hline(x1     ,y1     ,x2 - 1 ,@m_line_color ,cover_full );
141
 
 m_ren.blend_vline(x2     ,y1     ,y2 - 1 ,@m_line_color ,cover_full );
142
 
 m_ren.blend_hline(x1 + 1 ,y2     ,x2     ,@m_line_color ,cover_full );
143
 
 m_ren.blend_vline(x1     ,y1 + 1 ,y2     ,@m_line_color ,cover_full );
144
 
 
145
 
end;
146
 
 
147
 
{ SOLID_RECTANGLE }
148
 
procedure renderer_primitives.solid_rectangle;
149
 
begin
150
 
 m_ren.blend_bar(x1 ,y1 ,x2 ,y2 ,@m_fill_color ,cover_full );
151
 
 
152
 
end;
153
 
 
154
 
{ OUTLINED_RECTANGLE }
155
 
procedure renderer_primitives.outlined_rectangle;
156
 
begin
157
 
 rectangle      (x1 ,y1 ,x2 ,y2 );
158
 
 m_ren.blend_bar(x1 + 1 ,y1 + 1 ,x2 - 1 ,y2 - 1 ,@m_fill_color ,cover_full );
159
 
 
160
 
end;
161
 
 
162
 
{ ELLIPSE }
163
 
procedure renderer_primitives.ellipse;
164
 
var
165
 
 ei : ellipse_bresenham_interpolator;
166
 
 dx ,
167
 
 dy : int;
168
 
 
169
 
begin
170
 
 ei.Construct(rx ,ry );
171
 
 
172
 
 dx:=0;
173
 
 dy:=-ry;
174
 
 
175
 
 repeat
176
 
  inc(dx ,ei._dx );
177
 
  inc(dy ,ei._dy );
178
 
 
179
 
  m_ren.blend_pixel(x + dx ,y + dy ,@m_line_color ,cover_full );
180
 
  m_ren.blend_pixel(x + dx ,y - dy ,@m_line_color ,cover_full );
181
 
  m_ren.blend_pixel(x - dx ,y - dy ,@m_line_color ,cover_full );
182
 
  m_ren.blend_pixel(x - dx ,y + dy ,@m_line_color ,cover_full );
183
 
 
184
 
  ei.inc_operator;
185
 
 
186
 
 until dy >= 0;
187
 
 
188
 
end;
189
 
 
190
 
{ SOLID_ELLIPSE }
191
 
procedure renderer_primitives.solid_ellipse;
192
 
var
193
 
 ei : ellipse_bresenham_interpolator;
194
 
 
195
 
 dx ,dy ,dx0 ,dy0 : int;
196
 
 
197
 
begin
198
 
 ei.Construct(rx ,ry );
199
 
 
200
 
 dx :=0;
201
 
 dy :=-ry;
202
 
 dy0:=dy;
203
 
 dx0:=dx;
204
 
 
205
 
 repeat
206
 
  inc(dx ,ei._dx );
207
 
  inc(dy ,ei._dy );
208
 
 
209
 
  if dy <> dy0 then
210
 
   begin
211
 
    m_ren.blend_hline(x - dx0 ,y + dy0 ,x + dx0 ,@m_fill_color ,cover_full );
212
 
    m_ren.blend_hline(x - dx0 ,y - dy0 ,x + dx0 ,@m_fill_color ,cover_full );
213
 
 
214
 
   end;
215
 
 
216
 
  dx0:=dx;
217
 
  dy0:=dy;
218
 
 
219
 
  ei.inc_operator;
220
 
 
221
 
 until dy >= 0;
222
 
 
223
 
 m_ren.blend_hline(x - dx0 ,y + dy0 ,x + dx0 ,@m_fill_color ,cover_full );
224
 
 
225
 
end;
226
 
 
227
 
{ OUTLINED_ELLIPSE }
228
 
procedure renderer_primitives.outlined_ellipse;
229
 
var
230
 
 ei : ellipse_bresenham_interpolator;
231
 
 dx ,
232
 
 dy : int;
233
 
 
234
 
begin
235
 
 ei.Construct(rx ,ry );
236
 
 
237
 
 dx:=0;
238
 
 dy:=-ry;
239
 
 
240
 
 repeat
241
 
  inc(dx ,ei._dx );
242
 
  inc(dy ,ei._dy );
243
 
 
244
 
  m_ren.blend_pixel(x + dx ,y + dy ,@m_line_color ,cover_full );
245
 
  m_ren.blend_pixel(x + dx ,y - dy ,@m_line_color ,cover_full );
246
 
  m_ren.blend_pixel(x - dx ,y - dy ,@m_line_color ,cover_full );
247
 
  m_ren.blend_pixel(x - dx ,y + dy ,@m_line_color ,cover_full );
248
 
 
249
 
  if (ei._dy <> 0 ) and
250
 
     (dx <> 0 ) then
251
 
   begin
252
 
    m_ren.blend_hline(x - dx + 1 ,y + dy ,x + dx - 1 ,@m_fill_color ,cover_full );
253
 
    m_ren.blend_hline(x - dx + 1 ,y - dy ,x + dx - 1 ,@m_fill_color ,cover_full );
254
 
 
255
 
   end;
256
 
 
257
 
  ei.inc_operator;
258
 
 
259
 
 until dy >= 0;
260
 
 
261
 
end;
262
 
 
263
 
{ LINE }
264
 
procedure renderer_primitives.line;
265
 
var
266
 
 li  : line_bresenham_interpolator;
267
 
 len : unsigned;
268
 
 
269
 
begin
270
 
 li.Construct(x1 ,y1 ,x2 ,y2 );
271
 
 
272
 
 len:=li._len;
273
 
 
274
 
 if len = 0 then
275
 
  begin
276
 
   if last then
277
 
    m_ren.blend_pixel(li.line_lr(x1 ) ,li.line_lr(y1 ) ,@m_line_color ,cover_full );
278
 
 
279
 
   exit;
280
 
 
281
 
  end;
282
 
 
283
 
 if last then
284
 
  inc(len );
285
 
 
286
 
 if li._is_ver then
287
 
  repeat
288
 
   m_ren.blend_pixel(li._x2 ,li._y1 ,@m_line_color ,cover_full );
289
 
 
290
 
   li.vstep;
291
 
 
292
 
   dec(len );
293
 
 
294
 
  until len = 0
295
 
 else 
296
 
  repeat
297
 
   m_ren.blend_pixel(li._x1 ,li._y2 ,@m_line_color ,cover_full );
298
 
 
299
 
   li.hstep;
300
 
 
301
 
   dec(len );
302
 
 
303
 
  until len = 0;
304
 
 
305
 
end;
306
 
 
307
 
{ MOVE_TO }
308
 
procedure renderer_primitives.move_to;
309
 
begin
310
 
 m_curr_x:=x;
311
 
 m_curr_y:=y;
312
 
 
313
 
end;
314
 
 
315
 
{ LINE_TO }
316
 
procedure renderer_primitives.line_to;
317
 
begin
318
 
 line(m_curr_x ,m_curr_y ,x ,y ,last );
319
 
 
320
 
 m_curr_x:=x;
321
 
 m_curr_y:=y;
322
 
 
323
 
end;
324
 
 
325
 
{ REN }
326
 
function renderer_primitives.ren;
327
 
begin
328
 
 result:=m_ren;
329
 
 
330
 
end;
331
 
 
332
 
END.
333