Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / muimaster / mui_addclipregion.c
blobcf7d70ac032ca706d1942e925a43bdb0fd68b865
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/intuition.h>
9 #include <proto/muimaster.h>
11 #include "mui.h"
12 #include "muimaster_intern.h"
14 #include "debug.h"
16 /*****************************************************************************
18 NAME */
19 AROS_LH2(APTR, MUI_AddClipRegion,
21 /* SYNOPSIS */
22 AROS_LHA(struct MUI_RenderInfo *, mri, A0),
23 AROS_LHA(struct Region *, r, A1),
25 /* LOCATION */
26 struct Library *, MUIMasterBase, 26, MUIMaster)
28 /* FUNCTION
30 INPUTS
32 RESULT
34 NOTES
36 EXAMPLE
38 BUGS
40 SEE ALSO
42 INTERNALS
44 HISTORY
46 *****************************************************************************/
48 AROS_LIBFUNC_INIT
50 struct Window *w = mri->mri_Window;
51 struct Layer *l;
52 APTR result;
54 if (w != NULL)
55 l = w->WLayer;
56 else
57 l = mri->mri_RastPort->Layer;
59 // if (mri->mri_rCount == MRI_RARRAY_SIZE) kprintf(" --------- mui_addclipregion clip overflow ---------------------\n");
61 if ((l == NULL) || (r == NULL) || (mri->mri_rCount == MRI_RARRAY_SIZE))
63 if (r) DisposeRegion(r);
64 return (APTR)-1;
67 if (mri->mri_rCount != 0)
68 /* NOTE: ignoring the result here... */
69 AndRegionRegion(mri->mri_rArray[mri->mri_rCount-1], r);
71 if ((w != NULL) && (mri->mri_Flags & MUIMRI_REFRESHMODE))
73 LockLayerInfo(&w->WScreen->LayerInfo);
74 EndRefresh(w, FALSE);
77 #if 1 /* stegerg: what's this good for? */
78 if ((w != NULL) && !(w->Flags & WFLG_SIMPLE_REFRESH))
79 LockLayerInfo(&w->WScreen->LayerInfo);
80 #endif
82 result = InstallClipRegion(l, r);
84 #if 1 /* stegerg: what's this good for? */
85 if ((w != NULL) && !(w->Flags & WFLG_SIMPLE_REFRESH))
86 UnlockLayerInfo(&w->WScreen->LayerInfo);
87 #endif
89 if ((w != NULL) && (mri->mri_Flags & MUIMRI_REFRESHMODE))
91 BeginRefresh(w);
92 UnlockLayerInfo(&w->WScreen->LayerInfo);
95 mri->mri_rArray[mri->mri_rCount++] = r;
97 return result;
99 AROS_LIBFUNC_EXIT
101 } /* MUIA_AddClipRegion */