2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
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 /*****************************************************************************
35 #include <proto/layers.h>
36 AROS_LH2(ULONG
, ScaleLayer
,
39 AROS_LHA(struct Layer
*, l
, A0
),
40 AROS_LHA(struct TagItem
*, taglist
, A1
),
43 struct LayersBase
*, LayersBase
, 42, Layers
)
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.
52 newwidth - new width of the layer
53 newheight - new height of the layer
56 TRUE if everything went alright, FALSE otherwise
70 *****************************************************************************/
74 struct ScaleLayerParam parm
= {taglist
, LayersBase
};
75 struct Region
* oldshape
;
78 hook
.h_Entry
= (IPTR
*)ScaleLayerCallback
;
79 hook
.h_Data
= (APTR
)&parm
;
81 oldshape
= ChangeLayerShape(l
, 0, &hook
);
84 * I must not free oldshape here since it is also the new shape!
98 * The ScaleLayer callback is doing the actul work of
101 AROS_UFH3(struct Region
*, ScaleLayerCallback
,
102 AROS_UFHA(struct Hook
*, hook
, A0
),
103 AROS_UFHA(struct Layer
*, l
, A2
),
104 AROS_UFHA(struct ChangeLayerShapeMsg
*, clsm
, A1
))
108 struct BitScaleArgs bsa
;
109 struct BitMap
* bm
= NULL
;
110 struct ScaleLayerParam
* slp
= (struct ScaleLayerParam
*)hook
->h_Data
;
111 struct LayersBase
* LayersBase
= slp
->LayersBase
;
113 struct TagItem
* taglist
= slp
->taglist
;
115 if (l
->ClipRect
->Next
)
117 kprintf("%s: Only expecting one ClipRect - leaving!\n",__FUNCTION__
);
121 bm
= AllocBitMap(GetTagData(LA_DESTWIDTH
, l
->Width
, taglist
),
122 GetTagData(LA_DESTHEIGHT
, l
->Height
, taglist
),
123 l
->ClipRect
->BitMap
->Depth
,
127 bsa
.bsa_SrcX
= GetTagData(LA_SRCX
, 0, taglist
);
128 bsa
.bsa_SrcY
= GetTagData(LA_SRCY
, 0, taglist
);
129 bsa
.bsa_SrcWidth
= GetTagData(LA_SRCWIDTH
, l
->Width
, taglist
);
130 bsa
.bsa_SrcHeight
= GetTagData(LA_SRCHEIGHT
, l
->Height
, taglist
);
131 bsa
.bsa_XSrcFactor
= bsa
.bsa_SrcWidth
;
132 bsa
.bsa_YSrcFactor
= bsa
.bsa_SrcHeight
;
133 bsa
.bsa_DestX
= GetTagData(LA_DESTX
, 0, taglist
);
134 bsa
.bsa_DestY
= GetTagData(LA_DESTY
, 0, taglist
);
136 bsa.bsa_DestWidth = GetTagData(LA_DESTWIDTH , l->Width , taglist);
137 bsa.bsa_DestHeight = GetTagData(LA_DESTHEIGHT, l->Height, taglist);
139 bsa
.bsa_XDestFactor
= GetTagData(LA_DESTWIDTH
, l
->Width
, taglist
);
140 bsa
.bsa_YDestFactor
= GetTagData(LA_DESTHEIGHT
, l
->Height
, taglist
);
141 bsa
.bsa_SrcBitMap
= l
->ClipRect
->BitMap
;
142 bsa
.bsa_DestBitMap
= bm
;
151 //kprintf("Scaling bitmap!\n");
154 FreeBitMap(l
->ClipRect
->BitMap
);
155 l
->ClipRect
->BitMap
= bm
;
156 //kprintf("Leaving %s!\n",__FUNCTION__);
158 kprintf("shaperegion: %p\n",l
->shaperegion
);
160 return l
->shaperegion
;