2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
5 Desc: Pixelformat class
9 /****************************************************************************************/
11 #include "gfx_debug.h"
13 #include <proto/oop.h>
14 #include <proto/utility.h>
17 #include <utility/tagitem.h>
19 #include <libraries/cybergraphics.h>
21 #include "gfx_intern.h"
23 /*****************************************************************************************
26 aoHidd_PixFmt_CgxPixFmt
35 Returns pixelformat number according to CyberGraphX standard or -1
36 if the pixelformat has no correct representation in CGX (for example,
46 aoHidd_PixFmt_StdPixFmt
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
);
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
);
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"));
84 OOP_MethodID dispose_mid
;
86 dispose_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
87 OOP_CoerceMethod(cl
, o
, (OOP_Msg
)&dispose_mid
);
92 ReturnPtr("PixFmt::New(Success)", OOP_Object
*, o
);
96 /****************************************************************************************/
98 static const BYTE hidd2cgx_pixfmt
[] =
125 VOID
PF__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
127 HIDDT_PixelFormat
*pf
;
128 struct pixfmt_data
*data
;
131 data
= OOP_INST_DATA(cl
, o
);
134 if (IS_PIXFMT_ATTR(msg
->attrID
, idx
))
138 case aoHidd_PixFmt_RedShift
:
139 *msg
->storage
= pf
->red_shift
;
142 case aoHidd_PixFmt_GreenShift
:
143 *msg
->storage
= pf
->green_shift
;
146 case aoHidd_PixFmt_BlueShift
:
147 *msg
->storage
= pf
->blue_shift
;
150 case aoHidd_PixFmt_AlphaShift
:
151 *msg
->storage
= pf
->alpha_shift
;
154 case aoHidd_PixFmt_RedMask
:
155 *msg
->storage
= pf
->red_mask
;
158 case aoHidd_PixFmt_GreenMask
:
159 *msg
->storage
= pf
->green_mask
;
162 case aoHidd_PixFmt_BlueMask
:
163 *msg
->storage
= pf
->blue_mask
;
166 case aoHidd_PixFmt_AlphaMask
:
167 *msg
->storage
= pf
->alpha_mask
;
170 case aoHidd_PixFmt_CLUTShift
:
171 *msg
->storage
= pf
->clut_shift
;
174 case aoHidd_PixFmt_CLUTMask
:
175 *msg
->storage
= pf
->clut_mask
;
178 case aoHidd_PixFmt_Depth
:
179 *msg
->storage
= pf
->depth
;
182 case aoHidd_PixFmt_BitsPerPixel
:
183 *msg
->storage
= pf
->size
;
186 case aoHidd_PixFmt_BytesPerPixel
:
187 *msg
->storage
= pf
->bytes_per_pixel
;
190 case aoHidd_PixFmt_StdPixFmt
:
191 *msg
->storage
= pf
->stdpixfmt
;
194 case aoHidd_PixFmt_ColorModel
:
195 *msg
->storage
= HIDD_PF_COLMODEL(pf
);
198 case aoHidd_PixFmt_BitMapType
:
199 *msg
->storage
= HIDD_PF_BITMAPTYPE(pf
);
202 case aoHidd_PixFmt_SwapPixelBytes
:
203 *msg
->storage
= HIDD_PF_SWAPPIXELBYTES(pf
);
206 case aoHidd_PixFmt_CgxPixFmt
:
207 *msg
->storage
= hidd2cgx_pixfmt
[pf
->stdpixfmt
];
211 D(bug("TRYING TO GET UNKNOWN PIXFMT ATTR\n"));
212 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
219 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
225 /****************************************************************************************/