2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
8 #include <graphics/clip.h>
9 #include <aros/libcall.h>
10 #include <aros/asmcall.h>
13 #include <aros/debug.h>
16 AROS_UFP2(BOOL
, _SLCR_CompFunc_Down
,
17 AROS_UFPA(struct ClipRect
*, cr1
, A0
),
18 AROS_UFPA(struct ClipRect
*, cr2
, A1
));
19 AROS_UFP2(BOOL
, _SLCR_CompFunc_Up
,
20 AROS_UFPA(struct ClipRect
*, cr1
, A0
),
21 AROS_UFPA(struct ClipRect
*, cr2
, A1
));
22 AROS_UFP2(BOOL
, _SLCR_CompFunc_Right
,
23 AROS_UFPA(struct ClipRect
*, cr1
, A0
),
24 AROS_UFPA(struct ClipRect
*, cr2
, A1
));
25 AROS_UFP2(BOOL
, _SLCR_CompFunc_Left
,
26 AROS_UFPA(struct ClipRect
*, cr1
, A0
),
27 AROS_UFPA(struct ClipRect
*, cr2
, A1
));
28 AROS_UFP2(BOOL
, _SLCR_CompFunc_RightDown
,
29 AROS_UFPA(struct ClipRect
*, cr1
, A0
),
30 AROS_UFPA(struct ClipRect
*, cr2
, A1
));
31 AROS_UFP2(BOOL
, _SLCR_CompFunc_RightUp
,
32 AROS_UFPA(struct ClipRect
*, cr1
, A0
),
33 AROS_UFPA(struct ClipRect
*, cr2
, A1
));
34 AROS_UFP2(BOOL
, _SLCR_CompFunc_LeftDown
,
35 AROS_UFPA(struct ClipRect
*, cr1
, A0
),
36 AROS_UFPA(struct ClipRect
*, cr2
, A1
));
37 AROS_UFP2(BOOL
, _SLCR_CompFunc_LeftUp
,
38 AROS_UFPA(struct ClipRect
*, cr1
, A0
),
39 AROS_UFPA(struct ClipRect
*, cr2
, A1
));
41 void _SLCR_SortClipRects(struct Layer
*layer
,
42 AROS_UFP2(BOOL
, (*CompFunc
),
43 AROS_UFPA(struct ClipRect
*, cr1
, A0
),
44 AROS_UFPA(struct ClipRect
*, cr2
, A1
))
47 /*****************************************************************************
50 #include <proto/layers.h>
51 #include "layers_intern.h"
53 AROS_LH3(void, SortLayerCR
,
56 AROS_LHA(struct Layer
*, layer
, A0
),
57 AROS_LHA(LONG
, dx
, D0
),
58 AROS_LHA(LONG
, dy
, D1
),
61 struct LayersBase
*, LayersBase
, 35, Layers
)
64 Sorts the list of ClipRects associated with the given layer.
65 The direction of the sort is indicated by dx and dy.
68 layer -- the layer with the ClipRect list to sort
69 dx -- the left/right ordering
70 dy -- the up/down ordering
73 The layer->ClipRect pointer now points to a sorted list of ClipRects.
84 Implemented as an InsertSort on a singly linked list.
87 27-11-96 digulla automatically created from
88 layers_lib.fd and clib/layers_protos.h
90 *****************************************************************************/
94 D(bug("SortLayerCR(layer @ $%lx, dx %ld, dy %ld)\n", layer
, dx
, dy
));
98 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_Down
);
101 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_RightDown
);
104 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_LeftDown
);
109 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_Up
);
112 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_RightUp
);
115 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_LeftUp
);
120 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_Right
);
123 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_Left
);
129 AROS_UFH2(BOOL
, _SLCR_CompFunc_Down
,
130 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
131 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
134 return (BOOL
)(cr1
->bounds
.MinY
<= cr2
->bounds
.MinY
);
138 AROS_UFH2(BOOL
, _SLCR_CompFunc_Up
,
139 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
140 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
143 return (BOOL
)(cr1
->bounds
.MaxY
>= cr2
->bounds
.MaxY
);
147 AROS_UFH2(BOOL
, _SLCR_CompFunc_Right
,
148 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
149 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
152 return (BOOL
)(cr1
->bounds
.MinX
<= cr2
->bounds
.MinX
);
156 AROS_UFH2(BOOL
, _SLCR_CompFunc_Left
,
157 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
158 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
161 return (BOOL
)(cr1
->bounds
.MaxX
>= cr2
->bounds
.MaxX
);
165 AROS_UFH2(BOOL
, _SLCR_CompFunc_RightDown
,
166 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
167 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
170 if(cr1
->bounds
.MinY
> cr2
->bounds
.MaxY
) return 0;
171 return (BOOL
)(cr1
->bounds
.MinX
<= cr2
->bounds
.MaxX
);
175 AROS_UFH2(BOOL
, _SLCR_CompFunc_RightUp
,
176 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
177 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
180 if(cr1
->bounds
.MaxY
< cr2
->bounds
.MinY
) return 0;
181 return (BOOL
)(cr1
->bounds
.MinX
<= cr2
->bounds
.MaxX
);
185 AROS_UFH2(BOOL
, _SLCR_CompFunc_LeftDown
,
186 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
187 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
190 if(cr1
->bounds
.MinY
> cr2
->bounds
.MaxY
) return 0;
191 return (BOOL
)(cr1
->bounds
.MaxX
>= cr2
->bounds
.MinX
);
195 AROS_UFH2(BOOL
, _SLCR_CompFunc_LeftUp
,
196 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
197 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
200 if(cr1
->bounds
.MaxY
< cr2
->bounds
.MinY
) return 0;
201 return (BOOL
)(cr1
->bounds
.MaxX
>= cr2
->bounds
.MinX
);
205 void _SLCR_SortClipRects(struct Layer
*layer
,
206 AROS_UFP2(BOOL
, (*CompFunc
),
207 AROS_UFPA(struct ClipRect
*, cr1
, A0
),
208 AROS_UFPA(struct ClipRect
*, cr2
, A1
))
212 struct ClipRect
*CurCR
;
213 struct ClipRect
*NextCR
;
214 struct ClipRect
**CRptr
;
215 struct ClipRect
*FirstCR
;
222 for(CurCR
= layer
->ClipRect
, CRptr
= &FirstCR
; ; )
224 NextCR
= CurCR
->Next
;
225 CurCR
->Next
= *CRptr
;
231 for(CurCR
= NextCR
, CRptr
= &FirstCR
; ; )
233 if(!(NextCR
= *CRptr
))
236 if(AROS_UFC2(BOOL
, (*CompFunc
),
237 AROS_UFCA(struct ClipRect
*, CurCR
, A0
),
238 AROS_UFCA(struct ClipRect
*, NextCR
, A1
)))
242 CRptr
= &NextCR
->Next
;
246 layer
->ClipRect
= FirstCR
;