Moved DisplayError() back to base code
[AROS.git] / rom / graphics / getrpattrsa.c
blob6f04da297617dd86e98ef39f676699cb8b73a22e
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function GetRPAttrsA()
6 Lang: english
7 */
9 #include <graphics/rpattr.h>
10 #include <graphics/rastport.h>
11 #include <graphics/gfx.h>
12 #include <proto/utility.h>
14 #include "graphics_intern.h"
15 #include "gfxfuncsupport.h"
16 #include "graphics_driver.h"
18 /*****************************************************************************
20 NAME */
21 #include <proto/graphics.h>
23 AROS_LH2(void, GetRPAttrsA,
25 /* SYNOPSIS */
26 AROS_LHA(struct RastPort *, rp , A0),
27 AROS_LHA(struct TagItem *, tags, A1),
29 /* LOCATION */
30 struct GfxBase *, GfxBase, 174, Graphics)
32 /* FUNCTION
34 Read the current settings of a RastPort into variables.
35 The ti_Tag field specifies the attribute to read and the
36 ti_Data field points to an address where to store the result.
37 All results are stored as IPTRs!
39 INPUTS
40 rp = pointer to a RastPort structure
41 tags = pointer to a taglist specifying the attributes to read and
42 the addresses to store the results
44 TAGS
45 RPTAG_Font (UBYTE) - Font for Text()
46 RPTAG_APen (UBYTE) - Primary rendering pen
47 RPTAG_BPen (UBYTE) - Secondary rendering pen
48 RPTAG_DrMd (UBYTE) - Drawing mode (graphics/rastport.h)
49 RPTAG_OutlinePen (UBYTE) - Area Outline pen
50 RPTAG_WriteMask (ULONG) - Bit Mask for writing
51 RPTAG_MaxPen (ULONG) - Maximum pen to render (see SetMaxPen())
53 MorphOS- and AmigaOSv4- compatible extensions:
55 RPTAG_FgColor (ULONG) - Primary rendering color in A8R8G8B8 format.
56 Only working on hicolor/truecolor bitmaps/screens.
57 RPTAG_BgColor (ULONG) - Secondary rendering color in A8R8G8B8 format.
58 Only working on hicolor/truecolor bitmaps/screens.
59 RPTAG_RemapColorFonts (BOOL) - Automatically remap colorfonts to their color
60 on hicolor/truecolor screens.
62 AROS-specific extensions:
64 RPTAG_ClipRectangle (struct Rectangle *) - Rectangle to clip rendering to. Rectangle will
65 be cloned.
66 RPTAG_ClipRectangleFlags (LONG) - RPCRF_RELRIGHT | RPCRF_RELBOTTOM (see <graphics/rpattr.h>)
68 RESULT
70 NOTES
71 RPTAG_ClipRectangle and RPTAG_ClipRectangleFlags must not be
72 used on manually inited or cloned rastports. Instead the rastport
73 must have been created with CreateRastPort() or CloneRastPort().
75 EXAMPLE
77 BUGS
78 RPTAG_SoftStyle and RPTAG_DrawBounds are not supported yet.
80 SEE ALSO
81 SetRPAttrsA(), GetAPen(), GetBPen(), GetOutLinePen(), graphics/rpattr.h
83 INTERNALS
85 HISTORY
87 *****************************************************************************/
89 AROS_LIBFUNC_INIT
91 struct TagItem *tag, *tstate = tags;
92 ULONG MaxPen, z;
93 struct gfx_driverdata *driverdata;
94 HIDDT_Color col;
96 while ((tag = NextTagItem ((const struct TagItem **)&tstate)))
98 switch(tag->ti_Tag)
100 case RPTAG_Font :
101 *((IPTR *)tag->ti_Data) = (IPTR)rp->Font;
102 break;
104 case RPTAG_APen :
105 *((IPTR *)tag->ti_Data) = (IPTR)GetAPen(rp);
106 break;
108 case RPTAG_BPen :
109 *((IPTR *)tag->ti_Data) = (IPTR)GetBPen(rp);
110 break;
112 case RPTAG_DrMd :
113 *((IPTR *)tag->ti_Data) = (IPTR)GetDrMd(rp);
114 break;
116 case RPTAG_OutlinePen :
117 *((IPTR *)tag->ti_Data) = (IPTR)GetOutlinePen(rp);
118 break;
120 case RPTAG_WriteMask :
121 *((IPTR *)tag->ti_Data) = (IPTR)rp->Mask;
122 break;
124 case RPTAG_MaxPen :
125 MaxPen = 0x01;
126 z = (LONG)rp->Mask;
127 if (0 == z)
128 MaxPen = 0x100;
129 else
130 while (z != 0)
132 z >>= 1;
133 MaxPen <<= 1;
135 *((IPTR *)tag->ti_Data) = MaxPen;
136 break;
138 case RPTAG_DrawBounds :
139 /* FIXME: Implement this */
140 ((struct Rectangle *)tag->ti_Data)->MinX = 0;
141 ((struct Rectangle *)tag->ti_Data)->MinY = 0;
142 ((struct Rectangle *)tag->ti_Data)->MaxX = 0;
143 ((struct Rectangle *)tag->ti_Data)->MaxY = 0;
144 break;
146 case RPTAG_PenMode:
147 /* PenMode is applicable only if there's an RTG bitmap attached to the RastPort */
148 *((IPTR *)tag->ti_Data) = (rp->BitMap && IS_HIDD_BM(rp->BitMap) && (rp->Flags & RPF_NO_PENS)) ? TRUE : FALSE;
149 break;
151 case RPTAG_FgColor:
152 case RPTAG_BgColor:
154 /* We return zero if not applicable */
155 col.alpha = 0;
156 col.red = 0;
157 col.green = 0;
158 col.blue = 0;
160 if (rp->BitMap && IS_HIDD_BM(rp->BitMap))
162 if (rp->Flags & RPF_NO_PENS)
164 /* Remap pixel value back from bitmap's format to ARGB8888 */
165 HIDDT_Pixel pixval = (tag->ti_Tag == RPTAG_FgColor) ? RP_FGCOLOR(rp) : RP_BGCOLOR(rp);
167 HIDD_BM_UnmapPixel(HIDD_BM_OBJ(rp->BitMap), pixval, &col);
169 else
171 /* Pens are used. Get a corresponding LUT entry. */
172 if (HIDD_BM_COLMAP(rp->BitMap))
174 ULONG pen = (tag->ti_Tag == RPTAG_FgColor) ? rp->FgPen : rp->BgPen;
176 HIDD_CM_GetColor(HIDD_BM_COLMAP(rp->BitMap), pen & PEN_MASK, &col);
181 *((IPTR *)tag->ti_Data) = ((col.alpha & 0xFF00) << 16) |
182 ((col.red & 0xFF00) << 8) |
183 (col.green & 0xFF00) |
184 ((col.blue & 0xFF00) >> 8);
185 break;
187 case RPTAG_ClipRectangle:
188 driverdata = ObtainDriverData(rp);
189 if (driverdata && (driverdata->dd_ClipRectangleFlags & RPCRF_VALID))
191 *((struct Rectangle **)tag->ti_Data) = &driverdata->dd_ClipRectangle;
193 else
195 *((struct Rectangle **)tag->ti_Data) = NULL;
197 break;
199 case RPTAG_ClipRectangleFlags:
200 driverdata = ObtainDriverData(rp);
201 if (driverdata)
203 *((IPTR *)tag->ti_Data) = driverdata->dd_ClipRectangleFlags;
205 else
207 *((IPTR *)tag->ti_Data) = 0;
209 break;
211 case RPTAG_RemapColorFonts:
212 *((IPTR *)tag->ti_Data) = (rp->Flags & RPF_REMAP_COLORFONTS) ? TRUE : FALSE;
213 break;
215 } /* switch(tag->ti_Tag) */
217 } /* while ((tag = NextTagItem ((const struct TagItem **)&tstate))) */
219 AROS_LIBFUNC_EXIT
220 } /* GetRPAttrsA */