2 Copyright © 1995-2011, 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 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
80 struct LayersBase
*LayersBase
= GetPrivIBase(IntuitionBase
)->LayersBase
;
81 IPTR apen
, bpen
, drmd
;
86 EXTENDWORD(leftOffset
);
87 EXTENDWORD(topOffset
);
92 if (rp
->Layer
) LockLayer(0,rp
->Layer
);
94 /* Store important variables of the RastPort */
96 GetRPAttrs(rp
, RPTAG_PenMode
, &penmode
, RPTAG_APen
, &apen
,
97 RPTAG_BPen
, &bpen
, RPTAG_DrMd
, &drmd
, TAG_DONE
);
99 GetRPAttrs(rp
, RPTAG_APen
, &apen
,
100 RPTAG_BPen
, &bpen
, RPTAG_DrMd
, &drmd
, TAG_DONE
);
105 if (image
->Depth
== CUSTOMIMAGEDEPTH
)
107 struct impDraw method
;
109 method
.MethodID
= IM_DRAW
;
110 method
.imp_RPort
= rp
;
111 method
.imp_Offset
.X
= leftOffset
;
112 method
.imp_Offset
.Y
= topOffset
;
113 method
.imp_State
= state
;
114 method
.imp_DrInfo
= drawInfo
;
115 DoMethodA ((Object
*)image
, (Msg
)&method
);
121 ULONG planeonoff
, planepick
;
123 #if !USE_BLTBITMAPRASTPORT
130 WORD xoff
, yoff
, plane
;
132 #define START_BITMASK 0x8000
134 /* Change RastPort to the mode I need */
139 /* kprintf("*** Drawing Image %x. Next Image = %x\n widht = %d height = %d depth = %d planepick = %d planeonoff = %d\n",
140 image,image->NextImage,
141 image->Width,image->Height,image->Depth,image->PlanePick,image->PlaneOnOff);*/
144 planepick
= image
->PlanePick
;
145 planeonoff
= image
->PlaneOnOff
& ~planepick
;
147 #if USE_FASTPLANEPICK0
151 SetAPen(rp
, planeonoff
);
152 RectFill(rp
, leftOffset
+ image
->LeftEdge
,
153 topOffset
+ image
->TopEdge
,
154 leftOffset
+ image
->LeftEdge
+ image
->Width
- 1,
155 topOffset
+ image
->TopEdge
+ image
->Height
- 1);
157 image
= image
->NextImage
;
163 /* Use x to store size of one image plane */
164 x
= ((image
->Width
+ 15) >> 4) * image
->Height
;
169 #if USE_BLTBITMAPRASTPORT
171 struct BitMap bitmap
;
173 int imagedepth
= image
->Depth
;
176 /* The "8" (instead of image->Depth) seems to be correct,
177 as for example DOpus uses prop gadget knob images with
178 a depth of 0 (planepick 0, planeonoff color) */
182 /* That makes far more sense than just a 8
183 * R.Schmidt...still doesn`t resolve some weird icon problem i have
185 //depth = rp->BitMap->Depth;
188 ** Be system friendly. - Piru
190 depth
= GetBitMapAttr(rp
->BitMap
, BMA_DEPTH
);
194 InitBitMap(&bitmap
, depth
, image
->Width
, image
->Height
);
196 for(d
= 0; d
< depth
; d
++)
198 /* Don't use more planes than image->depth. This solves
199 corrupt images of Garshneblanker's FlyingToaster which
200 uses a PlanePick of 0xff. */
201 if ((imagedepth
> 0) && (planepick
& shift
))
204 bitmap
.Planes
[d
] = (PLANEPTR
)(image
->ImageData
+ (y
++) * x
);
208 bitmap
.Planes
[d
] = (planeonoff
& shift
) ? (PLANEPTR
)-1 : NULL
;
213 BltBitMapRastPort(&bitmap
,
216 leftOffset
+ image
->LeftEdge
, topOffset
+ image
->TopEdge
,
217 image
->Width
, image
->Height
,
218 (state
== IDS_SELECTED
) ? 0x30 : 0xC0);
224 for(d
= 0; d
< image
->Depth
;d
++)
226 bits
[d
] = (planepick
& shift
) ? image
->ImageData
+ (y
++) * x
: NULL
;
232 yoff
= image
->TopEdge
+ topOffset
;
234 for (y
=0; y
< image
->Height
; y
++, yoff
++)
237 bitmask
= START_BITMASK
;
239 xoff
= image
->LeftEdge
+ leftOffset
;
241 for (x
=0; x
< image
->Width
; x
++, xoff
++)
247 for(d
= 0; d
< image
->Depth
; d
++)
249 if (planepick
& shift
)
253 dat
= bits
[d
][offset
];
254 dat
= AROS_WORD2BE(dat
);
268 Move (rp
, xoff
, yoff
);
273 SetAPen (rp
, lastPen
);
274 Draw (rp
, xoff
, yoff
);
282 bitmask
= START_BITMASK
;
286 } /* for (x=0; x < image->Width; x++, xoff++) */
289 Draw (rp
, xoff
-1, yoff
);
291 if (bitmask
!= START_BITMASK
)
294 } /* for (y=0; y < image->Height; y++, yoff++) */
299 image
= image
->NextImage
;
303 SetRPAttrs(rp
,RPTAG_APen
,apen
,RPTAG_BPen
,bpen
,RPTAG_DrMd
,drmd
,RPTAG_PenMode
,penmode
,TAG_DONE
);
305 SetRPAttrs(rp
,RPTAG_APen
,apen
,RPTAG_BPen
,bpen
,RPTAG_DrMd
,drmd
,TAG_DONE
);
308 if (rp
->Layer
) UnlockLayer(rp
->Layer
);
311 } /* DrawImageState */