2 Copyright © 1995-2013, 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.
71 *****************************************************************************/
75 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
76 struct LayersBase
*LayersBase
= GetPrivIBase(IntuitionBase
)->LayersBase
;
77 IPTR apen
, bpen
, drmd
;
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
, &penmode
, RPTAG_APen
, &apen
,
93 RPTAG_BPen
, &bpen
, RPTAG_DrMd
, &drmd
, TAG_DONE
);
95 GetRPAttrs(rp
, RPTAG_APen
, &apen
,
96 RPTAG_BPen
, &bpen
, RPTAG_DrMd
, &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 0x8000
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
;
169 int imagedepth
= image
->Depth
;
172 /* The "8" (instead of image->Depth) seems to be correct,
173 as for example DOpus uses prop gadget knob images with
174 a depth of 0 (planepick 0, planeonoff color) */
178 /* That makes far more sense than just a 8
179 * R.Schmidt...still doesn`t resolve some weird icon problem i have
181 //depth = rp->BitMap->Depth;
184 ** Be system friendly. - Piru
186 depth
= GetBitMapAttr(rp
->BitMap
, BMA_DEPTH
);
190 InitBitMap(&bitmap
, depth
, image
->Width
, image
->Height
);
192 for(d
= 0; d
< depth
; d
++)
194 /* Don't use more planes than image->depth. This solves
195 corrupt images of Garshneblanker's FlyingToaster which
196 uses a PlanePick of 0xff. */
197 if ((imagedepth
> 0) && (planepick
& shift
))
200 bitmap
.Planes
[d
] = (PLANEPTR
)(image
->ImageData
+ (y
++) * x
);
204 bitmap
.Planes
[d
] = (planeonoff
& shift
) ? (PLANEPTR
)-1 : NULL
;
209 BltBitMapRastPort(&bitmap
,
212 leftOffset
+ image
->LeftEdge
, topOffset
+ image
->TopEdge
,
213 image
->Width
, image
->Height
,
214 (state
== IDS_SELECTED
) ? 0x30 : 0xC0);
220 for(d
= 0; d
< image
->Depth
;d
++)
222 bits
[d
] = (planepick
& shift
) ? image
->ImageData
+ (y
++) * x
: NULL
;
228 yoff
= image
->TopEdge
+ topOffset
;
230 for (y
=0; y
< image
->Height
; y
++, yoff
++)
233 bitmask
= START_BITMASK
;
235 xoff
= image
->LeftEdge
+ leftOffset
;
237 for (x
=0; x
< image
->Width
; x
++, xoff
++)
243 for(d
= 0; d
< image
->Depth
; d
++)
245 if (planepick
& shift
)
249 dat
= bits
[d
][offset
];
250 dat
= AROS_WORD2BE(dat
);
264 Move (rp
, xoff
, yoff
);
269 SetAPen (rp
, lastPen
);
270 Draw (rp
, xoff
, yoff
);
278 bitmask
= START_BITMASK
;
282 } /* for (x=0; x < image->Width; x++, xoff++) */
285 Draw (rp
, xoff
-1, yoff
);
287 if (bitmask
!= START_BITMASK
)
290 } /* for (y=0; y < image->Height; y++, yoff++) */
295 image
= image
->NextImage
;
299 SetRPAttrs(rp
,RPTAG_APen
,apen
,RPTAG_BPen
,bpen
,RPTAG_DrMd
,drmd
,RPTAG_PenMode
,penmode
,TAG_DONE
);
301 SetRPAttrs(rp
,RPTAG_APen
,apen
,RPTAG_BPen
,bpen
,RPTAG_DrMd
,drmd
,TAG_DONE
);
304 if (rp
->Layer
) UnlockLayer(rp
->Layer
);
307 } /* DrawImageState */