2 Copyright © 1995-2001, 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 *****************************************************************************/
93 AROS_LIBBASE_EXT_DECL(struct LayersBase
*,LayersBase
)
95 D(bug("SortLayerCR(layer @ $%lx, dx %ld, dy %ld)\n", layer
, dx
, dy
));
99 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_Down
);
102 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_RightDown
);
105 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_LeftDown
);
110 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_Up
);
113 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_RightUp
);
116 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_LeftUp
);
121 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_Right
);
124 _SLCR_SortClipRects(layer
, _SLCR_CompFunc_Left
);
130 AROS_UFH2(BOOL
, _SLCR_CompFunc_Down
,
131 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
132 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
135 return (BOOL
)(cr1
->bounds
.MinY
<= cr2
->bounds
.MinY
);
139 AROS_UFH2(BOOL
, _SLCR_CompFunc_Up
,
140 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
141 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
144 return (BOOL
)(cr1
->bounds
.MaxY
>= cr2
->bounds
.MaxY
);
148 AROS_UFH2(BOOL
, _SLCR_CompFunc_Right
,
149 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
150 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
153 return (BOOL
)(cr1
->bounds
.MinX
<= cr2
->bounds
.MinX
);
157 AROS_UFH2(BOOL
, _SLCR_CompFunc_Left
,
158 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
159 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
162 return (BOOL
)(cr1
->bounds
.MaxX
>= cr2
->bounds
.MaxX
);
166 AROS_UFH2(BOOL
, _SLCR_CompFunc_RightDown
,
167 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
168 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
171 if(cr1
->bounds
.MinY
> cr2
->bounds
.MaxY
) return 0;
172 return (BOOL
)(cr1
->bounds
.MinX
<= cr2
->bounds
.MaxX
);
176 AROS_UFH2(BOOL
, _SLCR_CompFunc_RightUp
,
177 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
178 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
181 if(cr1
->bounds
.MaxY
< cr2
->bounds
.MinY
) return 0;
182 return (BOOL
)(cr1
->bounds
.MinX
<= cr2
->bounds
.MaxX
);
186 AROS_UFH2(BOOL
, _SLCR_CompFunc_LeftDown
,
187 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
188 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
191 if(cr1
->bounds
.MinY
> cr2
->bounds
.MaxY
) return 0;
192 return (BOOL
)(cr1
->bounds
.MaxX
>= cr2
->bounds
.MinX
);
196 AROS_UFH2(BOOL
, _SLCR_CompFunc_LeftUp
,
197 AROS_UFHA(struct ClipRect
*, cr1
, A0
),
198 AROS_UFHA(struct ClipRect
*, cr2
, A1
))
201 if(cr1
->bounds
.MaxY
< cr2
->bounds
.MinY
) return 0;
202 return (BOOL
)(cr1
->bounds
.MaxX
>= cr2
->bounds
.MinX
);
206 void _SLCR_SortClipRects(struct Layer
*layer
,
207 AROS_UFP2(BOOL
, (*CompFunc
),
208 AROS_UFPA(struct ClipRect
*, cr1
, A0
),
209 AROS_UFPA(struct ClipRect
*, cr2
, A1
))
213 struct ClipRect
*CurCR
;
214 struct ClipRect
*NextCR
;
215 struct ClipRect
**CRptr
;
216 struct ClipRect
*FirstCR
;
223 for(CurCR
= layer
->ClipRect
, CRptr
= &FirstCR
; ; )
225 NextCR
= CurCR
->Next
;
226 CurCR
->Next
= *CRptr
;
232 for(CurCR
= NextCR
, CRptr
= &FirstCR
; ; )
234 if(!(NextCR
= *CRptr
))
237 if(AROS_UFC2(BOOL
, (*CompFunc
),
238 AROS_UFCA(struct ClipRect
*, CurCR
, A0
),
239 AROS_UFCA(struct ClipRect
*, NextCR
, A1
)))
243 CRptr
= &NextCR
->Next
;
247 layer
->ClipRect
= FirstCR
;