revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / cgfx / getcybermapattr.c
blob5791967b3dea7551941682127c15f4a215a379e5
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <cybergraphx/cybergraphics.h>
11 #include <hidd/gfx.h>
12 #include <proto/oop.h>
13 #include <proto/utility.h>
15 #include "cybergraphics_intern.h"
16 #include "gfxfuncsupport.h"
18 /*****************************************************************************
20 NAME */
21 #include <proto/cybergraphics.h>
23 AROS_LH2(ULONG, GetCyberMapAttr,
25 /* SYNOPSIS */
26 AROS_LHA(struct BitMap *, bitMap, A0),
27 AROS_LHA(ULONG , attribute, D0),
29 /* LOCATION */
30 struct Library *, CyberGfxBase, 16, Cybergraphics)
32 /* FUNCTION
33 Provides information about an RTG bitmap. If you are unsure whether
34 the bitmap is an RTG one, you must retrieve and check
35 CYBRMATTR_ISCYBERGFX first, as all other attributes are only allowed
36 to be retrieved for RTG bitmaps.
38 INPUTS
39 bitMap - an RTG bitmap.
40 attribute - one of the following bitmap attributes:
41 CYBRMATTR_PIXFMT - the bitmap's pixel format. See
42 LockBitMapTagList() for possible values.
43 CYBRMATTR_WIDTH - the bitmap's width (in pixels).
44 CYBRMATTR_HEIGHT - the bitmap's height (in pixels).
45 CYBRMATTR_DEPTH - the number of bits per pixel.
46 CYBRMATTR_BPPIX - the number of bytes per pixel.
47 CYBRMATTR_XMOD - the number of bytes per row.
48 CYBRMATTR_ISCYBERGFX - TRUE only if the bitmap is an RTG one.
49 CYBRMATTR_ISLINEARMEM - TRUE only if the bitmap's display buffer
50 is linear.
51 CYBRMATTR_COLORMAP - the bitmap's color map.
53 RESULT
54 value - the value associated with the requested attribute.
56 NOTES
57 If an unknown attribute is requested, -1 is returned.
59 EXAMPLE
61 BUGS
62 CYBRMATTR_COLORMAP is unimplemented.
64 SEE ALSO
66 INTERNALS
68 *****************************************************************************/
70 AROS_LIBFUNC_INIT
72 OOP_Object *bm_obj = NULL;
73 OOP_Object *pf = NULL;
75 IPTR retval;
77 if (IS_HIDD_BM(bitMap))
79 bm_obj = HIDD_BM_OBJ(bitMap);
80 OOP_GetAttr(bm_obj, aHidd_BitMap_PixFmt, (IPTR *)&pf);
83 switch (attribute) {
84 case CYBRMATTR_XMOD:
85 if (bm_obj)
86 OOP_GetAttr(bm_obj, aHidd_BitMap_BytesPerRow, &retval);
87 else
88 retval = bitMap->BytesPerRow;
89 break;
91 case CYBRMATTR_BPPIX:
92 if (pf)
93 OOP_GetAttr(pf, aHidd_PixFmt_BytesPerPixel, &retval);
94 else
95 retval = 0;
96 break;
98 case CYBRMATTR_PIXFMT:
99 case CYBRMATTR_PIXFMT_ALPHA:
100 if (pf)
102 OOP_GetAttr(pf, aHidd_PixFmt_CgxPixFmt, &retval);
104 /* Backwards compatibility kludge. To be removed.
105 Used only by Cairo, do not use CYBRMATTR_PIXFMT_ALPHA
106 anywhere else. */
107 if (attribute == CYBRMATTR_PIXFMT_ALPHA)
109 IPTR stdpf;
111 OOP_GetAttr(pf, aHidd_PixFmt_StdPixFmt, &stdpf);
112 if ((stdpf >= vHidd_StdPixFmt_0RGB32) && (stdpf >= vHidd_StdPixFmt_0BGR32))
113 retval += 91;
116 D(bug("[GetCyberMapAttr] Pixel format is %d\n", retval));
118 else
119 retval = -1;
120 break;
122 case CYBRMATTR_WIDTH:
123 retval = GetBitMapAttr(bitMap, BMA_WIDTH);
124 break;
126 case CYBRMATTR_HEIGHT:
127 retval = GetBitMapAttr(bitMap, BMA_HEIGHT);
128 break;
130 case CYBRMATTR_DEPTH:
131 retval = GetBitMapAttr(bitMap, BMA_DEPTH);
132 break;
134 case CYBRMATTR_ISCYBERGFX:
135 retval = bm_obj ? TRUE : FALSE;
136 break;
138 case CYBRMATTR_ISLINEARMEM:
139 if (bm_obj)
140 OOP_GetAttr(bm_obj, aHidd_BitMap_IsLinearMem, &retval);
141 else
142 retval = TRUE;
143 break;
145 default:
146 D(bug("!!! UNKNOWN ATTRIBUTE PASSED TO GetCyberMapAttr()\n"));
147 break;
148 } /* switch (attribute) */
150 return retval;
152 AROS_LIBFUNC_EXIT
153 } /* GetCyberMapAttr */