define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / rom / graphics / setrpattrsa.c
blobac91b513880089c30fd2576cedbe09b0754970f1
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$ $Log
5 Desc: Graphics function SetRPAttrsA()
6 Lang: english
7 */
8 #include "graphics_intern.h"
9 #include <proto/utility.h>
10 #include <proto/oop.h>
11 #include "gfxfuncsupport.h"
13 /*****************************************************************************
15 NAME */
16 #include <graphics/rastport.h>
17 #include <graphics/rpattr.h>
18 #include <utility/tagitem.h>
19 #include <proto/graphics.h>
21 AROS_LH2(void, SetRPAttrsA,
23 /* SYNOPSIS */
24 AROS_LHA(struct RastPort *, rp, A0),
25 AROS_LHA(struct TagItem *, tags, A1),
27 /* LOCATION */
28 struct GfxBase *, GfxBase, 173, Graphics)
30 /* FUNCTION
31 Modify rastport with values from a taglist.
33 INPUTS
34 rp - RastPort
35 tags - see below
37 TAGS
38 RPTAG_Font (struct TextFont *) - Font for Text()
39 RPTAG_APen (UBYTE) - Primary rendering pen
40 RPTAG_BPen (UBYTE) - Secondary rendering pen
41 RPTAG_DrMd (UBYTE) - Drawing mode (graphics/rastport.h)
42 RPTAG_OutlinePen (UBYTE) - Area Outline pen
43 RPTAG_WriteMask (ULONG) - Bit mask for writing
45 AROS extensions
46 RPTAG_FgColor (ULONG) - Primary rendering color in A8R8G8B8 format.
47 Only working on hicolor/truecolor bitmaps/screens.
48 RPTAG_BgColor (ULONG) - Secondary rendering color in A8R8G8B8 format.
49 Only working on hicolor/truecolor bitmaps/screens.
50 RPTAG_PatternOriginX (WORD) - X origin of pattern
51 RPTAG_PatternOriginY (WORD) - Y origin of pattern
52 RPTAG_ClipRectangle (struct Rectangle *) - Clipping rectangle
53 RPTAG_ClipRectangleFlags (LONG) - RPCRF_RELRIGHT | RPCRF_RELBOTTOM (see graphics/rpattrs.h)
54 RPTAG_RemapColorFonts (BOOL) - Automatically remap colorfonts to their color
55 on hicolor/truecolor screens.
57 RESULT
59 NOTES
61 EXAMPLE
63 BUGS
65 SEE ALSO
66 GetRPAttrsA(), graphics/rpattr.h
68 INTERNALS
70 HISTORY
71 29-10-95 digulla automatically created from
72 graphics_lib.fd and clib/graphics_protos.h
74 *****************************************************************************/
76 AROS_LIBFUNC_INIT
78 struct TagItem *tag, *tstate = tags;
79 BOOL havedriverdata = FALSE;
81 while ((tag = NextTagItem ((const struct TagItem **)&tstate)))
83 switch (tag->ti_Tag)
85 case RPTAG_Font:
86 SetFont (rp, (struct TextFont *)(tag->ti_Data));
87 break;
89 case RPTAG_APen:
90 SetAPen (rp, tag->ti_Data);
91 break;
93 case RPTAG_BPen:
94 SetBPen (rp, tag->ti_Data);
95 break;
97 case RPTAG_DrMd:
98 SetDrMd (rp, tag->ti_Data);
99 break;
101 case RPTAG_OutlinePen:
102 SetOutlinePen (rp, tag->ti_Data);
103 break;
105 case RPTAG_WriteMask:
106 SetWriteMask (rp, tag->ti_Data);
107 break;
109 case RPTAG_MaxPen:
110 break;
112 case RPTAG_DrawBounds:
113 break;
115 case RPTAG_FgColor:
116 case RPTAG_BgColor:
118 IPTR attr;
120 if (tag->ti_Tag == RPTAG_FgColor)
122 attr = aHidd_GC_Foreground;
123 RP_FGCOLOR(rp) = (ULONG)tag->ti_Data;
125 else
127 attr = aHidd_GC_Background;
128 RP_BGCOLOR(rp) = (ULONG)tag->ti_Data;
131 if (!rp->BitMap) break;
132 if (!IS_HIDD_BM(rp->BitMap)) break;
134 if (!havedriverdata)
136 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
139 if (havedriverdata)
141 struct TagItem col_tags[] =
143 { attr, 0 },
144 { TAG_DONE }
146 HIDDT_Color col;
147 ULONG rgb = (ULONG)tag->ti_Data;
149 /* HIDDT_ColComp are 16 Bit */
150 col.alpha = (HIDDT_ColComp)((rgb >> 16) & 0x0000FF00);
151 col.red = (HIDDT_ColComp)((rgb >> 8) & 0x0000FF00);
152 col.green = (HIDDT_ColComp)(rgb & 0x0000FF00);
153 col.blue = (HIDDT_ColComp)((rgb << 8) & 0x0000FF00);
155 col_tags[0].ti_Data = HIDD_BM_MapColor(HIDD_BM_OBJ(rp->BitMap), &col);
156 OOP_SetAttrs(RP_DRIVERDATA(rp)->dd_GC, col_tags);
158 break;
160 } /**/
162 case RPTAG_PatternOriginX:
163 RP_PATORIGINX(rp) = (WORD)tag->ti_Data;
164 break;
166 case RPTAG_PatternOriginY:
167 RP_PATORIGINY(rp) = (WORD)tag->ti_Data;
168 break;
170 case RPTAG_ClipRectangle:
171 if (!havedriverdata)
173 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
176 if (havedriverdata)
178 if (tag->ti_Data)
180 RP_DRIVERDATA(rp)->dd_ClipRectangle = *(struct Rectangle *)tag->ti_Data;
181 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags |= RPCRF_VALID;
183 else
185 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags &= ~RPCRF_VALID;
188 break;
190 case RPTAG_ClipRectangleFlags:
191 if (!havedriverdata)
193 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
196 if (havedriverdata)
198 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags &= ~(RPCRF_RELRIGHT | RPCRF_RELBOTTOM);
199 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags |= (tag->ti_Data & (RPCRF_RELRIGHT | RPCRF_RELBOTTOM));
201 break;
203 case RPTAG_RemapColorFonts:
204 if (tag->ti_Data)
206 rp->Flags |= RPF_REMAP_COLORFONTS;
208 else
210 rp->Flags &= ~RPF_REMAP_COLORFONTS;
212 break;
214 } /* switch (tag) */
216 } /* while (tag) */
218 if (havedriverdata)
220 RELEASE_DRIVERDATA(rp, GfxBase);
223 AROS_LIBFUNC_EXIT
224 } /* SetRPAttrsA */