revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-linux / hidd / linuxfb / linuxfbgfx_bitmapclass.c
blobefd6799e898ebc7ae4f6d05e51da08ecf3ccdd60
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Onscreen bitmap class for Linux FB Gfx Hidd
6 Lang: English.
7 */
9 #define DEBUG 0
10 #include <aros/debug.h>
12 #include <aros/symbolsets.h>
13 #include <hidd/gfx.h>
14 #include <hidd/unixio.h>
15 #include <oop/oop.h>
16 #include <proto/oop.h>
17 #include <proto/utility.h>
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <string.h>
23 #include "linuxfbgfx_intern.h"
24 #include "linuxfbgfx_bitmap.h"
26 /*********** BitMap::New() *************************************/
28 OOP_Object *LinuxFBBM__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
30 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg) msg);
31 D(bug("[LinuxBM] Created base bitmap %p\n", o));
33 if (NULL != o)
35 struct LinuxFBBitMapData *data = OOP_INST_DATA(cl, o);
36 OOP_Object *pf;
38 data->fbdev = GetTagData(aHidd_LinuxFBBitmap_FBDevInfo, -1, msg->attrList);
40 OOP_GetAttr(o, aHidd_BitMap_PixFmt, (IPTR *)&pf);
41 OOP_GetAttr(pf, aHidd_PixFmt_BitsPerPixel, &data->bpp);
44 return o;
47 BOOL LinuxFBBM__Hidd_BitMap__SetColors(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_SetColors *msg)
49 struct LinuxFBBitMapData *data = OOP_INST_DATA(cl, o);
51 if ((msg->firstColor + msg->numColors) > (1 << (data->bpp)))
53 return FALSE;
56 if (!OOP_DoSuperMethod(cl, o, (OOP_Msg)msg))
58 return FALSE;
61 if (data->fbdev != -1)
63 struct LinuxFB_staticdata *fsd = LSD(cl);
64 ULONG xc_i, col_i;
66 for ( xc_i = msg->firstColor, col_i = 0;
67 col_i < msg->numColors;
68 xc_i ++, col_i ++)
70 struct fb_cmap col =
72 xc_i, 1,
73 &msg->colors[col_i].red,
74 &msg->colors[col_i].green,
75 &msg->colors[col_i].blue,
76 &msg->colors[col_i].alpha
79 Hidd_UnixIO_IOControlFile(fsd->unixio, data->fbdev, FBIOPUTCMAP, &col, NULL);
82 return TRUE;