2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <proto/graphics.h>
8 #include <proto/layers.h>
9 #include "intuition_intern.h"
10 #include <intuition/classusr.h>
11 #include <proto/alib.h>
13 #include <aros/macros.h>
17 # include <aros/debug.h>
18 //#include <proto/arossupport.h>
20 #define USE_BLTBITMAPRASTPORT 1
21 #define USE_FASTPLANEPICK0 1
23 /*****************************************************************************
26 #include <graphics/rastport.h>
27 #include <graphics/rpattr.h>
28 #include <intuition/intuition.h>
29 #include <intuition/imageclass.h>
30 #include <proto/intuition.h>
32 AROS_LH6(void, DrawImageState
,
35 AROS_LHA(struct RastPort
*, rp
, A0
),
36 AROS_LHA(struct Image
*, image
, A1
),
37 AROS_LHA(LONG
, leftOffset
, D0
),
38 AROS_LHA(LONG
, topOffset
, D1
),
39 AROS_LHA(ULONG
, state
, D2
),
40 AROS_LHA(struct DrawInfo
*, drawInfo
, A2
),
43 struct IntuitionBase
*, IntuitionBase
, 103, Intuition
)
46 This function renders an image in a certain state.
49 rp - Render in this RastPort
50 image - Render this image
51 leftOffset, topOffset - Add this offset to the position stored in the
53 state - Which state (see intuition/imageclass.h for possible
55 drawInfo - The DrawInfo from the screen.
61 DrawImageState(), handles both boopsi and conventional images.
72 29-10-95 digulla automatically created from
73 intuition_lib.fd and clib/intuition_protos.h
75 *****************************************************************************/
78 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
80 ULONG apen
, bpen
, drmd
, penmode
;
82 EXTENDWORD(leftOffset
);
83 EXTENDWORD(topOffset
);
88 if (rp
->Layer
) LockLayer(0,rp
->Layer
);
90 /* Store important variables of the RastPort */
92 GetRPAttrs(rp
,RPTAG_PenMode
,(ULONG
)&penmode
,RPTAG_APen
,(ULONG
)&apen
,
93 RPTAG_BPen
,(ULONG
)&bpen
,RPTAG_DrMd
,(ULONG
)&drmd
,TAG_DONE
);
95 GetRPAttrs(rp
,RPTAG_APen
,(ULONG
)&apen
,
96 RPTAG_BPen
,(ULONG
)&bpen
,RPTAG_DrMd
,(ULONG
)&drmd
,TAG_DONE
);
101 if (image
->Depth
== CUSTOMIMAGEDEPTH
)
103 struct impDraw method
;
105 method
.MethodID
= IM_DRAW
;
106 method
.imp_RPort
= rp
;
107 method
.imp_Offset
.X
= leftOffset
;
108 method
.imp_Offset
.Y
= topOffset
;
109 method
.imp_State
= state
;
110 method
.imp_DrInfo
= drawInfo
;
111 DoMethodA ((Object
*)image
, (Msg
)&method
);
117 ULONG planeonoff
, planepick
;
119 #if !USE_BLTBITMAPRASTPORT
126 WORD xoff
, yoff
, plane
;
128 #define START_BITMASK 0x8000L
130 /* Change RastPort to the mode I need */
135 /* kprintf("*** Drawing Image %x. Next Image = %x\n widht = %d height = %d depth = %d planepick = %d planeonoff = %d\n",
136 image,image->NextImage,
137 image->Width,image->Height,image->Depth,image->PlanePick,image->PlaneOnOff);*/
140 planepick
= image
->PlanePick
;
141 planeonoff
= image
->PlaneOnOff
& ~planepick
;
143 #if USE_FASTPLANEPICK0
147 SetAPen(rp
, planeonoff
);
148 RectFill(rp
, leftOffset
+ image
->LeftEdge
,
149 topOffset
+ image
->TopEdge
,
150 leftOffset
+ image
->LeftEdge
+ image
->Width
- 1,
151 topOffset
+ image
->TopEdge
+ image
->Height
- 1);
153 image
= image
->NextImage
;
159 /* Use x to store size of one image plane */
160 x
= ((image
->Width
+ 15) >> 4) * image
->Height
;
165 #if USE_BLTBITMAPRASTPORT
167 struct BitMap bitmap
;
171 /* The "8" (instead of image->Depth) seems to be correct,
172 as for example DOpus uses prop gadget knob images with
173 a depth of 0 (planepick 0, planeonoff color) */
177 /* That makes far more sense than just a 8
178 * R.Schmidt...still doesn`t resolve some weird icon problem i have
180 //depth = rp->BitMap->Depth;
183 ** Be system friendly. - Piru
185 depth
= GetBitMapAttr(rp
->BitMap
, BMA_DEPTH
);
189 InitBitMap(&bitmap
, depth
, image
->Width
, image
->Height
);
191 for(d
= 0; d
< depth
; d
++)
193 if (planepick
& shift
)
195 bitmap
.Planes
[d
] = (PLANEPTR
)(image
->ImageData
+ (y
++) * x
);
199 bitmap
.Planes
[d
] = (planeonoff
& shift
) ? (PLANEPTR
)-1 : NULL
;
204 BltBitMapRastPort(&bitmap
,
207 leftOffset
+ image
->LeftEdge
, topOffset
+ image
->TopEdge
,
208 image
->Width
, image
->Height
,
215 for(d
= 0; d
< image
->Depth
;d
++)
217 bits
[d
] = (planepick
& shift
) ? image
->ImageData
+ (y
++) * x
: NULL
;
223 yoff
= image
->TopEdge
+ topOffset
;
225 for (y
=0; y
< image
->Height
; y
++, yoff
++)
228 bitmask
= START_BITMASK
;
230 xoff
= image
->LeftEdge
+ leftOffset
;
232 for (x
=0; x
< image
->Width
; x
++, xoff
++)
238 for(d
= 0; d
< image
->Depth
; d
++)
240 if (planepick
& shift
)
244 dat
= bits
[d
][offset
];
245 dat
= AROS_WORD2BE(dat
);
259 Move (rp
, xoff
, yoff
);
264 SetAPen (rp
, lastPen
);
265 Draw (rp
, xoff
, yoff
);
273 bitmask
= START_BITMASK
;
277 } /* for (x=0; x < image->Width; x++, xoff++) */
280 Draw (rp
, xoff
-1, yoff
);
282 if (bitmask
!= START_BITMASK
)
285 } /* for (y=0; y < image->Height; y++, yoff++) */
290 image
= image
->NextImage
;
294 SetRPAttrs(rp
,RPTAG_APen
,apen
,RPTAG_BPen
,bpen
,RPTAG_DrMd
,drmd
,RPTAG_PenMode
,penmode
,TAG_DONE
);
296 SetRPAttrs(rp
,RPTAG_APen
,apen
,RPTAG_BPen
,bpen
,RPTAG_DrMd
,drmd
,TAG_DONE
);
299 if (rp
->Layer
) UnlockLayer(rp
->Layer
);
302 } /* DrawImageState */