fall back to a repository that does provide the version of acpica we use. (NicJA)
[AROS.git] / rom / intuition / obtaingirport.c
blobde761f70b5be61a1270d6ae0bcbc59f3af5ca3ae
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <proto/graphics.h>
8 #include <proto/layers.h>
9 #include <proto/exec.h>
10 #include <graphics/rpattr.h>
12 #include "intuition_intern.h"
14 /*****************************************************************************
16 NAME */
17 #include <graphics/rastport.h>
18 #include <intuition/cghooks.h>
19 #include <proto/intuition.h>
21 AROS_LH1(struct RastPort *, ObtainGIRPort,
23 /* SYNOPSIS */
24 AROS_LHA(struct GadgetInfo *, gInfo, A0),
26 /* LOCATION */
27 struct IntuitionBase *, IntuitionBase, 93, Intuition)
29 /* FUNCTION
30 This function sets up a RastPort for exclusive use by custom
31 gadget hook routines. Call this function each time a hook
32 routine needs to render into the gadget and ReleaseGIRPort()
33 immediately afterwards.
35 INPUTS
36 gInfo - Pointer to GadgetInfo structure, as passed to each
37 custom gadget hook function.
39 RESULT
40 Pointer to a RastPort you can render to. NULL if you aren't
41 allowed to render into this gadget.
43 NOTES
44 If a routine passes a RastPort, eg. GM_RENDER, ObtainGIRPort()
45 needn't be called.
47 EXAMPLE
49 BUGS
51 SEE ALSO
52 ReleaseGIRPort()
54 INTERNALS
56 *****************************************************************************/
58 AROS_LIBFUNC_INIT
60 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
61 struct LayersBase *LayersBase = GetPrivIBase(IntuitionBase)->LayersBase;
62 struct RastPort *rp;
64 DEBUG_OBTAINGIRPORT(dprintf("ObtainGIRPort: GInfo 0x%lx Task 0x%lx <%s>\n",
65 gInfo, FindTask(NULL),
66 FindTask(NULL)->tc_Node.ln_Name ? FindTask(NULL)->tc_Node.ln_Name : "NULL"));
68 if (gInfo && gInfo->gi_RastPort)
70 rp = CloneRastPort (gInfo->gi_RastPort);
71 if (rp)
74 LOCKGADGET(IntuitionBase)
75 /*bug("+++++++++++++ OBTAIN rp=%p lay=%p font=%p origfont=%p\n",rp,rp->Layer,rp->Font,gInfo->gi_RastPort->Font);*/
77 if (rp->Layer)
79 LockLayer(0,rp->Layer);
81 if (((GetPrivIBase(IntuitionBase)->BackupLayerContext.nestcount)++) == 0)
83 GetPrivIBase(IntuitionBase)->BackupLayerContext.scroll_x = rp->Layer->Scroll_X;
84 GetPrivIBase(IntuitionBase)->BackupLayerContext.scroll_y = rp->Layer->Scroll_Y;
86 rp->Layer->Scroll_X = 0;
87 rp->Layer->Scroll_Y = 0;
89 GetPrivIBase(IntuitionBase)->BackupLayerContext.clipregion = InstallClipRegion(rp->Layer, NULL);
92 SetWriteMask(rp, 0xFF);
93 SetRPAttrs(rp,RPTAG_DrMd,JAM1,RPTAG_PenMode,TRUE,TAG_DONE);
97 DEBUG_OBTAINGIRPORT(dprintf("ObtainGIRPort: RPort 0x%lx\n", rp));
98 return rp;
100 else
102 return NULL;
105 AROS_LIBFUNC_EXIT
106 } /* ObtainGIRPort */