New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / graphics / setrpattrsa.c
blob29fa72545b4905982a2c41064e379c5005876f89
1 /*
2 Copyright © 1995-2001, 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
32 INPUTS
34 RESULT
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 HISTORY
47 29-10-95 digulla automatically created from
48 graphics_lib.fd and clib/graphics_protos.h
50 *****************************************************************************/
52 AROS_LIBFUNC_INIT
53 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
55 struct TagItem *tag, *tstate = tags;
56 BOOL havedriverdata = FALSE;
58 while ((tag = NextTagItem ((const struct TagItem **)&tstate)))
60 switch (tag->ti_Tag)
62 case RPTAG_Font:
63 SetFont (rp, (struct TextFont *)(tag->ti_Data));
64 break;
66 case RPTAG_APen:
67 SetAPen (rp, tag->ti_Data);
68 break;
70 case RPTAG_BPen:
71 SetBPen (rp, tag->ti_Data);
72 break;
74 case RPTAG_DrMd:
75 SetDrMd (rp, tag->ti_Data);
76 break;
78 case RPTAG_OutlinePen:
79 SetOutlinePen (rp, tag->ti_Data);
80 break;
82 case RPTAG_WriteMask:
83 SetWriteMask (rp, tag->ti_Data);
84 break;
86 case RPTAG_MaxPen:
87 break;
89 case RPTAG_DrawBounds:
90 break;
92 case RPTAG_FgColor:
93 case RPTAG_BgColor:
95 IPTR attr;
97 if (tag->ti_Tag == RPTAG_FgColor)
99 attr = aHidd_GC_Foreground;
100 RP_FGCOLOR(rp) = (ULONG)tag->ti_Data;
102 else
104 attr = aHidd_GC_Background;
105 RP_BGCOLOR(rp) = (ULONG)tag->ti_Data;
108 if (!rp->BitMap) break;
109 if (!IS_HIDD_BM(rp->BitMap)) break;
111 if (!havedriverdata)
113 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
116 if (havedriverdata)
118 struct TagItem col_tags[] =
120 { attr, 0 },
121 { TAG_DONE }
123 HIDDT_Color col;
124 ULONG rgb = (ULONG)tag->ti_Data;
126 /* HIDDT_ColComp are 16 Bit */
127 col.alpha = (HIDDT_ColComp)((rgb >> 16) & 0x0000FF00);
128 col.red = (HIDDT_ColComp)((rgb >> 8) & 0x0000FF00);
129 col.green = (HIDDT_ColComp)(rgb & 0x0000FF00);
130 col.blue = (HIDDT_ColComp)((rgb << 8) & 0x0000FF00);
132 col_tags[0].ti_Data = HIDD_BM_MapColor(HIDD_BM_OBJ(rp->BitMap), &col);
133 OOP_SetAttrs(RP_DRIVERDATA(rp)->dd_GC, col_tags);
135 break;
137 } /**/
139 case RPTAG_PatternOriginX:
140 RP_PATORIGINX(rp) = (WORD)tag->ti_Data;
141 break;
143 case RPTAG_PatternOriginY:
144 RP_PATORIGINY(rp) = (WORD)tag->ti_Data;
145 break;
147 case RPTAG_ClipRectangle:
148 if (!havedriverdata)
150 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
153 if (havedriverdata)
155 if (tag->ti_Data)
157 RP_DRIVERDATA(rp)->dd_ClipRectangle = *(struct Rectangle *)tag->ti_Data;
158 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags |= RPCRF_VALID;
160 else
162 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags &= ~RPCRF_VALID;
165 break;
167 case RPTAG_ClipRectangleFlags:
168 if (!havedriverdata)
170 havedriverdata = OBTAIN_DRIVERDATA(rp, GfxBase);
173 if (havedriverdata)
175 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags &= ~(RPCRF_RELRIGHT | RPCRF_RELBOTTOM);
176 RP_DRIVERDATA(rp)->dd_ClipRectangleFlags |= (tag->ti_Data & (RPCRF_RELRIGHT | RPCRF_RELBOTTOM));
178 break;
180 case RPTAG_RemapColorFonts:
181 if (tag->ti_Data)
183 rp->Flags |= RPF_REMAP_COLORFONTS;
185 else
187 rp->Flags &= ~RPF_REMAP_COLORFONTS;
189 break;
191 } /* switch (tag) */
193 } /* while (tag) */
195 if (havedriverdata)
197 RELEASE_DRIVERDATA(rp, GfxBase);
200 AROS_LIBFUNC_EXIT
201 } /* SetRPAttrsA */