2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
7 #include <cybergraphx/cybergraphics.h>
8 #include <hidd/graphics.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"
27 /*i***************************************************************************************
30 --background_monitorclass--
36 In AROS display drivers have associated BOOPSI objects of MONITORCLASS class.
37 This class provides information about relative physical placement of monitors
38 in user's workspace as well as some additional properties.
40 MONITORCLASS is a pseudo name. This class is in fact private to the system and
41 does not have a public ID. The user can't create objects of this class manually.
43 This class is fully compatible with MorphOS starting from v2.6.
45 *****************************************************************************************/
47 Object
*DisplayDriverNotify(APTR obj
, BOOL add
, struct IntuitionBase
*IntuitionBase
)
51 Object
*mon
= NewObject(GetPrivIBase(IntuitionBase
)->monitorclass
, NULL
, MA_MonitorHandle
, obj
, TAG_DONE
);
53 D(bug("[monitorclass] Created monitorclass object 0x%p\n", mon
));
55 /* Install default mouse pointer on the new monitor */
56 Object
*ptr
= GetPrivIBase(IntuitionBase
)->DefaultPointer
;
59 struct SharedPointer
*pointer
;
61 GetAttr(POINTERA_SharedPointer
, ptr
, (IPTR
*)&pointer
);
62 DoMethod(mon
, MM_SetPointerShape
, pointer
);
75 /*i*********************************************************************************/
77 static void SetPointerPos(struct IMonitorNode
*data
, struct IntuitionBase
*IntuitionBase
)
79 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
80 ULONG x
= data
->mouseX
;
81 ULONG y
= data
->mouseY
;
83 DB2(bug("[monitorclass] SetPointerPos(%d, %d), pointer 0x%p\n", x
, y
, data
->pointer
));
86 /* Update sprite position, just for backwards compatibility */
87 data
->pointer
->sprite
->es_SimpleSprite
.x
= x
;
88 data
->pointer
->sprite
->es_SimpleSprite
.y
= y
;
91 DB2(bug("[monitorclass] Physical coordinates: (%d, %d)\n", x
, y
));
92 HIDD_Gfx_SetCursorPos(data
->handle
->gfxhidd
, x
, y
);
95 /*i*********************************************************************************/
97 static void ActivationHandler(Object
*mon
, OOP_Object
*bitmap
)
99 Class
*cl
= OCLASS(mon
);
100 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
102 /* NewMonitor will be picked up by input handler when the next event arrives, so no signals etc */
103 GetPrivIBase(IntuitionBase
)->NewMonitor
= mon
;
106 /*i*********************************************************************************/
108 static void ResetGamma(struct IMonitorNode
*data
)
110 data
->active_r
= &data
->gamma
[GAMMA_R
];
111 data
->active_g
= &data
->gamma
[GAMMA_G
];
112 data
->active_b
= &data
->gamma
[GAMMA_B
];
115 Object
*MonitorClass__OM_NEW(Class
*cl
, Object
*o
, struct opSet
*msg
)
117 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
118 struct Library
*UtilityBase
= GetPrivIBase(IntuitionBase
)->UtilityBase
;
119 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
120 OOP_AttrBase HiddAttrBase
= GetPrivIBase(IntuitionBase
)->HiddAttrBase
;
121 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
122 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
123 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
124 struct MonitorHandle
*handle
= (struct MonitorHandle
*)GetTagData(MA_MonitorHandle
, 0, msg
->ops_AttrList
);
125 HIDDT_ModeID mode
= vHidd_ModeID_Invalid
;
126 struct IMonitorNode
*data
;
127 OOP_Object
*sync
, *pixfmt
;
128 /* Tags order is important because CallBackData needs to be set before
129 function pointer. Otherwise the function can be called with a wrong
131 struct TagItem tags
[] =
133 {aHidd_Gfx_ActiveCallBackData
, 0 },
134 {aHidd_Gfx_ActiveCallBack
, (IPTR
)ActivationHandler
},
138 D(kprintf("[monitorclass] OM_NEW\n"));
143 o
= (Object
*)DoSuperMethodA(cl
, o
, (Msg
)msg
);
147 data
= INST_DATA(cl
, o
);
149 data
->handle
= handle
;
151 /* We can't list driver's pixelformats, we can list only modes. This does not harm however,
152 just some pixelformats will be processed more than once */
153 while ((mode
= HIDD_Gfx_NextModeID(handle
->gfxhidd
, mode
, &sync
, &pixfmt
)) != vHidd_ModeID_Invalid
)
157 OOP_GetAttr(pixfmt
, aHidd_PixFmt_CgxPixFmt
, &cgxpf
);
158 D(bug("[monitorclass] Mode 0x%08lX, CGX pixfmt %ld\n", mode
, cgxpf
));
162 data
->pfobjects
[cgxpf
] = pixfmt
;
163 data
->pixelformats
[cgxpf
] = TRUE
;
167 if (OOP_GET(data
->handle
->gfxhidd
, aHidd_Gfx_SupportsGamma
))
171 D(bug("[monitorclass] Creating gamma table\n"));
173 data
->gamma
= AllocMem(256 * 3, MEMF_ANY
);
176 DoSuperMethod(cl
, o
, OM_DISPOSE
);
180 /* Create default gamma table */
181 for (i
= 0; i
< 256; i
++)
183 data
->gamma
[i
+ GAMMA_R
] = i
;
184 data
->gamma
[i
+ GAMMA_G
] = i
;
185 data
->gamma
[i
+ GAMMA_B
] = i
;
190 OOP_GetAttr(handle
->gfxhidd
, aHidd_Name
, (IPTR
*)&data
->MonitorName
);
192 tags
[0].ti_Data
= (IPTR
)o
;
193 OOP_SetAttrs(handle
->gfxhidd
, tags
);
195 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
196 AddTail((struct List
*)&GetPrivIBase(IntuitionBase
)->MonitorList
, (struct Node
*)data
);
197 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
202 /*i***************************************************************************************
214 Query monitor driver name
226 *****************************************************************************************/
228 /*i***************************************************************************************
240 Query video card hardware manufacturer name
243 Not all drivers may specify manufacturer string. NULL is a valid return value.
253 *****************************************************************************************/
255 /*i***************************************************************************************
267 Query video card hardware's numeric manufacturer ID (which may come from PCI,
271 Not all drivers may have assigned IDs. For example VGA driver and virtual
272 hosted drivers do not associate themselves with any IDs.
283 *****************************************************************************************/
285 /*i***************************************************************************************
297 Query video card hardware's numeric product ID (which may come from PCI, Zorro, etc).
300 Not all drivers may have assigned IDs. For example VGA driver and virtual
301 hosted drivers do not associate themselves with any IDs.
312 *****************************************************************************************/
314 /*i***************************************************************************************
326 Query total size of video card memory in bytes.
339 *****************************************************************************************/
341 /*i***************************************************************************************
353 Query table of supported pixelformats.
355 A returned value is a pointer to static array of ULONGs, one ULONG per CyberGraphX
356 pixelformat. Values of these ULONGs are actually booleans. TRUE value in the array
357 says that the pixelformat is supported, FALSE means it's not.
364 GetAttr(MA_PixelFormats, monitor, (IPTR *)&pfs);
365 if (pfs[PUXFMT_LUT8])
366 printf("The display driver supports LUT8 format\n");
375 *****************************************************************************************/
377 /*i***************************************************************************************
389 Get a pointer to a monitor placed in top-left diagonal direction relative to
392 This attribute is used to describe relative placement of monitors in user's
393 physical environment.
400 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
404 MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
405 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
409 *****************************************************************************************/
411 /*i***************************************************************************************
423 Get a pointer to a monitor placed in top direction relative to the current one.
425 This attribute is used to describe relative placement of monitors in user's
426 physical environment.
433 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
437 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
438 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
442 *****************************************************************************************/
444 /*i***************************************************************************************
456 Get a pointer to a monitor placed in top-right diagonal direction relative to
459 This attribute is used to describe relative placement of monitors in user's
460 physical environment.
467 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
471 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
472 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
476 *****************************************************************************************/
478 /*i***************************************************************************************
490 Get a pointer to a monitor placed in left direction relative to
493 This attribute is used to describe relative placement of monitors in user's
494 physical environment.
501 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
505 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleRightMonitor,
506 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
510 *****************************************************************************************/
512 /*i***************************************************************************************
515 MA_MiddleRightMonitor
524 Get a pointer to a monitor placed in right direction relative to
527 This attribute is used to describe relative placement of monitors in user's
528 physical environment.
535 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
539 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
540 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
544 *****************************************************************************************/
546 /*i***************************************************************************************
558 Get a pointer to a monitor placed in bottom-left diagonal direction relative to
561 This attribute is used to describe relative placement of monitors in user's
562 physical environment.
569 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
573 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
574 MA_MiddleRightMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
578 *****************************************************************************************/
580 /*i***************************************************************************************
583 MA_BottomMiddleMonitor
592 Get a pointer to a monitor placed in bottom direction relative to the current one.
594 This attribute is used to describe relative placement of monitors in user's
595 physical environment.
602 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
606 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
607 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomRightMonitor
611 *****************************************************************************************/
613 /*i***************************************************************************************
616 MA_BottomRightMonitor
625 Get a pointer to a monitor placed in bottom-right diagonal direction relative to
628 This attribute is used to describe relative placement of monitors in user's
629 physical environment.
636 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
640 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
641 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor
645 *****************************************************************************************/
647 /*i***************************************************************************************
659 Query if the display driver supports gamma control
668 MM_GetDefaultGammaTables, MM_SetDefaultGammaTables
672 *****************************************************************************************/
674 /*i***************************************************************************************
686 Query supported mouse pointer sprite formats.
688 The returned value is a combination of the following bit flags:
689 PointerType_3Plus1 - color 0 transparent, 1-3 visible (Amiga(tm) chipset sprite)
690 PointerType_2Plus1 - color 0 transparent, 1 undefined (can be for example clear or
691 inverse), 2-3 visible
692 PointerType_ARGB - Direct color bitmap (hi-color or truecolor, possibly with alpha
706 *****************************************************************************************/
708 /*i***************************************************************************************
720 Query CyberGraphX driver name. It is the name which can be given to
721 cybergraphics.library/BestCModeIDTagList() as CYBRBIDTG_BoardName value.
734 *****************************************************************************************/
736 /*i***************************************************************************************
748 Query video card's memory clock in Hz. 0 is a valid value meaning 'unknown'.
761 *****************************************************************************************/
763 /*i***************************************************************************************
775 Check if this monitor is a window on hosted OS desktop.
777 This means that the host OS is responsible for handling mouse input and display
778 activation. Monitors with this attribute set to TRUE should be ignored by
779 multi-display desktop configuration software.
781 These monitors should have no spatial links to other monitors. Activation of these
782 monitors is done by clicking on their windows on the host's desktop and is handled
783 by the driver itself.
786 This attribute is AROS-specific, it does not exist in MorphOS.
796 *****************************************************************************************/
798 /*i*********************************************************************************/
800 IPTR
MonitorClass__OM_GET(Class
*cl
, Object
*o
, struct opGet
*msg
)
802 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
803 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
804 OOP_AttrBase HiddAttrBase
= GetPrivIBase(IntuitionBase
)->HiddAttrBase
;
805 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
806 struct IMonitorNode
*data
= INST_DATA(cl
, o
);
808 D(kprintf("[monitorclass] OM_GET\n"));
810 switch (msg
->opg_AttrID
)
813 *msg
->opg_Storage
= (IPTR
)data
->MonitorName
;
816 case MA_Manufacturer
:
817 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_ProducerName
, msg
->opg_Storage
);
820 case MA_ManufacturerID
:
821 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Producer
, msg
->opg_Storage
);
825 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Product
, msg
->opg_Storage
);
829 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_MemorySize
, msg
->opg_Storage
);
832 case MA_PixelFormats
:
833 *msg
->opg_Storage
= (IPTR
)data
->pixelformats
;
836 case MA_TopLeftMonitor
:
837 *msg
->opg_Storage
= (IPTR
)data
->topleft
;
840 case MA_TopMiddleMonitor
:
841 *msg
->opg_Storage
= (IPTR
)data
->topmiddle
;
844 case MA_TopRightMonitor
:
845 *msg
->opg_Storage
= (IPTR
)data
->topright
;
848 case MA_MiddleLeftMonitor
:
849 *msg
->opg_Storage
= (IPTR
)data
->middleleft
;
852 case MA_MiddleRightMonitor
:
853 *msg
->opg_Storage
= (IPTR
)data
->middleright
;
856 case MA_BottomLeftMonitor
:
857 *msg
->opg_Storage
= (IPTR
)data
->bottomleft
;
860 case MA_BottomMiddleMonitor
:
861 *msg
->opg_Storage
= (IPTR
)data
->bottommiddle
;
864 case MA_BottomRightMonitor
:
865 *msg
->opg_Storage
= (IPTR
)data
->bottomright
;
868 case MA_GammaControl
:
869 *msg
->opg_Storage
= data
->gamma
? TRUE
: FALSE
;
873 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_HWSpriteTypes
, msg
->opg_Storage
);
877 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_DriverName
, msg
->opg_Storage
);
881 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_MemoryClock
, msg
->opg_Storage
);
885 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_IsWindowed
, msg
->opg_Storage
);
889 *msg
->opg_Storage
= data
->handle
->id
;
893 return DoSuperMethodA(cl
, o
, (Msg
)msg
);
899 /*i*********************************************************************************/
901 IPTR
MonitorClass__OM_SET(Class
*cl
, Object
*o
, struct opSet
*msg
)
903 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
904 struct Library
*UtilityBase
= GetPrivIBase(IntuitionBase
)->UtilityBase
;
905 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
906 struct IMonitorNode
*data
= INST_DATA(cl
, o
);
907 struct TagItem
*tag
, *tstate
;
909 tstate
= msg
->ops_AttrList
;
910 while((tag
= NextTagItem(&tstate
))) {
911 switch (tag
->ti_Tag
) {
912 case MA_TopLeftMonitor
:
913 data
->topleft
= (Object
*)tag
->ti_Data
;
916 case MA_TopMiddleMonitor
:
917 data
->topmiddle
= (Object
*)tag
->ti_Data
;
920 case MA_TopRightMonitor
:
921 data
->topright
= (Object
*)tag
->ti_Data
;
924 case MA_MiddleLeftMonitor
:
925 data
->middleleft
= (Object
*)tag
->ti_Data
;
928 case MA_MiddleRightMonitor
:
929 data
->middleright
= (Object
*)tag
->ti_Data
;
932 case MA_BottomLeftMonitor
:
933 data
->bottomleft
= (Object
*)tag
->ti_Data
;
936 case MA_BottomMiddleMonitor
:
937 data
->bottommiddle
= (Object
*)tag
->ti_Data
;
940 case MA_BottomRightMonitor
:
941 data
->bottomright
= (Object
*)tag
->ti_Data
;
944 case MA_PointerVisible
:
945 HIDD_Gfx_SetCursorVisible(data
->handle
->gfxhidd
, tag
->ti_Data
);
949 return DoSuperMethodA(cl
, o
, (Msg
)msg
);
952 /*i*********************************************************************************/
954 #define Relink(nextAttr, prev, prevAttr, next) \
956 SetAttrs(prev, nextAttr, next, TAG_DONE); \
958 SetAttrs(next, prevAttr, prev, TAG_DONE)
960 IPTR
MonitorClass__OM_DISPOSE(Class
*cl
, Object
*o
, Msg msg
)
962 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
963 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
964 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
965 struct IMonitorNode
*data
= INST_DATA(cl
, o
);
966 struct TagItem tags
[] =
968 {aHidd_Gfx_ActiveCallBack
, 0},
972 D(kprintf("MonitorClass: OM_DISPOSE\n"));
974 /* Disable activation callback */
975 OOP_SetAttrs(data
->handle
->gfxhidd
, tags
);
977 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
978 Remove((struct Node
*)data
);
980 /* Remove this monitor from spatial links */
981 Relink(MA_BottomRightMonitor
, data
->topleft
, MA_TopLeftMonitor
, data
->bottomright
);
982 Relink(MA_BottomMiddleMonitor
, data
->topmiddle
, MA_TopMiddleMonitor
, data
->bottommiddle
);
983 Relink(MA_BottomLeftMonitor
, data
->topright
, MA_TopRightMonitor
, data
->bottomleft
);
984 Relink(MA_MiddleLeftMonitor
, data
->middleright
, MA_MiddleRightMonitor
, data
->middleleft
);
986 /* If an active monitor is being removed, we should activate another one */
987 if (GetPrivIBase(IntuitionBase
)->ActiveMonitor
== o
)
988 ActivateMonitor((Object
*)GetHead(&GetPrivIBase(IntuitionBase
)->MonitorList
), -1, -1, IntuitionBase
);
990 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
993 FreeMem(data
->gamma
, 256 * 3);
995 return DoSuperMethodA(cl
, o
, msg
);
998 /*i**********************************************************************************
1004 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, struct BitMap **Store);
1006 DoMethodA(Object *obj, struct msGetRootBitMap *msg);
1011 This method is provided only for source code compatibility with MorphOS operating
1014 Under MorphOS this method returns a pointer to internal root bitmap of the
1015 display driver corresponding to the specified pixelformat. Displayable bitmaps are
1016 supposed to be created as friends of the root bitmap.
1018 In AROS displayable bitmaps need complete display mode information and not
1019 only pixelformat. So this method will never be implemented and will always return NULL
1020 pointer. In order to create a displayable RTG bitmap on AROS the user needs to supply
1021 a taglist with BMATags_DisplayID specification to AllocBitMap() function.
1024 obj - A monitor object
1025 MethodID - MM_GetRootBitMap
1026 PixelFormat - A CyberGraphX pixelformat code to get root bitmap for
1027 Store - A storage where root bitmap pointer will be placed.
1039 graphics.library/AllocBitMap()
1043 ************************************************************************************/
1045 IPTR
MonitorClass__MM_GetRootBitMap(Class
*cl
, Object
*obj
, struct msGetRootBitMap
*msg
)
1052 /*i**********************************************************************************
1058 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, ULONG *Store);
1060 DoMethodA(Object *obj, struct msQuery3DSupport *msg);
1065 Ask the display driver for type of 3D support for the given pixelformat.
1067 Supplied storage will be filled with one of:
1068 MSQUERY3D_UNKNOWN - Unsupported pixelformat or some internal error
1069 MSQUERY3D_NODRIVER - There is no 3D support for the given pixelformat
1070 MSQUERY3D_SWDRIVER - A software 3D support is available for the given
1072 MSQUERY3D_HWDRIVER - A hardware 3D support is available for the given
1076 obj - A monitor object to query
1077 MethodID - MM_Query3DSupport
1078 PixelFormat - A CyberGraphX pixelformat code
1079 Store - A pointer to a storage where return value will be placed
1094 ************************************************************************************/
1096 IPTR
MonitorClass__MM_Query3DSupport(Class
*cl
, Object
*obj
, struct msQuery3DSupport
*msg
)
1098 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1099 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1100 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1101 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1102 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1103 OOP_Object
*pf
= data
->pfobjects
[msg
->PixelFormat
];
1106 if (HIDD_Gfx_QueryHardware3D(data
->handle
->gfxhidd
, pf
))
1107 *msg
->Store
= MSQUERY3D_HWDRIVER
;
1111 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
1113 *msg
->Store
= MSQUERY3D_SWDRIVER
;
1115 *msg
->Store
= MSQUERY3D_NODRIVER
;
1118 *msg
->Store
= MSQUERY3D_UNKNOWN
;
1123 /*i**********************************************************************************
1126 MM_GetDefaultGammaTables
1129 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green, UBYTE *Blue);
1131 DoMethodA(Object *obj, struct msGetDefaultGammaTables *msg);
1136 Get default gamma correction tables for the monitor
1139 obj - A monitor object to query
1140 MethodID - MM_GetDefaultGammaTables
1141 Red - A pointer to an array of 256 bytes where gamma correction data for
1142 red component will be placed. You may speciy a NULL pointer in order
1143 to ignore this component.
1144 Green - A pointer to an array of 256 bytes where gamma correction data for
1145 green component will be placed. You may speciy a NULL pointer in order
1146 to ignore this component.
1147 Blue - A pointer to an array of 256 bytes where gamma correction data for
1148 blue component will be placed. You may speciy a NULL pointer in order
1149 to ignore this component.
1161 MM_SetDefaultGammaTables
1165 ************************************************************************************/
1167 void MonitorClass__MM_GetDefaultGammaTables(Class
*cl
, Object
*obj
, struct msGetDefaultGammaTables
*msg
)
1169 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1174 CopyMem(&data
->gamma
[GAMMA_R
], msg
->Red
, 256);
1176 CopyMem(&data
->gamma
[GAMMA_G
], msg
->Green
, 256);
1178 CopyMem(&data
->gamma
[GAMMA_B
], msg
->Blue
, 256);
1182 /*i**********************************************************************************
1185 MM_GetDefaultPixelFormat
1188 DoMethod(Object *obj, ULONG MethodID, ULONG Depth, ULONG *Store);
1190 DoMethodA(Object *obj, struct msGetDefaultPixelFormat *msg);
1195 Get driver's preferred pixelformat for specified bitmap depth.
1198 obj - A monitor object
1199 MethodID - MM_GetDefaultPixelFormat
1200 Depth - Depth to ask about
1201 Store - A pointer to an ULONG location where CyberGraphX pixelformat
1202 number will be placed. -1 means unsupported depth.
1217 ************************************************************************************/
1219 IPTR
MonitorClass__MM_GetDefaultPixelFormat(Class
*cl
, Object
*obj
, struct msGetDefaultPixelFormat
*msg
)
1221 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1222 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1223 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1224 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1227 for (i
= 0; i
< MONITOR_MAXPIXELFORMATS
; i
++) {
1228 if (data
->pfobjects
[i
]) {
1231 OOP_GetAttr(data
->pfobjects
[i
], aHidd_PixFmt_Depth
, &depth
);
1232 if (depth
== msg
->Depth
) {
1239 if (i
== MONITOR_MAXPIXELFORMATS
)
1245 /*i**********************************************************************************
1251 DoMethod(Object *obj, ULONG MethodID, ULONG PointerType, ULONG *Width, ULONG *Height);
1253 DoMethodA(Object *obj, struct msGetPointerBounds *msg);
1259 Get maximum allowed size of mouse pointer sprite.
1262 obj - A monitor object
1263 MethodID - MM_GetPointerBounds
1264 PointerType - Pointer type (one of PointerType_...)
1265 Width - A pointer to an ULONG location where width will be placed.
1266 Height - A pointer to an ULONG location where height will be placed.
1269 FALSE is given pointer type is not supported, TRUE otherwise.
1272 Width and Height are considered undefined if the method returns FALSE.
1283 ************************************************************************************/
1285 IPTR
MonitorClass__MM_GetPointerBounds(Class
*cl
, Object
*obj
, struct msGetPointerBounds
*msg
)
1287 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1288 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1289 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1291 return HIDD_Gfx_GetMaxSpriteSize(data
->handle
->gfxhidd
, msg
->PointerType
, msg
->Width
, msg
->Height
);
1294 /*i**********************************************************************************
1300 DoMethod(Object *obj, ULONG MethodID);
1302 DoMethodA(Object *obj, Msg *msg);
1307 Starts screensaver on the monitor.
1309 At the moment AROS has no integrated screensaver support. The method is
1310 considered reserved and not implemented.
1313 obj - A monitor object
1314 MethodID - MM_RunBlanker
1326 MM_EnterPowerSaveMode, MM_ExitBlanker
1330 ************************************************************************************/
1332 IPTR
MonitorClass__MM_RunBlanker(Class
*cl
, Object
*obj
, Msg
*msg
)
1334 /* We have no integrated screensaver support */
1339 /*i**********************************************************************************
1342 MM_EnterPowerSaveMode
1345 DoMethod(Object *obj, ULONG MethodID);
1347 DoMethodA(Object *obj, Msg *msg);
1352 Starts power saving mode on the monitor.
1355 obj - A monitor object
1356 MethodID - MM_EnterPowerSaveMode
1368 MM_RunBlanker, MM_ExitBlanker
1371 Current implementation just immediately sets DMPS level to "Off" for the
1374 ************************************************************************************/
1376 IPTR
MonitorClass__MM_EnterPowerSaveMode(Class
*cl
, Object
*obj
, Msg
*msg
)
1378 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1379 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1380 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
1381 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1382 struct TagItem tags
[] =
1384 {aHidd_Gfx_DPMSLevel
, vHidd_Gfx_DPMSLevel_Off
},
1388 return OOP_SetAttrs(data
->handle
->gfxhidd
, tags
);
1391 /*i**********************************************************************************
1397 DoMethod(Object *obj, ULONG MethodID);
1399 DoMethodA(Object *obj, Msg *msg);
1404 Stops screensaver and/or power saving mode on the monitor.
1407 obj - A monitor object
1408 MethodID - MM_ExitBlanker
1420 MM_EnterPowerSaveMode, MM_RunBlanker
1424 ************************************************************************************/
1426 IPTR
MonitorClass__MM_ExitBlanker(Class
*cl
, Object
*obj
, Msg
*msg
)
1428 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1429 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1430 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
1431 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1432 struct TagItem tags
[] =
1434 {aHidd_Gfx_DPMSLevel
, vHidd_Gfx_DPMSLevel_On
},
1438 return OOP_SetAttrs(data
->handle
->gfxhidd
, tags
);
1441 /*i**********************************************************************************
1444 MM_SetDefaultGammaTables
1447 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green, UBYTE *Blue);
1449 DoMethodA(Object *obj, struct msSetDefaultGammaTables *msg);
1454 Set default gamma correction tables for the monitor
1457 obj - A monitor object to query
1458 MethodID - MM_GetDefaultGammaTables
1459 Red - A pointer to an array of 256 bytes where gamma correction data for
1460 red component is placed. You may speciy a NULL pointer in order
1461 to ignore this component.
1462 Green - A pointer to an array of 256 bytes where gamma correction data for
1463 green component is placed. You may speciy a NULL pointer in order
1464 to ignore this component.
1465 Blue - A pointer to an array of 256 bytes where gamma correction data for
1466 blue component is placed. You may speciy a NULL pointer in order
1467 to ignore this component.
1473 This method is AROS-specific.
1480 MM_GetDefaultGammaTables
1484 ************************************************************************************/
1486 IPTR
MonitorClass__MM_SetDefaultGammaTables(Class
*cl
, Object
*obj
, struct msSetDefaultGammaTables
*msg
)
1488 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1489 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1496 CopyMem(msg
->Red
, &data
->gamma
[GAMMA_R
], 256);
1498 CopyMem(msg
->Green
, &data
->gamma
[GAMMA_G
], 256);
1500 CopyMem(msg
->Blue
, &data
->gamma
[GAMMA_B
], 256);
1502 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1504 if (data
->screenGamma
== 3)
1507 * All three components are determined by screen.
1515 * This monitor currently uses default gamma table.
1518 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1520 ret
= HIDD_Gfx_SetGamma(data
->handle
->gfxhidd
, data
->active_r
, data
->active_g
, data
->active_b
);
1523 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1530 /*i**********************************************************************************/
1532 ULONG
MonitorClass__MM_GetCompositionFlags(Class
*cl
, Object
*obj
, struct msGetCompositionFlags
*msg
)
1534 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1535 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1536 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1537 struct HIDD_ModeProperties modeprops
;
1539 HIDD_Gfx_ModeProperties(data
->handle
->gfxhidd
, msg
->ModeID
& (!data
->handle
->mask
),
1540 &modeprops
, sizeof(modeprops
));
1541 return modeprops
.CompositionFlags
;
1544 /*i**********************************************************************************/
1546 void MonitorClass__MM_SetPointerPos(Class
*cl
, Object
*obj
, struct msSetPointerPos
*msg
)
1548 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1549 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1551 data
->mouseX
= msg
->x
;
1552 data
->mouseY
= msg
->y
;
1553 SetPointerPos(data
, IntuitionBase
);
1556 /*i**********************************************************************************/
1558 IPTR
MonitorClass__MM_CheckID(Class
*cl
, Object
*obj
, struct msGetCompositionFlags
*msg
)
1560 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1562 return ((msg
->ModeID
& data
->handle
->mask
) == data
->handle
->id
);
1565 /*i**********************************************************************************/
1567 IPTR
MonitorClass__MM_SetPointerShape(Class
*cl
, Object
*obj
, struct msSetPointerShape
*msg
)
1569 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1570 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1571 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1575 D(bug("[monitorclass] SetPointerShape(0x%p), old pointer 0x%p\n", msg
->pointer
, data
->pointer
));
1576 /* Don't do anything if already set */
1577 if (data
->pointer
== msg
->pointer
)
1580 bm
= msg
->pointer
->sprite
->es_BitMap
;
1581 /* Currently we don't work with non-hidd sprites */
1582 if (!IS_HIDD_BM(bm
))
1585 res
= HIDD_Gfx_SetCursorShape(data
->handle
->gfxhidd
, HIDD_BM_OBJ(bm
), msg
->pointer
->xoffset
, msg
->pointer
->yoffset
);
1586 D(bug("[monitorclass] SetPointerShape() returned %d\n", res
));
1588 data
->pointer
= msg
->pointer
;
1589 /* This will fix up sprite position if hotspot changed */
1590 SetPointerPos(data
, IntuitionBase
);
1596 void MonitorClass__MM_SetScreenGamma(Class
*cl
, Object
*obj
, struct msSetScreenGamma
*msg
)
1598 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1602 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1603 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1604 struct GammaControl
*gamma
= msg
->gamma
;
1606 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1610 UBYTE screengamma
= 0;
1613 if (gamma
->UseGammaControl
)
1615 if (gamma
->GammaTableR
)
1617 data
->active_r
= gamma
->GammaTableR
;
1620 if (gamma
->GammaTableB
)
1622 data
->active_b
= gamma
->GammaTableB
;
1625 if (gamma
->GammaTableG
);
1627 data
->active_g
= gamma
->GammaTableG
;
1633 * The condition here reflects the following variants:
1634 * 1. We used default gamma and switched to custom one.
1635 * 2. We used custom gamma and switched to default one.
1636 * 3. We changed custom gamma.
1638 if (data
->screenGamma
|| screengamma
|| msg
->force
)
1640 data
->screenGamma
= screengamma
;
1641 HIDD_Gfx_SetGamma(data
->handle
->gfxhidd
, data
->active_r
, data
->active_g
, data
->active_b
);
1645 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1650 * Find the best (closest to the given) depth with 3D support.
1651 * This method will give the priority to hardware 3D.
1653 ULONG
MonitorClass__MM_FindBest3dDepth(Class
*cl
, Object
*obj
, struct msFindBest3dDepth
*msg
)
1655 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1656 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1657 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1658 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1659 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1663 for (i
= 0; i
< MONITOR_MAXPIXELFORMATS
; i
++)
1665 if (data
->pfobjects
[i
])
1669 OOP_GetAttr(data
->pfobjects
[i
], aHidd_PixFmt_Depth
, &depth
);
1671 if (depth
< msg
->depth
)
1673 /* Skip all pixelformats with depth less than requested */
1677 if (HIDD_Gfx_QueryHardware3D(data
->handle
->gfxhidd
, data
->pfobjects
[i
]))
1679 /* Found hardware 3D ? Good. */
1683 if ((depth
> 8) && (swdepth
== -1))
1685 /* This remembers the first depth suitable for software 3D */
1695 * Calculate 3D capability index.
1696 * Used for finding the best 3D monitor.
1698 ULONG
MonitorClass__MM_Calc3dCapability(Class
*cl
, Object
*obj
, Msg msg
)
1700 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1701 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1702 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1703 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1704 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1708 for (i
= 0; i
< MONITOR_MAXPIXELFORMATS
; i
++)
1710 if (data
->pfobjects
[i
])
1712 if (HIDD_Gfx_QueryHardware3D(data
->handle
->gfxhidd
, data
->pfobjects
[i
]))
1715 * Each HW 3D mode scores 2.
1716 * As a result, monitor with one HW 3D mode will beat SW-only 3D.
1720 else if (OOP_GET(data
->pfobjects
[i
], aHidd_PixFmt_Depth
) > 8)
1722 /* Any number of SW 3D modes scores 1 */