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

« back to all changes in this revision

Viewing changes to components/aggpas/src/pf_rgb565.inc

  • 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
 
// AggPas 2.4 RM3 pixel format definition file
3
 
//
4
 
{ make_pix_565 }
5
 
function make_pix_565(r ,g ,b : unsigned ) : int16u;
6
 
begin
7
 
 result:=
8
 
  ((r and $F8 ) shl 8 ) or
9
 
  ((g and $FC ) shl 3 ) or
10
 
   (b shr 3 );
11
 
 
12
 
end;
13
 
 
14
 
{ make_color_565 }
15
 
procedure make_color_565(var color : aggclr; p : int16u_ptr );
16
 
begin
17
 
 color.ConstrInt(
18
 
  (p^ shr 8 ) and $F8 ,
19
 
  (p^ shr 3 ) and $FC ,
20
 
  (p^ shl 3 ) and $F8 );
21
 
 
22
 
end;
23
 
 
24
 
{ blend_pix_565 }
25
 
procedure blend_pix_565(p : int16u_ptr; cr ,cg ,cb ,alpha : int );
26
 
var
27
 
 rgb : int16u;
28
 
 
29
 
 r ,g ,b : int;
30
 
 
31
 
begin
32
 
 rgb:=p^;
33
 
 
34
 
 r:=(rgb shr 8 ) and $F8;
35
 
 g:=(rgb shr 3 ) and $FC;
36
 
 b:=(rgb shl 3 ) and $F8;
37
 
 
38
 
 p^:=
39
 
 ((((cr - r ) * alpha + (r shl 8 ) )        ) and $F800 ) or
40
 
 ((((cg - g ) * alpha + (g shl 8 ) ) shr 5  ) and $07E0 ) or
41
 
  (((cb - b ) * alpha + (b shl 8 ) ) shr 11 );
42
 
 
43
 
end;
44
 
 
45
 
{ copy_or_blend_pix_565 }
46
 
procedure copy_or_blend_pix_565(p : int16u_ptr; c : aggclr_ptr; cover : unsigned );
47
 
var
48
 
 alpha : unsigned;
49
 
 
50
 
begin
51
 
 if c.a <> 0 then
52
 
  begin
53
 
   alpha:=(c.a * (cover + 1 ) ) shr 8;
54
 
 
55
 
   if alpha = base_mask then
56
 
    p^:=make_pix_565(c.r ,c.g ,c.b )
57
 
   else
58
 
    blend_pix_565(p ,c.r ,c.g ,c.b ,alpha );
59
 
 
60
 
  end;
61
 
 
62
 
end;
63
 
 
64
 
{ rgb565_copy_pixel }
65
 
procedure rgb565_copy_pixel(this : pixel_formats_ptr; x ,y : int; c : aggclr_ptr );
66
 
begin
67
 
 int16u_ptr(ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) )^:=make_pix_565(c.r ,c.g ,c.b );
68
 
 
69
 
end;
70
 
 
71
 
{ rgb565_blend_pixel }
72
 
procedure rgb565_blend_pixel(this : pixel_formats_ptr; x ,y : int; c : aggclr_ptr; cover : int8u );
73
 
begin
74
 
 copy_or_blend_pix_565(int16u_ptr(ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) ) ,c ,cover );
75
 
 
76
 
end;
77
 
 
78
 
{ rgb565_pixel }
79
 
function rgb565_pixel(this : pixel_formats_ptr; x ,y : int ) : aggclr;
80
 
begin
81
 
 make_color_565(
82
 
  result ,
83
 
  int16u_ptr(ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) ) );
84
 
 
85
 
end;
86
 
 
87
 
{ rgb565_copy_hline }
88
 
procedure rgb565_copy_hline(this : pixel_formats_ptr; x ,y : int; len : unsigned; c : aggclr_ptr );
89
 
var
90
 
 p : int16u_ptr;
91
 
 v : int16u;
92
 
 
93
 
begin
94
 
 p:=int16u_ptr  (ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) );
95
 
 v:=make_pix_565(c.r ,c.g ,c.b );
96
 
 
97
 
 repeat
98
 
  p^:=v;
99
 
 
100
 
  inc(ptrcomp(p ) ,sizeof(int16u ) );
101
 
  dec(len );
102
 
 
103
 
 until len = 0;
104
 
 
105
 
end;
106
 
 
107
 
{ rgb565_copy_vline }
108
 
procedure rgb565_copy_vline(this : pixel_formats_ptr; x ,y : int; len : unsigned; c : aggclr_ptr );
109
 
var
110
 
 p : int16u_ptr;
111
 
 v : int16u;
112
 
 
113
 
begin
114
 
 p:=int16u_ptr  (ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) );
115
 
 v:=make_pix_565(c.r ,c.g ,c.b );
116
 
 
117
 
 repeat
118
 
  p^:=v;
119
 
  p :=int16u_ptr(this.m_rbuf.next_row(int8u_ptr(p ) ) );
120
 
 
121
 
  dec(len );
122
 
 
123
 
 until len = 0;
124
 
 
125
 
end;
126
 
 
127
 
{ rgb565_blend_hline }
128
 
procedure rgb565_blend_hline(this : pixel_formats_ptr; x ,y : int; len : unsigned; c : aggclr_ptr; cover : int8u );
129
 
var
130
 
 p : int16u_ptr;
131
 
 v : int16u;
132
 
 
133
 
 alpha : unsigned;
134
 
 
135
 
begin
136
 
 if c.a <> 0 then
137
 
  begin
138
 
   p:=int16u_ptr(ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) );
139
 
 
140
 
   alpha:=(c.a * (cover + 1 ) ) shr 8;
141
 
 
142
 
   if alpha = base_mask then
143
 
    begin
144
 
     v:=make_pix_565(c.r ,c.g ,c.b );
145
 
 
146
 
     repeat
147
 
      p^:=v;
148
 
 
149
 
      inc(ptrcomp(p ) ,sizeof(int16u ) );
150
 
      dec(len );
151
 
 
152
 
     until len = 0;
153
 
 
154
 
    end
155
 
   else
156
 
    repeat
157
 
     blend_pix_565(p ,c.r ,c.g ,c.b ,alpha );
158
 
 
159
 
     inc(ptrcomp(p ) ,sizeof(int16u ) );
160
 
     dec(len );
161
 
 
162
 
    until len = 0;
163
 
 
164
 
  end;
165
 
 
166
 
end;
167
 
 
168
 
{ rgb565_blend_vline }
169
 
procedure rgb565_blend_vline(this : pixel_formats_ptr; x ,y : int; len : unsigned; c : aggclr_ptr; cover : int8u );
170
 
var
171
 
 p : int16u_ptr;
172
 
 v : int16u;
173
 
 
174
 
 alpha : unsigned;
175
 
 
176
 
begin
177
 
 if c.a <> 0 then
178
 
  begin
179
 
   p:=int16u_ptr(ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) );
180
 
 
181
 
   alpha:=(c.a * (cover + 1 ) ) shr 8;
182
 
 
183
 
   if alpha = base_mask then
184
 
    begin
185
 
     v:=make_pix_565(c.r ,c.g ,c.b );
186
 
 
187
 
     repeat
188
 
      p^:=v;
189
 
      p :=int16u_ptr(this.m_rbuf.next_row(int8u_ptr(p ) ) );
190
 
 
191
 
      dec(len );
192
 
 
193
 
     until len = 0;
194
 
 
195
 
    end
196
 
   else
197
 
    repeat
198
 
     blend_pix_565(p ,c.r ,c.g ,c.b ,alpha );
199
 
 
200
 
     p:=int16u_ptr(this.m_rbuf.next_row(int8u_ptr(p ) ) );
201
 
 
202
 
     dec(len );
203
 
 
204
 
    until len = 0;
205
 
 
206
 
  end;
207
 
 
208
 
end;
209
 
 
210
 
{ rgb565_blend_solid_hspan }
211
 
procedure rgb565_blend_solid_hspan(this : pixel_formats_ptr; x ,y : int; len : unsigned; c : aggclr_ptr; covers : int8u_ptr );
212
 
var
213
 
 p : int16u_ptr;
214
 
 
215
 
begin
216
 
 p:=int16u_ptr(ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) );
217
 
 
218
 
 repeat
219
 
  copy_or_blend_pix_565(p ,c ,covers^ );
220
 
 
221
 
  inc(ptrcomp(covers ) );
222
 
  inc(ptrcomp(p ) ,sizeof(int16u ) );
223
 
  dec(len );
224
 
 
225
 
 until len = 0;
226
 
 
227
 
end;
228
 
 
229
 
{ rgb565_blend_solid_vspan }
230
 
procedure rgb565_blend_solid_vspan(this : pixel_formats_ptr; x ,y : int; len : unsigned; c : aggclr_ptr; covers : int8u_ptr );
231
 
var
232
 
 p : int16u_ptr;
233
 
 
234
 
begin
235
 
 p:=int16u_ptr(ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) );
236
 
 
237
 
 repeat
238
 
  copy_or_blend_pix_565(p ,c ,covers^ );
239
 
 
240
 
  inc(ptrcomp(covers ) );
241
 
 
242
 
  p:=int16u_ptr(this.m_rbuf.next_row(int8u_ptr(p ) ) );
243
 
 
244
 
  dec(len );
245
 
 
246
 
 until len = 0;
247
 
 
248
 
end;
249
 
 
250
 
{ rgb565_blend_color_hspan }
251
 
procedure rgb565_blend_color_hspan(this : pixel_formats_ptr; x ,y : int; len : unsigned; colors : aggclr_ptr; covers : int8u_ptr; cover : int8u );
252
 
var
253
 
 p : int16u_ptr;
254
 
 
255
 
begin
256
 
 p:=int16u_ptr(ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) );
257
 
 
258
 
 repeat
259
 
  if covers <> NIL then
260
 
   begin
261
 
    copy_or_blend_pix_565(p ,colors ,covers^ );
262
 
 
263
 
    inc(ptrcomp(covers ) ,sizeof(int8u ) );
264
 
 
265
 
   end
266
 
  else
267
 
   copy_or_blend_pix_565(p ,colors ,cover );
268
 
 
269
 
  inc(ptrcomp(p ) ,sizeof(int16u ) );
270
 
  inc(ptrcomp(colors ) ,sizeof(aggclr ) );
271
 
  dec(len );
272
 
 
273
 
 until len = 0;
274
 
 
275
 
end;
276
 
 
277
 
{ rgb565_blend_color_vspan }
278
 
procedure rgb565_blend_color_vspan(this : pixel_formats_ptr; x ,y : int; len : unsigned; colors : aggclr_ptr; covers : int8u_ptr; cover : int8u );
279
 
var
280
 
 p : int16u_ptr;
281
 
 
282
 
begin
283
 
 p:=int16u_ptr(ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) );
284
 
 
285
 
 repeat
286
 
  if covers <> NIL then
287
 
   begin
288
 
    copy_or_blend_pix_565(p ,colors ,covers^ );
289
 
 
290
 
    inc(ptrcomp(covers ) ,sizeof(int8u ) );
291
 
 
292
 
   end
293
 
  else
294
 
   copy_or_blend_pix_565(p ,colors ,cover );
295
 
 
296
 
  p:=int16u_ptr(this.m_rbuf.next_row(int8u_ptr(p ) ) );
297
 
 
298
 
  inc(ptrcomp(colors ) ,sizeof(aggclr ) );
299
 
  dec(len );
300
 
 
301
 
 until len = 0;
302
 
 
303
 
end;
304
 
 
305
 
{ rgb565_copy_from }
306
 
procedure rgb565_copy_from(this : pixel_formats_ptr; from : rendering_buffer_ptr; xdst ,ydst ,xsrc ,ysrc : int; len : unsigned );
307
 
begin
308
 
 move(
309
 
  int16u_ptr(ptrcomp(from.row(ysrc ) ) + xsrc * sizeof(int16u ) )^ ,
310
 
  int16u_ptr(ptrcomp(this.m_rbuf.row(ydst ) ) + xdst * sizeof(int16 ) )^ ,
311
 
  len * sizeof(int16u ) );
312
 
 
313
 
end;
314
 
 
315
 
{ rgb565_blend_from }
316
 
procedure rgb565_blend_from(this : pixel_formats_ptr; from : pixel_formats_ptr; psrc_ : int8u_ptr; xdst ,ydst ,xsrc ,ysrc : int; len : unsigned; cover : int8u );
317
 
var
318
 
 psrc : int8u_ptr;
319
 
 pdst : int16u_ptr;
320
 
 
321
 
 alpha : unsigned;
322
 
 
323
 
begin
324
 
 psrc:=psrc_;
325
 
 pdst:=int16u_ptr(ptrcomp(this.m_rbuf.row(ydst ) ) + xdst * sizeof(int16u ) );
326
 
 
327
 
 repeat
328
 
  alpha:=int8u_ptr(ptrcomp(psrc ) + from.m_order.A )^;
329
 
 
330
 
  if alpha <> 0 then
331
 
   if (alpha = base_mask ) and
332
 
      (cover = 255 ) then
333
 
    pdst^:=make_pix_565(
334
 
     int8u_ptr(ptrcomp(psrc ) + from.m_order.R )^ ,
335
 
     int8u_ptr(ptrcomp(psrc ) + from.m_order.G )^ ,
336
 
     int8u_ptr(ptrcomp(psrc ) + from.m_order.B )^ )
337
 
   else
338
 
    blend_pix_565(
339
 
     pdst ,
340
 
     int8u_ptr(ptrcomp(psrc ) + from.m_order.R )^ ,
341
 
     int8u_ptr(ptrcomp(psrc ) + from.m_order.G )^ ,
342
 
     int8u_ptr(ptrcomp(psrc ) + from.m_order.B )^ ,
343
 
     alpha );
344
 
 
345
 
  inc(ptrcomp(psrc ) ,4 );
346
 
  inc(ptrcomp(pdst ) ,sizeof(int16u ) );
347
 
  dec(len );
348
 
 
349
 
 until len = 0;
350
 
 
351
 
end;
352
 
 
353
 
{ rgb565_copy_color_hspan }
354
 
procedure rgb565_copy_color_hspan(this : pixel_formats_ptr; x ,y : int; len : unsigned; colors : aggclr_ptr );
355
 
var
356
 
 p : int16u_ptr;
357
 
 
358
 
begin
359
 
 p:=int16u_ptr(ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) );
360
 
 
361
 
 repeat
362
 
  p^:=make_pix_565(colors.r ,colors.g ,colors.b );
363
 
 
364
 
  inc(ptrcomp(p ) ,sizeof(int16u ) );
365
 
  inc(ptrcomp(colors ) ,sizeof(aggclr ) );
366
 
  dec(len );
367
 
 
368
 
 until len = 0;
369
 
 
370
 
end;
371
 
 
372
 
{ rgb565_copy_color_vspan }
373
 
procedure rgb565_copy_color_vspan(this : pixel_formats_ptr; x ,y : int; len : unsigned; colors : aggclr_ptr );
374
 
var
375
 
 p : int16u_ptr;
376
 
 
377
 
begin
378
 
 p:=int16u_ptr(ptrcomp(this.m_rbuf.row(y ) ) + x * sizeof(int16u ) );
379
 
 
380
 
 repeat
381
 
  p^:=make_pix_565(colors.r ,colors.g ,colors.b );
382
 
  p :=int16u_ptr(this.m_rbuf.next_row(int8u_ptr(p ) ) );
383
 
 
384
 
  inc(ptrcomp(colors ) ,sizeof(aggclr ) );
385
 
  dec(len );
386
 
 
387
 
 until len = 0;
388
 
 
389
 
end;
390
 
 
391
 
{ rgb565_blend_from_color }
392
 
procedure rgb565_blend_from_color(this : pixel_formats_ptr; from : pixel_formats_ptr; color : aggclr_ptr; xdst ,ydst ,xsrc ,ysrc : int; len : unsigned; cover : int8u );
393
 
var
394
 
 ppsz : unsigned;
395
 
 
396
 
 psrc : int8u_ptr;
397
 
 pdst : int16u_ptr;
398
 
 
399
 
begin
400
 
 ppsz:=from._pix_width;
401
 
 psrc:=from.row_ptr(ysrc );
402
 
 
403
 
 if psrc <> NIL then
404
 
  begin
405
 
   pdst:=int16u_ptr(ptrcomp(this.m_rbuf.row_xy(xdst ,ydst ,len ) ) + xdst * sizeof(int16u ) );
406
 
 
407
 
   repeat
408
 
    blend_pix_565(pdst ,color.r ,color.g ,color.b ,shr_int32(psrc^ * cover + base_mask ,base_shift ) );
409
 
 
410
 
    inc(ptrcomp(psrc ) ,ppsz );
411
 
    inc(ptrcomp(pdst ) ,sizeof(int16u ) );
412
 
    dec(len );
413
 
 
414
 
   until len = 0;
415
 
 
416
 
  end;
417
 
 
418
 
end;
419
 
 
420
 
{ rgb565_blend_from_lut }
421
 
procedure rgb565_blend_from_lut(this : pixel_formats_ptr; from : pixel_formats_ptr; color_lut : aggclr_ptr; xdst ,ydst ,xsrc ,ysrc : int; len : unsigned; cover : int8u );
422
 
var
423
 
 ppsz : unsigned;
424
 
 
425
 
 psrc : int8u_ptr;
426
 
 pdst : int16u_ptr;
427
 
 
428
 
 color : aggclr_ptr;
429
 
 
430
 
begin
431
 
 ppsz:=from._pix_width;
432
 
 psrc:=from.row_ptr(ysrc );
433
 
 
434
 
 if psrc <> NIL then
435
 
  begin
436
 
   pdst:=int16u_ptr(ptrcomp(this.m_rbuf.row_xy(xdst ,ydst ,len ) ) + xdst * sizeof(int16u ) );
437
 
 
438
 
   repeat
439
 
    color:=aggclr_ptr(ptrcomp(color_lut ) + psrc^ * sizeof(aggclr ) );
440
 
 
441
 
    blend_pix_565(pdst ,color.r ,color.g ,color.b ,shr_int32(psrc^ * cover + base_mask ,base_shift ) );
442
 
 
443
 
    inc(ptrcomp(psrc ) ,ppsz );
444
 
    inc(ptrcomp(pdst ) ,sizeof(int16u ) );
445
 
    dec(len );
446
 
 
447
 
   until len = 0;
448
 
 
449
 
  end;
450
 
 
451
 
end;
452