add the common pc IRQTYPE definitions, and copy them for both the 32bit and 64bit...
[AROS.git] / rom / intuition / monitorclass.c
blob81372caf59613d58c9144043d55b3cbc7b714c23
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <cybergraphx/cybergraphics.h>
8 #include <hidd/gfx.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
37 class. This class provides information about relative physical
38 placement of monitors in user's workspace as well as some additional
39 properties.
41 MONITORCLASS is a pseudo-name. This class is in fact private to the
42 system and does not have a public ID. The user can't create objects of
43 this class manually.
45 This class is fully compatible with MorphOS starting from v2.6.
47 *****************************************************************************/
49 Object *DisplayDriverNotify(APTR obj, BOOL add, struct IntuitionBase *IntuitionBase)
51 if (add)
53 Object *mon = NewObject(GetPrivIBase(IntuitionBase)->monitorclass, NULL, MA_MonitorHandle, obj, TAG_DONE);
55 D(bug("[monitorclass] Created monitorclass object 0x%p\n", mon));
56 if (mon) {
57 /* Install default mouse pointer on the new monitor */
58 Object *ptr = GetPrivIBase(IntuitionBase)->DefaultPointer;
60 if (ptr) {
61 struct SharedPointer *pointer;
63 GetAttr(POINTERA_SharedPointer, ptr, (IPTR *)&pointer);
64 DoMethod(mon, MM_SetPointerShape, pointer);
68 return mon;
70 else
72 DisposeObject(obj);
73 return NULL;
77 /*i**************************************************************************/
79 static void SetPointerPos(struct IMonitorNode *data, struct IntuitionBase *IntuitionBase)
81 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
82 ULONG x = data->mouseX;
83 ULONG y = data->mouseY;
85 DB2(bug("[monitorclass] SetPointerPos(%d, %d), pointer 0x%p\n", x, y, data->pointer));
86 if (data->pointer)
88 /* Update sprite position, just for backwards compatibility */
89 data->pointer->sprite->es_SimpleSprite.x = x;
90 data->pointer->sprite->es_SimpleSprite.y = y;
93 DB2(bug("[monitorclass] Physical coordinates: (%d, %d)\n", x, y));
94 HIDD_Gfx_SetCursorPos(data->handle->gfxhidd, x, y);
97 /*i**************************************************************************/
99 static void ActivationHandler(Object *mon, OOP_Object *bitmap)
101 Class *cl = OCLASS(mon);
102 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
104 /* NewMonitor will be picked up by input handler when the next event arrives, so no signals etc */
105 GetPrivIBase(IntuitionBase)->NewMonitor = mon;
108 /*i**************************************************************************/
110 static void ResetGamma(struct IMonitorNode *data)
112 data->active_r = &data->gamma[GAMMA_R];
113 data->active_g = &data->gamma[GAMMA_G];
114 data->active_b = &data->gamma[GAMMA_B];
117 Object *MonitorClass__OM_NEW(Class *cl, Object *o, struct opSet *msg)
119 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
120 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
121 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
122 OOP_AttrBase HiddAttrBase = GetPrivIBase(IntuitionBase)->HiddAttrBase;
123 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
124 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
125 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
126 struct MonitorHandle *handle = (struct MonitorHandle *)GetTagData(MA_MonitorHandle, 0, msg->ops_AttrList);
127 HIDDT_ModeID mode = vHidd_ModeID_Invalid;
128 struct IMonitorNode *data;
129 OOP_Object *sync, *pixfmt;
130 /* Tags order is important because CallBackData needs to be set before
131 function pointer. Otherwise the function can be called with a wrong
132 pointer. */
133 struct TagItem tags[] =
135 {aHidd_Gfx_ActiveCallBackData, 0 },
136 {aHidd_Gfx_ActiveCallBack , (IPTR)ActivationHandler},
137 {TAG_DONE , 0 }
140 D(kprintf("[monitorclass] OM_NEW\n"));
142 if (!handle)
143 return NULL;
145 o = (Object *)DoSuperMethodA(cl, o, (Msg)msg);
146 if (!o)
147 return NULL;
149 data = INST_DATA(cl, o);
151 data->handle = handle;
153 /* We can't list driver's pixelformats, we can list only modes. This does not harm however,
154 just some pixelformats will be processed more than once */
155 while ((mode = HIDD_Gfx_NextModeID(handle->gfxhidd, mode, &sync, &pixfmt)) != vHidd_ModeID_Invalid)
157 IPTR cgxpf;
159 OOP_GetAttr(pixfmt, aHidd_PixFmt_CgxPixFmt, &cgxpf);
160 D(bug("[monitorclass] Mode 0x%08lX, CGX pixfmt %ld\n", mode, cgxpf));
162 if (cgxpf != -1)
164 data->pfobjects[cgxpf] = pixfmt;
165 data->pixelformats[cgxpf] = TRUE;
169 if (OOP_GET(data->handle->gfxhidd, aHidd_Gfx_SupportsGamma))
171 UWORD i;
173 D(bug("[monitorclass] Creating gamma table\n"));
175 data->gamma = AllocMem(256 * 3, MEMF_ANY);
176 if (!data->gamma)
178 DoSuperMethod(cl, o, OM_DISPOSE);
179 return NULL;
182 /* Create default gamma table */
183 for (i = 0; i < 256; i++)
185 data->gamma[i + GAMMA_R] = i;
186 data->gamma[i + GAMMA_G] = i;
187 data->gamma[i + GAMMA_B] = i;
189 ResetGamma(data);
192 OOP_GetAttr(handle->gfxhidd, aHidd_Name, (IPTR *)&data->MonitorName);
194 tags[0].ti_Data = (IPTR)o;
195 OOP_SetAttrs(handle->gfxhidd, tags);
197 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
198 AddTail((struct List *)&GetPrivIBase(IntuitionBase)->MonitorList, (struct Node *)data);
199 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
201 return o;
204 /*i***************************************************************************
206 NAME
207 MA_MonitorName
209 SYNOPSIS
210 [..G], STRPTR
212 LOCATION
213 MONITORCLASS
215 FUNCTION
216 Query monitor driver name.
218 NOTES
220 EXAMPLE
222 BUGS
224 SEE ALSO
226 INTERNALS
228 *****************************************************************************/
230 /*i***************************************************************************
232 NAME
233 MA_Manufacturer
235 SYNOPSIS
236 [..G], STRPTR
238 LOCATION
239 MONITORCLASS
241 FUNCTION
242 Query video card hardware manufacturer name
244 NOTES
245 Not all drivers may specify manufacturer string. NULL is a valid
246 return value.
248 EXAMPLE
250 BUGS
252 SEE ALSO
254 INTERNALS
256 *****************************************************************************/
258 /*i***************************************************************************
260 NAME
261 MA_ManufacturerID
263 SYNOPSIS
264 [..G], ULONG
266 LOCATION
267 MONITORCLASS
269 FUNCTION
270 Query video card hardware's numeric manufacturer ID (which may come
271 from PCI, Zorro, etc).
273 NOTES
274 Not all drivers may have assigned IDs. For example VGA driver and
275 virtual hosted drivers do not associate themselves with any IDs.
277 EXAMPLE
279 BUGS
281 SEE ALSO
282 MA_ProductID
284 INTERNALS
286 *****************************************************************************/
288 /*i***************************************************************************
290 NAME
291 MA_ProductID
293 SYNOPSIS
294 [..G], ULONG
296 LOCATION
297 MONITORCLASS
299 FUNCTION
300 Query video card hardware's numeric product ID (which may come from
301 PCI, Zorro, etc).
303 NOTES
304 Not all drivers may have assigned IDs. For example VGA driver and
305 virtual hosted drivers do not associate themselves with any IDs.
307 EXAMPLE
309 BUGS
311 SEE ALSO
312 MA_ManufacturerID
314 INTERNALS
316 *****************************************************************************/
318 /*i***************************************************************************
320 NAME
321 MA_MemorySize
323 SYNOPSIS
324 [..G], ULONG
326 LOCATION
327 MONITORCLASS
329 FUNCTION
330 Query total size of video card memory in bytes.
332 NOTES
334 EXAMPLE
336 BUGS
338 SEE ALSO
339 MA_MemoryClock
341 INTERNALS
343 *****************************************************************************/
345 /*i***************************************************************************
347 NAME
348 MA_PixelFormats
350 SYNOPSIS
351 [..G], ULONG *
353 LOCATION
354 MONITORCLASS
356 FUNCTION
357 Query table of supported pixelformats.
359 A returned value is a pointer to static array of ULONGs, one ULONG per
360 CyberGraphX pixelformat. Values of these ULONGs are actually booleans.
361 A TRUE value in the array says that the pixelformat is supported,
362 FALSE means it is not.
364 NOTES
366 EXAMPLE
367 ULONG *pfs;
369 GetAttr(MA_PixelFormats, monitor, (IPTR *)&pfs);
370 if (pfs[PUXFMT_LUT8])
371 printf("The display driver supports LUT8 format\n");
373 BUGS
375 SEE ALSO
376 MA_ManufacturerID
378 INTERNALS
380 *****************************************************************************/
382 /*i***************************************************************************
384 NAME
385 MA_TopLeftMonitor
387 SYNOPSIS
388 [.SG], Object *
390 LOCATION
391 MONITORCLASS
393 FUNCTION
394 Get a pointer to a monitor placed in top-left diagonal direction
395 relative tothe current one.
397 This attribute is used to describe relative placement of monitors in
398 user's physical environment.
400 NOTES
402 EXAMPLE
404 BUGS
405 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
406 monitor object.
408 SEE ALSO
409 MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
410 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
411 MA_BottomRightMonitor
413 INTERNALS
415 *****************************************************************************/
417 /*i***************************************************************************
419 NAME
420 MA_TopMiddleMonitor
422 SYNOPSIS
423 [.SG], Object *
425 LOCATION
426 MONITORCLASS
428 FUNCTION
429 Get a pointer to a monitor placed in top direction relative to the
430 current one.
432 This attribute is used to describe relative placement of monitors in
433 the user's physical environment.
435 NOTES
437 EXAMPLE
439 BUGS
440 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
441 pointer to a monitor object.
443 SEE ALSO
444 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
445 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
446 MA_BottomRightMonitor
448 INTERNALS
450 *****************************************************************************/
452 /*i***************************************************************************
454 NAME
455 MA_TopRightMonitor
457 SYNOPSIS
458 [.SG], Object *
460 LOCATION
461 MONITORCLASS
463 FUNCTION
464 Get a pointer to a monitor placed in top-right diagonal direction
465 relative to the current one.
467 This attribute is used to describe relative placement of monitors in
468 the user's physical environment.
470 NOTES
472 EXAMPLE
474 BUGS
475 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
476 pointer to a monitor object.
478 SEE ALSO
479 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
480 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
481 MA_BottomRightMonitor
483 INTERNALS
485 *****************************************************************************/
487 /*i***************************************************************************
489 NAME
490 MA_MiddleLeftMonitor
492 SYNOPSIS
493 [.SG], Object *
495 LOCATION
496 MONITORCLASS
498 FUNCTION
499 Get a pointer to a monitor placed in left direction relative to
500 the current one.
502 This attribute is used to describe relative placement of monitors in
503 the user's physical environment.
505 NOTES
507 EXAMPLE
509 BUGS
510 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
511 pointer to a monitor object.
513 SEE ALSO
514 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
515 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
516 MA_BottomRightMonitor
518 INTERNALS
520 *****************************************************************************/
522 /*i***************************************************************************
524 NAME
525 MA_MiddleRightMonitor
527 SYNOPSIS
528 [.SG], Object *
530 LOCATION
531 MONITORCLASS
533 FUNCTION
534 Get a pointer to a monitor placed in right direction relative to
535 the current one.
537 This attribute is used to describe relative placement of monitors in
538 the user's physical environment.
540 NOTES
542 EXAMPLE
544 BUGS
545 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
546 pointer to a monitor object.
548 SEE ALSO
549 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
550 MA_MiddleLeftMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
551 MA_BottomRightMonitor
553 INTERNALS
555 *****************************************************************************/
557 /*i***************************************************************************
559 NAME
560 MA_BottomLeftMonitor
562 SYNOPSIS
563 [.SG], Object *
565 LOCATION
566 MONITORCLASS
568 FUNCTION
569 Get a pointer to a monitor placed in bottom-left diagonal direction
570 relative to the current one.
572 This attribute is used to describe relative placement of monitors in
573 the user's physical environment.
575 NOTES
577 EXAMPLE
579 BUGS
580 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
581 pointer to a monitor object.
583 SEE ALSO
584 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
585 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomMiddleMonitor,
586 MA_BottomRightMonitor
588 INTERNALS
590 *****************************************************************************/
592 /*i***************************************************************************
594 NAME
595 MA_BottomMiddleMonitor
597 SYNOPSIS
598 [.SG], Object *
600 LOCATION
601 MONITORCLASS
603 FUNCTION
604 Get a pointer to a monitor placed in bottom direction relative to the
605 current one.
607 This attribute is used to describe relative placement of monitors in
608 the user's physical environment.
610 NOTES
612 EXAMPLE
614 BUGS
615 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
616 pointer to a monitor object.
618 SEE ALSO
619 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
620 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomLeftMonitor,
621 MA_BottomRightMonitor
623 INTERNALS
625 *****************************************************************************/
627 /*i***************************************************************************
629 NAME
630 MA_BottomRightMonitor
632 SYNOPSIS
633 [.SG], Object *
635 LOCATION
636 MONITORCLASS
638 FUNCTION
639 Get a pointer to a monitor placed in bottom-right diagonal direction
640 relative to the current one.
642 This attribute is used to describe relative placement of monitors in
643 the user's physical environment.
645 NOTES
647 EXAMPLE
649 BUGS
650 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
651 pointer to a monitor object.
653 SEE ALSO
654 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
655 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomLeftMonitor,
656 MA_BottomMiddleMonitor
658 INTERNALS
660 *****************************************************************************/
662 /*i***************************************************************************
664 NAME
665 MA_GammaControl
667 SYNOPSIS
668 [..G], BOOL
670 LOCATION
671 MONITORCLASS
673 FUNCTION
674 Query if the display driver supports gamma control.
676 NOTES
678 EXAMPLE
680 BUGS
682 SEE ALSO
683 MM_GetDefaultGammaTables, MM_SetDefaultGammaTables
685 INTERNALS
687 *****************************************************************************/
689 /*i***************************************************************************
691 NAME
692 MA_PointerType
694 SYNOPSIS
695 [..G], ULONG
697 LOCATION
698 MONITORCLASS
700 FUNCTION
701 Query supported mouse pointer sprite formats.
703 The returned value is a combination of the following bit flags:
704 PointerType_3Plus1 - color 0 transparent, 1-3 visible (Amiga(tm)
705 chipset sprite)
706 PointerType_2Plus1 - color 0 transparent, 1 undefined (can be for
707 example clear or inverse), 2-3 visible
708 PointerType_ARGB - Direct color bitmap (hi-color or truecolor,
709 possibly with alpha channel
711 NOTES
713 EXAMPLE
715 BUGS
717 SEE ALSO
718 MM_GetPointerBounds
720 INTERNALS
722 *****************************************************************************/
724 /*i***************************************************************************
726 NAME
727 MA_DriverName
729 SYNOPSIS
730 [..G], STRPTR
732 LOCATION
733 MONITORCLASS
735 FUNCTION
736 Query CyberGraphX driver name. It is the name which can be given to
737 cybergraphics.library/BestCModeIDTagList() as CYBRBIDTG_BoardName
738 value.
740 NOTES
742 EXAMPLE
744 BUGS
746 SEE ALSO
747 MM_GetPointerBounds
749 INTERNALS
751 *****************************************************************************/
753 /*i***************************************************************************
755 NAME
756 MA_MemoryClock
758 SYNOPSIS
759 [..G], ULONG
761 LOCATION
762 MONITORCLASS
764 FUNCTION
765 Query the video card's memory clock in Hertz. 0 is a valid value
766 meaning 'unknown'.
768 NOTES
770 EXAMPLE
772 BUGS
774 SEE ALSO
775 MA_MemorySize
777 INTERNALS
779 *****************************************************************************/
781 /*i***************************************************************************
783 NAME
784 MA_Windowed
786 SYNOPSIS
787 [..G], BOOL
789 LOCATION
790 MONITORCLASS
792 FUNCTION
793 Check if this monitor is a window on hosted OS desktop.
795 This means that the host OS is responsible for handling mouse input
796 and display activation. Monitors with this attribute set to TRUE
797 should be ignored by multi-display desktop configuration software.
799 These monitors should have no spatial links to other monitors.
800 Activation of these monitors is done by clicking on their windows on
801 the host's desktop and is handled by the driver itself.
803 NOTES
804 This attribute is AROS-specific; it does not exist in MorphOS.
806 EXAMPLE
808 BUGS
810 SEE ALSO
812 INTERNALS
814 *****************************************************************************/
816 /*i**************************************************************************/
818 IPTR MonitorClass__OM_GET(Class *cl, Object *o, struct opGet *msg)
820 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
821 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
822 OOP_AttrBase HiddAttrBase = GetPrivIBase(IntuitionBase)->HiddAttrBase;
823 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
824 struct IMonitorNode *data = INST_DATA(cl, o);
826 D(kprintf("[monitorclass] OM_GET\n"));
828 switch (msg->opg_AttrID)
830 case MA_MonitorName:
831 *msg->opg_Storage = (IPTR)data->MonitorName;
832 break;
834 case MA_Manufacturer:
835 OOP_GetAttr(data->handle->gfxhidd, aHidd_ProducerName, msg->opg_Storage);
836 break;
838 case MA_ManufacturerID:
839 OOP_GetAttr(data->handle->gfxhidd, aHidd_Producer, msg->opg_Storage);
840 break;
842 case MA_ProductID:
843 OOP_GetAttr(data->handle->gfxhidd, aHidd_Product, msg->opg_Storage);
844 break;
846 case MA_MemorySize:
847 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_MemorySize, msg->opg_Storage);
848 break;
850 case MA_PixelFormats:
851 *msg->opg_Storage = (IPTR)data->pixelformats;
852 break;
854 case MA_TopLeftMonitor:
855 *msg->opg_Storage = (IPTR)data->topleft;
856 break;
858 case MA_TopMiddleMonitor:
859 *msg->opg_Storage = (IPTR)data->topmiddle;
860 break;
862 case MA_TopRightMonitor:
863 *msg->opg_Storage = (IPTR)data->topright;
864 break;
866 case MA_MiddleLeftMonitor:
867 *msg->opg_Storage = (IPTR)data->middleleft;
868 break;
870 case MA_MiddleRightMonitor:
871 *msg->opg_Storage = (IPTR)data->middleright;
872 break;
874 case MA_BottomLeftMonitor:
875 *msg->opg_Storage = (IPTR)data->bottomleft;
876 break;
878 case MA_BottomMiddleMonitor:
879 *msg->opg_Storage = (IPTR)data->bottommiddle;
880 break;
882 case MA_BottomRightMonitor:
883 *msg->opg_Storage = (IPTR)data->bottomright;
884 break;
886 case MA_GammaControl:
887 *msg->opg_Storage = data->gamma ? TRUE : FALSE;
888 break;
890 case MA_PointerType:
891 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_HWSpriteTypes, msg->opg_Storage);
892 break;
894 case MA_DriverName:
895 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_DriverName, msg->opg_Storage);
896 break;
898 case MA_MemoryClock:
899 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_MemoryClock, msg->opg_Storage);
900 break;
902 case MA_Windowed:
903 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_IsWindowed, msg->opg_Storage);
904 break;
906 case MA_MonitorID:
907 *msg->opg_Storage = data->handle->id;
908 break;
910 default:
911 return DoSuperMethodA(cl, o, (Msg)msg);
914 return TRUE;
917 /*i**************************************************************************/
919 IPTR MonitorClass__OM_SET(Class *cl, Object *o, struct opSet *msg)
921 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
922 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
923 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
924 struct IMonitorNode *data = INST_DATA(cl, o);
925 struct TagItem *tag, *tstate;
927 tstate = msg->ops_AttrList;
928 while((tag = NextTagItem(&tstate))) {
929 switch (tag->ti_Tag) {
930 case MA_TopLeftMonitor:
931 data->topleft = (Object *)tag->ti_Data;
932 break;
934 case MA_TopMiddleMonitor:
935 data->topmiddle = (Object *)tag->ti_Data;
936 break;
938 case MA_TopRightMonitor:
939 data->topright = (Object *)tag->ti_Data;
940 break;
942 case MA_MiddleLeftMonitor:
943 data->middleleft = (Object *)tag->ti_Data;
944 break;
946 case MA_MiddleRightMonitor:
947 data->middleright = (Object *)tag->ti_Data;
948 break;
950 case MA_BottomLeftMonitor:
951 data->bottomleft = (Object *)tag->ti_Data;
952 break;
954 case MA_BottomMiddleMonitor:
955 data->bottommiddle = (Object *)tag->ti_Data;
956 break;
958 case MA_BottomRightMonitor:
959 data->bottomright = (Object *)tag->ti_Data;
960 break;
962 case MA_PointerVisible:
963 HIDD_Gfx_SetCursorVisible(data->handle->gfxhidd, tag->ti_Data);
964 break;
967 return DoSuperMethodA(cl, o, (Msg)msg);
970 /*i**************************************************************************/
972 #define Relink(nextAttr, prev, prevAttr, next) \
973 if (prev) \
974 SetAttrs(prev, nextAttr, next, TAG_DONE); \
975 if (next) \
976 SetAttrs(next, prevAttr, prev, TAG_DONE)
978 IPTR MonitorClass__OM_DISPOSE(Class *cl, Object *o, Msg msg)
980 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
981 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
982 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
983 struct IMonitorNode *data = INST_DATA(cl, o);
984 struct TagItem tags[] =
986 {aHidd_Gfx_ActiveCallBack, 0},
987 {TAG_DONE , 0}
990 D(kprintf("MonitorClass: OM_DISPOSE\n"));
992 /* Disable activation callback */
993 OOP_SetAttrs(data->handle->gfxhidd, tags);
995 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
996 Remove((struct Node *)data);
998 /* Remove this monitor from spatial links */
999 Relink(MA_BottomRightMonitor, data->topleft, MA_TopLeftMonitor, data->bottomright);
1000 Relink(MA_BottomMiddleMonitor, data->topmiddle, MA_TopMiddleMonitor, data->bottommiddle);
1001 Relink(MA_BottomLeftMonitor, data->topright, MA_TopRightMonitor, data->bottomleft);
1002 Relink(MA_MiddleLeftMonitor, data->middleright, MA_MiddleRightMonitor, data->middleleft);
1004 /* If an active monitor is being removed, we should activate another one */
1005 if (GetPrivIBase(IntuitionBase)->ActiveMonitor == o)
1006 ActivateMonitor((Object *)GetHead(&GetPrivIBase(IntuitionBase)->MonitorList), -1, -1, IntuitionBase);
1008 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
1010 if (data->gamma)
1011 FreeMem(data->gamma, 256 * 3);
1013 return DoSuperMethodA(cl, o, msg);
1016 /*i***************************************************************************
1018 NAME
1019 MM_GetRootBitMap
1021 SYNOPSIS
1022 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat,
1023 struct BitMap **Store);
1025 DoMethodA(Object *obj, struct msGetRootBitMap *msg);
1027 LOCATION
1029 FUNCTION
1030 This method is provided only for source code compatibility with the
1031 MorphOS operating system.
1033 Under MorphOS this method returns a pointer to internal root bitmap of
1034 the display driver corresponding to the specified pixelformat.
1035 Displayable bitmaps are supposed to be created as friends of the root
1036 bitmap.
1038 In AROS displayable bitmaps need complete display mode information and
1039 not only pixelformat. So this method will never be implemented and will
1040 always return a NULL pointer. In order to create a displayable RTG
1041 bitmap on AROS the user needs to supply a taglist with
1042 BMATags_DisplayID specification to the AllocBitMap() function.
1044 INPUTS
1045 obj - A monitor object
1046 MethodID - MM_GetRootBitMap
1047 PixelFormat - A CyberGraphX pixelformat code to get root bitmap for
1048 Store - A storage where root bitmap pointer will be placed.
1050 RESULT
1051 Undefined.
1053 NOTES
1055 EXAMPLE
1057 BUGS
1059 SEE ALSO
1060 graphics.library/AllocBitMap()
1062 INTERNALS
1064 *****************************************************************************/
1066 IPTR MonitorClass__MM_GetRootBitMap(Class *cl, Object *obj, struct msGetRootBitMap *msg)
1068 *msg->Store = NULL;
1070 return 0;
1073 /*i***************************************************************************
1075 NAME
1076 MM_Query3DSupport
1078 SYNOPSIS
1079 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, ULONG *Store);
1081 DoMethodA(Object *obj, struct msQuery3DSupport *msg);
1083 LOCATION
1085 FUNCTION
1086 Ask the display driver for type of 3D support for the given
1087 pixelformat.
1089 Supplied storage will be filled with one of:
1090 MSQUERY3D_UNKNOWN - Unsupported pixelformat or some internal error
1091 MSQUERY3D_NODRIVER - There is no 3D support for the given
1092 pixelformat
1093 MSQUERY3D_SWDRIVER - A software 3D support is available for the
1094 given pixelformat
1095 MSQUERY3D_HWDRIVER - A hardware 3D support is available for the
1096 given pixelformat
1098 INPUTS
1099 obj - A monitor object to query
1100 MethodID - MM_Query3DSupport
1101 PixelFormat - A CyberGraphX pixelformat code
1102 Store - A pointer to a storage where return value will be placed
1104 RESULT
1105 Undefined.
1107 NOTES
1109 EXAMPLE
1111 BUGS
1113 SEE ALSO
1115 INTERNALS
1117 *****************************************************************************/
1119 IPTR MonitorClass__MM_Query3DSupport(Class *cl, Object *obj, struct msQuery3DSupport *msg)
1121 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1122 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1123 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1124 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1125 struct IMonitorNode *data = INST_DATA(cl, obj);
1126 OOP_Object *pf = data->pfobjects[msg->PixelFormat];
1128 if (pf) {
1129 if (HIDD_Gfx_QueryHardware3D(data->handle->gfxhidd, pf))
1130 *msg->Store = MSQUERY3D_HWDRIVER;
1131 else {
1132 IPTR depth;
1134 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
1135 if (depth > 8)
1136 *msg->Store = MSQUERY3D_SWDRIVER;
1137 else
1138 *msg->Store = MSQUERY3D_NODRIVER;
1140 } else
1141 *msg->Store = MSQUERY3D_UNKNOWN;
1143 return *msg->Store;
1146 /*i***************************************************************************
1148 NAME
1149 MM_GetDefaultGammaTables
1151 SYNOPSIS
1152 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green,
1153 UBYTE *Blue);
1155 DoMethodA(Object *obj, struct msGetDefaultGammaTables *msg);
1157 LOCATION
1159 FUNCTION
1160 Get default gamma correction tables for the monitor.
1162 INPUTS
1163 obj - A monitor object to query
1164 MethodID - MM_GetDefaultGammaTables
1165 Red - A pointer to an array of 256 bytes where gamma correction
1166 data for the red component will be placed. You may specify
1167 a NULL pointer in order to ignore this component.
1168 Green - A pointer to an array of 256 bytes where gamma correction
1169 data for the green component will be placed. You may
1170 specify a NULL pointer in order to ignore this component.
1171 Blue - A pointer to an array of 256 bytes where gamma correction
1172 data for the blue component will be placed. You may specify
1173 a NULL pointer in order to ignore this component.
1175 RESULT
1176 Undefined.
1178 NOTES
1180 EXAMPLE
1182 BUGS
1184 SEE ALSO
1185 MM_SetDefaultGammaTables
1187 INTERNALS
1189 *****************************************************************************/
1191 void MonitorClass__MM_GetDefaultGammaTables(Class *cl, Object *obj, struct msGetDefaultGammaTables *msg)
1193 struct IMonitorNode *data = INST_DATA(cl, obj);
1195 if (data->gamma)
1197 if (msg->Red)
1198 CopyMem(&data->gamma[GAMMA_R], msg->Red, 256);
1199 if (msg->Green)
1200 CopyMem(&data->gamma[GAMMA_G], msg->Green, 256);
1201 if (msg->Blue)
1202 CopyMem(&data->gamma[GAMMA_B], msg->Blue, 256);
1206 /*i***************************************************************************
1208 NAME
1209 MM_GetDefaultPixelFormat
1211 SYNOPSIS
1212 DoMethod(Object *obj, ULONG MethodID, ULONG Depth, ULONG *Store);
1214 DoMethodA(Object *obj, struct msGetDefaultPixelFormat *msg);
1216 LOCATION
1218 FUNCTION
1219 Get the driver's preferred pixelformat for the specified bitmap depth.
1221 INPUTS
1222 obj - A monitor object
1223 MethodID - MM_GetDefaultPixelFormat
1224 Depth - Depth to ask about
1225 Store - A pointer to an ULONG location where CyberGraphX
1226 pixelformat number will be placed. -1 means unsupported
1227 depth.
1229 RESULT
1230 Undefined.
1232 NOTES
1234 EXAMPLE
1236 BUGS
1238 SEE ALSO
1240 INTERNALS
1242 *****************************************************************************/
1244 IPTR MonitorClass__MM_GetDefaultPixelFormat(Class *cl, Object *obj, struct msGetDefaultPixelFormat *msg)
1246 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1247 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1248 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1249 struct IMonitorNode *data = INST_DATA(cl, obj);
1250 ULONG i;
1252 for (i = 0; i < MONITOR_MAXPIXELFORMATS; i++) {
1253 if (data->pfobjects[i]) {
1254 IPTR depth;
1256 OOP_GetAttr(data->pfobjects[i], aHidd_PixFmt_Depth, &depth);
1257 if (depth == msg->Depth) {
1258 *msg->Store = i;
1259 break;
1264 if (i == MONITOR_MAXPIXELFORMATS)
1265 *msg->Store = -1;
1267 return *msg->Store;
1270 /*i***************************************************************************
1272 NAME
1273 MM_GetPointerBounds
1275 SYNOPSIS
1276 DoMethod(Object *obj, ULONG MethodID, ULONG PointerType, ULONG *Width,
1277 ULONG *Height);
1279 DoMethodA(Object *obj, struct msGetPointerBounds *msg);
1281 LOCATION
1282 monitorclass
1284 FUNCTION
1285 Get the maximum allowed size of a mouse pointer sprite.
1287 INPUTS
1288 obj - A monitor object
1289 MethodID - MM_GetPointerBounds
1290 PointerType - Pointer type (one of PointerType_...)
1291 Width - A pointer to an ULONG location where width will be
1292 placed.
1293 Height - A pointer to an ULONG location where height will be
1294 placed.
1296 RESULT
1297 FALSE is given pointer type is not supported, TRUE otherwise.
1299 NOTES
1300 Width and Height are considered undefined if the method returns FALSE.
1302 EXAMPLE
1304 BUGS
1306 SEE ALSO
1307 MA_PointerType
1309 INTERNALS
1311 *****************************************************************************/
1313 IPTR MonitorClass__MM_GetPointerBounds(Class *cl, Object *obj, struct msGetPointerBounds *msg)
1315 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1316 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1317 struct IMonitorNode *data = INST_DATA(cl, obj);
1319 return HIDD_Gfx_GetMaxSpriteSize(data->handle->gfxhidd, msg->PointerType, msg->Width, msg->Height);
1322 /*i***************************************************************************
1324 NAME
1325 MM_RunBlanker
1327 SYNOPSIS
1328 DoMethod(Object *obj, ULONG MethodID);
1330 DoMethodA(Object *obj, Msg *msg);
1332 LOCATION
1334 FUNCTION
1335 Starts screensaver on the monitor.
1337 At the moment AROS has no integrated screensaver support. The method
1338 is considered reserved and not implemented.
1340 INPUTS
1341 obj - A monitor object
1342 MethodID - MM_RunBlanker
1344 RESULT
1345 Undefined.
1347 NOTES
1349 EXAMPLE
1351 BUGS
1353 SEE ALSO
1354 MM_EnterPowerSaveMode, MM_ExitBlanker
1356 INTERNALS
1358 *****************************************************************************/
1360 IPTR MonitorClass__MM_RunBlanker(Class *cl, Object *obj, Msg *msg)
1362 /* We have no integrated screensaver support */
1364 return FALSE;
1367 /*i***************************************************************************
1369 NAME
1370 MM_EnterPowerSaveMode
1372 SYNOPSIS
1373 DoMethod(Object *obj, ULONG MethodID);
1375 DoMethodA(Object *obj, Msg *msg);
1377 LOCATION
1379 FUNCTION
1380 Starts power saving mode on the monitor.
1382 INPUTS
1383 obj - A monitor object
1384 MethodID - MM_EnterPowerSaveMode
1386 RESULT
1387 Undefined.
1389 NOTES
1391 EXAMPLE
1393 BUGS
1395 SEE ALSO
1396 MM_RunBlanker, MM_ExitBlanker
1398 INTERNALS
1399 Current implementation just immediately sets DMPS level to "Off" for
1400 the monitor.
1402 *****************************************************************************/
1404 IPTR MonitorClass__MM_EnterPowerSaveMode(Class *cl, Object *obj, Msg *msg)
1406 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1407 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1408 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
1409 struct IMonitorNode *data = INST_DATA(cl, obj);
1410 struct TagItem tags[] =
1412 {aHidd_Gfx_DPMSLevel, vHidd_Gfx_DPMSLevel_Off},
1413 {TAG_DONE , 0 }
1416 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1419 /*i***************************************************************************
1421 NAME
1422 MM_ExitBlanker
1424 SYNOPSIS
1425 DoMethod(Object *obj, ULONG MethodID);
1427 DoMethodA(Object *obj, Msg *msg);
1429 LOCATION
1431 FUNCTION
1432 Stops screensaver and/or power saving mode on the monitor.
1434 INPUTS
1435 obj - A monitor object
1436 MethodID - MM_ExitBlanker
1438 RESULT
1439 Undefined.
1441 NOTES
1443 EXAMPLE
1445 BUGS
1447 SEE ALSO
1448 MM_EnterPowerSaveMode, MM_RunBlanker
1450 INTERNALS
1452 *****************************************************************************/
1454 IPTR MonitorClass__MM_ExitBlanker(Class *cl, Object *obj, Msg *msg)
1456 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1457 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1458 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
1459 struct IMonitorNode *data = INST_DATA(cl, obj);
1460 struct TagItem tags[] =
1462 {aHidd_Gfx_DPMSLevel, vHidd_Gfx_DPMSLevel_On},
1463 {TAG_DONE , 0 }
1466 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1469 /*i***************************************************************************
1471 NAME
1472 MM_SetDefaultGammaTables
1474 SYNOPSIS
1475 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green,
1476 UBYTE *Blue);
1478 DoMethodA(Object *obj, struct msSetDefaultGammaTables *msg);
1480 LOCATION
1482 FUNCTION
1483 Set default gamma correction tables for the monitor.
1485 INPUTS
1486 obj - A monitor object to query
1487 MethodID - MM_GetDefaultGammaTables
1488 Red - A pointer to an array of 256 bytes where gamma correction
1489 data for the red component is placed. You may specify a
1490 NULL pointer in order to ignore this component.
1491 Green - A pointer to an array of 256 bytes where gamma correction
1492 data for the green component is placed. You may specify a
1493 NULL pointer in order to ignore this component.
1494 Blue - A pointer to an array of 256 bytes where gamma correction
1495 data for the blue component is placed. You may specify a
1496 NULL pointer in order to ignore this component.
1498 RESULT
1499 Undefined.
1501 NOTES
1502 This method is AROS-specific.
1504 EXAMPLE
1506 BUGS
1508 SEE ALSO
1509 MM_GetDefaultGammaTables
1511 INTERNALS
1513 *****************************************************************************/
1515 IPTR MonitorClass__MM_SetDefaultGammaTables(Class *cl, Object *obj, struct msSetDefaultGammaTables *msg)
1517 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1518 struct IMonitorNode *data = INST_DATA(cl, obj);
1520 if (data->gamma)
1522 IPTR ret;
1524 if (msg->Red)
1525 CopyMem(msg->Red , &data->gamma[GAMMA_R], 256);
1526 if (msg->Green)
1527 CopyMem(msg->Green, &data->gamma[GAMMA_G], 256);
1528 if (msg->Blue)
1529 CopyMem(msg->Blue , &data->gamma[GAMMA_B], 256);
1531 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->ViewLordLock);
1533 if (data->screenGamma == 3)
1536 * All three components are determined by screen.
1537 * Do not disturb.
1539 ret = TRUE;
1541 else
1544 * This monitor currently uses default gamma table.
1545 * Update it.
1547 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1549 ret = HIDD_Gfx_SetGamma(data->handle->gfxhidd, data->active_r, data->active_g, data->active_b);
1552 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->ViewLordLock);
1553 return ret;
1556 return FALSE;
1559 /*i**************************************************************************/
1561 ULONG MonitorClass__MM_GetCompositionFlags(Class *cl, Object *obj, struct msGetCompositionFlags *msg)
1563 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1564 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1565 struct IMonitorNode *data = INST_DATA(cl, obj);
1566 struct HIDD_ModeProperties modeprops;
1568 HIDD_Gfx_ModeProperties(data->handle->gfxhidd, msg->ModeID & (!data->handle->mask),
1569 &modeprops, sizeof(modeprops));
1570 return modeprops.CompositionFlags;
1573 /*i**************************************************************************/
1575 void MonitorClass__MM_SetPointerPos(Class *cl, Object *obj, struct msSetPointerPos *msg)
1577 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1578 struct IMonitorNode *data = INST_DATA(cl, obj);
1580 data->mouseX = msg->x;
1581 data->mouseY = msg->y;
1582 SetPointerPos(data, IntuitionBase);
1585 /*i**************************************************************************/
1587 IPTR MonitorClass__MM_CheckID(Class *cl, Object *obj, struct msGetCompositionFlags *msg)
1589 struct IMonitorNode *data = INST_DATA(cl, obj);
1591 return ((msg->ModeID & data->handle->mask) == data->handle->id);
1594 /*i**************************************************************************/
1596 IPTR MonitorClass__MM_SetPointerShape(Class *cl, Object *obj, struct msSetPointerShape *msg)
1598 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1599 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1600 struct IMonitorNode *data = INST_DATA(cl, obj);
1601 struct BitMap *bm;
1602 BOOL res;
1604 D(bug("[monitorclass] SetPointerShape(0x%p), old pointer 0x%p\n", msg->pointer, data->pointer));
1605 /* Don't do anything if already set */
1606 if (data->pointer == msg->pointer)
1607 return TRUE;
1609 bm = msg->pointer->sprite->es_BitMap;
1610 /* Currently we don't work with non-hidd sprites */
1611 if (!IS_HIDD_BM(bm))
1612 return FALSE;
1614 res = HIDD_Gfx_SetCursorShape(data->handle->gfxhidd, HIDD_BM_OBJ(bm), msg->pointer->xoffset, msg->pointer->yoffset);
1615 D(bug("[monitorclass] SetPointerShape() returned %d\n", res));
1616 if (res) {
1617 data->pointer = msg->pointer;
1618 /* This will fix up sprite position if hotspot changed */
1619 SetPointerPos(data, IntuitionBase);
1622 return res;
1625 void MonitorClass__MM_SetScreenGamma(Class *cl, Object *obj, struct msSetScreenGamma *msg)
1627 struct IMonitorNode *data = INST_DATA(cl, obj);
1629 if (data->gamma)
1631 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1632 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1633 struct GammaControl *gamma = msg->gamma;
1635 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->ViewLordLock);
1637 if (gamma->Active)
1639 UBYTE screengamma = 0;
1641 ResetGamma(data);
1642 if (gamma->UseGammaControl)
1644 if (gamma->GammaTableR)
1646 data->active_r = gamma->GammaTableR;
1647 screengamma++;
1649 if (gamma->GammaTableB)
1651 data->active_b = gamma->GammaTableB;
1652 screengamma++;
1654 if (gamma->GammaTableG)
1656 data->active_g = gamma->GammaTableG;
1657 screengamma++;
1662 * The condition here reflects the following variants:
1663 * 1. We used default gamma and switched to custom one.
1664 * 2. We used custom gamma and switched to default one.
1665 * 3. We changed custom gamma.
1667 if (data->screenGamma || screengamma || msg->force)
1669 data->screenGamma = screengamma;
1670 HIDD_Gfx_SetGamma(data->handle->gfxhidd, data->active_r, data->active_g, data->active_b);
1674 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->ViewLordLock);
1679 * Find the best (closest to the given) depth with 3D support.
1680 * This method will give the priority to hardware 3D.
1682 ULONG MonitorClass__MM_FindBest3dDepth(Class *cl, Object *obj, struct msFindBest3dDepth *msg)
1684 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1685 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1686 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1687 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1688 struct IMonitorNode *data = INST_DATA(cl, obj);
1689 ULONG swdepth = -1;
1690 ULONG i;
1692 for (i = 0; i < MONITOR_MAXPIXELFORMATS; i++)
1694 if (data->pfobjects[i])
1696 IPTR depth;
1698 OOP_GetAttr(data->pfobjects[i], aHidd_PixFmt_Depth, &depth);
1700 if (depth < msg->depth)
1702 /* Skip all pixelformats with depth less than requested */
1703 continue;
1706 if (HIDD_Gfx_QueryHardware3D(data->handle->gfxhidd, data->pfobjects[i]))
1708 /* Found hardware 3D ? Good. */
1709 return depth;
1712 if ((depth > 8) && (swdepth == -1))
1714 /* This remembers the first depth suitable for software 3D */
1715 swdepth = depth;
1720 return swdepth;
1724 * Calculate 3D capability index.
1725 * Used for finding the best 3D monitor.
1727 ULONG MonitorClass__MM_Calc3dCapability(Class *cl, Object *obj, Msg msg)
1729 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1730 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1731 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1732 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1733 struct IMonitorNode *data = INST_DATA(cl, obj);
1734 ULONG idx = 0;
1735 ULONG i;
1737 for (i = 0; i < MONITOR_MAXPIXELFORMATS; i++)
1739 if (data->pfobjects[i])
1741 if (HIDD_Gfx_QueryHardware3D(data->handle->gfxhidd, data->pfobjects[i]))
1744 * Each HW 3D mode scores 2.
1745 * As a result, monitor with one HW 3D mode will beat SW-only 3D.
1747 idx += 2;
1749 else if (OOP_GET(data->pfobjects[i], aHidd_PixFmt_Depth) > 8)
1751 /* Any number of SW 3D modes scores 1 */
1752 idx |= 1;
1757 return idx;