1 {
2 This file is part of the Free Pascal run time library.
3 Copyright (c) 2004 Karoly Balogh for Genesi S.a.r.l. <www.genesi.lu>
4
5 layers.library interface unit for MorphOS/PowerPC
6
7 Based on work of Nils Sjoholm member of the Amiga RTL
8 development team.
9
10 MorphOS port was done on a free Pegasos II/G4 machine
11 provided by Genesi S.a.r.l. <www.genesi.lu>
12
13 See the file COPYING.FPC, included in this distribution,
14 for details about the copyright.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20 **********************************************************************}
21
22 {$PACKRECORDS 2}
23 unit layers;
24
25 interface
26
27 uses exec, agraphics, utility;
28
29 const
30 LAYERSIMPLE = 1;
31 LAYERSMART = 2;
32 LAYERSUPER = 4;
33 LAYERUPDATING = $10;
34 LAYERBACKDROP = $40;
35 LAYERREFRESH = $80;
36 LAYER_CLIPRECTS_LOST = $100; // during BeginUpdate or during layerop this happens if out of memory
37 LAYERIREFRESH = $200;
38 LAYERIREFRESH2 = $400;
39
40 type
41 PLayer_Info = ^TLayer_Info;
42 TLayer_Info = packed record
43 top_layer : PLayer;
44 check_lp : PLayer; // Private
45 obs : PClipRect;
46 FreeClipRects : PClipRect; // Private
47 PrivateReserve1, // Private
48 PrivateReserve2 : LongInt; // Private
49 Lock : TSignalSemaphore; // Private
50 gs_Head : TMinList; // Private
51 PrivateReserve3 : SmallInt; // Private
52 PrivateReserve4 : APTR; // Private
53 Flags : Word;
54 fatten_count : ShortInt; // Private
55 LockLayersCount : ShortInt; // Private
56 PrivateReserve5 : SmallInt; // Private
57 BlankHook, // Private
58 LayerInfo_extra : APTR; // Private
59 end;
60
61 const
62 NEWLAYERINFO_CALLED = 1;
63
64 // LAYERS_NEVERBACKFILL, available since v52.22
65 // unlike with NOBACKFILL, the new layer will not be filled with contents
66 // of layers underneath it, contents is lost after resize
67 LAYERS_NEVERBACKFILL = 2;
68 LAYERS_NOBACKFILL = 1;
69 LAYERS_BACKFILL = 0;
70
71 // Tags for Create#?LayerTagList
72 LA_Dummy = TAG_USER + 1024;
73 LA_BackfillHook = LA_Dummy + $0001;
74 LA_TransRegion = LA_Dummy + $0002;
75 LA_TransHook = LA_Dummy + $0003;
76 LA_WindowPtr = LA_Dummy + $0004;
callnull77 LA_SuperBitMap = LA_Dummy + $0005; // replaces bm2 in function call
78
79 LR_Dummy = TAG_USER + 1150;
80 LR_Destination_RastPort = LR_Dummy + 1; // PRastPort to render in
81 LR_Destination_BitMap = LR_Dummy + 2; // PBitMap to render in. mutually exclusive with LR_Destination_RastPort. Do note that the destination
82 // bitmap (or the rastport's bitmap) MUST be in the same format as the source you want to render from!
83 LR_Destination_Bounds = LR_Dummy + 3; // PRectangle. the graphics will be rendered inside of the given boundaries. if not passed, the call assumes the buffer has at least the same size as LayerInfo
84 LR_LayerInfo_Bounds = LR_Dummy + 4; // PRectangle. limits the portion of a LayerInfo to draw
85 LR_Erase = LR_Dummy + 5; // LongBool. setting to FALSE will make the layers be drawn without the background being cleared with the screen's backfill hook TRUE by default
86 LR_RenderList = LR_Dummy + 6; // PPLayer. a nil terminated list of PLayer pointers to render if they are within given bounds
87 LR_IgnoreList = LR_Dummy + 7; // PPLayer. a nil terminated list of PLayer pointers to ommit when rendering the layerinfo. mutually exclusive with LR_RenderList!
88
89 LAYERSNAME: PChar = 'layers.library';
90
91 var
92 LayersBase: PLibrary = nil;
93
94 procedure InitLayers(Li: PLayer_Info location 'a0'); SysCall LayersBase 030;
CreateUpfrontLayernull95 function CreateUpfrontLayer(Li: PLayer_Info location 'a0'; Bm: PBitmap location 'a1'; X0: LongInt location 'd0'; Y0: LongInt location 'd1'; X1: LongInt location 'd2'; Y1: LongInt location 'd3'; Flags: LongInt location 'd4'; Bm2: PBitmap location 'a2'): PLayer; SysCall LayersBase 036;
CreateBehindLayernull96 function CreateBehindLayer(Li: PLayer_Info location 'a0'; Bm: PBitmap location 'a1'; X0: LongInt location 'd0'; Y0: LongInt location 'd1'; X1: LongInt location 'd2'; Y1: LongInt location 'd3'; Flags: LongInt location 'd4'; Bm2: PBitmap location 'a2'): PLayer; SysCall LayersBase 042;
UpfrontLayernull97 function UpfrontLayer(Dummy: LongInt location 'a0'; Layer: PLayer location 'a1'): LongInt; SysCall LayersBase 048;
BehindLayernull98 function BehindLayer(Dummy: LongInt location 'a0'; Layer: PLayer location 'a1'): LongInt; SysCall LayersBase 054;
MoveLayernull99 function MoveLayer(Dummy: LongInt location 'a0'; Layer: PLayer location 'a1'; Dx: LongInt location 'd0'; Dy: LongInt location 'd1'): LongInt; SysCall LayersBase 060;
SizeLayernull100 function SizeLayer(Dummy: LongInt location 'a0'; Layer: PLayer location 'a1'; Dx: LongInt location 'd0'; Dy: LongInt location 'd1'): LongInt; SysCall LayersBase 066;
101 procedure ScrollLayer(Dummy: LongInt location 'a0'; Layer: PLayer location 'a1'; Dx: LongInt location 'd0'; Dy: LongInt location 'd1'); SysCall LayersBase 072;
BeginUpdatenull102 function BeginUpdate(L: PLayer location 'a0'): LongInt; SysCall LayersBase 078;
103 procedure EndUpdate(Layer: PLayer location 'a0'; Flag: LongWord location 'd0'); SysCall LayersBase 084;
DeleteLayernull104 function DeleteLayer(Dummy: LongInt location 'a0'; Layer: PLayer location 'a1'): LongInt; SysCall LayersBase 090;
105 procedure LockLayer(Dummy: LongInt location 'a0'; Layer: PLayer location 'a1'); SysCall LayersBase 096;
106 procedure UnlockLayer(Layer: PLayer location 'a0'); SysCall LayersBase 102;
107 procedure LockLayers(Li: PLayer_Info location 'a0'); SysCall LayersBase 108;
108 procedure UnlockLayers(Li: PLayer_Info location 'a0'); SysCall LayersBase 114;
109 procedure LockLayerInfo(Li: PLayer_Info location 'a0'); SysCall LayersBase 120;
110 procedure SwapBitsRastPortClipRect(Rp: PRastPort location 'a0'; Cr: PClipRect location 'a1'); SysCall LayersBase 126;
WhichLayernull111 function WhichLayer(Li: PLayer_Info location 'a0'; X: LongInt location 'd0'; Y: LongInt location 'd1'): PLayer; SysCall LayersBase 132;
112 procedure UnlockLayerInfo(Li: PLayer_Info location 'a0'); SysCall LayersBase 138;
NewLayerInfonull113 function NewLayerInfo: PLayer_Info; SysCall LayersBase 144;
114 procedure DisposeLayerInfo(Li: PLayer_Info location 'a0'); SysCall LayersBase 150;
FattenLayerInfonull115 function FattenLayerInfo(Li: PLayer_Info location 'a0'): LongInt; SysCall LayersBase 156;
116 procedure ThinLayerInfo(Li: PLayer_Info location 'a0'); SysCall LayersBase 162;
MoveLayerInFrontOfnull117 function MoveLayerInFrontOf(Layer_To_Move: PLayer location 'a0'; Other_Layer: PLayer location 'a1'): LongInt; SysCall LayersBase 168;
InstallClipRegionnull118 function InstallClipRegion(Layer: PLayer location 'a0'; const Region: PRegion location 'a1'): PRegion; SysCall LayersBase 174;
MoveSizeLayernull119 function MoveSizeLayer(Layer: PLayer location 'a0'; Dx: LongInt location 'd0'; Dy: LongInt location 'd1'; Dw: LongInt location 'd2'; Dh: LongInt location 'd3'): LongInt; SysCall LayersBase 180;
CreateUpfrontHookLayernull120 function CreateUpfrontHookLayer(Li: PLayer_Info location 'a0'; Bm: PBitmap location 'a1'; X0: LongInt location 'd0'; Y0: LongInt location 'd1'; X1: LongInt location 'd2'; Y1: LongInt location 'd3'; Flags: LongInt location 'd4'; Hook: PHook location 'a3'; Bm2: PBitmap location 'a2'): PLayer; SysCall LayersBase 186;
CreateBehindHookLayernull121 function CreateBehindHookLayer(Li: PLayer_Info location 'a0'; Bm: PBitmap location 'a1'; X0: LongInt location 'd0'; Y0: LongInt location 'd1'; X1: LongInt location 'd2'; Y1: LongInt location 'd3'; Flags: LongInt location 'd4'; Hook: PHook location 'a3'; Bm2: PBitmap location 'a2'): PLayer; SysCall LayersBase 192;
InstallLayerHooknull122 function InstallLayerHook(Layer: PLayer location 'a0'; Hook: PHook location 'a1'): PHook; SysCall LayersBase 198;
InstallLayerInfoHooknull123 function InstallLayerInfoHook(Li: PLayer_Info location 'a0'; const Hook: PHook location 'a1'): PHook; SysCall LayersBase 204;
124 procedure SortLayerCR(Layer: PLayer location 'a0'; Dx: LongInt location 'd0'; Dy: LongInt location 'd1'); SysCall LayersBase 210;
125 procedure DoHookClipRects(Hook: PHook location 'a0'; RPort: PRastPort location 'a1'; const Rect: PRectangle location 'a2'); SysCall LayersBase 216;
126
127 // V50 (MorphOS)
CreateUpfrontLayerTagListnull128 function CreateUpfrontLayerTagList(Li: PLayer_Info location 'a0'; Bm: PBitmap location 'a1'; X0: LongInt location 'd0'; Y0: LongInt location 'd1'; X1: LongInt location 'd2'; Y1: LongInt location 'd3'; Flags: LongInt location 'd4'; Taglist: PTagItem location 'a2'): PLayer; SysCall LayersBase 234;
CreateBehindLayerTagListnull129 function CreateBehindLayerTagList(Li: PLayer_Info location 'a0'; Bm: PBitmap location 'a1'; X0: LongInt location 'd0'; Y0: LongInt location 'd1'; X1: LongInt location 'd2'; Y1: LongInt location 'd3'; Flags: LongInt location 'd4'; Taglist: PTagItem location 'a2'): PLayer; SysCall LayersBase 240;
130
131 // V52 (MorphOS)
WhichLayerBehindLayernull132 function WhichLayerBehindLayer(L: PLayer location 'a0'; X: LongInt location 'd0'; Y: LongInt location 'd1'): PLayer; SysCall LayersBase 252;
IsLayerVisiblenull133 function IsLayerVisible(L: PLayer location 'a0'): LongBool; SysCall LayersBase 258;
RenderLayerInfoTagListnull134 function RenderLayerInfoTagList(Li: PLayer_Info location 'a0'; Tags: PTagItem location 'a1'): LongBool; SysCall LayersBase 282;
135
136 procedure LockLayerUpdates(L: PLayer location 'a0'); SysCall LayersBase 288;
137 procedure UnlockLayerUpdates(L: PLayer location 'a0'); SysCall LayersBase 294;
138
IsVisibleInLayernull139 function IsVisibleInLayer(L: PLayer location 'a0'; X0: LongInt location 'd0'; Y0: LongInt location 'd1'; X1: LongInt location 'd2'; Y1: LongInt location 'd3'): LongBool; SysCall LayersBase 300;
IsLayerHitablenull140 function IsLayerHitable(L: PLayer location 'a0'): LongBool; SysCall LayersBase 306;
141
142 // Var args Version
RenderLayerInfoTagsnull143 function RenderLayerInfoTags(Li: PLayer_Info; const Tags: array of PtrUInt): LongBool; inline;
144
145 { Helper func }
InitLayersLibrarynull146 function InitLayersLibrary : boolean;
147
148 implementation
149
RenderLayerInfoTagsnull150 function RenderLayerInfoTags(Li: PLayer_Info; const Tags: array of PtrUInt): LongBool; inline;
151 begin
152 RenderLayerInfoTags := RenderLayerInfoTagList(Li, @Tags);
153 end;
154
155 const
156 { Change VERSION and LIBVERSION to proper values }
157 VERSION : string[2] = '50';
158 LIBVERSION : longword = 50;
159
InitLayersLibrarynull160 function InitLayersLibrary : boolean;
161 begin
162 InitLayersLibrary := Assigned(LayersBase);
163 end;
164
165 initialization
166 LayersBase := OpenLibrary(LAYERSNAME,LIBVERSION);
167 finalization
168 if Assigned(LayersBase) then
169 CloseLibrary(LayersBase);
170 end.
171