2 Copyright © 1995-2019, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
7 #include <cybergraphx/cybergraphics.h>
10 #include <graphics/driver.h>
11 #include <graphics/sprite.h>
12 #include <intuition/intuition.h>
13 #include <intuition/intuitionbase.h>
14 #include <intuition/classes.h>
15 #include <intuition/classusr.h>
16 #include <intuition/monitorclass.h>
17 #include <proto/alib.h>
18 #include <proto/exec.h>
19 #include <proto/intuition.h>
20 #include <proto/oop.h>
21 #include <proto/utility.h>
23 #include "intuition_intern.h"
24 #include "monitorclass_intern.h"
25 #include "monitorclass_private.h"
30 /*i***************************************************************************
33 --background_monitorclass--
39 In AROS display drivers have associated BOOPSI objects of MONITORCLASS
40 class. This class provides information about relative physical
41 placement of monitors in user's workspace as well as some additional
44 MONITORCLASS is a pseudo-name. This class is in fact private to the
45 system and does not have a public ID. The user can't create objects of
48 This class is fully compatible with MorphOS starting from v2.6.
50 *****************************************************************************/
52 Object
*DisplayDriverNotify(APTR obj
, BOOL add
, struct IntuitionBase
*IntuitionBase
)
54 D(bug("[Monitor] %s()\n", __func__
));
57 Object
*mon
= NewObject(GetPrivIBase(IntuitionBase
)->monitorclass
, NULL
, MA_MonitorHandle
, obj
, TAG_DONE
);
59 D(bug("[Monitor] %s: Monitor object 0x%p\n", __func__
, mon
));
61 /* Install default mouse pointer on the new monitor */
62 Object
*ptr
= GetPrivIBase(IntuitionBase
)->DefaultPointer
;
65 struct SharedPointer
*pointer
;
67 GetAttr(POINTERA_SharedPointer
, ptr
, (IPTR
*)&pointer
);
68 DoMethod(mon
, MM_SetPointerShape
, pointer
);
81 /*i**************************************************************************/
83 static void SetPointerPos(struct IMonitorNode
*data
, struct IntuitionBase
*IntuitionBase
)
85 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
86 ULONG x
= data
->mouseX
;
87 ULONG y
= data
->mouseY
;
90 bug("[Monitor] %s(%d, %d)\n", __func__
, x
, y
);
91 bug("[Monitor] %s: pointer @ 0x%p\n", __func__
, data
->pointer
);
95 /* Update sprite position, just for backwards compatibility */
96 data
->pointer
->sprite
->es_SimpleSprite
.x
= x
;
97 data
->pointer
->sprite
->es_SimpleSprite
.y
= y
;
100 DPOINTER(bug("[Monitor] %s: Physical co-ordinates %d,%d\n", __func__
, x
, y
);)
102 HIDD_Gfx_SetCursorPos(data
->handle
->gfxhidd
, x
, y
);
105 /*i**************************************************************************/
107 static void ActivationHandler(Object
*mon
, OOP_Object
*bitmap
)
109 Class
*cl
= OCLASS(mon
);
110 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
111 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
112 OOP_AttrBase HiddBitMapAttrBase
= GetPrivIBase(IntuitionBase
)->HiddBitMapAttrBase
;
113 struct TagItem tags
[] =
115 {aHidd_BitMap_Focus
, TRUE
},
120 bug("[Monitor] %s()\n", __func__
);
121 bug("[Monitor] %s: IntuitionBase @ 0x%p\n", __func__
, IntuitionBase
);
122 bug("[Monitor] %s: OOPBase @ 0x%p\n", __func__
, OOPBase
);
123 bug("[Monitor] %s: bitmap @ 0x%p\n", __func__
, bitmap
);
124 bug("[Monitor] %s: HiddBitMapAttrBase = %d\n", __func__
, HiddBitMapAttrBase
);
127 /* NewMonitor will be picked up by input handler when the next event arrives, so no signals etc */
128 GetPrivIBase(IntuitionBase
)->NewMonitor
= mon
;
130 OOP_SetAttrs(bitmap
, tags
);
133 /*i**************************************************************************/
135 static void ResetGamma(struct IMonitorNode
*data
)
137 data
->active_r
= &data
->gamma
[GAMMA_R
];
138 data
->active_g
= &data
->gamma
[GAMMA_G
];
139 data
->active_b
= &data
->gamma
[GAMMA_B
];
142 Object
*MonitorClass__OM_NEW(Class
*cl
, Object
*o
, struct opSet
*msg
)
144 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
145 struct Library
*UtilityBase
= GetPrivIBase(IntuitionBase
)->UtilityBase
;
146 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
147 OOP_AttrBase HiddAttrBase
= GetPrivIBase(IntuitionBase
)->HiddAttrBase
;
148 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
149 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
150 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
151 struct MonitorHandle
*handle
= (struct MonitorHandle
*)GetTagData(MA_MonitorHandle
, 0, msg
->ops_AttrList
);
152 HIDDT_ModeID mode
= vHidd_ModeID_Invalid
;
153 struct IMonitorNode
*data
;
154 OOP_Object
*sync
, *pixfmt
;
155 /* Tags order is important because CallBackData needs to be set before
156 function pointer. Otherwise the function can be called with a wrong
158 struct TagItem tags
[] =
160 {aHidd_Gfx_ActiveCallBackData
, 0 },
161 {aHidd_Gfx_ActiveCallBack
, (IPTR
)ActivationHandler
},
165 D(bug("[Monitor] %s()\n", __func__
));
170 o
= (Object
*)DoSuperMethodA(cl
, o
, (Msg
)msg
);
174 data
= INST_DATA(cl
, o
);
176 data
->handle
= handle
;
178 /* We can't list driver's pixelformats, we can list only modes. This does not harm however,
179 just some pixelformats will be processed more than once */
180 while ((mode
= HIDD_Gfx_NextModeID(handle
->gfxhidd
, mode
, &sync
, &pixfmt
)) != vHidd_ModeID_Invalid
)
184 OOP_GetAttr(pixfmt
, aHidd_PixFmt_CgxPixFmt
, &cgxpf
);
185 D(bug("[Monitor] %s: Mode 0x%08lX, CGX pixfmt %ld\n", __func__
, mode
, cgxpf
));
189 data
->pfobjects
[cgxpf
] = pixfmt
;
190 data
->pixelformats
[cgxpf
] = TRUE
;
194 if (OOP_GET(data
->handle
->gfxhidd
, aHidd_Gfx_SupportsGamma
))
198 D(bug("[Monitor] %s: Creating gamma table\n", __func__
));
200 data
->gamma
= AllocMem(256 * 3, MEMF_ANY
);
203 DoSuperMethod(cl
, o
, OM_DISPOSE
);
207 /* Create default gamma table */
208 for (i
= 0; i
< 256; i
++)
210 data
->gamma
[i
+ GAMMA_R
] = i
;
211 data
->gamma
[i
+ GAMMA_G
] = i
;
212 data
->gamma
[i
+ GAMMA_B
] = i
;
217 OOP_GetAttr(handle
->gfxhidd
, aHidd_Name
, (IPTR
*)&data
->MonitorName
);
218 OOP_GetAttr(handle
->gfxhidd
, aHidd_Gfx_HWSpriteTypes
, (IPTR
*)&data
->SpriteType
);
219 D(bug("[Monitor] %s: SpriteType = %08x\n", __func__
, data
->SpriteType
));
221 tags
[0].ti_Data
= (IPTR
)o
;
222 OOP_SetAttrs(handle
->gfxhidd
, tags
);
224 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
225 AddTail((struct List
*)&GetPrivIBase(IntuitionBase
)->MonitorList
, (struct Node
*)data
);
226 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
231 /*i***************************************************************************
243 Query monitor driver name.
255 *****************************************************************************/
257 /*i***************************************************************************
269 Query video card hardware manufacturer name
272 Not all drivers may specify manufacturer string. NULL is a valid
283 *****************************************************************************/
285 /*i***************************************************************************
297 Query video card hardware's numeric manufacturer ID (which may come
298 from PCI, Zorro, etc).
301 Not all drivers may have assigned IDs. For example VGA driver and
302 virtual hosted drivers do not associate themselves with any IDs.
313 *****************************************************************************/
315 /*i***************************************************************************
327 Query video card hardware's numeric product ID (which may come from
331 Not all drivers may have assigned IDs. For example VGA driver and
332 virtual hosted drivers do not associate themselves with any IDs.
343 *****************************************************************************/
345 /*i***************************************************************************
357 Query total size of video card memory in bytes.
370 *****************************************************************************/
372 /*i***************************************************************************
384 Query table of supported pixelformats.
386 A returned value is a pointer to static array of ULONGs, one ULONG per
387 CyberGraphX pixelformat. Values of these ULONGs are actually booleans.
388 A TRUE value in the array says that the pixelformat is supported,
389 FALSE means it is not.
396 GetAttr(MA_PixelFormats, monitor, (IPTR *)&pfs);
397 if (pfs[PUXFMT_LUT8])
398 printf("The display driver supports LUT8 format\n");
407 *****************************************************************************/
409 /*i***************************************************************************
421 Get a pointer to a monitor placed in top-left diagonal direction
422 relative tothe current one.
424 This attribute is used to describe relative placement of monitors in
425 user's physical environment.
432 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
436 MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
437 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
438 MA_BottomRightMonitor
442 *****************************************************************************/
444 /*i***************************************************************************
456 Get a pointer to a monitor placed in top direction relative to the
459 This attribute is used to describe relative placement of monitors in
460 the user's physical environment.
467 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
468 pointer to a monitor object.
471 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
472 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
473 MA_BottomRightMonitor
477 *****************************************************************************/
479 /*i***************************************************************************
491 Get a pointer to a monitor placed in top-right diagonal direction
492 relative to the current one.
494 This attribute is used to describe relative placement of monitors in
495 the user's physical environment.
502 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
503 pointer to a monitor object.
506 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
507 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
508 MA_BottomRightMonitor
512 *****************************************************************************/
514 /*i***************************************************************************
526 Get a pointer to a monitor placed in left direction relative to
529 This attribute is used to describe relative placement of monitors in
530 the user's physical environment.
537 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
538 pointer to a monitor object.
541 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
542 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
543 MA_BottomRightMonitor
547 *****************************************************************************/
549 /*i***************************************************************************
552 MA_MiddleRightMonitor
561 Get a pointer to a monitor placed in right direction relative to
564 This attribute is used to describe relative placement of monitors in
565 the user's physical environment.
572 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
573 pointer to a monitor object.
576 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
577 MA_MiddleLeftMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
578 MA_BottomRightMonitor
582 *****************************************************************************/
584 /*i***************************************************************************
596 Get a pointer to a monitor placed in bottom-left diagonal direction
597 relative to the current one.
599 This attribute is used to describe relative placement of monitors in
600 the user's physical environment.
607 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
608 pointer to a monitor object.
611 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
612 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomMiddleMonitor,
613 MA_BottomRightMonitor
617 *****************************************************************************/
619 /*i***************************************************************************
622 MA_BottomMiddleMonitor
631 Get a pointer to a monitor placed in bottom direction relative to the
634 This attribute is used to describe relative placement of monitors in
635 the user's physical environment.
642 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
643 pointer to a monitor object.
646 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
647 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomLeftMonitor,
648 MA_BottomRightMonitor
652 *****************************************************************************/
654 /*i***************************************************************************
657 MA_BottomRightMonitor
666 Get a pointer to a monitor placed in bottom-right diagonal direction
667 relative to the current one.
669 This attribute is used to describe relative placement of monitors in
670 the user's physical environment.
677 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
678 pointer to a monitor object.
681 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
682 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomLeftMonitor,
683 MA_BottomMiddleMonitor
687 *****************************************************************************/
689 /*i***************************************************************************
701 Query if the display driver supports gamma control.
710 MM_GetDefaultGammaTables, MM_SetDefaultGammaTables
714 *****************************************************************************/
716 /*i***************************************************************************
728 Query supported mouse pointer sprite formats.
730 The returned value is a combination of the following bit flags:
731 PointerType_3Plus1 - color 0 transparent, 1-3 visible (Amiga(tm)
733 PointerType_2Plus1 - color 0 transparent, 1 undefined (can be for
734 example clear or inverse), 2-3 visible
735 PointerType_ARGB - Direct color bitmap (hi-color or truecolor,
736 possibly with alpha channel
749 *****************************************************************************/
751 /*i***************************************************************************
763 Query CyberGraphX driver name. It is the name which can be given to
764 cybergraphics.library/BestCModeIDTagList() as CYBRBIDTG_BoardName
778 *****************************************************************************/
780 /*i***************************************************************************
792 Query the video card's memory clock in Hertz. 0 is a valid value
806 *****************************************************************************/
808 /*i***************************************************************************
820 Check if this monitor is a window on hosted OS desktop.
822 This means that the host OS is responsible for handling mouse input
823 and display activation. Monitors with this attribute set to TRUE
824 should be ignored by multi-display desktop configuration software.
826 These monitors should have no spatial links to other monitors.
827 Activation of these monitors is done by clicking on their windows on
828 the host's desktop and is handled by the driver itself.
831 This attribute is AROS-specific; it does not exist in MorphOS.
841 *****************************************************************************/
843 /*i**************************************************************************/
845 IPTR
MonitorClass__OM_GET(Class
*cl
, Object
*o
, struct opGet
*msg
)
847 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
848 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
849 OOP_AttrBase HiddAttrBase
= GetPrivIBase(IntuitionBase
)->HiddAttrBase
;
850 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
851 struct IMonitorNode
*data
= INST_DATA(cl
, o
);
853 D(bug("[Monitor] %s()\n", __func__
));
855 switch (msg
->opg_AttrID
)
858 *msg
->opg_Storage
= (IPTR
)data
->MonitorName
;
861 case MA_Manufacturer
:
862 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_ProducerName
, msg
->opg_Storage
);
865 case MA_ManufacturerID
:
866 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Producer
, msg
->opg_Storage
);
870 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Product
, msg
->opg_Storage
);
874 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_MemorySize
, msg
->opg_Storage
);
877 case MA_PixelFormats
:
878 *msg
->opg_Storage
= (IPTR
)data
->pixelformats
;
881 case MA_TopLeftMonitor
:
882 *msg
->opg_Storage
= (IPTR
)data
->topleft
;
885 case MA_TopMiddleMonitor
:
886 *msg
->opg_Storage
= (IPTR
)data
->topmiddle
;
889 case MA_TopRightMonitor
:
890 *msg
->opg_Storage
= (IPTR
)data
->topright
;
893 case MA_MiddleLeftMonitor
:
894 *msg
->opg_Storage
= (IPTR
)data
->middleleft
;
897 case MA_MiddleRightMonitor
:
898 *msg
->opg_Storage
= (IPTR
)data
->middleright
;
901 case MA_BottomLeftMonitor
:
902 *msg
->opg_Storage
= (IPTR
)data
->bottomleft
;
905 case MA_BottomMiddleMonitor
:
906 *msg
->opg_Storage
= (IPTR
)data
->bottommiddle
;
909 case MA_BottomRightMonitor
:
910 *msg
->opg_Storage
= (IPTR
)data
->bottomright
;
913 case MA_GammaControl
:
914 *msg
->opg_Storage
= data
->gamma
? TRUE
: FALSE
;
918 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_HWSpriteTypes
, msg
->opg_Storage
);
922 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_DriverName
, msg
->opg_Storage
);
926 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_MemoryClock
, msg
->opg_Storage
);
930 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_IsWindowed
, msg
->opg_Storage
);
934 *msg
->opg_Storage
= data
->handle
->id
;
938 return DoSuperMethodA(cl
, o
, (Msg
)msg
);
944 /*i**************************************************************************/
946 IPTR
MonitorClass__OM_SET(Class
*cl
, Object
*o
, struct opSet
*msg
)
948 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
949 struct Library
*UtilityBase
= GetPrivIBase(IntuitionBase
)->UtilityBase
;
950 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
951 struct IMonitorNode
*data
= INST_DATA(cl
, o
);
952 struct TagItem
*tag
, *tstate
;
954 tstate
= msg
->ops_AttrList
;
955 while((tag
= NextTagItem(&tstate
))) {
956 switch (tag
->ti_Tag
) {
957 case MA_TopLeftMonitor
:
958 data
->topleft
= (Object
*)tag
->ti_Data
;
961 case MA_TopMiddleMonitor
:
962 data
->topmiddle
= (Object
*)tag
->ti_Data
;
965 case MA_TopRightMonitor
:
966 data
->topright
= (Object
*)tag
->ti_Data
;
969 case MA_MiddleLeftMonitor
:
970 data
->middleleft
= (Object
*)tag
->ti_Data
;
973 case MA_MiddleRightMonitor
:
974 data
->middleright
= (Object
*)tag
->ti_Data
;
977 case MA_BottomLeftMonitor
:
978 data
->bottomleft
= (Object
*)tag
->ti_Data
;
981 case MA_BottomMiddleMonitor
:
982 data
->bottommiddle
= (Object
*)tag
->ti_Data
;
985 case MA_BottomRightMonitor
:
986 data
->bottomright
= (Object
*)tag
->ti_Data
;
989 case MA_PointerVisible
:
990 HIDD_Gfx_SetCursorVisible(data
->handle
->gfxhidd
, tag
->ti_Data
);
994 return DoSuperMethodA(cl
, o
, (Msg
)msg
);
997 /*i**************************************************************************/
999 #define Relink(nextAttr, prev, prevAttr, next) \
1001 SetAttrs(prev, nextAttr, next, TAG_DONE); \
1003 SetAttrs(next, prevAttr, prev, TAG_DONE)
1005 IPTR
MonitorClass__OM_DISPOSE(Class
*cl
, Object
*o
, Msg msg
)
1007 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1008 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1009 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
1010 struct IMonitorNode
*data
= INST_DATA(cl
, o
);
1011 struct TagItem tags
[] =
1013 {aHidd_Gfx_ActiveCallBack
, 0},
1017 D(bug("[Monitor] %s()\n", __func__
));
1019 /* Disable activation callback */
1020 OOP_SetAttrs(data
->handle
->gfxhidd
, tags
);
1022 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
1023 Remove((struct Node
*)data
);
1025 /* Remove this monitor from spatial links */
1026 Relink(MA_BottomRightMonitor
, data
->topleft
, MA_TopLeftMonitor
, data
->bottomright
);
1027 Relink(MA_BottomMiddleMonitor
, data
->topmiddle
, MA_TopMiddleMonitor
, data
->bottommiddle
);
1028 Relink(MA_BottomLeftMonitor
, data
->topright
, MA_TopRightMonitor
, data
->bottomleft
);
1029 Relink(MA_MiddleLeftMonitor
, data
->middleright
, MA_MiddleRightMonitor
, data
->middleleft
);
1031 /* If an active monitor is being removed, we should activate another one */
1032 if (GetPrivIBase(IntuitionBase
)->ActiveMonitor
== o
)
1033 ActivateMonitor((Object
*)GetHead(&GetPrivIBase(IntuitionBase
)->MonitorList
), -1, -1, IntuitionBase
);
1035 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
1038 FreeMem(data
->gamma
, 256 * 3);
1040 return DoSuperMethodA(cl
, o
, msg
);
1043 /*i***************************************************************************
1049 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat,
1050 struct BitMap **Store);
1052 DoMethodA(Object *obj, struct msGetRootBitMap *msg);
1057 This method is provided only for source code compatibility with the
1058 MorphOS operating system.
1060 Under MorphOS this method returns a pointer to internal root bitmap of
1061 the display driver corresponding to the specified pixelformat.
1062 Displayable bitmaps are supposed to be created as friends of the root
1065 In AROS displayable bitmaps need complete display mode information and
1066 not only pixelformat. So this method will never be implemented and will
1067 always return a NULL pointer. In order to create a displayable RTG
1068 bitmap on AROS the user needs to supply a taglist with
1069 BMATags_DisplayID specification to the AllocBitMap() function.
1072 obj - A monitor object
1073 MethodID - MM_GetRootBitMap
1074 PixelFormat - A CyberGraphX pixelformat code to get root bitmap for
1075 Store - A storage where root bitmap pointer will be placed.
1087 graphics.library/AllocBitMap()
1091 *****************************************************************************/
1093 IPTR
MonitorClass__MM_GetRootBitMap(Class
*cl
, Object
*obj
, struct msGetRootBitMap
*msg
)
1100 /*i***************************************************************************
1106 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, ULONG *Store);
1108 DoMethodA(Object *obj, struct msQuery3DSupport *msg);
1113 Ask the display driver for type of 3D support for the given
1116 Supplied storage will be filled with one of:
1117 MSQUERY3D_UNKNOWN - Unsupported pixelformat or some internal error
1118 MSQUERY3D_NODRIVER - There is no 3D support for the given
1120 MSQUERY3D_SWDRIVER - A software 3D support is available for the
1122 MSQUERY3D_HWDRIVER - A hardware 3D support is available for the
1126 obj - A monitor object to query
1127 MethodID - MM_Query3DSupport
1128 PixelFormat - A CyberGraphX pixelformat code
1129 Store - A pointer to a storage where return value will be placed
1144 *****************************************************************************/
1146 IPTR
MonitorClass__MM_Query3DSupport(Class
*cl
, Object
*obj
, struct msQuery3DSupport
*msg
)
1148 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1149 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1150 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1151 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1152 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1153 OOP_Object
*pf
= data
->pfobjects
[msg
->PixelFormat
];
1156 if (HIDD_Gfx_QueryHardware3D(data
->handle
->gfxhidd
, pf
))
1157 *msg
->Store
= MSQUERY3D_HWDRIVER
;
1161 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
1163 *msg
->Store
= MSQUERY3D_SWDRIVER
;
1165 *msg
->Store
= MSQUERY3D_NODRIVER
;
1168 *msg
->Store
= MSQUERY3D_UNKNOWN
;
1173 /*i***************************************************************************
1176 MM_GetDefaultGammaTables
1179 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green,
1182 DoMethodA(Object *obj, struct msGetDefaultGammaTables *msg);
1187 Get default gamma correction tables for the monitor.
1190 obj - A monitor object to query
1191 MethodID - MM_GetDefaultGammaTables
1192 Red - A pointer to an array of 256 bytes where gamma correction
1193 data for the red component will be placed. You may specify
1194 a NULL pointer in order to ignore this component.
1195 Green - A pointer to an array of 256 bytes where gamma correction
1196 data for the green component will be placed. You may
1197 specify a NULL pointer in order to ignore this component.
1198 Blue - A pointer to an array of 256 bytes where gamma correction
1199 data for the blue component will be placed. You may specify
1200 a NULL pointer in order to ignore this component.
1212 MM_SetDefaultGammaTables
1216 *****************************************************************************/
1218 void MonitorClass__MM_GetDefaultGammaTables(Class
*cl
, Object
*obj
, struct msGetDefaultGammaTables
*msg
)
1220 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1225 CopyMem(&data
->gamma
[GAMMA_R
], msg
->Red
, 256);
1227 CopyMem(&data
->gamma
[GAMMA_G
], msg
->Green
, 256);
1229 CopyMem(&data
->gamma
[GAMMA_B
], msg
->Blue
, 256);
1233 /*i***************************************************************************
1236 MM_GetDefaultPixelFormat
1239 DoMethod(Object *obj, ULONG MethodID, ULONG Depth, ULONG *Store);
1241 DoMethodA(Object *obj, struct msGetDefaultPixelFormat *msg);
1246 Get the driver's preferred pixelformat for the specified bitmap depth.
1249 obj - A monitor object
1250 MethodID - MM_GetDefaultPixelFormat
1251 Depth - Depth to ask about
1252 Store - A pointer to an ULONG location where CyberGraphX
1253 pixelformat number will be placed. -1 means unsupported
1269 *****************************************************************************/
1271 IPTR
MonitorClass__MM_GetDefaultPixelFormat(Class
*cl
, Object
*obj
, struct msGetDefaultPixelFormat
*msg
)
1273 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1274 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1275 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1276 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1279 for (i
= 0; i
< MONITOR_MAXPIXELFORMATS
; i
++) {
1280 if (data
->pfobjects
[i
]) {
1283 OOP_GetAttr(data
->pfobjects
[i
], aHidd_PixFmt_Depth
, &depth
);
1284 if (depth
== msg
->Depth
) {
1291 if (i
== MONITOR_MAXPIXELFORMATS
)
1297 /*i***************************************************************************
1303 DoMethod(Object *obj, ULONG MethodID, ULONG PointerType, ULONG *Width,
1306 DoMethodA(Object *obj, struct msGetPointerBounds *msg);
1312 Get the maximum allowed size of a mouse pointer sprite.
1315 obj - A monitor object
1316 MethodID - MM_GetPointerBounds
1317 PointerType - Pointer type (one of PointerType_...)
1318 Width - A pointer to an ULONG location where width will be
1320 Height - A pointer to an ULONG location where height will be
1324 FALSE is given pointer type is not supported, TRUE otherwise.
1327 Width and Height are considered undefined if the method returns FALSE.
1338 *****************************************************************************/
1340 IPTR
MonitorClass__MM_GetPointerBounds(Class
*cl
, Object
*obj
, struct msGetPointerBounds
*msg
)
1342 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1343 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1344 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1346 return HIDD_Gfx_GetMaxSpriteSize(data
->handle
->gfxhidd
, msg
->PointerType
, msg
->Width
, msg
->Height
);
1349 /*i***************************************************************************
1355 DoMethod(Object *obj, ULONG MethodID);
1357 DoMethodA(Object *obj, Msg *msg);
1362 Starts screensaver on the monitor.
1364 At the moment AROS has no integrated screensaver support. The method
1365 is considered reserved and not implemented.
1368 obj - A monitor object
1369 MethodID - MM_RunBlanker
1381 MM_EnterPowerSaveMode, MM_ExitBlanker
1385 *****************************************************************************/
1387 IPTR
MonitorClass__MM_RunBlanker(Class
*cl
, Object
*obj
, Msg
*msg
)
1389 /* We have no integrated screensaver support */
1394 /*i***************************************************************************
1397 MM_EnterPowerSaveMode
1400 DoMethod(Object *obj, ULONG MethodID);
1402 DoMethodA(Object *obj, Msg *msg);
1407 Starts power saving mode on the monitor.
1410 obj - A monitor object
1411 MethodID - MM_EnterPowerSaveMode
1423 MM_RunBlanker, MM_ExitBlanker
1426 Current implementation just immediately sets DMPS level to "Off" for
1429 *****************************************************************************/
1431 IPTR
MonitorClass__MM_EnterPowerSaveMode(Class
*cl
, Object
*obj
, Msg
*msg
)
1433 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1434 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1435 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
1436 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1437 struct TagItem tags
[] =
1439 {aHidd_Gfx_DPMSLevel
, vHidd_Gfx_DPMSLevel_Off
},
1443 return OOP_SetAttrs(data
->handle
->gfxhidd
, tags
);
1446 /*i***************************************************************************
1452 DoMethod(Object *obj, ULONG MethodID);
1454 DoMethodA(Object *obj, Msg *msg);
1459 Stops screensaver and/or power saving mode on the monitor.
1462 obj - A monitor object
1463 MethodID - MM_ExitBlanker
1475 MM_EnterPowerSaveMode, MM_RunBlanker
1479 *****************************************************************************/
1481 IPTR
MonitorClass__MM_ExitBlanker(Class
*cl
, Object
*obj
, Msg
*msg
)
1483 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1484 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1485 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
1486 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1487 struct TagItem tags
[] =
1489 {aHidd_Gfx_DPMSLevel
, vHidd_Gfx_DPMSLevel_On
},
1493 return OOP_SetAttrs(data
->handle
->gfxhidd
, tags
);
1496 /*i***************************************************************************
1499 MM_SetDefaultGammaTables
1502 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green,
1505 DoMethodA(Object *obj, struct msSetDefaultGammaTables *msg);
1510 Set default gamma correction tables for the monitor.
1513 obj - A monitor object to query
1514 MethodID - MM_GetDefaultGammaTables
1515 Red - A pointer to an array of 256 bytes where gamma correction
1516 data for the red component is placed. You may specify a
1517 NULL pointer in order to ignore this component.
1518 Green - A pointer to an array of 256 bytes where gamma correction
1519 data for the green component is placed. You may specify a
1520 NULL pointer in order to ignore this component.
1521 Blue - A pointer to an array of 256 bytes where gamma correction
1522 data for the blue component is placed. You may specify a
1523 NULL pointer in order to ignore this component.
1529 This method is AROS-specific.
1536 MM_GetDefaultGammaTables
1540 *****************************************************************************/
1542 IPTR
MonitorClass__MM_SetDefaultGammaTables(Class
*cl
, Object
*obj
, struct msSetDefaultGammaTables
*msg
)
1544 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1545 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1552 CopyMem(msg
->Red
, &data
->gamma
[GAMMA_R
], 256);
1554 CopyMem(msg
->Green
, &data
->gamma
[GAMMA_G
], 256);
1556 CopyMem(msg
->Blue
, &data
->gamma
[GAMMA_B
], 256);
1558 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1560 if (data
->screenGamma
== 3)
1563 * All three components are determined by screen.
1571 * This monitor currently uses default gamma table.
1574 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1576 ret
= HIDD_Gfx_SetGamma(data
->handle
->gfxhidd
, data
->active_r
, data
->active_g
, data
->active_b
);
1579 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1586 /*i**************************************************************************/
1588 ULONG
MonitorClass__MM_GetCompositionFlags(Class
*cl
, Object
*obj
, struct msGetCompositionFlags
*msg
)
1590 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1591 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1592 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1593 struct HIDD_ModeProperties modeprops
;
1595 HIDD_Gfx_ModeProperties(data
->handle
->gfxhidd
, msg
->ModeID
& (!data
->handle
->mask
),
1596 &modeprops
, sizeof(modeprops
));
1597 return modeprops
.CompositionFlags
;
1600 /*i**************************************************************************/
1602 void MonitorClass__MM_SetPointerPos(Class
*cl
, Object
*obj
, struct msSetPointerPos
*msg
)
1604 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1605 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1607 data
->mouseX
= msg
->x
;
1608 data
->mouseY
= msg
->y
;
1609 SetPointerPos(data
, IntuitionBase
);
1612 /*i**************************************************************************/
1614 IPTR
MonitorClass__MM_CheckID(Class
*cl
, Object
*obj
, struct msGetCompositionFlags
*msg
)
1616 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1618 return ((msg
->ModeID
& data
->handle
->mask
) == data
->handle
->id
);
1621 /*i**************************************************************************/
1623 IPTR
MonitorClass__MM_SetPointerShape(Class
*cl
, Object
*obj
, struct msSetPointerShape
*msg
)
1625 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1626 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1627 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1632 bug("[Monitor] %s(0x%p)\n", __func__
, msg
->pointer
);
1633 bug("[Monitor] %s: old pointer 0x%p\n", __func__
, data
->pointer
);
1635 /* Don't do anything if already set */
1636 if (data
->pointer
== msg
->pointer
)
1639 DPOINTER(bug("[Monitor] %s: Display SpriteType = %08x\n", __func__
, data
->SpriteType
);)
1641 bm
= msg
->pointer
->sprite
->es_BitMap
;
1642 /* Currently we don't work with non-hidd sprites */
1643 if (!IS_HIDD_BM(bm
))
1646 res
= HIDD_Gfx_SetCursorShape(data
->handle
->gfxhidd
, HIDD_BM_OBJ(bm
), msg
->pointer
->xoffset
, msg
->pointer
->yoffset
);
1647 DPOINTER(bug("[Monitor] %s: SetCursorShape() returned %d\n", __func__
, res
));
1649 data
->pointer
= msg
->pointer
;
1650 /* This will fix up sprite position if hotspot changed */
1651 SetPointerPos(data
, IntuitionBase
);
1657 void MonitorClass__MM_SetScreenGamma(Class
*cl
, Object
*obj
, struct msSetScreenGamma
*msg
)
1659 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1663 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1664 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1665 struct GammaControl
*gamma
= msg
->gamma
;
1667 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1671 UBYTE screengamma
= 0;
1674 if (gamma
->UseGammaControl
)
1676 if (gamma
->GammaTableR
)
1678 data
->active_r
= gamma
->GammaTableR
;
1681 if (gamma
->GammaTableB
)
1683 data
->active_b
= gamma
->GammaTableB
;
1686 if (gamma
->GammaTableG
)
1688 data
->active_g
= gamma
->GammaTableG
;
1694 * The condition here reflects the following variants:
1695 * 1. We used default gamma and switched to custom one.
1696 * 2. We used custom gamma and switched to default one.
1697 * 3. We changed custom gamma.
1699 if (data
->screenGamma
|| screengamma
|| msg
->force
)
1701 data
->screenGamma
= screengamma
;
1702 HIDD_Gfx_SetGamma(data
->handle
->gfxhidd
, data
->active_r
, data
->active_g
, data
->active_b
);
1706 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1711 * Find the best (closest to the given) depth with 3D support.
1712 * This method will give the priority to hardware 3D.
1714 ULONG
MonitorClass__MM_FindBest3dDepth(Class
*cl
, Object
*obj
, struct msFindBest3dDepth
*msg
)
1716 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1717 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1718 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1719 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1720 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1724 for (i
= 0; i
< MONITOR_MAXPIXELFORMATS
; i
++)
1726 if (data
->pfobjects
[i
])
1730 OOP_GetAttr(data
->pfobjects
[i
], aHidd_PixFmt_Depth
, &depth
);
1732 if (depth
< msg
->depth
)
1734 /* Skip all pixelformats with depth less than requested */
1738 if (HIDD_Gfx_QueryHardware3D(data
->handle
->gfxhidd
, data
->pfobjects
[i
]))
1740 /* Found hardware 3D ? Good. */
1744 if ((depth
> 8) && (swdepth
== -1))
1746 /* This remembers the first depth suitable for software 3D */
1756 * Calculate 3D capability index.
1757 * Used for finding the best 3D monitor.
1759 ULONG
MonitorClass__MM_Calc3dCapability(Class
*cl
, Object
*obj
, Msg msg
)
1761 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1762 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1763 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1764 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1765 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1769 for (i
= 0; i
< MONITOR_MAXPIXELFORMATS
; i
++)
1771 if (data
->pfobjects
[i
])
1773 if (HIDD_Gfx_QueryHardware3D(data
->handle
->gfxhidd
, data
->pfobjects
[i
]))
1776 * Each HW 3D mode scores 2.
1777 * As a result, monitor with one HW 3D mode will beat SW-only 3D.
1781 else if (OOP_GET(data
->pfobjects
[i
], aHidd_PixFmt_Depth
) > 8)
1783 /* Any number of SW 3D modes scores 1 */