grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / hidds / graphics / pixfmt.c
blobe64d6eb91012300fde3606d5b8d6fdc900c2e8ad
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Pixelformat class
6 Lang: English.
7 */
9 /****************************************************************************************/
11 #include <proto/oop.h>
12 #include <proto/utility.h>
14 #include <oop/oop.h>
15 #include <utility/tagitem.h>
16 #include <hidd/graphics.h>
17 #include <libraries/cybergraphics.h>
19 #define DEBUG 0
20 #include <aros/debug.h>
22 #include "graphics_intern.h"
24 /*****************************************************************************************
26 NAME
27 aoHidd_PixFmt_CgxPixFmt
29 SYNOPSIS
30 [..G], ULONG
32 LOCATION
33 hidd.gfx.pixfmt
35 FUNCTION
36 Returns pixelformat number according to CyberGraphX standard or -1
37 if the pixelformat has no correct representation in CGX (for example,
38 planar pixelformats).
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 aoHidd_PixFmt_StdPixFmt
49 INTERNALS
51 *****************************************************************************************/
53 /****************************************************************************************/
55 OOP_Object *PF__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
57 struct Library *OOPBase = CSD(cl)->cs_OOPBase;
58 DECLARE_ATTRCHECK(pixfmt);
60 HIDDT_PixelFormat pf;
61 BOOL ok = FALSE;
63 /* If no attrs are supplied, just create an empty pixfmt object */
65 EnterFunc(bug("PixFmt::New()\n"));
67 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
68 if (NULL == o)
69 ReturnPtr("PixFmt::New(Failed from superclass", OOP_Object *, NULL);
71 if (NULL == msg->attrList)
72 ReturnPtr("PixFmt::New(empty)", OOP_Object *, o);
74 if (!parse_pixfmt_tags(msg->attrList, &pf, ATTRCHECK(pixfmt), CSD(cl) ))
76 D(bug("!!! ERROR PARSINF ATTRS IN PixFmt::New() !!!\n"));
78 else
80 ok = TRUE;
83 if (!ok)
85 OOP_MethodID dispose_mid;
87 dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
88 OOP_CoerceMethod(cl, o, (OOP_Msg)&dispose_mid);
90 o = NULL;
93 ReturnPtr("PixFmt::New(Success)", OOP_Object *, o);
97 /****************************************************************************************/
99 static const BYTE hidd2cgx_pixfmt[] =
104 PIXFMT_RGB24,
105 PIXFMT_BGR24,
106 PIXFMT_RGB16,
107 PIXFMT_RGB16PC,
108 PIXFMT_BGR16,
109 PIXFMT_BGR16PC,
110 PIXFMT_RGB15,
111 PIXFMT_RGB15PC,
112 PIXFMT_BGR15,
113 PIXFMT_BGR15PC,
114 PIXFMT_ARGB32,
115 PIXFMT_BGRA32,
116 PIXFMT_RGBA32,
118 PIXFMT_ARGB32,
119 PIXFMT_BGRA32,
120 PIXFMT_RGBA32,
122 PIXFMT_LUT8,
126 VOID PF__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
128 HIDDT_PixelFormat *pf;
129 struct pixfmt_data *data;
130 ULONG idx;
132 data = OOP_INST_DATA(cl, o);
133 pf = &data->pf;
135 if (IS_PIXFMT_ATTR(msg->attrID, idx))
137 switch (idx)
139 case aoHidd_PixFmt_RedShift:
140 *msg->storage = pf->red_shift;
141 break;
143 case aoHidd_PixFmt_GreenShift:
144 *msg->storage = pf->green_shift;
145 break;
147 case aoHidd_PixFmt_BlueShift:
148 *msg->storage = pf->blue_shift;
149 break;
151 case aoHidd_PixFmt_AlphaShift:
152 *msg->storage = pf->alpha_shift;
153 break;
155 case aoHidd_PixFmt_RedMask:
156 *msg->storage = pf->red_mask;
157 break;
159 case aoHidd_PixFmt_GreenMask:
160 *msg->storage = pf->green_mask;
161 break;
163 case aoHidd_PixFmt_BlueMask:
164 *msg->storage = pf->blue_mask;
165 break;
167 case aoHidd_PixFmt_AlphaMask:
168 *msg->storage = pf->alpha_mask;
169 break;
171 case aoHidd_PixFmt_CLUTShift:
172 *msg->storage = pf->clut_shift;
173 break;
175 case aoHidd_PixFmt_CLUTMask:
176 *msg->storage = pf->clut_mask;
177 break;
179 case aoHidd_PixFmt_Depth:
180 *msg->storage = pf->depth;
181 break;
183 case aoHidd_PixFmt_BitsPerPixel:
184 *msg->storage = pf->size;
185 break;
187 case aoHidd_PixFmt_BytesPerPixel:
188 *msg->storage = pf->bytes_per_pixel;
189 break;
191 case aoHidd_PixFmt_StdPixFmt:
192 *msg->storage = pf->stdpixfmt;
193 break;
195 case aoHidd_PixFmt_ColorModel:
196 *msg->storage = HIDD_PF_COLMODEL(pf);
197 break;
199 case aoHidd_PixFmt_BitMapType:
200 *msg->storage = HIDD_PF_BITMAPTYPE(pf);
201 break;
203 case aoHidd_PixFmt_SwapPixelBytes:
204 *msg->storage = HIDD_PF_SWAPPIXELBYTES(pf);
205 break;
207 case aoHidd_PixFmt_CgxPixFmt:
208 *msg->storage = hidd2cgx_pixfmt[pf->stdpixfmt];
209 break;
211 default:
212 D(bug("TRYING TO GET UNKNOWN PIXFMT ATTR\n"));
213 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
214 break;
218 else
220 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
223 return;
226 /****************************************************************************************/