Port the SB128 code to AROS.
[AROS.git] / rom / hidds / graphics / pixfmt.c
blob37eec08ae8b80ae1f4b79a2a63c4976746b7ae45
1 /*
2 Copyright © 1995-2001, 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>
13 #include <oop/oop.h>
14 #include <utility/tagitem.h>
15 #include <hidd/graphics.h>
17 #define DEBUG 0
18 #include <aros/debug.h>
20 #include "graphics_intern.h"
22 /****************************************************************************************/
24 OOP_Object *PF__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
26 DECLARE_ATTRCHECK(pixfmt);
28 HIDDT_PixelFormat pf;
29 BOOL ok = FALSE;
31 /* If no attrs are supplied, just create an empty pixfmt object */
33 EnterFunc(bug("PixFmt::New()\n"));
35 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
36 if (NULL == o)
37 ReturnPtr("PixFmt::New(Failed from superclass", OOP_Object *, NULL);
39 if (NULL == msg->attrList)
40 ReturnPtr("PixFmt::New(empty)", OOP_Object *, o);
42 if (!parse_pixfmt_tags(msg->attrList, &pf, ATTRCHECK(pixfmt), CSD(cl) ))
44 D(bug("!!! ERROR PARSINF ATTRS IN PixFmt::New() !!!\n"));
46 else
48 ok = TRUE;
51 if (!ok)
53 OOP_MethodID dispose_mid;
55 dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
56 OOP_CoerceMethod(cl, o, (OOP_Msg)&dispose_mid);
58 o = NULL;
61 ReturnPtr("PixFmt::New(Success)", OOP_Object *, o);
65 /****************************************************************************************/
67 VOID PF__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
69 HIDDT_PixelFormat *pf;
70 struct pixfmt_data *data;
71 ULONG idx;
73 data = OOP_INST_DATA(cl, o);
74 pf = &data->pf;
76 if (IS_PIXFMT_ATTR(msg->attrID, idx))
78 switch (idx)
80 case aoHidd_PixFmt_RedShift:
81 *msg->storage = pf->red_shift;
82 break;
84 case aoHidd_PixFmt_GreenShift:
85 *msg->storage = pf->green_shift;
86 break;
88 case aoHidd_PixFmt_BlueShift:
89 *msg->storage = pf->blue_shift;
90 break;
92 case aoHidd_PixFmt_AlphaShift:
93 *msg->storage = pf->alpha_shift;
94 break;
96 case aoHidd_PixFmt_RedMask:
97 *msg->storage = pf->red_mask;
98 break;
100 case aoHidd_PixFmt_GreenMask:
101 *msg->storage = pf->green_mask;
102 break;
104 case aoHidd_PixFmt_BlueMask:
105 *msg->storage = pf->blue_mask;
106 break;
108 case aoHidd_PixFmt_AlphaMask:
109 *msg->storage = pf->alpha_mask;
110 break;
112 case aoHidd_PixFmt_CLUTShift:
113 *msg->storage = pf->clut_shift;
114 break;
116 case aoHidd_PixFmt_CLUTMask:
117 *msg->storage = pf->clut_mask;
118 break;
120 case aoHidd_PixFmt_Depth:
121 *msg->storage = pf->depth;
122 break;
124 case aoHidd_PixFmt_BitsPerPixel:
125 *msg->storage = pf->size;
126 break;
128 case aoHidd_PixFmt_BytesPerPixel:
129 *msg->storage = pf->bytes_per_pixel;
130 break;
132 case aoHidd_PixFmt_StdPixFmt:
133 *msg->storage = pf->stdpixfmt;
134 break;
136 case aoHidd_PixFmt_ColorModel:
137 *msg->storage = HIDD_PF_COLMODEL(pf);
138 break;
140 case aoHidd_PixFmt_BitMapType:
141 *msg->storage = HIDD_PF_BITMAPTYPE(pf);
142 break;
144 case aoHidd_PixFmt_SwapPixelBytes:
145 *msg->storage = HIDD_PF_SWAPPIXELBYTES(pf);
146 break;
148 default:
149 D(bug("TRYING TO GET UNKNOWN PIXFMT ATTR\n"));
150 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
151 break;
155 else
157 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
160 return;
163 /****************************************************************************************/