gcc-4.6.2: Update with patch for gengtype.c
[AROS.git] / rom / hyperlayers / scalelayer.c
blobd43aef41e53e997fe99a0807a6d27ae76ec9d01e
1 /*
2 Copyright © 1995-2008, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <aros/asmcall.h>
9 #include <aros/debug.h>
10 #include <proto/exec.h>
11 #include <proto/utility.h>
12 #include <exec/types.h>
13 #include <exec/memory.h>
14 #include <aros/libcall.h>
15 #include <proto/graphics.h>
16 #include <graphics/scale.h>
18 #include "layers_intern.h"
19 #include "basicfuncs.h"
22 struct ScaleLayerParam
24 struct TagItem * taglist;
25 struct LayersBase * LayersBase;
28 AROS_UFP3(struct Region *, ScaleLayerCallback,
29 AROS_UFPA(struct Hook *, hook , A0),
30 AROS_UFPA(struct Layer *, l , A2),
31 AROS_UFPA(struct ChangeLayerShapeMsg *, clsm , A1));
33 /*****************************************************************************
35 NAME */
36 #include <proto/layers.h>
37 AROS_LH2(ULONG, ScaleLayer,
39 /* SYNOPSIS */
40 AROS_LHA(struct Layer *, l , A0),
41 AROS_LHA(struct TagItem *, taglist , A1),
43 /* LOCATION */
44 struct LayersBase *, LayersBase, 38, Layers)
46 /* FUNCTION
47 Scale the given layer. This function will use the
48 current shape of the layer and resize it according to
49 the given newwidth/newheight.
51 INPUTS
52 L - pointer to layer
53 newwidth - new width of the layer
54 newheight - new height of the layer
56 RESULT
57 TRUE if everything went alright, FALSE otherwise
59 NOTES
61 EXAMPLE
63 BUGS
65 SEE ALSO
67 INTERNALS
69 *****************************************************************************/
71 AROS_LIBFUNC_INIT
73 struct ScaleLayerParam parm = {taglist, LayersBase};
74 struct Region * oldshape;
75 struct Hook hook;
77 hook.h_Entry = (HOOKFUNC)ScaleLayerCallback;
78 hook.h_Data = (APTR)&parm;
80 oldshape = ChangeLayerShape(l, 0, &hook);
83 * I must not free oldshape here since it is also the new shape!
85 if (oldshape == NULL) {
86 /* TODO: Can this happen? */
89 return FALSE;
90 AROS_LIBFUNC_EXIT
91 } /* ScaleLayer */
96 * The ScaleLayer callback is doing the actual work of
97 * scaling the layer.
99 AROS_UFH3(struct Region *, ScaleLayerCallback,
100 AROS_UFHA(struct Hook *, hook , A0),
101 AROS_UFHA(struct Layer *, l , A2),
102 AROS_UFHA(struct ChangeLayerShapeMsg *, clsm , A1))
104 AROS_USERFUNC_INIT
106 struct BitScaleArgs bsa;
107 struct BitMap * bm = NULL;
108 struct ScaleLayerParam * slp = (struct ScaleLayerParam *)hook->h_Data;
109 struct LayersBase * LayersBase = slp->LayersBase;
111 struct TagItem * taglist = slp->taglist;
113 if (l->ClipRect->Next)
115 kprintf("%s: Only expecting one ClipRect - leaving!\n",__FUNCTION__);
116 return NULL;
119 bm = AllocBitMap(GetTagData(LA_DESTWIDTH , l->Width , taglist),
120 GetTagData(LA_DESTHEIGHT, l->Height, taglist),
121 l->ClipRect->BitMap->Depth,
123 l->rp->BitMap);
125 bsa.bsa_SrcX = GetTagData(LA_SRCX, 0, taglist);
126 bsa.bsa_SrcY = GetTagData(LA_SRCY, 0, taglist);
127 bsa.bsa_SrcWidth = GetTagData(LA_SRCWIDTH , l->Width , taglist);
128 bsa.bsa_SrcHeight = GetTagData(LA_SRCHEIGHT, l->Height, taglist);
129 bsa.bsa_XSrcFactor = bsa.bsa_SrcWidth;
130 bsa.bsa_YSrcFactor = bsa.bsa_SrcHeight;
131 bsa.bsa_DestX = GetTagData(LA_DESTX, 0, taglist);
132 bsa.bsa_DestY = GetTagData(LA_DESTY, 0, taglist);
134 bsa.bsa_DestWidth = GetTagData(LA_DESTWIDTH , l->Width , taglist);
135 bsa.bsa_DestHeight = GetTagData(LA_DESTHEIGHT, l->Height, taglist);
137 bsa.bsa_XDestFactor = GetTagData(LA_DESTWIDTH , l->Width , taglist);
138 bsa.bsa_YDestFactor = GetTagData(LA_DESTHEIGHT, l->Height, taglist);
139 bsa.bsa_SrcBitMap = l->ClipRect->BitMap;
140 bsa.bsa_DestBitMap = bm;
141 bsa.bsa_Flags = 0;
142 #if 0
143 bsa.bsa_XDDA;
144 bsa.bsa_YDDA;
145 bsa.bsa_Reserved1;
146 bsa.bsa_Reserved2;
147 #endif
149 //kprintf("Scaling bitmap!\n");
150 BitMapScale(&bsa);
152 FreeBitMap(l->ClipRect->BitMap);
153 l->ClipRect->BitMap = bm;
154 //kprintf("Leaving %s!\n",__FUNCTION__);
156 kprintf("shaperegion: %p\n",l->shaperegion);
158 return l->shaperegion;
160 AROS_USERFUNC_EXIT