compiler/clib: #error if not cpu specific implementation of setjmp(), longjmp(),...
[AROS.git] / rom / hidds / graphics / pixfmt.c
blob412f98402949c75fbccd36f669f40b0245ed8aa0
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 struct Library *OOPBase = CSD(cl)->cs_OOPBase;
27 DECLARE_ATTRCHECK(pixfmt);
29 HIDDT_PixelFormat pf;
30 BOOL ok = FALSE;
32 /* If no attrs are supplied, just create an empty pixfmt object */
34 EnterFunc(bug("PixFmt::New()\n"));
36 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
37 if (NULL == o)
38 ReturnPtr("PixFmt::New(Failed from superclass", OOP_Object *, NULL);
40 if (NULL == msg->attrList)
41 ReturnPtr("PixFmt::New(empty)", OOP_Object *, o);
43 if (!parse_pixfmt_tags(msg->attrList, &pf, ATTRCHECK(pixfmt), CSD(cl) ))
45 D(bug("!!! ERROR PARSINF ATTRS IN PixFmt::New() !!!\n"));
47 else
49 ok = TRUE;
52 if (!ok)
54 OOP_MethodID dispose_mid;
56 dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
57 OOP_CoerceMethod(cl, o, (OOP_Msg)&dispose_mid);
59 o = NULL;
62 ReturnPtr("PixFmt::New(Success)", OOP_Object *, o);
66 /****************************************************************************************/
68 VOID PF__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
70 HIDDT_PixelFormat *pf;
71 struct pixfmt_data *data;
72 ULONG idx;
74 data = OOP_INST_DATA(cl, o);
75 pf = &data->pf;
77 if (IS_PIXFMT_ATTR(msg->attrID, idx))
79 switch (idx)
81 case aoHidd_PixFmt_RedShift:
82 *msg->storage = pf->red_shift;
83 break;
85 case aoHidd_PixFmt_GreenShift:
86 *msg->storage = pf->green_shift;
87 break;
89 case aoHidd_PixFmt_BlueShift:
90 *msg->storage = pf->blue_shift;
91 break;
93 case aoHidd_PixFmt_AlphaShift:
94 *msg->storage = pf->alpha_shift;
95 break;
97 case aoHidd_PixFmt_RedMask:
98 *msg->storage = pf->red_mask;
99 break;
101 case aoHidd_PixFmt_GreenMask:
102 *msg->storage = pf->green_mask;
103 break;
105 case aoHidd_PixFmt_BlueMask:
106 *msg->storage = pf->blue_mask;
107 break;
109 case aoHidd_PixFmt_AlphaMask:
110 *msg->storage = pf->alpha_mask;
111 break;
113 case aoHidd_PixFmt_CLUTShift:
114 *msg->storage = pf->clut_shift;
115 break;
117 case aoHidd_PixFmt_CLUTMask:
118 *msg->storage = pf->clut_mask;
119 break;
121 case aoHidd_PixFmt_Depth:
122 *msg->storage = pf->depth;
123 break;
125 case aoHidd_PixFmt_BitsPerPixel:
126 *msg->storage = pf->size;
127 break;
129 case aoHidd_PixFmt_BytesPerPixel:
130 *msg->storage = pf->bytes_per_pixel;
131 break;
133 case aoHidd_PixFmt_StdPixFmt:
134 *msg->storage = pf->stdpixfmt;
135 break;
137 case aoHidd_PixFmt_ColorModel:
138 *msg->storage = HIDD_PF_COLMODEL(pf);
139 break;
141 case aoHidd_PixFmt_BitMapType:
142 *msg->storage = HIDD_PF_BITMAPTYPE(pf);
143 break;
145 case aoHidd_PixFmt_SwapPixelBytes:
146 *msg->storage = HIDD_PF_SWAPPIXELBYTES(pf);
147 break;
149 default:
150 D(bug("TRYING TO GET UNKNOWN PIXFMT ATTR\n"));
151 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
152 break;
156 else
158 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
161 return;
164 /****************************************************************************************/