exec.library: Add some ExecLog style debugging to interrupt management
[AROS.git] / rom / intuition / monitorclass.c
blob854bfd446b379b8aa93ef5b019f5964bde2e04c1
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <cybergraphx/cybergraphics.h>
8 #include <hidd/graphics.h>
9 #include <hidd/hidd.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***************************************************************************************
29 NAME
30 --background_monitorclass--
32 LOCATION
33 MONITORCLASS
35 NOTES
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)
49 if (add)
51 Object *mon = NewObject(GetPrivIBase(IntuitionBase)->monitorclass, NULL, MA_MonitorHandle, obj, TAG_DONE);
53 D(bug("[monitorclass] Created monitorclass object 0x%p\n", mon));
54 if (mon) {
55 /* Install default mouse pointer on the new monitor */
56 Object *ptr = GetPrivIBase(IntuitionBase)->DefaultPointer;
58 if (ptr) {
59 struct SharedPointer *pointer;
61 GetAttr(POINTERA_SharedPointer, ptr, (IPTR *)&pointer);
62 DoMethod(mon, MM_SetPointerShape, pointer);
66 return mon;
68 else
70 DisposeObject(obj);
71 return NULL;
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));
84 if (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
130 pointer. */
131 struct TagItem tags[] =
133 {aHidd_Gfx_ActiveCallBackData, 0 },
134 {aHidd_Gfx_ActiveCallBack , (IPTR)ActivationHandler},
135 {TAG_DONE , 0 }
138 D(kprintf("[monitorclass] OM_NEW\n"));
140 if (!handle)
141 return NULL;
143 o = (Object *)DoSuperMethodA(cl, o, (Msg)msg);
144 if (!o)
145 return NULL;
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)
155 IPTR cgxpf;
157 OOP_GetAttr(pixfmt, aHidd_PixFmt_CgxPixFmt, &cgxpf);
158 D(bug("[monitorclass] Mode 0x%08lX, CGX pixfmt %ld\n", mode, cgxpf));
160 if (cgxpf != -1)
162 data->pfobjects[cgxpf] = pixfmt;
163 data->pixelformats[cgxpf] = TRUE;
167 if (OOP_GET(data->handle->gfxhidd, aHidd_Gfx_SupportsGamma))
169 UWORD i;
171 D(bug("[monitorclass] Creating gamma table\n"));
173 data->gamma = AllocMem(256 * 3, MEMF_ANY);
174 if (!data->gamma)
176 DoSuperMethod(cl, o, OM_DISPOSE);
177 return NULL;
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;
187 ResetGamma(data);
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);
199 return o;
202 /*i***************************************************************************************
204 NAME
205 MA_MonitorName
207 SYNOPSIS
208 [..G], STRPTR
210 LOCATION
211 MONITORCLASS
213 FUNCTION
214 Query monitor driver name
216 NOTES
218 EXAMPLE
220 BUGS
222 SEE ALSO
224 INTERNALS
226 *****************************************************************************************/
228 /*i***************************************************************************************
230 NAME
231 MA_Manufacturer
233 SYNOPSIS
234 [..G], STRPTR
236 LOCATION
237 MONITORCLASS
239 FUNCTION
240 Query video card hardware manufacturer name
242 NOTES
243 Not all drivers may specify manufacturer string. NULL is a valid return value.
245 EXAMPLE
247 BUGS
249 SEE ALSO
251 INTERNALS
253 *****************************************************************************************/
255 /*i***************************************************************************************
257 NAME
258 MA_ManufacturerID
260 SYNOPSIS
261 [..G], ULONG
263 LOCATION
264 MONITORCLASS
266 FUNCTION
267 Query video card hardware's numeric manufacturer ID (which may come from PCI,
268 Zorro, etc).
270 NOTES
271 Not all drivers may have assigned IDs. For example VGA driver and virtual
272 hosted drivers do not associate themselves with any IDs.
274 EXAMPLE
276 BUGS
278 SEE ALSO
279 MA_ProductID
281 INTERNALS
283 *****************************************************************************************/
285 /*i***************************************************************************************
287 NAME
288 MA_ProductID
290 SYNOPSIS
291 [..G], ULONG
293 LOCATION
294 MONITORCLASS
296 FUNCTION
297 Query video card hardware's numeric product ID (which may come from PCI, Zorro, etc).
299 NOTES
300 Not all drivers may have assigned IDs. For example VGA driver and virtual
301 hosted drivers do not associate themselves with any IDs.
303 EXAMPLE
305 BUGS
307 SEE ALSO
308 MA_ManufacturerID
310 INTERNALS
312 *****************************************************************************************/
314 /*i***************************************************************************************
316 NAME
317 MA_MemorySize
319 SYNOPSIS
320 [..G], ULONG
322 LOCATION
323 MONITORCLASS
325 FUNCTION
326 Query total size of video card memory in bytes.
328 NOTES
330 EXAMPLE
332 BUGS
334 SEE ALSO
335 MA_MemoryClock
337 INTERNALS
339 *****************************************************************************************/
341 /*i***************************************************************************************
343 NAME
344 MA_PixelFormats
346 SYNOPSIS
347 [..G], ULONG *
349 LOCATION
350 MONITORCLASS
352 FUNCTION
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.
359 NOTES
361 EXAMPLE
362 ULONG *pfs;
364 GetAttr(MA_PixelFormats, monitor, (IPTR *)&pfs);
365 if (pfs[PUXFMT_LUT8])
366 printf("The display driver supports LUT8 format\n");
368 BUGS
370 SEE ALSO
371 MA_ManufacturerID
373 INTERNALS
375 *****************************************************************************************/
377 /*i***************************************************************************************
379 NAME
380 MA_TopLeftMonitor
382 SYNOPSIS
383 [.SG], Object *
385 LOCATION
386 MONITORCLASS
388 FUNCTION
389 Get a pointer to a monitor placed in top-left diagonal direction relative to
390 the current one.
392 This attribute is used to describe relative placement of monitors in user's
393 physical environment.
395 NOTES
397 EXAMPLE
399 BUGS
400 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
401 monitor object.
403 SEE ALSO
404 MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
405 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
407 INTERNALS
409 *****************************************************************************************/
411 /*i***************************************************************************************
413 NAME
414 MA_TopMiddleMonitor
416 SYNOPSIS
417 [.SG], Object *
419 LOCATION
420 MONITORCLASS
422 FUNCTION
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.
428 NOTES
430 EXAMPLE
432 BUGS
433 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
434 monitor object.
436 SEE ALSO
437 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
438 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
440 INTERNALS
442 *****************************************************************************************/
444 /*i***************************************************************************************
446 NAME
447 MA_TopRightMonitor
449 SYNOPSIS
450 [.SG], Object *
452 LOCATION
453 MONITORCLASS
455 FUNCTION
456 Get a pointer to a monitor placed in top-right diagonal direction relative to
457 the current one.
459 This attribute is used to describe relative placement of monitors in user's
460 physical environment.
462 NOTES
464 EXAMPLE
466 BUGS
467 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
468 monitor object.
470 SEE ALSO
471 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
472 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
474 INTERNALS
476 *****************************************************************************************/
478 /*i***************************************************************************************
480 NAME
481 MA_MiddleLeftMonitor
483 SYNOPSIS
484 [.SG], Object *
486 LOCATION
487 MONITORCLASS
489 FUNCTION
490 Get a pointer to a monitor placed in left direction relative to
491 the current one.
493 This attribute is used to describe relative placement of monitors in user's
494 physical environment.
496 NOTES
498 EXAMPLE
500 BUGS
501 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
502 monitor object.
504 SEE ALSO
505 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleRightMonitor,
506 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
508 INTERNALS
510 *****************************************************************************************/
512 /*i***************************************************************************************
514 NAME
515 MA_MiddleRightMonitor
517 SYNOPSIS
518 [.SG], Object *
520 LOCATION
521 MONITORCLASS
523 FUNCTION
524 Get a pointer to a monitor placed in right direction relative to
525 the current one.
527 This attribute is used to describe relative placement of monitors in user's
528 physical environment.
530 NOTES
532 EXAMPLE
534 BUGS
535 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
536 monitor object.
538 SEE ALSO
539 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
540 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
542 INTERNALS
544 *****************************************************************************************/
546 /*i***************************************************************************************
548 NAME
549 MA_BottomLeftMonitor
551 SYNOPSIS
552 [.SG], Object *
554 LOCATION
555 MONITORCLASS
557 FUNCTION
558 Get a pointer to a monitor placed in bottom-left diagonal direction relative to
559 the current one.
561 This attribute is used to describe relative placement of monitors in user's
562 physical environment.
564 NOTES
566 EXAMPLE
568 BUGS
569 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
570 monitor object.
572 SEE ALSO
573 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
574 MA_MiddleRightMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
576 INTERNALS
578 *****************************************************************************************/
580 /*i***************************************************************************************
582 NAME
583 MA_BottomMiddleMonitor
585 SYNOPSIS
586 [.SG], Object *
588 LOCATION
589 MONITORCLASS
591 FUNCTION
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.
597 NOTES
599 EXAMPLE
601 BUGS
602 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
603 monitor object.
605 SEE ALSO
606 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
607 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomRightMonitor
609 INTERNALS
611 *****************************************************************************************/
613 /*i***************************************************************************************
615 NAME
616 MA_BottomRightMonitor
618 SYNOPSIS
619 [.SG], Object *
621 LOCATION
622 MONITORCLASS
624 FUNCTION
625 Get a pointer to a monitor placed in bottom-right diagonal direction relative to
626 the current one.
628 This attribute is used to describe relative placement of monitors in user's
629 physical environment.
631 NOTES
633 EXAMPLE
635 BUGS
636 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
637 monitor object.
639 SEE ALSO
640 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
641 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor
643 INTERNALS
645 *****************************************************************************************/
647 /*i***************************************************************************************
649 NAME
650 MA_GammaControl
652 SYNOPSIS
653 [..G], BOOL
655 LOCATION
656 MONITORCLASS
658 FUNCTION
659 Query if the display driver supports gamma control
661 NOTES
663 EXAMPLE
665 BUGS
667 SEE ALSO
668 MM_GetDefaultGammaTables, MM_SetDefaultGammaTables
670 INTERNALS
672 *****************************************************************************************/
674 /*i***************************************************************************************
676 NAME
677 MA_PointerType
679 SYNOPSIS
680 [..G], ULONG
682 LOCATION
683 MONITORCLASS
685 FUNCTION
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
693 channel
695 NOTES
697 EXAMPLE
699 BUGS
701 SEE ALSO
702 MM_GetPointerBounds
704 INTERNALS
706 *****************************************************************************************/
708 /*i***************************************************************************************
710 NAME
711 MA_DriverName
713 SYNOPSIS
714 [..G], STRPTR
716 LOCATION
717 MONITORCLASS
719 FUNCTION
720 Query CyberGraphX driver name. It is the name which can be given to
721 cybergraphics.library/BestCModeIDTagList() as CYBRBIDTG_BoardName value.
723 NOTES
725 EXAMPLE
727 BUGS
729 SEE ALSO
730 MM_GetPointerBounds
732 INTERNALS
734 *****************************************************************************************/
736 /*i***************************************************************************************
738 NAME
739 MA_MemoryClock
741 SYNOPSIS
742 [..G], ULONG
744 LOCATION
745 MONITORCLASS
747 FUNCTION
748 Query video card's memory clock in Hz. 0 is a valid value meaning 'unknown'.
750 NOTES
752 EXAMPLE
754 BUGS
756 SEE ALSO
757 MA_MemorySize
759 INTERNALS
761 *****************************************************************************************/
763 /*i***************************************************************************************
765 NAME
766 MA_Windowed
768 SYNOPSIS
769 [..G], BOOL
771 LOCATION
772 MONITORCLASS
774 FUNCTION
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.
785 NOTES
786 This attribute is AROS-specific, it does not exist in MorphOS.
788 EXAMPLE
790 BUGS
792 SEE ALSO
794 INTERNALS
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)
812 case MA_MonitorName:
813 *msg->opg_Storage = (IPTR)data->MonitorName;
814 break;
816 case MA_Manufacturer:
817 OOP_GetAttr(data->handle->gfxhidd, aHidd_ProducerName, msg->opg_Storage);
818 break;
820 case MA_ManufacturerID:
821 OOP_GetAttr(data->handle->gfxhidd, aHidd_Producer, msg->opg_Storage);
822 break;
824 case MA_ProductID:
825 OOP_GetAttr(data->handle->gfxhidd, aHidd_Product, msg->opg_Storage);
826 break;
828 case MA_MemorySize:
829 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_MemorySize, msg->opg_Storage);
830 break;
832 case MA_PixelFormats:
833 *msg->opg_Storage = (IPTR)data->pixelformats;
834 break;
836 case MA_TopLeftMonitor:
837 *msg->opg_Storage = (IPTR)data->topleft;
838 break;
840 case MA_TopMiddleMonitor:
841 *msg->opg_Storage = (IPTR)data->topmiddle;
842 break;
844 case MA_TopRightMonitor:
845 *msg->opg_Storage = (IPTR)data->topright;
846 break;
848 case MA_MiddleLeftMonitor:
849 *msg->opg_Storage = (IPTR)data->middleleft;
850 break;
852 case MA_MiddleRightMonitor:
853 *msg->opg_Storage = (IPTR)data->middleright;
854 break;
856 case MA_BottomLeftMonitor:
857 *msg->opg_Storage = (IPTR)data->bottomleft;
858 break;
860 case MA_BottomMiddleMonitor:
861 *msg->opg_Storage = (IPTR)data->bottommiddle;
862 break;
864 case MA_BottomRightMonitor:
865 *msg->opg_Storage = (IPTR)data->bottomright;
866 break;
868 case MA_GammaControl:
869 *msg->opg_Storage = data->gamma ? TRUE : FALSE;
870 break;
872 case MA_PointerType:
873 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_HWSpriteTypes, msg->opg_Storage);
874 break;
876 case MA_DriverName:
877 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_DriverName, msg->opg_Storage);
878 break;
880 case MA_MemoryClock:
881 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_MemoryClock, msg->opg_Storage);
882 break;
884 case MA_Windowed:
885 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_IsWindowed, msg->opg_Storage);
886 break;
888 case MA_MonitorID:
889 *msg->opg_Storage = data->handle->id;
890 break;
892 default:
893 return DoSuperMethodA(cl, o, (Msg)msg);
896 return TRUE;
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;
914 break;
916 case MA_TopMiddleMonitor:
917 data->topmiddle = (Object *)tag->ti_Data;
918 break;
920 case MA_TopRightMonitor:
921 data->topright = (Object *)tag->ti_Data;
922 break;
924 case MA_MiddleLeftMonitor:
925 data->middleleft = (Object *)tag->ti_Data;
926 break;
928 case MA_MiddleRightMonitor:
929 data->middleright = (Object *)tag->ti_Data;
930 break;
932 case MA_BottomLeftMonitor:
933 data->bottomleft = (Object *)tag->ti_Data;
934 break;
936 case MA_BottomMiddleMonitor:
937 data->bottommiddle = (Object *)tag->ti_Data;
938 break;
940 case MA_BottomRightMonitor:
941 data->bottomright = (Object *)tag->ti_Data;
942 break;
944 case MA_PointerVisible:
945 HIDD_Gfx_SetCursorVisible(data->handle->gfxhidd, tag->ti_Data);
946 break;
949 return DoSuperMethodA(cl, o, (Msg)msg);
952 /*i*********************************************************************************/
954 #define Relink(nextAttr, prev, prevAttr, next) \
955 if (prev) \
956 SetAttrs(prev, nextAttr, next, TAG_DONE); \
957 if (next) \
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},
969 {TAG_DONE , 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);
992 if (data->gamma)
993 FreeMem(data->gamma, 256 * 3);
995 return DoSuperMethodA(cl, o, msg);
998 /*i**********************************************************************************
1000 NAME
1001 MM_GetRootBitMap
1003 SYNOPSIS
1004 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, struct BitMap **Store);
1006 DoMethodA(Object *obj, struct msGetRootBitMap *msg);
1008 LOCATION
1010 FUNCTION
1011 This method is provided only for source code compatibility with MorphOS operating
1012 system.
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.
1023 INPUTS
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.
1029 RESULT
1030 Undefined.
1032 NOTES
1034 EXAMPLE
1036 BUGS
1038 SEE ALSO
1039 graphics.library/AllocBitMap()
1041 INTERNALS
1043 ************************************************************************************/
1045 IPTR MonitorClass__MM_GetRootBitMap(Class *cl, Object *obj, struct msGetRootBitMap *msg)
1047 *msg->Store = NULL;
1049 return 0;
1052 /*i**********************************************************************************
1054 NAME
1055 MM_Query3DSupport
1057 SYNOPSIS
1058 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, ULONG *Store);
1060 DoMethodA(Object *obj, struct msQuery3DSupport *msg);
1062 LOCATION
1064 FUNCTION
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
1071 pixelformat
1072 MSQUERY3D_HWDRIVER - A hardware 3D support is available for the given
1073 pixelformat
1075 INPUTS
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
1081 RESULT
1082 Undefined.
1084 NOTES
1086 EXAMPLE
1088 BUGS
1090 SEE ALSO
1092 INTERNALS
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];
1105 if (pf) {
1106 if (HIDD_Gfx_QueryHardware3D(data->handle->gfxhidd, pf))
1107 *msg->Store = MSQUERY3D_HWDRIVER;
1108 else {
1109 IPTR depth;
1111 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
1112 if (depth > 8)
1113 *msg->Store = MSQUERY3D_SWDRIVER;
1114 else
1115 *msg->Store = MSQUERY3D_NODRIVER;
1117 } else
1118 *msg->Store = MSQUERY3D_UNKNOWN;
1120 return *msg->Store;
1123 /*i**********************************************************************************
1125 NAME
1126 MM_GetDefaultGammaTables
1128 SYNOPSIS
1129 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green, UBYTE *Blue);
1131 DoMethodA(Object *obj, struct msGetDefaultGammaTables *msg);
1133 LOCATION
1135 FUNCTION
1136 Get default gamma correction tables for the monitor
1138 INPUTS
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.
1151 RESULT
1152 Undefined.
1154 NOTES
1156 EXAMPLE
1158 BUGS
1160 SEE ALSO
1161 MM_SetDefaultGammaTables
1163 INTERNALS
1165 ************************************************************************************/
1167 void MonitorClass__MM_GetDefaultGammaTables(Class *cl, Object *obj, struct msGetDefaultGammaTables *msg)
1169 struct IMonitorNode *data = INST_DATA(cl, obj);
1171 if (data->gamma)
1173 if (msg->Red)
1174 CopyMem(&data->gamma[GAMMA_R], msg->Red, 256);
1175 if (msg->Green)
1176 CopyMem(&data->gamma[GAMMA_G], msg->Green, 256);
1177 if (msg->Blue)
1178 CopyMem(&data->gamma[GAMMA_B], msg->Blue, 256);
1182 /*i**********************************************************************************
1184 NAME
1185 MM_GetDefaultPixelFormat
1187 SYNOPSIS
1188 DoMethod(Object *obj, ULONG MethodID, ULONG Depth, ULONG *Store);
1190 DoMethodA(Object *obj, struct msGetDefaultPixelFormat *msg);
1192 LOCATION
1194 FUNCTION
1195 Get driver's preferred pixelformat for specified bitmap depth.
1197 INPUTS
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.
1204 RESULT
1205 Undefined.
1207 NOTES
1209 EXAMPLE
1211 BUGS
1213 SEE ALSO
1215 INTERNALS
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);
1225 ULONG i;
1227 for (i = 0; i < MONITOR_MAXPIXELFORMATS; i++) {
1228 if (data->pfobjects[i]) {
1229 IPTR depth;
1231 OOP_GetAttr(data->pfobjects[i], aHidd_PixFmt_Depth, &depth);
1232 if (depth == msg->Depth) {
1233 *msg->Store = i;
1234 break;
1239 if (i == MONITOR_MAXPIXELFORMATS)
1240 *msg->Store = -1;
1242 return *msg->Store;
1245 /*i**********************************************************************************
1247 NAME
1248 MM_GetPointerBounds
1250 SYNOPSIS
1251 DoMethod(Object *obj, ULONG MethodID, ULONG PointerType, ULONG *Width, ULONG *Height);
1253 DoMethodA(Object *obj, struct msGetPointerBounds *msg);
1255 LOCATION
1256 monitorclass
1258 FUNCTION
1259 Get maximum allowed size of mouse pointer sprite.
1261 INPUTS
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.
1268 RESULT
1269 FALSE is given pointer type is not supported, TRUE otherwise.
1271 NOTES
1272 Width and Height are considered undefined if the method returns FALSE.
1274 EXAMPLE
1276 BUGS
1278 SEE ALSO
1279 MA_PointerType
1281 INTERNALS
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**********************************************************************************
1296 NAME
1297 MM_RunBlanker
1299 SYNOPSIS
1300 DoMethod(Object *obj, ULONG MethodID);
1302 DoMethodA(Object *obj, Msg *msg);
1304 LOCATION
1306 FUNCTION
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.
1312 INPUTS
1313 obj - A monitor object
1314 MethodID - MM_RunBlanker
1316 RESULT
1317 Undefined.
1319 NOTES
1321 EXAMPLE
1323 BUGS
1325 SEE ALSO
1326 MM_EnterPowerSaveMode, MM_ExitBlanker
1328 INTERNALS
1330 ************************************************************************************/
1332 IPTR MonitorClass__MM_RunBlanker(Class *cl, Object *obj, Msg *msg)
1334 /* We have no integrated screensaver support */
1336 return FALSE;
1339 /*i**********************************************************************************
1341 NAME
1342 MM_EnterPowerSaveMode
1344 SYNOPSIS
1345 DoMethod(Object *obj, ULONG MethodID);
1347 DoMethodA(Object *obj, Msg *msg);
1349 LOCATION
1351 FUNCTION
1352 Starts power saving mode on the monitor.
1354 INPUTS
1355 obj - A monitor object
1356 MethodID - MM_EnterPowerSaveMode
1358 RESULT
1359 Undefined.
1361 NOTES
1363 EXAMPLE
1365 BUGS
1367 SEE ALSO
1368 MM_RunBlanker, MM_ExitBlanker
1370 INTERNALS
1371 Current implementation just immediately sets DMPS level to "Off" for the
1372 monitor.
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},
1385 {TAG_DONE , 0 }
1388 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1391 /*i**********************************************************************************
1393 NAME
1394 MM_ExitBlanker
1396 SYNOPSIS
1397 DoMethod(Object *obj, ULONG MethodID);
1399 DoMethodA(Object *obj, Msg *msg);
1401 LOCATION
1403 FUNCTION
1404 Stops screensaver and/or power saving mode on the monitor.
1406 INPUTS
1407 obj - A monitor object
1408 MethodID - MM_ExitBlanker
1410 RESULT
1411 Undefined.
1413 NOTES
1415 EXAMPLE
1417 BUGS
1419 SEE ALSO
1420 MM_EnterPowerSaveMode, MM_RunBlanker
1422 INTERNALS
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},
1435 {TAG_DONE , 0 }
1438 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1441 /*i**********************************************************************************
1443 NAME
1444 MM_SetDefaultGammaTables
1446 SYNOPSIS
1447 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green, UBYTE *Blue);
1449 DoMethodA(Object *obj, struct msSetDefaultGammaTables *msg);
1451 LOCATION
1453 FUNCTION
1454 Set default gamma correction tables for the monitor
1456 INPUTS
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.
1469 RESULT
1470 Undefined.
1472 NOTES
1473 This method is AROS-specific.
1475 EXAMPLE
1477 BUGS
1479 SEE ALSO
1480 MM_GetDefaultGammaTables
1482 INTERNALS
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);
1491 if (data->gamma)
1493 IPTR ret;
1495 if (msg->Red)
1496 CopyMem(msg->Red , &data->gamma[GAMMA_R], 256);
1497 if (msg->Green)
1498 CopyMem(msg->Green, &data->gamma[GAMMA_G], 256);
1499 if (msg->Blue)
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.
1508 * Do not disturb.
1510 ret = TRUE;
1512 else
1515 * This monitor currently uses default gamma table.
1516 * Update it.
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);
1524 return ret;
1527 return FALSE;
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);
1572 struct BitMap *bm;
1573 BOOL res;
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)
1578 return TRUE;
1580 bm = msg->pointer->sprite->es_BitMap;
1581 /* Currently we don't work with non-hidd sprites */
1582 if (!IS_HIDD_BM(bm))
1583 return FALSE;
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));
1587 if (res) {
1588 data->pointer = msg->pointer;
1589 /* This will fix up sprite position if hotspot changed */
1590 SetPointerPos(data, IntuitionBase);
1593 return res;
1596 void MonitorClass__MM_SetScreenGamma(Class *cl, Object *obj, struct msSetScreenGamma *msg)
1598 struct IMonitorNode *data = INST_DATA(cl, obj);
1600 if (data->gamma)
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);
1608 if (gamma->Active)
1610 UBYTE screengamma = 0;
1612 ResetGamma(data);
1613 if (gamma->UseGammaControl)
1615 if (gamma->GammaTableR)
1617 data->active_r = gamma->GammaTableR;
1618 screengamma++;
1620 if (gamma->GammaTableB)
1622 data->active_b = gamma->GammaTableB;
1623 screengamma++;
1625 if (gamma->GammaTableG);
1627 data->active_g = gamma->GammaTableG;
1628 screengamma++;
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);
1660 ULONG swdepth = -1;
1661 ULONG i;
1663 for (i = 0; i < MONITOR_MAXPIXELFORMATS; i++)
1665 if (data->pfobjects[i])
1667 IPTR depth;
1669 OOP_GetAttr(data->pfobjects[i], aHidd_PixFmt_Depth, &depth);
1671 if (depth < msg->depth)
1673 /* Skip all pixelformats with depth less than requested */
1674 continue;
1677 if (HIDD_Gfx_QueryHardware3D(data->handle->gfxhidd, data->pfobjects[i]))
1679 /* Found hardware 3D ? Good. */
1680 return depth;
1683 if ((depth > 8) && (swdepth == -1))
1685 /* This remembers the first depth suitable for software 3D */
1686 swdepth = depth;
1691 return swdepth;
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);
1705 ULONG idx = 0;
1706 ULONG i;
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.
1718 idx += 2;
1720 else if (OOP_GET(data->pfobjects[i], aHidd_PixFmt_Depth) > 8)
1722 /* Any number of SW 3D modes scores 1 */
1723 idx |= 1;
1728 return idx;