2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Graphics function GetRPAttrsA()
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 /*****************************************************************************
21 #include <proto/graphics.h>
23 AROS_LH2(void, GetRPAttrsA
,
26 AROS_LHA(struct RastPort
*, rp
, A0
),
27 AROS_LHA(struct TagItem
*, tags
, A1
),
30 struct GfxBase
*, GfxBase
, 174, Graphics
)
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!
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
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
66 RPTAG_ClipRectangleFlags (LONG) - RPCRF_RELRIGHT | RPCRF_RELBOTTOM (see <graphics/rpattr.h>)
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().
78 RPTAG_SoftStyle and RPTAG_DrawBounds are not supported yet.
81 SetRPAttrsA(), GetAPen(), GetBPen(), GetOutLinePen(), graphics/rpattr.h
87 *****************************************************************************/
91 struct TagItem
*tag
, *tstate
= tags
;
93 struct gfx_driverdata
*driverdata
;
96 while ((tag
= NextTagItem ((const struct TagItem
**)&tstate
)))
101 *((IPTR
*)tag
->ti_Data
) = (IPTR
)rp
->Font
;
105 *((IPTR
*)tag
->ti_Data
) = (IPTR
)GetAPen(rp
);
109 *((IPTR
*)tag
->ti_Data
) = (IPTR
)GetBPen(rp
);
113 *((IPTR
*)tag
->ti_Data
) = (IPTR
)GetDrMd(rp
);
116 case RPTAG_OutlinePen
:
117 *((IPTR
*)tag
->ti_Data
) = (IPTR
)GetOutlinePen(rp
);
120 case RPTAG_WriteMask
:
121 *((IPTR
*)tag
->ti_Data
) = (IPTR
)rp
->Mask
;
135 *((IPTR
*)tag
->ti_Data
) = MaxPen
;
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;
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
;
154 /* We return zero if not applicable */
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
);
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);
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
;
195 *((struct Rectangle
**)tag
->ti_Data
) = NULL
;
199 case RPTAG_ClipRectangleFlags
:
200 driverdata
= ObtainDriverData(rp
);
203 *((IPTR
*)tag
->ti_Data
) = driverdata
->dd_ClipRectangleFlags
;
207 *((IPTR
*)tag
->ti_Data
) = 0;
211 case RPTAG_RemapColorFonts
:
212 *((IPTR
*)tag
->ti_Data
) = (rp
->Flags
& RPF_REMAP_COLORFONTS
) ? TRUE
: FALSE
;
215 } /* switch(tag->ti_Tag) */
217 } /* while ((tag = NextTagItem ((const struct TagItem **)&tstate))) */