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

« back to all changes in this revision

Viewing changes to components/aggpas/src/agg_gamma_lut.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
 
// 16.01.2006-Milano: Unit port establishment
25
 
//
26
 
{ agg_gamma_lut.pas }
27
 
unit
28
 
 agg_gamma_lut ;
29
 
 
30
 
INTERFACE
31
 
 
32
 
{$I agg_mode.inc }
33
 
 
34
 
uses
35
 
 Math ,
36
 
 agg_basics ,
37
 
 agg_pixfmt ;
38
 
 
39
 
{ TYPES DEFINITION }
40
 
type
41
 
 gamma_lut = object(gamma )
42
 
   gamma_shift ,
43
 
   gamma_size  ,
44
 
   gamma_mask  ,
45
 
 
46
 
   hi_res_shift ,
47
 
   hi_res_size  ,
48
 
   hi_res_mask  ,
49
 
 
50
 
   HiResT ,
51
 
   LoResT : unsigned;
52
 
 
53
 
   m_gamma : double;
54
 
 
55
 
   m_dir_gamma ,
56
 
   m_inv_gamma : int8u_ptr;
57
 
 
58
 
   constructor Construct_(GammaShift : unsigned = 8; HiResShift : unsigned = 8 );
59
 
   constructor Construct (g : double; GammaShift : unsigned = 8; HiResShift : unsigned = 8 );
60
 
   destructor  Destruct;
61
 
 
62
 
   procedure gamma_(g : double );
63
 
   function  _gamma : double;
64
 
 
65
 
   function dir(v : unsigned ) : unsigned; virtual;
66
 
   function inv(v : unsigned ) : unsigned; virtual;
67
 
 
68
 
  end;
69
 
 
70
 
{ GLOBAL PROCEDURES }
71
 
 
72
 
 
73
 
IMPLEMENTATION
74
 
{ LOCAL VARIABLES & CONSTANTS }
75
 
{ UNIT IMPLEMENTATION }
76
 
{ CONSTRUCT }
77
 
constructor gamma_lut.Construct_;
78
 
var
79
 
 i : unsigned;
80
 
 
81
 
begin
82
 
 gamma_shift:=GammaShift;
83
 
 gamma_size :=1 shl gamma_shift;
84
 
 gamma_mask :=gamma_size - 1;
85
 
 
86
 
 hi_res_shift:=HiResShift;
87
 
 hi_res_size :=1 shl hi_res_shift;
88
 
 hi_res_mask :=hi_res_size - 1;
89
 
 
90
 
 HiResT:=hi_res_shift div 8;
91
 
 LoResT:=gamma_shift div 8;
92
 
 
93
 
 agg_getmem(pointer(m_dir_gamma ) ,gamma_size * HiResT );
94
 
 agg_getmem(pointer(m_inv_gamma ) ,hi_res_size * LoResT );
95
 
 
96
 
// dir_gamma
97
 
 for i:=0 to gamma_size - 1 do
98
 
  try
99
 
   case HiResT of
100
 
    1 :
101
 
     int8u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
102
 
      int8u(i shl (hi_res_shift - gamma_shift ) );
103
 
 
104
 
    2 :
105
 
     int16u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
106
 
      int16u(i shl (hi_res_shift - gamma_shift ) );
107
 
 
108
 
    4 :
109
 
     int32u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
110
 
      int32u(i shl (hi_res_shift - gamma_shift ) );
111
 
 
112
 
   end;
113
 
  except
114
 
  end;
115
 
 
116
 
// inv_gamma
117
 
 for i:=0 to hi_res_size - 1 do
118
 
  try
119
 
   case LoResT of
120
 
    1 :
121
 
     int8u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
122
 
      int8u(i shr (hi_res_shift - gamma_shift ) );
123
 
 
124
 
    2 :
125
 
     int16u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
126
 
      int16u(i shr (hi_res_shift - gamma_shift ) );
127
 
 
128
 
    4 :
129
 
     int32u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
130
 
      int32u(i shr (hi_res_shift - gamma_shift ) );
131
 
 
132
 
   end;
133
 
  except
134
 
  end;
135
 
 
136
 
end;
137
 
 
138
 
{ CONSTRUCT }
139
 
constructor gamma_lut.Construct;
140
 
begin
141
 
 gamma_shift:=GammaShift;
142
 
 gamma_size :=1 shl gamma_shift;
143
 
 gamma_mask :=gamma_size - 1;
144
 
 
145
 
 hi_res_shift:=HiResShift;
146
 
 hi_res_size :=1 shl hi_res_shift;
147
 
 hi_res_mask :=hi_res_size - 1;
148
 
 
149
 
 HiResT:=hi_res_shift div 8;
150
 
 LoResT:=gamma_shift div 8;
151
 
 
152
 
 m_gamma:=1;
153
 
 
154
 
 agg_getmem(pointer(m_dir_gamma ) ,gamma_size * HiResT );
155
 
 agg_getmem(pointer(m_inv_gamma ) ,hi_res_size * LoResT );
156
 
 
157
 
 gamma_(g );
158
 
 
159
 
end;
160
 
 
161
 
{ DESTRUCT }
162
 
destructor gamma_lut.Destruct;
163
 
begin
164
 
 agg_freemem(pointer(m_dir_gamma ) ,gamma_size * HiResT );
165
 
 agg_freemem(pointer(m_inv_gamma ) ,hi_res_size * LoResT );
166
 
 
167
 
end;
168
 
 
169
 
{ GAMMA_ }
170
 
procedure gamma_lut.gamma_;
171
 
var
172
 
 i : unsigned;
173
 
 
174
 
 inv_g : double;
175
 
 
176
 
begin
177
 
 m_gamma:=g;
178
 
 
179
 
// dir_gamma
180
 
 for i:=0 to gamma_size - 1 do
181
 
  try
182
 
   case HiResT of
183
 
    1 :
184
 
     int8u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
185
 
      int8u(trunc(Power(i / gamma_mask ,m_gamma ) * hi_res_mask + 0.5 ) );
186
 
 
187
 
    2 :
188
 
     int16u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
189
 
      int16u(trunc(Power(i / gamma_mask ,m_gamma ) * hi_res_mask + 0.5 ) );
190
 
 
191
 
    4 :
192
 
     int32u_ptr(ptrcomp(m_dir_gamma ) + i * HiResT )^:=
193
 
      int32u(trunc(Power(i / gamma_mask ,m_gamma ) * hi_res_mask + 0.5 ) );
194
 
 
195
 
   end;
196
 
  except
197
 
  end;
198
 
 
199
 
// inv_gamma
200
 
 if g = 0 then
201
 
  fillchar(m_inv_gamma^ ,hi_res_size * LoResT ,0 )
202
 
 
203
 
 else
204
 
  begin
205
 
   inv_g:=1 / g;
206
 
 
207
 
   for i:=0 to hi_res_size - 1 do
208
 
    try
209
 
     case LoResT of
210
 
      1 :
211
 
       int8u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
212
 
        int8u(trunc(Power(i / hi_res_mask ,inv_g ) * gamma_mask + 0.5 ) );
213
 
 
214
 
      2 :
215
 
       int16u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
216
 
        int16u(trunc(Power(i / hi_res_mask ,inv_g ) * gamma_mask + 0.5 ) );
217
 
 
218
 
      4 :
219
 
       int32u_ptr(ptrcomp(m_inv_gamma ) + i * LoResT )^:=
220
 
        int32u(trunc(Power(i / hi_res_mask ,inv_g ) * gamma_mask + 0.5 ) );
221
 
 
222
 
     end;
223
 
    except
224
 
    end;
225
 
 
226
 
  end;
227
 
 
228
 
end;
229
 
 
230
 
{ _GAMMA }
231
 
function gamma_lut._gamma : double;
232
 
begin
233
 
 result:=m_gamma;
234
 
 
235
 
end;
236
 
 
237
 
{ DIR }
238
 
function gamma_lut.dir;
239
 
begin
240
 
 case HiResT of
241
 
  1 :
242
 
   result:=int8u_ptr(ptrcomp(m_dir_gamma ) + v * HiResT )^;
243
 
 
244
 
  2 :
245
 
   result:=int16u_ptr(ptrcomp(m_dir_gamma ) + v * HiResT )^;
246
 
 
247
 
  4 :
248
 
   result:=int32u_ptr(ptrcomp(m_dir_gamma ) + v * HiResT )^;
249
 
 
250
 
  else
251
 
   result:=0;
252
 
 
253
 
 end;
254
 
 
255
 
end;
256
 
 
257
 
{ INV }
258
 
function gamma_lut.inv;
259
 
begin
260
 
 case LoResT of
261
 
  1 :
262
 
   result:=int8u_ptr(ptrcomp(m_inv_gamma ) + v * LoResT )^;
263
 
 
264
 
  2 :
265
 
   result:=int16u_ptr(ptrcomp(m_inv_gamma ) + v * LoResT )^;
266
 
 
267
 
  4 :
268
 
   result:=int32u_ptr(ptrcomp(m_inv_gamma ) + v * LoResT )^;
269
 
 
270
 
  else
271
 
   result:=0;
272
 
 
273
 
 end;
274
 
 
275
 
end;
276
 
 
277
 
END.
278