Minor fixes to comments.
[AROS.git] / rom / graphics / setrpattrsa.c
blob97e776d3b3564b6ba0488ac543e8514266a56087
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$ $Log
5 Desc: Graphics function SetRPAttrsA()
6 Lang: english
7 */
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 /*****************************************************************************
18 NAME */
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,
26 /* SYNOPSIS */
27 AROS_LHA(struct RastPort *, rp, A0),
28 AROS_LHA(struct TagItem *, tags, A1),
30 /* LOCATION */
31 struct GfxBase *, GfxBase, 173, Graphics)
33 /* FUNCTION
34 Modify rastport with values from a taglist.
36 INPUTS
37 rp - RastPort
38 tags - see below
40 TAGS
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 and AmigaOSv4 (V51) :
50 RPTAG_FgColor (ULONG) - Primary rendering color in A8R8G8B8 format.
51 Only working on hicolor/truecolor bitmaps/screens.
52 RPTAG_BgColor (ULONG) - Secondary rendering color in A8R8G8B8 format.
53 Only working on hicolor/truecolor bitmaps/screens.
54 RPTAG_RemapColorFonts (BOOL) - Automatically remap colorfonts to their color
55 on hicolor/truecolor screens.
57 AROS-specific extensions
59 RPTAG_ClipRectangle (struct Rectangle *) - Clipping rectangle
60 RPTAG_ClipRectangleFlags (LONG) - RPCRF_RELRIGHT | RPCRF_RELBOTTOM (see graphics/rpattrs.h)
62 RESULT
64 NOTES
65 Setting one of RPTAG_ClipRectangle or RPTAG_ClipRectangleFlags allocates internal extra data
66 for the RastPort. After finishing using this RastPort, you need to manually deallocate
67 the extra data using FreeVec(rp->RP_Extra).
69 EXAMPLE
71 BUGS
73 SEE ALSO
74 GetRPAttrsA(), graphics/rpattr.h
76 INTERNALS
78 HISTORY
79 29-10-95 digulla automatically created from
80 graphics_lib.fd and clib/graphics_protos.h
82 *****************************************************************************/
84 AROS_LIBFUNC_INIT
86 struct TagItem *tag, *tstate = tags;
87 struct gfx_driverdata *driverdata;
89 while ((tag = NextTagItem (&tstate)))
91 switch (tag->ti_Tag)
93 case RPTAG_Font:
94 SetFont (rp, (struct TextFont *)(tag->ti_Data));
95 break;
97 case RPTAG_APen:
98 SetAPen (rp, tag->ti_Data);
99 break;
101 case RPTAG_BPen:
102 SetBPen (rp, tag->ti_Data);
103 break;
105 case RPTAG_DrMd:
106 SetDrMd (rp, tag->ti_Data);
107 break;
109 case RPTAG_OutlinePen:
110 SetOutlinePen (rp, tag->ti_Data);
111 break;
113 case RPTAG_WriteMask:
114 SetWriteMask (rp, tag->ti_Data);
115 break;
117 case RPTAG_MaxPen:
118 break;
120 case RPTAG_DrawBounds:
121 break;
123 case RPTAG_PenMode:
124 D(bug("[SetRPAttrs] RastPort 0x%p, PenMode set to %ld\n", rp, tag->ti_Data));
125 if (tag->ti_Data)
126 rp->Flags &= ~RPF_NO_PENS;
127 else
128 rp->Flags |= RPF_NO_PENS;
129 break;
131 case RPTAG_FgColor:
132 case RPTAG_BgColor:
133 D(bug("[SetRPAttrs] RastPort 0x%p, setting %sColor to 0x%08lX\n", rp, (tag->ti_Tag == RPTAG_FgColor) ? "Fg" : "Bg", tag->ti_Data));
135 if (rp->BitMap && IS_HIDD_BM(rp->BitMap))
137 /* Map ARGB8888 color value to bitmap's format */
138 HIDDT_Color col;
139 HIDDT_Pixel pixval;
140 ULONG rgb = (ULONG)tag->ti_Data;
142 /* HIDDT_ColComp are 16 Bit */
143 col.alpha = (HIDDT_ColComp)((rgb >> 16) & 0x0000FF00);
144 col.red = (HIDDT_ColComp)((rgb >> 8) & 0x0000FF00);
145 col.green = (HIDDT_ColComp)(rgb & 0x0000FF00);
146 col.blue = (HIDDT_ColComp)((rgb << 8) & 0x0000FF00);
148 pixval = HIDD_BM_MapColor(HIDD_BM_OBJ(rp->BitMap), &col);
150 if (tag->ti_Tag == RPTAG_FgColor)
151 RP_FGCOLOR(rp) = pixval;
152 else
153 RP_BGCOLOR(rp) = pixval;
155 break;
157 case RPTAG_ClipRectangle:
158 driverdata = AllocDriverData(rp, tag->ti_Data, GfxBase);
159 if (driverdata)
161 if (tag->ti_Data)
163 driverdata->dd_ClipRectangle = *(struct Rectangle *)tag->ti_Data;
164 driverdata->dd_ClipRectangleFlags |= RPCRF_VALID;
166 else
168 driverdata->dd_ClipRectangleFlags &= ~RPCRF_VALID;
171 break;
173 case RPTAG_ClipRectangleFlags:
174 driverdata = AllocDriverData(rp, TRUE, GfxBase);
175 if (driverdata)
177 driverdata->dd_ClipRectangleFlags &= ~(RPCRF_RELRIGHT | RPCRF_RELBOTTOM);
178 driverdata->dd_ClipRectangleFlags |= (tag->ti_Data & (RPCRF_RELRIGHT | RPCRF_RELBOTTOM));
180 break;
182 case RPTAG_RemapColorFonts:
183 if (tag->ti_Data)
185 rp->Flags |= RPF_REMAP_COLORFONTS;
187 else
189 rp->Flags &= ~RPF_REMAP_COLORFONTS;
191 break;
193 } /* switch (tag) */
195 } /* while (tag) */
197 AROS_LIBFUNC_EXIT
198 } /* SetRPAttrsA */