2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 Desc: Pixelformat class
9 /****************************************************************************************/
11 #include <proto/oop.h>
12 #include <proto/utility.h>
15 #include <utility/tagitem.h>
16 #include <hidd/graphics.h>
17 #include <libraries/cybergraphics.h>
20 #include <aros/debug.h>
22 #include "graphics_intern.h"
24 /*****************************************************************************************
27 aoHidd_PixFmt_CgxPixFmt
36 Returns pixelformat number according to CyberGraphX standard or -1
37 if the pixelformat has no correct representation in CGX (for example,
47 aoHidd_PixFmt_StdPixFmt
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
);
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
);
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"));
85 OOP_MethodID dispose_mid
;
87 dispose_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
88 OOP_CoerceMethod(cl
, o
, (OOP_Msg
)&dispose_mid
);
93 ReturnPtr("PixFmt::New(Success)", OOP_Object
*, o
);
97 /****************************************************************************************/
99 static const BYTE hidd2cgx_pixfmt
[] =
126 VOID
PF__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
128 HIDDT_PixelFormat
*pf
;
129 struct pixfmt_data
*data
;
132 data
= OOP_INST_DATA(cl
, o
);
135 if (IS_PIXFMT_ATTR(msg
->attrID
, idx
))
139 case aoHidd_PixFmt_RedShift
:
140 *msg
->storage
= pf
->red_shift
;
143 case aoHidd_PixFmt_GreenShift
:
144 *msg
->storage
= pf
->green_shift
;
147 case aoHidd_PixFmt_BlueShift
:
148 *msg
->storage
= pf
->blue_shift
;
151 case aoHidd_PixFmt_AlphaShift
:
152 *msg
->storage
= pf
->alpha_shift
;
155 case aoHidd_PixFmt_RedMask
:
156 *msg
->storage
= pf
->red_mask
;
159 case aoHidd_PixFmt_GreenMask
:
160 *msg
->storage
= pf
->green_mask
;
163 case aoHidd_PixFmt_BlueMask
:
164 *msg
->storage
= pf
->blue_mask
;
167 case aoHidd_PixFmt_AlphaMask
:
168 *msg
->storage
= pf
->alpha_mask
;
171 case aoHidd_PixFmt_CLUTShift
:
172 *msg
->storage
= pf
->clut_shift
;
175 case aoHidd_PixFmt_CLUTMask
:
176 *msg
->storage
= pf
->clut_mask
;
179 case aoHidd_PixFmt_Depth
:
180 *msg
->storage
= pf
->depth
;
183 case aoHidd_PixFmt_BitsPerPixel
:
184 *msg
->storage
= pf
->size
;
187 case aoHidd_PixFmt_BytesPerPixel
:
188 *msg
->storage
= pf
->bytes_per_pixel
;
191 case aoHidd_PixFmt_StdPixFmt
:
192 *msg
->storage
= pf
->stdpixfmt
;
195 case aoHidd_PixFmt_ColorModel
:
196 *msg
->storage
= HIDD_PF_COLMODEL(pf
);
199 case aoHidd_PixFmt_BitMapType
:
200 *msg
->storage
= HIDD_PF_BITMAPTYPE(pf
);
203 case aoHidd_PixFmt_SwapPixelBytes
:
204 *msg
->storage
= HIDD_PF_SWAPPIXELBYTES(pf
);
207 case aoHidd_PixFmt_CgxPixFmt
:
208 *msg
->storage
= hidd2cgx_pixfmt
[pf
->stdpixfmt
];
212 D(bug("TRYING TO GET UNKNOWN PIXFMT ATTR\n"));
213 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
220 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
226 /****************************************************************************************/