2 Copyright © 1995-2013, 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-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
69 RPTAG_ClipRectangleFlags (LONG) - RPCRF_RELRIGHT | RPCRF_RELBOTTOM (see <graphics/rpattr.h>)
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().
81 RPTAG_SoftStyle and RPTAG_DrawBounds are not supported yet.
84 SetRPAttrsA(), GetAPen(), GetBPen(), GetOutLinePen(), graphics/rpattr.h
88 *****************************************************************************/
92 struct TagItem
*tag
, *tstate
= tags
;
94 struct gfx_driverdata
*driverdata
;
97 while ((tag
= NextTagItem (&tstate
)))
102 *((IPTR
*)tag
->ti_Data
) = (IPTR
)rp
->Font
;
106 *((IPTR
*)tag
->ti_Data
) = (IPTR
)GetAPen(rp
);
110 *((IPTR
*)tag
->ti_Data
) = (IPTR
)GetBPen(rp
);
114 *((IPTR
*)tag
->ti_Data
) = (IPTR
)GetDrMd(rp
);
117 case RPTAG_OutlinePen
:
118 *((IPTR
*)tag
->ti_Data
) = (IPTR
)GetOutlinePen(rp
);
121 case RPTAG_WriteMask
:
122 *((IPTR
*)tag
->ti_Data
) = (IPTR
)rp
->Mask
;
136 *((IPTR
*)tag
->ti_Data
) = MaxPen
;
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;
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;
158 /* We return zero if not applicable */
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_Pixel pixval
= (tag
->ti_Tag
== RPTAG_FgColor
) ? RP_FGCOLOR(rp
) : RP_BGCOLOR(rp
);
171 HIDD_BM_UnmapPixel(HIDD_BM_OBJ(rp
->BitMap
), pixval
, &col
);
175 /* Pens are used. Get a corresponding LUT entry. */
176 if (HIDD_BM_COLMAP(rp
->BitMap
))
178 ULONG pen
= (tag
->ti_Tag
== RPTAG_FgColor
) ? rp
->FgPen
: rp
->BgPen
;
180 HIDD_CM_GetColor(HIDD_BM_COLMAP(rp
->BitMap
), pen
& PEN_MASK
, &col
);
185 *((IPTR
*)tag
->ti_Data
) = ((col
.alpha
& 0xFF00) << 16) |
186 ((col
.red
& 0xFF00) << 8) |
187 (col
.green
& 0xFF00) |
188 ((col
.blue
& 0xFF00) >> 8);
191 case RPTAG_ClipRectangle
:
192 driverdata
= ObtainDriverData(rp
);
193 if (driverdata
&& (driverdata
->dd_ClipRectangleFlags
& RPCRF_VALID
))
195 *((struct Rectangle
**)tag
->ti_Data
) = &driverdata
->dd_ClipRectangle
;
199 *((struct Rectangle
**)tag
->ti_Data
) = NULL
;
203 case RPTAG_ClipRectangleFlags
:
204 driverdata
= ObtainDriverData(rp
);
207 *((IPTR
*)tag
->ti_Data
) = driverdata
->dd_ClipRectangleFlags
;
211 *((IPTR
*)tag
->ti_Data
) = 0;
215 case RPTAG_RemapColorFonts
:
216 *((IPTR
*)tag
->ti_Data
) = (rp
->Flags
& RPF_REMAP_COLORFONTS
) ? TRUE
: FALSE
;
219 } /* switch(tag->ti_Tag) */
221 } /* while ((tag = NextTagItem(&tstate))) */