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

« back to all changes in this revision

Viewing changes to components/aggpas/src/agg_span_gradient_image.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
 
// AGG Contribution Pack - Gradients 1 (AGG CP - Gradients 1)
3
 
// http://milan.marusinec.sk/aggcp
4
 
//
5
 
// Anti-Grain Geometry - Version 2.4 Release Milano 3 (AggPas 2.4 RM3)
6
 
// http://www.aggpas.org
7
 
//
8
 
// Contribution Created By:
9
 
//  Milan Marusinec alias Milano
10
 
//  milan@marusinec.sk
11
 
//  Copyright (c) 2007
12
 
//
13
 
// Permission to copy, use, modify, sell and distribute this software
14
 
// is granted provided this copyright notice appears in all copies.
15
 
// This software is provided "as is" without express or implied
16
 
// warranty, and with no claim as to its suitability for any purpose.
17
 
//
18
 
// [History] -----------------------------------------------------------------
19
 
//
20
 
// 14.11.2007-Milano: Establishment
21
 
//
22
 
{ agg_span_gradient_image.pas }
23
 
unit
24
 
 agg_span_gradient_image ;
25
 
 
26
 
INTERFACE
27
 
 
28
 
{$I agg_mode.inc }
29
 
 
30
 
uses
31
 
 agg_basics ,
32
 
 agg_color ,
33
 
 agg_array ,
34
 
 agg_span_gradient ,
35
 
 agg_pixfmt ,
36
 
 agg_pixfmt_rgba ,
37
 
 agg_rendering_buffer ;
38
 
 
39
 
{ GLOBAL VARIABLES & CONSTANTS }
40
 
{ TYPES DEFINITION }
41
 
type
42
 
 one_color_function = object(array_base )
43
 
   m_color : aggclr;
44
 
 
45
 
   constructor Construct;
46
 
 
47
 
   function  size : unsigned; virtual;
48
 
   function  entry : unsigned; virtual;
49
 
   function  array_operator(i : unsigned ) : pointer; virtual;
50
 
 
51
 
  end;
52
 
 
53
 
 gradient_image = object(gradient )
54
 
  private
55
 
   m_buffer : pointer;
56
 
   m_alocdx ,
57
 
   m_alocdy ,
58
 
   m_width  ,
59
 
   m_height : int;
60
 
 
61
 
   m_renbuf : rendering_buffer_ptr;
62
 
   m_pixelf : pixel_formats;
63
 
 
64
 
   m_color : aggclr_ptr;
65
 
 
66
 
   m_color_function : one_color_function;
67
 
 
68
 
  public
69
 
   constructor Construct;
70
 
   destructor  Destruct;
71
 
 
72
 
   function  image_create(width ,height : int ) : pointer;
73
 
   function  image_buffer : pointer;
74
 
   function  image_width : int;
75
 
   function  image_height : int;
76
 
   function  image_stride : int;
77
 
 
78
 
   function  calculate(x ,y ,d : int ) : int; virtual;
79
 
 
80
 
   function  pixel_format : pixel_formats_ptr;
81
 
   function  color_function : array_base_ptr;
82
 
 
83
 
  end;
84
 
 
85
 
{ GLOBAL PROCEDURES }
86
 
 
87
 
 
88
 
IMPLEMENTATION
89
 
{ LOCAL VARIABLES & CONSTANTS }
90
 
{ UNIT IMPLEMENTATION }
91
 
{ CONSTRUCT }
92
 
constructor one_color_function.Construct;
93
 
begin
94
 
 m_color.Construct;
95
 
 
96
 
end;
97
 
 
98
 
{ SIZE }
99
 
function one_color_function.size : unsigned;
100
 
begin
101
 
 result:=1;
102
 
 
103
 
end;
104
 
 
105
 
{ ENTRY }
106
 
function one_color_function.entry : unsigned;
107
 
begin
108
 
 result:=sizeof(aggclr );
109
 
 
110
 
end;
111
 
 
112
 
{ ARRAY_OPERATOR }
113
 
function one_color_function.array_operator(i : unsigned ) : pointer;
114
 
begin
115
 
 result:=@m_color;
116
 
 
117
 
end;
118
 
 
119
 
{ CONSTRUCT }
120
 
constructor gradient_image.Construct;
121
 
begin
122
 
 m_color_function.Construct;
123
 
 
124
 
 m_buffer:=NIL;
125
 
 m_alocdx:=0;
126
 
 m_alocdy:=0;
127
 
 m_width :=0;
128
 
 m_height:=0;
129
 
 
130
 
 m_renbuf:=NIL;
131
 
 
132
 
 pixfmt_undefined(m_pixelf );
133
 
 
134
 
 m_color:=m_color_function.array_operator(0 );
135
 
 
136
 
end;
137
 
 
138
 
{ DESTRUCT }
139
 
destructor gradient_image.Destruct;
140
 
begin
141
 
 if m_buffer <> NIL then
142
 
  agg_freemem(m_buffer ,m_alocdx * m_alocdy * 4 );
143
 
 
144
 
 if m_renbuf <> NIL then
145
 
  dispose(m_renbuf ,Destruct );
146
 
 
147
 
end;
148
 
 
149
 
{ IMAGE_CREATE }
150
 
function gradient_image.image_create(width ,height : int ) : pointer;
151
 
var
152
 
 row  : pointer;
153
 
 rows : unsigned;
154
 
 
155
 
begin
156
 
 result:=NIL;
157
 
 
158
 
 if m_renbuf <> NIL then
159
 
  dispose(m_renbuf ,Destruct );
160
 
 
161
 
 m_renbuf:=NIL;
162
 
 
163
 
 if (width > m_alocdx ) or
164
 
    (height > m_alocdy ) then
165
 
  begin
166
 
   if m_buffer <> NIL then
167
 
    agg_freemem(m_buffer ,m_alocdx * m_alocdy * 4 );
168
 
 
169
 
   m_buffer:=NIL;
170
 
 
171
 
   if agg_getmem(m_buffer ,width * height * 4 ) then
172
 
    begin
173
 
     m_alocdx:=width;
174
 
     m_alocdy:=height;
175
 
 
176
 
    end
177
 
   else
178
 
    begin
179
 
     m_alocdx:=0;
180
 
     m_alocdy:=0;
181
 
 
182
 
    end;
183
 
 
184
 
  end;
185
 
 
186
 
 if m_buffer <> NIL then
187
 
  begin
188
 
   m_width :=width;
189
 
   m_height:=height;
190
 
 
191
 
   row :=m_buffer;
192
 
   rows:=height;
193
 
 
194
 
   while rows > 0 do
195
 
    begin
196
 
     FillChar(row^ ,m_width * 4 ,0 );
197
 
 
198
 
     inc(ptrcomp(row ) ,m_alocdx * 4 );
199
 
     dec(rows );
200
 
 
201
 
    end;
202
 
 
203
 
   result:=m_buffer;
204
 
 
205
 
  end
206
 
 else
207
 
  begin
208
 
   m_width :=0;
209
 
   m_height:=0;
210
 
 
211
 
  end;
212
 
 
213
 
end;
214
 
 
215
 
{ IMAGE_BUFFER }
216
 
function gradient_image.image_buffer : pointer;
217
 
begin
218
 
 result:=m_buffer;
219
 
 
220
 
end;
221
 
 
222
 
{ IMAGE_WIDTH }
223
 
function gradient_image.image_width : int;
224
 
begin
225
 
 result:=m_width;
226
 
 
227
 
end;
228
 
 
229
 
{ IMAGE_HEIGHT }
230
 
function gradient_image.image_height : int;
231
 
begin
232
 
 result:=m_height;
233
 
 
234
 
end;
235
 
 
236
 
{ IMAGE_STRIDE }
237
 
function gradient_image.image_stride : int;
238
 
begin
239
 
 result:=m_alocdx * 4;
240
 
 
241
 
end;
242
 
 
243
 
{ CALCULATE }
244
 
function gradient_image.calculate(x ,y ,d : int ) : int;
245
 
var
246
 
 px ,py : int;
247
 
 
248
 
 pixel : rgba8_ptr;
249
 
 
250
 
begin
251
 
 result:=0;
252
 
 
253
 
 if m_buffer <> NIL then
254
 
  begin
255
 
   px:=shr_int32(x ,gradient_subpixel_shift );
256
 
   py:=shr_int32(y ,gradient_subpixel_shift );
257
 
 
258
 
   px:=px mod m_width;
259
 
 
260
 
   if px < 0 then
261
 
    px:=m_width + px;
262
 
 
263
 
   py:=py mod m_height;
264
 
 
265
 
   if py < 0 then
266
 
    py:=m_height + py;
267
 
 
268
 
   pixel:=rgba8_ptr(ptrcomp(m_buffer ) + py * (m_alocdx * 4 ) + px * 4 );
269
 
 
270
 
   m_color.r:=pixel.r;
271
 
   m_color.g:=pixel.g;
272
 
   m_color.b:=pixel.b;
273
 
   m_color.a:=pixel.a;
274
 
 
275
 
  end
276
 
 else
277
 
  begin
278
 
   m_color.r:=0;
279
 
   m_color.g:=0;
280
 
   m_color.b:=0;
281
 
   m_color.a:=0;
282
 
 
283
 
  end;
284
 
 
285
 
end;
286
 
 
287
 
{ PIXEL_FORMAT }
288
 
function gradient_image.pixel_format : pixel_formats_ptr;
289
 
begin
290
 
 if (m_buffer <> NIL ) and
291
 
    (m_renbuf = NIL ) then
292
 
  begin
293
 
   new(m_renbuf ,Construct );
294
 
 
295
 
   m_renbuf.attach(m_buffer ,m_width ,m_height ,m_alocdx * 4 );
296
 
   pixfmt_rgba32  (m_pixelf ,m_renbuf );
297
 
 
298
 
  end;
299
 
 
300
 
 if m_renbuf = NIL then
301
 
  result:=NIL
302
 
 else
303
 
  result:=@m_pixelf;
304
 
 
305
 
end;
306
 
 
307
 
{ COLOR_FUNCTION }
308
 
function gradient_image.color_function : array_base_ptr;
309
 
begin
310
 
 result:=@m_color_function;
311
 
 
312
 
end;
313
 
 
314
 
END.
315