Indentation fix, cleanup.
[AROS.git] / rom / graphics / getrpattrsa.c
blob321a5d3dd3b500bb0c8ff33a2997358cd6ac9e60
1 /*
2 Copyright © 1995-2013, 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-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.
60 AmigaOSv4-compatible extensions:
62 RPTAG_RemapColorFonts (BOOL) - Automatically remap colorfonts to their color
63 on hicolor/truecolor screens.
65 AROS-specific extensions:
67 RPTAG_ClipRectangle (struct Rectangle *) - Rectangle to clip rendering to. Rectangle will
68 be cloned.
69 RPTAG_ClipRectangleFlags (LONG) - RPCRF_RELRIGHT | RPCRF_RELBOTTOM (see <graphics/rpattr.h>)
71 RESULT
73 NOTES
74 RPTAG_ClipRectangle and RPTAG_ClipRectangleFlags must not be
75 used on manually inited or cloned rastports. Instead the rastport
76 must have been created with CreateRastPort() or CloneRastPort().
78 EXAMPLE
80 BUGS
81 RPTAG_SoftStyle and RPTAG_DrawBounds are not supported yet.
83 SEE ALSO
84 SetRPAttrsA(), GetAPen(), GetBPen(), GetOutLinePen(), graphics/rpattr.h
86 INTERNALS
88 *****************************************************************************/
90 AROS_LIBFUNC_INIT
92 struct TagItem *tag, *tstate = tags;
93 ULONG MaxPen, z;
94 struct gfx_driverdata *driverdata;
95 HIDDT_Color col;
97 while ((tag = NextTagItem (&tstate)))
99 switch(tag->ti_Tag)
101 case RPTAG_Font :
102 *((IPTR *)tag->ti_Data) = (IPTR)rp->Font;
103 break;
105 case RPTAG_APen :
106 *((IPTR *)tag->ti_Data) = (IPTR)GetAPen(rp);
107 break;
109 case RPTAG_BPen :
110 *((IPTR *)tag->ti_Data) = (IPTR)GetBPen(rp);
111 break;
113 case RPTAG_DrMd :
114 *((IPTR *)tag->ti_Data) = (IPTR)GetDrMd(rp);
115 break;
117 case RPTAG_OutlinePen :
118 *((IPTR *)tag->ti_Data) = (IPTR)GetOutlinePen(rp);
119 break;
121 case RPTAG_WriteMask :
122 *((IPTR *)tag->ti_Data) = (IPTR)rp->Mask;
123 break;
125 case RPTAG_MaxPen :
126 MaxPen = 0x01;
127 z = (LONG)rp->Mask;
128 if (0 == z)
129 MaxPen = 0x100;
130 else
131 while (z != 0)
133 z >>= 1;
134 MaxPen <<= 1;
136 *((IPTR *)tag->ti_Data) = MaxPen;
137 break;
139 case RPTAG_DrawBounds :
140 /* FIXME: Implement this */
141 ((struct Rectangle *)tag->ti_Data)->MinX = 0;
142 ((struct Rectangle *)tag->ti_Data)->MinY = 0;
143 ((struct Rectangle *)tag->ti_Data)->MaxX = 0;
144 ((struct Rectangle *)tag->ti_Data)->MaxY = 0;
145 break;
147 case RPTAG_PenMode:
148 /* PenMode is applicable only if there's an RTG bitmap
149 * attached to the RastPort */
150 *((IPTR *)tag->ti_Data) = rp->BitMap != NULL
151 && IS_HIDD_BM(rp->BitMap)
152 && (rp->Flags & RPF_NO_PENS) == 0;
153 break;
155 case RPTAG_FgColor:
156 case RPTAG_BgColor:
158 /* We return zero if not applicable */
159 col.alpha = 0;
160 col.red = 0;
161 col.green = 0;
162 col.blue = 0;
164 if (rp->BitMap && IS_HIDD_BM(rp->BitMap))
166 if (rp->Flags & RPF_NO_PENS)
168 /* Remap pixel value back from bitmap's format to ARGB8888 */
169 HIDDT_GC_Intern *_gc = GCINT(&((rp)->longreserved[1]));
170 HIDDT_Pixel pixval;
172 if (tag->ti_Tag == RPTAG_FgColor)
173 pixval = _gc->fg;
174 else
175 pixval = _gc->bg;
177 HIDD_BM_UnmapPixel(HIDD_BM_OBJ(rp->BitMap), pixval, &col);
179 else
181 /* Pens are used. Get a corresponding LUT entry. */
182 if (HIDD_BM_COLMAP(rp->BitMap))
184 ULONG pen = (tag->ti_Tag == RPTAG_FgColor) ? rp->FgPen : rp->BgPen;
186 HIDD_CM_GetColor(HIDD_BM_COLMAP(rp->BitMap), pen & PEN_MASK, &col);
191 *((IPTR *)tag->ti_Data) = ((col.alpha & 0xFF00) << 16) |
192 ((col.red & 0xFF00) << 8) |
193 (col.green & 0xFF00) |
194 ((col.blue & 0xFF00) >> 8);
195 break;
197 case RPTAG_ClipRectangle:
198 driverdata = ObtainDriverData(rp);
199 if (driverdata && (driverdata->dd_ClipRectangleFlags & RPCRF_VALID))
201 *((struct Rectangle **)tag->ti_Data) = &driverdata->dd_ClipRectangle;
203 else
205 *((struct Rectangle **)tag->ti_Data) = NULL;
207 break;
209 case RPTAG_ClipRectangleFlags:
210 driverdata = ObtainDriverData(rp);
211 if (driverdata)
213 *((IPTR *)tag->ti_Data) = driverdata->dd_ClipRectangleFlags;
215 else
217 *((IPTR *)tag->ti_Data) = 0;
219 break;
221 case RPTAG_RemapColorFonts:
222 *((IPTR *)tag->ti_Data) = (rp->Flags & RPF_REMAP_COLORFONTS) ? TRUE : FALSE;
223 break;
225 } /* switch(tag->ti_Tag) */
227 } /* while ((tag = NextTagItem(&tstate))) */
229 AROS_LIBFUNC_EXIT
230 } /* GetRPAttrsA */