New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / hyperlayers / scalelayer.c
blob550c19046594978d075c1bdfd8574205e7c285d1
1 /*
2 Copyright © 1995-2001, 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 <layers_intern.h>
15 #include <aros/libcall.h>
16 #include <proto/graphics.h>
17 #include <graphics/scale.h>
18 #include "basicfuncs.h"
21 struct ScaleLayerParam
23 struct TagItem * taglist;
24 struct LayersBase * LayersBase;
27 AROS_UFP3(struct Region *, ScaleLayerCallback,
28 AROS_UFPA(struct Hook *, hook , A0),
29 AROS_UFPA(struct Layer *, l , A2),
30 AROS_UFPA(struct ChangeLayerShapeMsg *, clsm , A1));
32 /*****************************************************************************
34 NAME */
35 #include <proto/layers.h>
36 AROS_LH2(ULONG, ScaleLayer,
38 /* SYNOPSIS */
39 AROS_LHA(struct Layer *, l , A0),
40 AROS_LHA(struct TagItem *, taglist , A1),
42 /* LOCATION */
43 struct LayersBase *, LayersBase, 42, Layers)
45 /* FUNCTION
46 Scale the given layer. This function will use the
47 current shape of the layer and resize it according to
48 the given newwidth/newheight.
50 INPUTS
51 L - pointer to layer
52 newwidth - new width of the layer
53 newheight - new height of the layer
55 RESULT
56 TRUE if everything went alright, FALSE otherwise
58 NOTES
60 EXAMPLE
62 BUGS
64 SEE ALSO
66 INTERNALS
68 HISTORY
70 *****************************************************************************/
72 AROS_LIBFUNC_INIT
73 AROS_LIBBASE_EXT_DECL(struct LayersBase *,LayersBase)
75 struct ScaleLayerParam parm = {taglist, LayersBase};
76 struct Region * oldshape;
77 struct Hook hook;
79 hook.h_Entry = (IPTR *)ScaleLayerCallback;
80 hook.h_Data = (APTR)&parm;
82 oldshape = ChangeLayerShape(l, 0, &hook);
85 * I must not free oldshape here since it is also the new shape!
88 return FALSE;
89 AROS_LIBFUNC_EXIT
90 } /* ScaleLayer */
99 * The ScaleLayer callback is doing the actul work of
100 * scaling the layer.
102 AROS_UFH3(struct Region *, ScaleLayerCallback,
103 AROS_UFHA(struct Hook *, hook , A0),
104 AROS_UFHA(struct Layer *, l , A2),
105 AROS_UFHA(struct ChangeLayerShapeMsg *, clsm , A1))
107 AROS_USERFUNC_INIT
109 struct BitScaleArgs bsa;
110 struct BitMap * bm = NULL;
111 struct ScaleLayerParam * slp = (struct ScaleLayerParam *)hook->h_Data;
112 struct LayersBase * LayersBase = slp->LayersBase;
114 struct TagItem * taglist = slp->taglist;
116 if (l->ClipRect->Next)
118 kprintf("%s: Only expecting one ClipRect - leaving!\n",__FUNCTION__);
119 return NULL;
122 bm = AllocBitMap(GetTagData(LA_DESTWIDTH , l->Width , taglist),
123 GetTagData(LA_DESTHEIGHT, l->Height, taglist),
124 l->ClipRect->BitMap->Depth,
126 l->rp->BitMap);
128 bsa.bsa_SrcX = GetTagData(LA_SRCX, 0, taglist);
129 bsa.bsa_SrcY = GetTagData(LA_SRCY, 0, taglist);
130 bsa.bsa_SrcWidth = GetTagData(LA_SRCWIDTH , l->Width , taglist);
131 bsa.bsa_SrcHeight = GetTagData(LA_SRCHEIGHT, l->Height, taglist);
132 bsa.bsa_XSrcFactor = bsa.bsa_SrcWidth;
133 bsa.bsa_YSrcFactor = bsa.bsa_SrcHeight;
134 bsa.bsa_DestX = GetTagData(LA_DESTX, 0, taglist);
135 bsa.bsa_DestY = GetTagData(LA_DESTY, 0, taglist);
137 bsa.bsa_DestWidth = GetTagData(LA_DESTWIDTH , l->Width , taglist);
138 bsa.bsa_DestHeight = GetTagData(LA_DESTHEIGHT, l->Height, taglist);
140 bsa.bsa_XDestFactor = GetTagData(LA_DESTWIDTH , l->Width , taglist);
141 bsa.bsa_YDestFactor = GetTagData(LA_DESTHEIGHT, l->Height, taglist);
142 bsa.bsa_SrcBitMap = l->ClipRect->BitMap;
143 bsa.bsa_DestBitMap = bm;
144 bsa.bsa_Flags = 0;
145 #if 0
146 bsa.bsa_XDDA;
147 bsa.bsa_YDDA;
148 bsa.bsa_Reserved1;
149 bsa.bsa_Reserved2;
150 #endif
152 //kprintf("Scaling bitmap!\n");
153 BitMapScale(&bsa);
155 FreeBitMap(l->ClipRect->BitMap);
156 l->ClipRect->BitMap = bm;
157 //kprintf("Leaving %s!\n",__FUNCTION__);
159 kprintf("shaperegion: %p\n",l->shaperegion);
161 return l->shaperegion;
163 AROS_USERFUNC_EXIT