Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / muimaster / mui_addclipping.c
blob3e99724430fd9e29f14ff1db06d680a975d43521
1 /*
2 Copyright © 2002-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/graphics.h>
7 #include <proto/layers.h>
8 #include <proto/muimaster.h>
10 #include "support.h"
12 #include "mui.h"
13 #include "muimaster_intern.h"
15 /*****************************************************************************
17 NAME */
18 AROS_LH5(APTR, MUI_AddClipping,
20 /* SYNOPSIS */
21 AROS_LHA(struct MUI_RenderInfo *, mri, A0),
22 AROS_LHA(WORD, left, D0),
23 AROS_LHA(WORD, top, D1),
24 AROS_LHA(WORD, width, D2),
25 AROS_LHA(WORD, height, D3),
27 /* LOCATION */
28 struct Library *, MUIMasterBase, 24, MUIMaster)
30 /* FUNCTION
32 INPUTS
34 RESULT
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 HISTORY
48 *****************************************************************************/
50 AROS_LIBFUNC_INIT
52 struct Region *r;
53 struct Rectangle rect;
54 APTR handle;
56 if ((width >= MUI_MAXMAX) || (height >= MUI_MAXMAX))
57 return (APTR)-1;
59 if (mri->mri_rCount > 0)
61 if (isRegionWithinBounds(mri->mri_rArray[mri->mri_rCount-1], left, top, width, height))
62 return (APTR)-1;
65 if ((r = NewRegion()) == NULL)
66 return (APTR)-1;
68 rect.MinX = left;
69 rect.MinY = top;
70 rect.MaxX = left + width - 1;
71 rect.MaxY = top + height - 1;
72 OrRectRegion(r, &rect);
74 handle = MUI_AddClipRegion(mri, r);
76 #if 0 /* MUI_AddClipRegion frees region itself upon failure */
77 if (handle == (APTR)-1)
79 DisposeRegion(r);
81 #endif
82 return handle;
84 AROS_LIBFUNC_EXIT
86 } /* MUIA_AddClipping */