2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Quartz bitmap class.
13 #include <aros/debug.h>
14 #include <hidd/graphics.h>
16 #include <proto/hostlib.h>
17 #include <proto/oop.h>
18 #include <proto/utility.h>
20 #include "classbase.h"
21 #include "bitmapclass.h"
23 /****************************************************************************************/
25 OOP_Object
*QBitmap__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
27 struct UIKitBase
*base
= cl
->UserData
;
29 DNEW(bug("QBitmap::New()\n"));
31 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
) msg
);
34 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
35 OOP_Object
*gfx
= NULL
;
36 HIDDT_ModeID modeid
= vHidd_ModeID_Invalid
;
38 /* For faster operation we cache some data about ourselves */
39 data
->width
= OOP_GET(o
, aHidd_BitMap_Width
);
40 data
->height
= OOP_GET(o
, aHidd_BitMap_Height
);
41 data
->mod
= OOP_GET(o
, aHidd_BitMap_BytesPerRow
);
42 OOP_GetAttr(o
, aHidd_BitMap_ModeID
, &modeid
);
43 OOP_GetAttr(o
, aHidd_BitMap_GfxHidd
, (IPTR
*)&gfx
);
44 OOP_GetAttr(o
, aHidd_ChunkyBM_Buffer
, (IPTR
*)&data
->pixels
);
47 * Orientation currently depend on width:height ratio.
48 * For all existing devices this seems to be true. However it's not perfect. Perhaps we need to
49 * add Orientation attribute to sync class. Or introduce ability to subclass syncs.
50 * In fact would be good to have own support for screen rotation in AROS. This is not designed yet.
52 data
->orientation
= (data
->width
> data
->height
) ? O_LANDSCAPE
: O_PORTRAIT
;
54 DNEW(bug("[QBitmap] Created bitmap %d x %d\n", data
->width
, data
->height
));
55 DNEW(bug("[QBitmap] Buffer at 0x%p, %d bytes per row\n", data
->pixels
, data
->mod
));
56 DNEW(bug("[QBitmap] Display driver object: 0x%p\n", gfx
));
60 base
->iface
->NewContext(data
);
65 DNEW(bug("[QBitmap] Bitmap context: 0x%p\n", data
->context
));
69 OOP_MethodID disp_mid
= OOP_GetMethodID(IID_Root
, moRoot_Dispose
);
71 OOP_CoerceMethod(cl
, o
, &disp_mid
);
75 if (modeid
!= vHidd_ModeID_Invalid
)
77 OOP_Object
*sync
= NULL
;
78 OOP_Object
*pixfmt
= NULL
;
80 HIDD_Gfx_GetMode(gfx
, modeid
, &sync
, &pixfmt
);
82 data
->win_width
= OOP_GET(sync
, aHidd_Sync_HDisp
);
83 data
->win_height
= OOP_GET(sync
, aHidd_Sync_VDisp
);
85 DNEW(bug("[QBitmap] Display window size: %d x %d\n", data
->win_width
, data
->win_height
));
92 /****************************************************************************************/
94 void QBitmap__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
96 struct UIKitBase
*base
= cl
->UserData
;
97 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
101 base
->iface
->DisposeContext(data
->context
);
106 OOP_DoSuperMethod(cl
, o
, msg
);
109 /****************************************************************************************/
111 VOID
QBitmap__Root__Get(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_Get
*msg
)
113 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);
116 if (IS_BM_ATTR(msg
->attrID
, idx
))
120 case aoHidd_BitMap_LeftEdge
:
121 *msg
->storage
= data
->left
;
124 case aoHidd_BitMap_TopEdge
:
125 *msg
->storage
= data
->top
;
129 OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
132 /****************************************************************************************/
134 VOID
QBitmap__Root__Set(OOP_Class
*cl
, OOP_Object
*obj
, struct pRoot_Set
*msg
)
136 struct bitmap_data
*data
= OOP_INST_DATA(cl
, obj
);
137 struct TagItem
*tag
, *tstate
;
139 BOOL change_position
= FALSE
;
142 tstate
= msg
->attrList
;
143 while((tag
= NextTagItem(&tstate
)))
145 if (IS_BM_ATTR(tag
->ti_Tag
, idx
))
149 case aoHidd_BitMap_LeftEdge
:
150 data
->left
= tag
->ti_Data
;
151 change_position
= TRUE
;
154 case aoHidd_BitMap_TopEdge
:
155 data
->top
= tag
->ti_Data
;
156 change_position
= TRUE
;
159 case aoHidd_BitMap_Visible
:
160 // data->visible = tag->ti_Data;
169 /* Fix up position. We can completely scroll out
170 of our window into all 4 sides, but not more */
171 if (data
->left
> data
->win_width
)
172 data
->left
= data
->win_width
;
173 else if (data
->left
< -data
->width
)
174 data
->left
= -data
->width
;
175 if (data
->top
> data
->win_height
)
176 data
->top
= data
->win_height
;
177 else if (data
->top
< -data
->height
)
178 data
->top
= -data
->height
;
188 OOP_DoSuperMethod(cl
, obj
, (OOP_Msg
)msg
);
191 /****************************************************************************************/
193 VOID
QBitmap__Hidd_BitMap__UpdateRect(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_BitMap_UpdateRect
*msg
)
195 struct bitmap_data
*data
= OOP_INST_DATA(cl
, o
);