revert between 56095 -> 55830 in arch
[AROS.git] / rom / hidds / gfx / gfx_pixfmtclass.c
blob44b2df202cd9dfc1f99b3a862188ec651c6af4e8
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Pixelformat class
6 Lang: English.
7 */
9 /****************************************************************************************/
11 #include "gfx_debug.h"
13 #include <proto/oop.h>
14 #include <proto/utility.h>
16 #include <oop/oop.h>
17 #include <utility/tagitem.h>
18 #include <hidd/gfx.h>
19 #include <libraries/cybergraphics.h>
21 #include "gfx_intern.h"
23 /*****************************************************************************************
25 NAME
26 aoHidd_PixFmt_CgxPixFmt
28 SYNOPSIS
29 [..G], ULONG
31 LOCATION
32 hidd.gfx.pixfmt
34 FUNCTION
35 Returns pixelformat number according to CyberGraphX standard or -1
36 if the pixelformat has no correct representation in CGX (for example,
37 planar pixelformats).
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 aoHidd_PixFmt_StdPixFmt
48 INTERNALS
50 *****************************************************************************************/
52 /****************************************************************************************/
54 OOP_Object *PF__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
56 struct Library *OOPBase = CSD(cl)->cs_OOPBase;
57 DECLARE_ATTRCHECK(pixfmt);
59 HIDDT_PixelFormat pf;
60 BOOL ok = FALSE;
62 /* If no attrs are supplied, just create an empty pixfmt object */
64 EnterFunc(bug("PixFmt::New()\n"));
66 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
67 if (NULL == o)
68 ReturnPtr("PixFmt::New(Failed from superclass", OOP_Object *, NULL);
70 if (NULL == msg->attrList)
71 ReturnPtr("PixFmt::New(empty)", OOP_Object *, o);
73 if (!parse_pixfmt_tags(msg->attrList, &pf, ATTRCHECK(pixfmt), CSD(cl) ))
75 D(bug("!!! ERROR PARSINF ATTRS IN PixFmt::New() !!!\n"));
77 else
79 ok = TRUE;
82 if (!ok)
84 OOP_MethodID dispose_mid;
86 dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
87 OOP_CoerceMethod(cl, o, (OOP_Msg)&dispose_mid);
89 o = NULL;
92 ReturnPtr("PixFmt::New(Success)", OOP_Object *, o);
96 /****************************************************************************************/
98 static const BYTE hidd2cgx_pixfmt[] =
103 PIXFMT_RGB24,
104 PIXFMT_BGR24,
105 PIXFMT_RGB16,
106 PIXFMT_RGB16PC,
107 PIXFMT_BGR16,
108 PIXFMT_BGR16PC,
109 PIXFMT_RGB15,
110 PIXFMT_RGB15PC,
111 PIXFMT_BGR15,
112 PIXFMT_BGR15PC,
113 PIXFMT_ARGB32,
114 PIXFMT_BGRA32,
115 PIXFMT_RGBA32,
117 PIXFMT_ARGB32,
118 PIXFMT_BGRA32,
119 PIXFMT_RGBA32,
121 PIXFMT_LUT8,
125 VOID PF__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
127 HIDDT_PixelFormat *pf;
128 struct pixfmt_data *data;
129 ULONG idx;
131 data = OOP_INST_DATA(cl, o);
132 pf = &data->pf;
134 if (IS_PIXFMT_ATTR(msg->attrID, idx))
136 switch (idx)
138 case aoHidd_PixFmt_RedShift:
139 *msg->storage = pf->red_shift;
140 break;
142 case aoHidd_PixFmt_GreenShift:
143 *msg->storage = pf->green_shift;
144 break;
146 case aoHidd_PixFmt_BlueShift:
147 *msg->storage = pf->blue_shift;
148 break;
150 case aoHidd_PixFmt_AlphaShift:
151 *msg->storage = pf->alpha_shift;
152 break;
154 case aoHidd_PixFmt_RedMask:
155 *msg->storage = pf->red_mask;
156 break;
158 case aoHidd_PixFmt_GreenMask:
159 *msg->storage = pf->green_mask;
160 break;
162 case aoHidd_PixFmt_BlueMask:
163 *msg->storage = pf->blue_mask;
164 break;
166 case aoHidd_PixFmt_AlphaMask:
167 *msg->storage = pf->alpha_mask;
168 break;
170 case aoHidd_PixFmt_CLUTShift:
171 *msg->storage = pf->clut_shift;
172 break;
174 case aoHidd_PixFmt_CLUTMask:
175 *msg->storage = pf->clut_mask;
176 break;
178 case aoHidd_PixFmt_Depth:
179 *msg->storage = pf->depth;
180 break;
182 case aoHidd_PixFmt_BitsPerPixel:
183 *msg->storage = pf->size;
184 break;
186 case aoHidd_PixFmt_BytesPerPixel:
187 *msg->storage = pf->bytes_per_pixel;
188 break;
190 case aoHidd_PixFmt_StdPixFmt:
191 *msg->storage = pf->stdpixfmt;
192 break;
194 case aoHidd_PixFmt_ColorModel:
195 *msg->storage = HIDD_PF_COLMODEL(pf);
196 break;
198 case aoHidd_PixFmt_BitMapType:
199 *msg->storage = HIDD_PF_BITMAPTYPE(pf);
200 break;
202 case aoHidd_PixFmt_SwapPixelBytes:
203 *msg->storage = HIDD_PF_SWAPPIXELBYTES(pf);
204 break;
206 case aoHidd_PixFmt_CgxPixFmt:
207 *msg->storage = hidd2cgx_pixfmt[pf->stdpixfmt];
208 break;
210 default:
211 D(bug("TRYING TO GET UNKNOWN PIXFMT ATTR\n"));
212 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
213 break;
217 else
219 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
222 return;
225 /****************************************************************************************/