2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 Desc: Graphics function SetRPAttrsA()
9 #include <aros/debug.h>
10 #include <proto/utility.h>
11 #include <proto/oop.h>
13 #include "graphics_intern.h"
14 #include "gfxfuncsupport.h"
16 /*****************************************************************************
19 #include <graphics/rastport.h>
20 #include <graphics/rpattr.h>
21 #include <utility/tagitem.h>
22 #include <proto/graphics.h>
24 AROS_LH2(void, SetRPAttrsA
,
27 AROS_LHA(struct RastPort
*, rp
, A0
),
28 AROS_LHA(struct TagItem
*, tags
, A1
),
31 struct GfxBase
*, GfxBase
, 173, Graphics
)
34 Modify rastport with values from a taglist.
41 RPTAG_Font (struct TextFont *) - Font for Text()
42 RPTAG_APen (UBYTE) - Primary rendering pen
43 RPTAG_BPen (UBYTE) - Secondary rendering pen
44 RPTAG_DrMd (UBYTE) - Drawing mode (graphics/rastport.h)
45 RPTAG_OutlinePen (UBYTE) - Area Outline pen
46 RPTAG_WriteMask (ULONG) - Bit mask for writing
48 The following tags are compatible with MorphOS (V51) :
50 RPTAG_FgColor (ULONG) - Primary rendering color in A8R8G8B8
51 format. Only working on
52 hicolor/truecolor bitmaps/screens.
53 RPTAG_BgColor (ULONG) - Secondary rendering color in
54 A8R8G8B8 format. Only working on
55 hicolor/truecolor bitmaps/screens.
56 RPTAG_PenMode (BOOL) - TRUE if traditional pen numbers
57 should be used, FALSE if direct RGB
58 colors should be used. Has no effect
61 The following tags are compatible with AmigaOSv4 (V51) :
63 RPTAG_RemapColorFonts (BOOL) - Automatically remap colorfonts to
64 their color on hicolor/truecolor
67 AROS-specific extensions
69 RPTAG_ClipRectangle (struct Rectangle *) - Clipping rectangle
70 RPTAG_ClipRectangleFlags (LONG) - RPCRF_RELRIGHT | RPCRF_RELBOTTOM
71 (see graphics/rpattrs.h)
77 Setting one of RPTAG_ClipRectangle or RPTAG_ClipRectangleFlags
78 allocates internal extra data for the RastPort. After finishing using
79 this RastPort, you need to manually deallocate the extra data using
80 FreeVec(rp->RP_Extra).
87 GetRPAttrsA(), graphics/rpattr.h
91 *****************************************************************************/
95 struct TagItem
*tag
, *tstate
= tags
;
96 struct gfx_driverdata
*driverdata
;
98 while ((tag
= NextTagItem (&tstate
)))
103 SetFont (rp
, (struct TextFont
*)(tag
->ti_Data
));
107 SetAPen (rp
, tag
->ti_Data
);
111 SetBPen (rp
, tag
->ti_Data
);
115 SetDrMd (rp
, tag
->ti_Data
);
118 case RPTAG_OutlinePen
:
119 SetOutlinePen (rp
, tag
->ti_Data
);
122 case RPTAG_WriteMask
:
123 SetWriteMask (rp
, tag
->ti_Data
);
129 case RPTAG_DrawBounds
:
133 D(bug("[SetRPAttrs] RastPort 0x%p, PenMode set to %ld\n", rp
, tag
->ti_Data
));
135 rp
->Flags
&= ~RPF_NO_PENS
;
137 rp
->Flags
|= RPF_NO_PENS
;
142 D(bug("[SetRPAttrs] RastPort 0x%p, setting %sColor to 0x%08lX\n", rp
, (tag
->ti_Tag
== RPTAG_FgColor
) ? "Fg" : "Bg", tag
->ti_Data
));
144 if (rp
->BitMap
&& IS_HIDD_BM(rp
->BitMap
))
146 /* Map ARGB8888 color value to bitmap's format */
147 HIDDT_GC_Intern
*_gc
= GCINT(&((rp
)->longreserved
[1]));
150 ULONG rgb
= (ULONG
)tag
->ti_Data
;
152 /* HIDDT_ColComp are 16 Bit */
153 col
.alpha
= (HIDDT_ColComp
)((rgb
>> 16) & 0x0000FF00);
154 col
.red
= (HIDDT_ColComp
)((rgb
>> 8) & 0x0000FF00);
155 col
.green
= (HIDDT_ColComp
)(rgb
& 0x0000FF00);
156 col
.blue
= (HIDDT_ColComp
)((rgb
<< 8) & 0x0000FF00);
158 pixval
= HIDD_BM_MapColor(HIDD_BM_OBJ(rp
->BitMap
), &col
);
160 if (tag
->ti_Tag
== RPTAG_FgColor
)
167 case RPTAG_ClipRectangle
:
168 driverdata
= AllocDriverData(rp
, tag
->ti_Data
, GfxBase
);
173 driverdata
->dd_ClipRectangle
= *(struct Rectangle
*)tag
->ti_Data
;
174 driverdata
->dd_ClipRectangleFlags
|= RPCRF_VALID
;
178 driverdata
->dd_ClipRectangleFlags
&= ~RPCRF_VALID
;
183 case RPTAG_ClipRectangleFlags
:
184 driverdata
= AllocDriverData(rp
, TRUE
, GfxBase
);
187 driverdata
->dd_ClipRectangleFlags
&= ~(RPCRF_RELRIGHT
| RPCRF_RELBOTTOM
);
188 driverdata
->dd_ClipRectangleFlags
|= (tag
->ti_Data
& (RPCRF_RELRIGHT
| RPCRF_RELBOTTOM
));
192 case RPTAG_RemapColorFonts
:
195 rp
->Flags
|= RPF_REMAP_COLORFONTS
;
199 rp
->Flags
&= ~RPF_REMAP_COLORFONTS
;