2 Copyright © 1995-2007, 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 *****************************************************************************/
79 IPTR apen
, bpen
, drmd
;
84 EXTENDWORD(leftOffset
);
85 EXTENDWORD(topOffset
);
90 if (rp
->Layer
) LockLayer(0,rp
->Layer
);
92 /* Store important variables of the RastPort */
94 GetRPAttrs(rp
,RPTAG_PenMode
,(ULONG
)&penmode
,RPTAG_APen
,(ULONG
)&apen
,
95 RPTAG_BPen
,(ULONG
)&bpen
,RPTAG_DrMd
,(ULONG
)&drmd
,TAG_DONE
);
97 GetRPAttrs(rp
,RPTAG_APen
,(ULONG
)&apen
,
98 RPTAG_BPen
,(ULONG
)&bpen
,RPTAG_DrMd
,(ULONG
)&drmd
,TAG_DONE
);
103 if (image
->Depth
== CUSTOMIMAGEDEPTH
)
105 struct impDraw method
;
107 method
.MethodID
= IM_DRAW
;
108 method
.imp_RPort
= rp
;
109 method
.imp_Offset
.X
= leftOffset
;
110 method
.imp_Offset
.Y
= topOffset
;
111 method
.imp_State
= state
;
112 method
.imp_DrInfo
= drawInfo
;
113 DoMethodA ((Object
*)image
, (Msg
)&method
);
119 ULONG planeonoff
, planepick
;
121 #if !USE_BLTBITMAPRASTPORT
128 WORD xoff
, yoff
, plane
;
130 #define START_BITMASK 0x8000
132 /* Change RastPort to the mode I need */
137 /* kprintf("*** Drawing Image %x. Next Image = %x\n widht = %d height = %d depth = %d planepick = %d planeonoff = %d\n",
138 image,image->NextImage,
139 image->Width,image->Height,image->Depth,image->PlanePick,image->PlaneOnOff);*/
142 planepick
= image
->PlanePick
;
143 planeonoff
= image
->PlaneOnOff
& ~planepick
;
145 #if USE_FASTPLANEPICK0
149 SetAPen(rp
, planeonoff
);
150 RectFill(rp
, leftOffset
+ image
->LeftEdge
,
151 topOffset
+ image
->TopEdge
,
152 leftOffset
+ image
->LeftEdge
+ image
->Width
- 1,
153 topOffset
+ image
->TopEdge
+ image
->Height
- 1);
155 image
= image
->NextImage
;
161 /* Use x to store size of one image plane */
162 x
= ((image
->Width
+ 15) >> 4) * image
->Height
;
167 #if USE_BLTBITMAPRASTPORT
169 struct BitMap bitmap
;
173 /* The "8" (instead of image->Depth) seems to be correct,
174 as for example DOpus uses prop gadget knob images with
175 a depth of 0 (planepick 0, planeonoff color) */
179 /* That makes far more sense than just a 8
180 * R.Schmidt...still doesn`t resolve some weird icon problem i have
182 //depth = rp->BitMap->Depth;
185 ** Be system friendly. - Piru
187 depth
= GetBitMapAttr(rp
->BitMap
, BMA_DEPTH
);
191 InitBitMap(&bitmap
, depth
, image
->Width
, image
->Height
);
193 for(d
= 0; d
< depth
; d
++)
195 if (planepick
& shift
)
197 bitmap
.Planes
[d
] = (PLANEPTR
)(image
->ImageData
+ (y
++) * x
);
201 bitmap
.Planes
[d
] = (planeonoff
& shift
) ? (PLANEPTR
)-1 : NULL
;
206 BltBitMapRastPort(&bitmap
,
209 leftOffset
+ image
->LeftEdge
, topOffset
+ image
->TopEdge
,
210 image
->Width
, image
->Height
,
217 for(d
= 0; d
< image
->Depth
;d
++)
219 bits
[d
] = (planepick
& shift
) ? image
->ImageData
+ (y
++) * x
: NULL
;
225 yoff
= image
->TopEdge
+ topOffset
;
227 for (y
=0; y
< image
->Height
; y
++, yoff
++)
230 bitmask
= START_BITMASK
;
232 xoff
= image
->LeftEdge
+ leftOffset
;
234 for (x
=0; x
< image
->Width
; x
++, xoff
++)
240 for(d
= 0; d
< image
->Depth
; d
++)
242 if (planepick
& shift
)
246 dat
= bits
[d
][offset
];
247 dat
= AROS_WORD2BE(dat
);
261 Move (rp
, xoff
, yoff
);
266 SetAPen (rp
, lastPen
);
267 Draw (rp
, xoff
, yoff
);
275 bitmask
= START_BITMASK
;
279 } /* for (x=0; x < image->Width; x++, xoff++) */
282 Draw (rp
, xoff
-1, yoff
);
284 if (bitmask
!= START_BITMASK
)
287 } /* for (y=0; y < image->Height; y++, yoff++) */
292 image
= image
->NextImage
;
296 SetRPAttrs(rp
,RPTAG_APen
,apen
,RPTAG_BPen
,bpen
,RPTAG_DrMd
,drmd
,RPTAG_PenMode
,penmode
,TAG_DONE
);
298 SetRPAttrs(rp
,RPTAG_APen
,apen
,RPTAG_BPen
,bpen
,RPTAG_DrMd
,drmd
,TAG_DONE
);
301 if (rp
->Layer
) UnlockLayer(rp
->Layer
);
304 } /* DrawImageState */