revert between 56095 -> 55830 in arch
[AROS.git] / rom / intuition / monitorclass.c
blobc2eacf7d66124cab1b61c7385fc3d1843a07e153
1 /*
2 Copyright © 1995-2019, 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 #define DACTIVATE(x)
28 #define DPOINTER(x)
30 /*i***************************************************************************
32 NAME
33 --background_monitorclass--
35 LOCATION
36 MONITORCLASS
38 NOTES
39 In AROS display drivers have associated BOOPSI objects of MONITORCLASS
40 class. This class provides information about relative physical
41 placement of monitors in user's workspace as well as some additional
42 properties.
44 MONITORCLASS is a pseudo-name. This class is in fact private to the
45 system and does not have a public ID. The user can't create objects of
46 this class manually.
48 This class is fully compatible with MorphOS starting from v2.6.
50 *****************************************************************************/
52 Object *DisplayDriverNotify(APTR obj, BOOL add, struct IntuitionBase *IntuitionBase)
54 D(bug("[Monitor] %s()\n", __func__));
55 if (add)
57 Object *mon = NewObject(GetPrivIBase(IntuitionBase)->monitorclass, NULL, MA_MonitorHandle, obj, TAG_DONE);
59 D(bug("[Monitor] %s: Monitor object 0x%p\n", __func__, mon));
60 if (mon) {
61 /* Install default mouse pointer on the new monitor */
62 Object *ptr = GetPrivIBase(IntuitionBase)->DefaultPointer;
64 if (ptr) {
65 struct SharedPointer *pointer;
67 GetAttr(POINTERA_SharedPointer, ptr, (IPTR *)&pointer);
68 DoMethod(mon, MM_SetPointerShape, pointer);
72 return mon;
74 else
76 DisposeObject(obj);
77 return NULL;
81 /*i**************************************************************************/
83 static void SetPointerPos(struct IMonitorNode *data, struct IntuitionBase *IntuitionBase)
85 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
86 ULONG x = data->mouseX;
87 ULONG y = data->mouseY;
89 DPOINTER(
90 bug("[Monitor] %s(%d, %d)\n", __func__, x, y);
91 bug("[Monitor] %s: pointer @ 0x%p\n", __func__, data->pointer);
93 if (data->pointer)
95 /* Update sprite position, just for backwards compatibility */
96 data->pointer->sprite->es_SimpleSprite.x = x;
97 data->pointer->sprite->es_SimpleSprite.y = y;
100 DPOINTER(bug("[Monitor] %s: Physical co-ordinates %d,%d\n", __func__, x, y);)
102 HIDD_Gfx_SetCursorPos(data->handle->gfxhidd, x, y);
105 /*i**************************************************************************/
107 static void ActivationHandler(Object *mon, OOP_Object *bitmap)
109 Class *cl = OCLASS(mon);
110 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
111 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
112 OOP_AttrBase HiddBitMapAttrBase = GetPrivIBase(IntuitionBase)->HiddBitMapAttrBase;
113 struct TagItem tags[] =
115 {aHidd_BitMap_Focus, TRUE },
116 {TAG_DONE, 0 }
119 DACTIVATE(
120 bug("[Monitor] %s()\n", __func__);
121 bug("[Monitor] %s: IntuitionBase @ 0x%p\n", __func__, IntuitionBase);
122 bug("[Monitor] %s: OOPBase @ 0x%p\n", __func__, OOPBase);
123 bug("[Monitor] %s: bitmap @ 0x%p\n", __func__, bitmap);
124 bug("[Monitor] %s: HiddBitMapAttrBase = %d\n", __func__, HiddBitMapAttrBase);
127 /* NewMonitor will be picked up by input handler when the next event arrives, so no signals etc */
128 GetPrivIBase(IntuitionBase)->NewMonitor = mon;
129 if (bitmap)
130 OOP_SetAttrs(bitmap, tags);
133 /*i**************************************************************************/
135 static void ResetGamma(struct IMonitorNode *data)
137 data->active_r = &data->gamma[GAMMA_R];
138 data->active_g = &data->gamma[GAMMA_G];
139 data->active_b = &data->gamma[GAMMA_B];
142 Object *MonitorClass__OM_NEW(Class *cl, Object *o, struct opSet *msg)
144 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
145 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
146 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
147 OOP_AttrBase HiddAttrBase = GetPrivIBase(IntuitionBase)->HiddAttrBase;
148 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
149 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
150 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
151 struct MonitorHandle *handle = (struct MonitorHandle *)GetTagData(MA_MonitorHandle, 0, msg->ops_AttrList);
152 HIDDT_ModeID mode = vHidd_ModeID_Invalid;
153 struct IMonitorNode *data;
154 OOP_Object *sync, *pixfmt;
155 /* Tags order is important because CallBackData needs to be set before
156 function pointer. Otherwise the function can be called with a wrong
157 pointer. */
158 struct TagItem tags[] =
160 {aHidd_Gfx_ActiveCallBackData, 0 },
161 {aHidd_Gfx_ActiveCallBack , (IPTR)ActivationHandler},
162 {TAG_DONE , 0 }
165 D(bug("[Monitor] %s()\n", __func__));
167 if (!handle)
168 return NULL;
170 o = (Object *)DoSuperMethodA(cl, o, (Msg)msg);
171 if (!o)
172 return NULL;
174 data = INST_DATA(cl, o);
176 data->handle = handle;
178 /* We can't list driver's pixelformats, we can list only modes. This does not harm however,
179 just some pixelformats will be processed more than once */
180 while ((mode = HIDD_Gfx_NextModeID(handle->gfxhidd, mode, &sync, &pixfmt)) != vHidd_ModeID_Invalid)
182 IPTR cgxpf;
184 OOP_GetAttr(pixfmt, aHidd_PixFmt_CgxPixFmt, &cgxpf);
185 D(bug("[Monitor] %s: Mode 0x%08lX, CGX pixfmt %ld\n", __func__, mode, cgxpf));
187 if (cgxpf != -1)
189 data->pfobjects[cgxpf] = pixfmt;
190 data->pixelformats[cgxpf] = TRUE;
194 if (OOP_GET(data->handle->gfxhidd, aHidd_Gfx_SupportsGamma))
196 UWORD i;
198 D(bug("[Monitor] %s: Creating gamma table\n", __func__));
200 data->gamma = AllocMem(256 * 3, MEMF_ANY);
201 if (!data->gamma)
203 DoSuperMethod(cl, o, OM_DISPOSE);
204 return NULL;
207 /* Create default gamma table */
208 for (i = 0; i < 256; i++)
210 data->gamma[i + GAMMA_R] = i;
211 data->gamma[i + GAMMA_G] = i;
212 data->gamma[i + GAMMA_B] = i;
214 ResetGamma(data);
217 OOP_GetAttr(handle->gfxhidd, aHidd_Name, (IPTR *)&data->MonitorName);
218 OOP_GetAttr(handle->gfxhidd, aHidd_Gfx_HWSpriteTypes, (IPTR *)&data->SpriteType);
219 D(bug("[Monitor] %s: SpriteType = %08x\n", __func__, data->SpriteType));
221 tags[0].ti_Data = (IPTR)o;
222 OOP_SetAttrs(handle->gfxhidd, tags);
224 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
225 AddTail((struct List *)&GetPrivIBase(IntuitionBase)->MonitorList, (struct Node *)data);
226 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
228 return o;
231 /*i***************************************************************************
233 NAME
234 MA_MonitorName
236 SYNOPSIS
237 [..G], STRPTR
239 LOCATION
240 MONITORCLASS
242 FUNCTION
243 Query monitor driver name.
245 NOTES
247 EXAMPLE
249 BUGS
251 SEE ALSO
253 INTERNALS
255 *****************************************************************************/
257 /*i***************************************************************************
259 NAME
260 MA_Manufacturer
262 SYNOPSIS
263 [..G], STRPTR
265 LOCATION
266 MONITORCLASS
268 FUNCTION
269 Query video card hardware manufacturer name
271 NOTES
272 Not all drivers may specify manufacturer string. NULL is a valid
273 return value.
275 EXAMPLE
277 BUGS
279 SEE ALSO
281 INTERNALS
283 *****************************************************************************/
285 /*i***************************************************************************
287 NAME
288 MA_ManufacturerID
290 SYNOPSIS
291 [..G], ULONG
293 LOCATION
294 MONITORCLASS
296 FUNCTION
297 Query video card hardware's numeric manufacturer ID (which may come
298 from PCI, Zorro, etc).
300 NOTES
301 Not all drivers may have assigned IDs. For example VGA driver and
302 virtual hosted drivers do not associate themselves with any IDs.
304 EXAMPLE
306 BUGS
308 SEE ALSO
309 MA_ProductID
311 INTERNALS
313 *****************************************************************************/
315 /*i***************************************************************************
317 NAME
318 MA_ProductID
320 SYNOPSIS
321 [..G], ULONG
323 LOCATION
324 MONITORCLASS
326 FUNCTION
327 Query video card hardware's numeric product ID (which may come from
328 PCI, Zorro, etc).
330 NOTES
331 Not all drivers may have assigned IDs. For example VGA driver and
332 virtual hosted drivers do not associate themselves with any IDs.
334 EXAMPLE
336 BUGS
338 SEE ALSO
339 MA_ManufacturerID
341 INTERNALS
343 *****************************************************************************/
345 /*i***************************************************************************
347 NAME
348 MA_MemorySize
350 SYNOPSIS
351 [..G], ULONG
353 LOCATION
354 MONITORCLASS
356 FUNCTION
357 Query total size of video card memory in bytes.
359 NOTES
361 EXAMPLE
363 BUGS
365 SEE ALSO
366 MA_MemoryClock
368 INTERNALS
370 *****************************************************************************/
372 /*i***************************************************************************
374 NAME
375 MA_PixelFormats
377 SYNOPSIS
378 [..G], ULONG *
380 LOCATION
381 MONITORCLASS
383 FUNCTION
384 Query table of supported pixelformats.
386 A returned value is a pointer to static array of ULONGs, one ULONG per
387 CyberGraphX pixelformat. Values of these ULONGs are actually booleans.
388 A TRUE value in the array says that the pixelformat is supported,
389 FALSE means it is not.
391 NOTES
393 EXAMPLE
394 ULONG *pfs;
396 GetAttr(MA_PixelFormats, monitor, (IPTR *)&pfs);
397 if (pfs[PUXFMT_LUT8])
398 printf("The display driver supports LUT8 format\n");
400 BUGS
402 SEE ALSO
403 MA_ManufacturerID
405 INTERNALS
407 *****************************************************************************/
409 /*i***************************************************************************
411 NAME
412 MA_TopLeftMonitor
414 SYNOPSIS
415 [.SG], Object *
417 LOCATION
418 MONITORCLASS
420 FUNCTION
421 Get a pointer to a monitor placed in top-left diagonal direction
422 relative tothe current one.
424 This attribute is used to describe relative placement of monitors in
425 user's physical environment.
427 NOTES
429 EXAMPLE
431 BUGS
432 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
433 monitor object.
435 SEE ALSO
436 MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
437 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
438 MA_BottomRightMonitor
440 INTERNALS
442 *****************************************************************************/
444 /*i***************************************************************************
446 NAME
447 MA_TopMiddleMonitor
449 SYNOPSIS
450 [.SG], Object *
452 LOCATION
453 MONITORCLASS
455 FUNCTION
456 Get a pointer to a monitor placed in top direction relative to the
457 current one.
459 This attribute is used to describe relative placement of monitors in
460 the user's physical environment.
462 NOTES
464 EXAMPLE
466 BUGS
467 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
468 pointer to a monitor object.
470 SEE ALSO
471 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
472 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
473 MA_BottomRightMonitor
475 INTERNALS
477 *****************************************************************************/
479 /*i***************************************************************************
481 NAME
482 MA_TopRightMonitor
484 SYNOPSIS
485 [.SG], Object *
487 LOCATION
488 MONITORCLASS
490 FUNCTION
491 Get a pointer to a monitor placed in top-right diagonal direction
492 relative to the current one.
494 This attribute is used to describe relative placement of monitors in
495 the user's physical environment.
497 NOTES
499 EXAMPLE
501 BUGS
502 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
503 pointer to a monitor object.
505 SEE ALSO
506 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
507 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
508 MA_BottomRightMonitor
510 INTERNALS
512 *****************************************************************************/
514 /*i***************************************************************************
516 NAME
517 MA_MiddleLeftMonitor
519 SYNOPSIS
520 [.SG], Object *
522 LOCATION
523 MONITORCLASS
525 FUNCTION
526 Get a pointer to a monitor placed in left direction relative to
527 the current one.
529 This attribute is used to describe relative placement of monitors in
530 the user's physical environment.
532 NOTES
534 EXAMPLE
536 BUGS
537 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
538 pointer to a monitor object.
540 SEE ALSO
541 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
542 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
543 MA_BottomRightMonitor
545 INTERNALS
547 *****************************************************************************/
549 /*i***************************************************************************
551 NAME
552 MA_MiddleRightMonitor
554 SYNOPSIS
555 [.SG], Object *
557 LOCATION
558 MONITORCLASS
560 FUNCTION
561 Get a pointer to a monitor placed in right direction relative to
562 the current one.
564 This attribute is used to describe relative placement of monitors in
565 the user's physical environment.
567 NOTES
569 EXAMPLE
571 BUGS
572 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
573 pointer to a monitor object.
575 SEE ALSO
576 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
577 MA_MiddleLeftMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
578 MA_BottomRightMonitor
580 INTERNALS
582 *****************************************************************************/
584 /*i***************************************************************************
586 NAME
587 MA_BottomLeftMonitor
589 SYNOPSIS
590 [.SG], Object *
592 LOCATION
593 MONITORCLASS
595 FUNCTION
596 Get a pointer to a monitor placed in bottom-left diagonal direction
597 relative to the current one.
599 This attribute is used to describe relative placement of monitors in
600 the user's physical environment.
602 NOTES
604 EXAMPLE
606 BUGS
607 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
608 pointer to a monitor object.
610 SEE ALSO
611 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
612 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomMiddleMonitor,
613 MA_BottomRightMonitor
615 INTERNALS
617 *****************************************************************************/
619 /*i***************************************************************************
621 NAME
622 MA_BottomMiddleMonitor
624 SYNOPSIS
625 [.SG], Object *
627 LOCATION
628 MONITORCLASS
630 FUNCTION
631 Get a pointer to a monitor placed in bottom direction relative to the
632 current one.
634 This attribute is used to describe relative placement of monitors in
635 the user's physical environment.
637 NOTES
639 EXAMPLE
641 BUGS
642 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
643 pointer to a monitor object.
645 SEE ALSO
646 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
647 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomLeftMonitor,
648 MA_BottomRightMonitor
650 INTERNALS
652 *****************************************************************************/
654 /*i***************************************************************************
656 NAME
657 MA_BottomRightMonitor
659 SYNOPSIS
660 [.SG], Object *
662 LOCATION
663 MONITORCLASS
665 FUNCTION
666 Get a pointer to a monitor placed in bottom-right diagonal direction
667 relative to the current one.
669 This attribute is used to describe relative placement of monitors in
670 the user's physical environment.
672 NOTES
674 EXAMPLE
676 BUGS
677 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
678 pointer to a monitor object.
680 SEE ALSO
681 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
682 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomLeftMonitor,
683 MA_BottomMiddleMonitor
685 INTERNALS
687 *****************************************************************************/
689 /*i***************************************************************************
691 NAME
692 MA_GammaControl
694 SYNOPSIS
695 [..G], BOOL
697 LOCATION
698 MONITORCLASS
700 FUNCTION
701 Query if the display driver supports gamma control.
703 NOTES
705 EXAMPLE
707 BUGS
709 SEE ALSO
710 MM_GetDefaultGammaTables, MM_SetDefaultGammaTables
712 INTERNALS
714 *****************************************************************************/
716 /*i***************************************************************************
718 NAME
719 MA_PointerType
721 SYNOPSIS
722 [..G], ULONG
724 LOCATION
725 MONITORCLASS
727 FUNCTION
728 Query supported mouse pointer sprite formats.
730 The returned value is a combination of the following bit flags:
731 PointerType_3Plus1 - color 0 transparent, 1-3 visible (Amiga(tm)
732 chipset sprite)
733 PointerType_2Plus1 - color 0 transparent, 1 undefined (can be for
734 example clear or inverse), 2-3 visible
735 PointerType_ARGB - Direct color bitmap (hi-color or truecolor,
736 possibly with alpha channel
738 NOTES
740 EXAMPLE
742 BUGS
744 SEE ALSO
745 MM_GetPointerBounds
747 INTERNALS
749 *****************************************************************************/
751 /*i***************************************************************************
753 NAME
754 MA_DriverName
756 SYNOPSIS
757 [..G], STRPTR
759 LOCATION
760 MONITORCLASS
762 FUNCTION
763 Query CyberGraphX driver name. It is the name which can be given to
764 cybergraphics.library/BestCModeIDTagList() as CYBRBIDTG_BoardName
765 value.
767 NOTES
769 EXAMPLE
771 BUGS
773 SEE ALSO
774 MM_GetPointerBounds
776 INTERNALS
778 *****************************************************************************/
780 /*i***************************************************************************
782 NAME
783 MA_MemoryClock
785 SYNOPSIS
786 [..G], ULONG
788 LOCATION
789 MONITORCLASS
791 FUNCTION
792 Query the video card's memory clock in Hertz. 0 is a valid value
793 meaning 'unknown'.
795 NOTES
797 EXAMPLE
799 BUGS
801 SEE ALSO
802 MA_MemorySize
804 INTERNALS
806 *****************************************************************************/
808 /*i***************************************************************************
810 NAME
811 MA_Windowed
813 SYNOPSIS
814 [..G], BOOL
816 LOCATION
817 MONITORCLASS
819 FUNCTION
820 Check if this monitor is a window on hosted OS desktop.
822 This means that the host OS is responsible for handling mouse input
823 and display activation. Monitors with this attribute set to TRUE
824 should be ignored by multi-display desktop configuration software.
826 These monitors should have no spatial links to other monitors.
827 Activation of these monitors is done by clicking on their windows on
828 the host's desktop and is handled by the driver itself.
830 NOTES
831 This attribute is AROS-specific; it does not exist in MorphOS.
833 EXAMPLE
835 BUGS
837 SEE ALSO
839 INTERNALS
841 *****************************************************************************/
843 /*i**************************************************************************/
845 IPTR MonitorClass__OM_GET(Class *cl, Object *o, struct opGet *msg)
847 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
848 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
849 OOP_AttrBase HiddAttrBase = GetPrivIBase(IntuitionBase)->HiddAttrBase;
850 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
851 struct IMonitorNode *data = INST_DATA(cl, o);
853 D(bug("[Monitor] %s()\n", __func__));
855 switch (msg->opg_AttrID)
857 case MA_MonitorName:
858 *msg->opg_Storage = (IPTR)data->MonitorName;
859 break;
861 case MA_Manufacturer:
862 OOP_GetAttr(data->handle->gfxhidd, aHidd_ProducerName, msg->opg_Storage);
863 break;
865 case MA_ManufacturerID:
866 OOP_GetAttr(data->handle->gfxhidd, aHidd_Producer, msg->opg_Storage);
867 break;
869 case MA_ProductID:
870 OOP_GetAttr(data->handle->gfxhidd, aHidd_Product, msg->opg_Storage);
871 break;
873 case MA_MemorySize:
874 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_MemorySize, msg->opg_Storage);
875 break;
877 case MA_PixelFormats:
878 *msg->opg_Storage = (IPTR)data->pixelformats;
879 break;
881 case MA_TopLeftMonitor:
882 *msg->opg_Storage = (IPTR)data->topleft;
883 break;
885 case MA_TopMiddleMonitor:
886 *msg->opg_Storage = (IPTR)data->topmiddle;
887 break;
889 case MA_TopRightMonitor:
890 *msg->opg_Storage = (IPTR)data->topright;
891 break;
893 case MA_MiddleLeftMonitor:
894 *msg->opg_Storage = (IPTR)data->middleleft;
895 break;
897 case MA_MiddleRightMonitor:
898 *msg->opg_Storage = (IPTR)data->middleright;
899 break;
901 case MA_BottomLeftMonitor:
902 *msg->opg_Storage = (IPTR)data->bottomleft;
903 break;
905 case MA_BottomMiddleMonitor:
906 *msg->opg_Storage = (IPTR)data->bottommiddle;
907 break;
909 case MA_BottomRightMonitor:
910 *msg->opg_Storage = (IPTR)data->bottomright;
911 break;
913 case MA_GammaControl:
914 *msg->opg_Storage = data->gamma ? TRUE : FALSE;
915 break;
917 case MA_PointerType:
918 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_HWSpriteTypes, msg->opg_Storage);
919 break;
921 case MA_DriverName:
922 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_DriverName, msg->opg_Storage);
923 break;
925 case MA_MemoryClock:
926 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_MemoryClock, msg->opg_Storage);
927 break;
929 case MA_Windowed:
930 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_IsWindowed, msg->opg_Storage);
931 break;
933 case MA_MonitorID:
934 *msg->opg_Storage = data->handle->id;
935 break;
937 default:
938 return DoSuperMethodA(cl, o, (Msg)msg);
941 return TRUE;
944 /*i**************************************************************************/
946 IPTR MonitorClass__OM_SET(Class *cl, Object *o, struct opSet *msg)
948 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
949 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
950 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
951 struct IMonitorNode *data = INST_DATA(cl, o);
952 struct TagItem *tag, *tstate;
954 tstate = msg->ops_AttrList;
955 while((tag = NextTagItem(&tstate))) {
956 switch (tag->ti_Tag) {
957 case MA_TopLeftMonitor:
958 data->topleft = (Object *)tag->ti_Data;
959 break;
961 case MA_TopMiddleMonitor:
962 data->topmiddle = (Object *)tag->ti_Data;
963 break;
965 case MA_TopRightMonitor:
966 data->topright = (Object *)tag->ti_Data;
967 break;
969 case MA_MiddleLeftMonitor:
970 data->middleleft = (Object *)tag->ti_Data;
971 break;
973 case MA_MiddleRightMonitor:
974 data->middleright = (Object *)tag->ti_Data;
975 break;
977 case MA_BottomLeftMonitor:
978 data->bottomleft = (Object *)tag->ti_Data;
979 break;
981 case MA_BottomMiddleMonitor:
982 data->bottommiddle = (Object *)tag->ti_Data;
983 break;
985 case MA_BottomRightMonitor:
986 data->bottomright = (Object *)tag->ti_Data;
987 break;
989 case MA_PointerVisible:
990 HIDD_Gfx_SetCursorVisible(data->handle->gfxhidd, tag->ti_Data);
991 break;
994 return DoSuperMethodA(cl, o, (Msg)msg);
997 /*i**************************************************************************/
999 #define Relink(nextAttr, prev, prevAttr, next) \
1000 if (prev) \
1001 SetAttrs(prev, nextAttr, next, TAG_DONE); \
1002 if (next) \
1003 SetAttrs(next, prevAttr, prev, TAG_DONE)
1005 IPTR MonitorClass__OM_DISPOSE(Class *cl, Object *o, Msg msg)
1007 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1008 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1009 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
1010 struct IMonitorNode *data = INST_DATA(cl, o);
1011 struct TagItem tags[] =
1013 {aHidd_Gfx_ActiveCallBack, 0},
1014 {TAG_DONE , 0}
1017 D(bug("[Monitor] %s()\n", __func__));
1019 /* Disable activation callback */
1020 OOP_SetAttrs(data->handle->gfxhidd, tags);
1022 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
1023 Remove((struct Node *)data);
1025 /* Remove this monitor from spatial links */
1026 Relink(MA_BottomRightMonitor, data->topleft, MA_TopLeftMonitor, data->bottomright);
1027 Relink(MA_BottomMiddleMonitor, data->topmiddle, MA_TopMiddleMonitor, data->bottommiddle);
1028 Relink(MA_BottomLeftMonitor, data->topright, MA_TopRightMonitor, data->bottomleft);
1029 Relink(MA_MiddleLeftMonitor, data->middleright, MA_MiddleRightMonitor, data->middleleft);
1031 /* If an active monitor is being removed, we should activate another one */
1032 if (GetPrivIBase(IntuitionBase)->ActiveMonitor == o)
1033 ActivateMonitor((Object *)GetHead(&GetPrivIBase(IntuitionBase)->MonitorList), -1, -1, IntuitionBase);
1035 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
1037 if (data->gamma)
1038 FreeMem(data->gamma, 256 * 3);
1040 return DoSuperMethodA(cl, o, msg);
1043 /*i***************************************************************************
1045 NAME
1046 MM_GetRootBitMap
1048 SYNOPSIS
1049 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat,
1050 struct BitMap **Store);
1052 DoMethodA(Object *obj, struct msGetRootBitMap *msg);
1054 LOCATION
1056 FUNCTION
1057 This method is provided only for source code compatibility with the
1058 MorphOS operating system.
1060 Under MorphOS this method returns a pointer to internal root bitmap of
1061 the display driver corresponding to the specified pixelformat.
1062 Displayable bitmaps are supposed to be created as friends of the root
1063 bitmap.
1065 In AROS displayable bitmaps need complete display mode information and
1066 not only pixelformat. So this method will never be implemented and will
1067 always return a NULL pointer. In order to create a displayable RTG
1068 bitmap on AROS the user needs to supply a taglist with
1069 BMATags_DisplayID specification to the AllocBitMap() function.
1071 INPUTS
1072 obj - A monitor object
1073 MethodID - MM_GetRootBitMap
1074 PixelFormat - A CyberGraphX pixelformat code to get root bitmap for
1075 Store - A storage where root bitmap pointer will be placed.
1077 RESULT
1078 Undefined.
1080 NOTES
1082 EXAMPLE
1084 BUGS
1086 SEE ALSO
1087 graphics.library/AllocBitMap()
1089 INTERNALS
1091 *****************************************************************************/
1093 IPTR MonitorClass__MM_GetRootBitMap(Class *cl, Object *obj, struct msGetRootBitMap *msg)
1095 *msg->Store = NULL;
1097 return 0;
1100 /*i***************************************************************************
1102 NAME
1103 MM_Query3DSupport
1105 SYNOPSIS
1106 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, ULONG *Store);
1108 DoMethodA(Object *obj, struct msQuery3DSupport *msg);
1110 LOCATION
1112 FUNCTION
1113 Ask the display driver for type of 3D support for the given
1114 pixelformat.
1116 Supplied storage will be filled with one of:
1117 MSQUERY3D_UNKNOWN - Unsupported pixelformat or some internal error
1118 MSQUERY3D_NODRIVER - There is no 3D support for the given
1119 pixelformat
1120 MSQUERY3D_SWDRIVER - A software 3D support is available for the
1121 given pixelformat
1122 MSQUERY3D_HWDRIVER - A hardware 3D support is available for the
1123 given pixelformat
1125 INPUTS
1126 obj - A monitor object to query
1127 MethodID - MM_Query3DSupport
1128 PixelFormat - A CyberGraphX pixelformat code
1129 Store - A pointer to a storage where return value will be placed
1131 RESULT
1132 Undefined.
1134 NOTES
1136 EXAMPLE
1138 BUGS
1140 SEE ALSO
1142 INTERNALS
1144 *****************************************************************************/
1146 IPTR MonitorClass__MM_Query3DSupport(Class *cl, Object *obj, struct msQuery3DSupport *msg)
1148 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1149 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1150 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1151 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1152 struct IMonitorNode *data = INST_DATA(cl, obj);
1153 OOP_Object *pf = data->pfobjects[msg->PixelFormat];
1155 if (pf) {
1156 if (HIDD_Gfx_QueryHardware3D(data->handle->gfxhidd, pf))
1157 *msg->Store = MSQUERY3D_HWDRIVER;
1158 else {
1159 IPTR depth;
1161 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
1162 if (depth > 8)
1163 *msg->Store = MSQUERY3D_SWDRIVER;
1164 else
1165 *msg->Store = MSQUERY3D_NODRIVER;
1167 } else
1168 *msg->Store = MSQUERY3D_UNKNOWN;
1170 return *msg->Store;
1173 /*i***************************************************************************
1175 NAME
1176 MM_GetDefaultGammaTables
1178 SYNOPSIS
1179 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green,
1180 UBYTE *Blue);
1182 DoMethodA(Object *obj, struct msGetDefaultGammaTables *msg);
1184 LOCATION
1186 FUNCTION
1187 Get default gamma correction tables for the monitor.
1189 INPUTS
1190 obj - A monitor object to query
1191 MethodID - MM_GetDefaultGammaTables
1192 Red - A pointer to an array of 256 bytes where gamma correction
1193 data for the red component will be placed. You may specify
1194 a NULL pointer in order to ignore this component.
1195 Green - A pointer to an array of 256 bytes where gamma correction
1196 data for the green component will be placed. You may
1197 specify a NULL pointer in order to ignore this component.
1198 Blue - A pointer to an array of 256 bytes where gamma correction
1199 data for the blue component will be placed. You may specify
1200 a NULL pointer in order to ignore this component.
1202 RESULT
1203 Undefined.
1205 NOTES
1207 EXAMPLE
1209 BUGS
1211 SEE ALSO
1212 MM_SetDefaultGammaTables
1214 INTERNALS
1216 *****************************************************************************/
1218 void MonitorClass__MM_GetDefaultGammaTables(Class *cl, Object *obj, struct msGetDefaultGammaTables *msg)
1220 struct IMonitorNode *data = INST_DATA(cl, obj);
1222 if (data->gamma)
1224 if (msg->Red)
1225 CopyMem(&data->gamma[GAMMA_R], msg->Red, 256);
1226 if (msg->Green)
1227 CopyMem(&data->gamma[GAMMA_G], msg->Green, 256);
1228 if (msg->Blue)
1229 CopyMem(&data->gamma[GAMMA_B], msg->Blue, 256);
1233 /*i***************************************************************************
1235 NAME
1236 MM_GetDefaultPixelFormat
1238 SYNOPSIS
1239 DoMethod(Object *obj, ULONG MethodID, ULONG Depth, ULONG *Store);
1241 DoMethodA(Object *obj, struct msGetDefaultPixelFormat *msg);
1243 LOCATION
1245 FUNCTION
1246 Get the driver's preferred pixelformat for the specified bitmap depth.
1248 INPUTS
1249 obj - A monitor object
1250 MethodID - MM_GetDefaultPixelFormat
1251 Depth - Depth to ask about
1252 Store - A pointer to an ULONG location where CyberGraphX
1253 pixelformat number will be placed. -1 means unsupported
1254 depth.
1256 RESULT
1257 Undefined.
1259 NOTES
1261 EXAMPLE
1263 BUGS
1265 SEE ALSO
1267 INTERNALS
1269 *****************************************************************************/
1271 IPTR MonitorClass__MM_GetDefaultPixelFormat(Class *cl, Object *obj, struct msGetDefaultPixelFormat *msg)
1273 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1274 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1275 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1276 struct IMonitorNode *data = INST_DATA(cl, obj);
1277 ULONG i;
1279 for (i = 0; i < MONITOR_MAXPIXELFORMATS; i++) {
1280 if (data->pfobjects[i]) {
1281 IPTR depth;
1283 OOP_GetAttr(data->pfobjects[i], aHidd_PixFmt_Depth, &depth);
1284 if (depth == msg->Depth) {
1285 *msg->Store = i;
1286 break;
1291 if (i == MONITOR_MAXPIXELFORMATS)
1292 *msg->Store = -1;
1294 return *msg->Store;
1297 /*i***************************************************************************
1299 NAME
1300 MM_GetPointerBounds
1302 SYNOPSIS
1303 DoMethod(Object *obj, ULONG MethodID, ULONG PointerType, ULONG *Width,
1304 ULONG *Height);
1306 DoMethodA(Object *obj, struct msGetPointerBounds *msg);
1308 LOCATION
1309 monitorclass
1311 FUNCTION
1312 Get the maximum allowed size of a mouse pointer sprite.
1314 INPUTS
1315 obj - A monitor object
1316 MethodID - MM_GetPointerBounds
1317 PointerType - Pointer type (one of PointerType_...)
1318 Width - A pointer to an ULONG location where width will be
1319 placed.
1320 Height - A pointer to an ULONG location where height will be
1321 placed.
1323 RESULT
1324 FALSE is given pointer type is not supported, TRUE otherwise.
1326 NOTES
1327 Width and Height are considered undefined if the method returns FALSE.
1329 EXAMPLE
1331 BUGS
1333 SEE ALSO
1334 MA_PointerType
1336 INTERNALS
1338 *****************************************************************************/
1340 IPTR MonitorClass__MM_GetPointerBounds(Class *cl, Object *obj, struct msGetPointerBounds *msg)
1342 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1343 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1344 struct IMonitorNode *data = INST_DATA(cl, obj);
1346 return HIDD_Gfx_GetMaxSpriteSize(data->handle->gfxhidd, msg->PointerType, msg->Width, msg->Height);
1349 /*i***************************************************************************
1351 NAME
1352 MM_RunBlanker
1354 SYNOPSIS
1355 DoMethod(Object *obj, ULONG MethodID);
1357 DoMethodA(Object *obj, Msg *msg);
1359 LOCATION
1361 FUNCTION
1362 Starts screensaver on the monitor.
1364 At the moment AROS has no integrated screensaver support. The method
1365 is considered reserved and not implemented.
1367 INPUTS
1368 obj - A monitor object
1369 MethodID - MM_RunBlanker
1371 RESULT
1372 Undefined.
1374 NOTES
1376 EXAMPLE
1378 BUGS
1380 SEE ALSO
1381 MM_EnterPowerSaveMode, MM_ExitBlanker
1383 INTERNALS
1385 *****************************************************************************/
1387 IPTR MonitorClass__MM_RunBlanker(Class *cl, Object *obj, Msg *msg)
1389 /* We have no integrated screensaver support */
1391 return FALSE;
1394 /*i***************************************************************************
1396 NAME
1397 MM_EnterPowerSaveMode
1399 SYNOPSIS
1400 DoMethod(Object *obj, ULONG MethodID);
1402 DoMethodA(Object *obj, Msg *msg);
1404 LOCATION
1406 FUNCTION
1407 Starts power saving mode on the monitor.
1409 INPUTS
1410 obj - A monitor object
1411 MethodID - MM_EnterPowerSaveMode
1413 RESULT
1414 Undefined.
1416 NOTES
1418 EXAMPLE
1420 BUGS
1422 SEE ALSO
1423 MM_RunBlanker, MM_ExitBlanker
1425 INTERNALS
1426 Current implementation just immediately sets DMPS level to "Off" for
1427 the monitor.
1429 *****************************************************************************/
1431 IPTR MonitorClass__MM_EnterPowerSaveMode(Class *cl, Object *obj, Msg *msg)
1433 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1434 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1435 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
1436 struct IMonitorNode *data = INST_DATA(cl, obj);
1437 struct TagItem tags[] =
1439 {aHidd_Gfx_DPMSLevel, vHidd_Gfx_DPMSLevel_Off},
1440 {TAG_DONE , 0 }
1443 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1446 /*i***************************************************************************
1448 NAME
1449 MM_ExitBlanker
1451 SYNOPSIS
1452 DoMethod(Object *obj, ULONG MethodID);
1454 DoMethodA(Object *obj, Msg *msg);
1456 LOCATION
1458 FUNCTION
1459 Stops screensaver and/or power saving mode on the monitor.
1461 INPUTS
1462 obj - A monitor object
1463 MethodID - MM_ExitBlanker
1465 RESULT
1466 Undefined.
1468 NOTES
1470 EXAMPLE
1472 BUGS
1474 SEE ALSO
1475 MM_EnterPowerSaveMode, MM_RunBlanker
1477 INTERNALS
1479 *****************************************************************************/
1481 IPTR MonitorClass__MM_ExitBlanker(Class *cl, Object *obj, Msg *msg)
1483 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1484 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1485 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
1486 struct IMonitorNode *data = INST_DATA(cl, obj);
1487 struct TagItem tags[] =
1489 {aHidd_Gfx_DPMSLevel, vHidd_Gfx_DPMSLevel_On},
1490 {TAG_DONE , 0 }
1493 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1496 /*i***************************************************************************
1498 NAME
1499 MM_SetDefaultGammaTables
1501 SYNOPSIS
1502 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green,
1503 UBYTE *Blue);
1505 DoMethodA(Object *obj, struct msSetDefaultGammaTables *msg);
1507 LOCATION
1509 FUNCTION
1510 Set default gamma correction tables for the monitor.
1512 INPUTS
1513 obj - A monitor object to query
1514 MethodID - MM_GetDefaultGammaTables
1515 Red - A pointer to an array of 256 bytes where gamma correction
1516 data for the red component is placed. You may specify a
1517 NULL pointer in order to ignore this component.
1518 Green - A pointer to an array of 256 bytes where gamma correction
1519 data for the green component is placed. You may specify a
1520 NULL pointer in order to ignore this component.
1521 Blue - A pointer to an array of 256 bytes where gamma correction
1522 data for the blue component is placed. You may specify a
1523 NULL pointer in order to ignore this component.
1525 RESULT
1526 Undefined.
1528 NOTES
1529 This method is AROS-specific.
1531 EXAMPLE
1533 BUGS
1535 SEE ALSO
1536 MM_GetDefaultGammaTables
1538 INTERNALS
1540 *****************************************************************************/
1542 IPTR MonitorClass__MM_SetDefaultGammaTables(Class *cl, Object *obj, struct msSetDefaultGammaTables *msg)
1544 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1545 struct IMonitorNode *data = INST_DATA(cl, obj);
1547 if (data->gamma)
1549 IPTR ret;
1551 if (msg->Red)
1552 CopyMem(msg->Red , &data->gamma[GAMMA_R], 256);
1553 if (msg->Green)
1554 CopyMem(msg->Green, &data->gamma[GAMMA_G], 256);
1555 if (msg->Blue)
1556 CopyMem(msg->Blue , &data->gamma[GAMMA_B], 256);
1558 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->ViewLordLock);
1560 if (data->screenGamma == 3)
1563 * All three components are determined by screen.
1564 * Do not disturb.
1566 ret = TRUE;
1568 else
1571 * This monitor currently uses default gamma table.
1572 * Update it.
1574 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1576 ret = HIDD_Gfx_SetGamma(data->handle->gfxhidd, data->active_r, data->active_g, data->active_b);
1579 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->ViewLordLock);
1580 return ret;
1583 return FALSE;
1586 /*i**************************************************************************/
1588 ULONG MonitorClass__MM_GetCompositionFlags(Class *cl, Object *obj, struct msGetCompositionFlags *msg)
1590 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1591 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1592 struct IMonitorNode *data = INST_DATA(cl, obj);
1593 struct HIDD_ModeProperties modeprops;
1595 HIDD_Gfx_ModeProperties(data->handle->gfxhidd, msg->ModeID & (!data->handle->mask),
1596 &modeprops, sizeof(modeprops));
1597 return modeprops.CompositionFlags;
1600 /*i**************************************************************************/
1602 void MonitorClass__MM_SetPointerPos(Class *cl, Object *obj, struct msSetPointerPos *msg)
1604 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1605 struct IMonitorNode *data = INST_DATA(cl, obj);
1607 data->mouseX = msg->x;
1608 data->mouseY = msg->y;
1609 SetPointerPos(data, IntuitionBase);
1612 /*i**************************************************************************/
1614 IPTR MonitorClass__MM_CheckID(Class *cl, Object *obj, struct msGetCompositionFlags *msg)
1616 struct IMonitorNode *data = INST_DATA(cl, obj);
1618 return ((msg->ModeID & data->handle->mask) == data->handle->id);
1621 /*i**************************************************************************/
1623 IPTR MonitorClass__MM_SetPointerShape(Class *cl, Object *obj, struct msSetPointerShape *msg)
1625 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1626 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1627 struct IMonitorNode *data = INST_DATA(cl, obj);
1628 struct BitMap *bm;
1629 BOOL res;
1631 DPOINTER(
1632 bug("[Monitor] %s(0x%p)\n", __func__, msg->pointer);
1633 bug("[Monitor] %s: old pointer 0x%p\n", __func__, data->pointer);
1635 /* Don't do anything if already set */
1636 if (data->pointer == msg->pointer)
1637 return TRUE;
1639 DPOINTER(bug("[Monitor] %s: Display SpriteType = %08x\n", __func__, data->SpriteType);)
1641 bm = msg->pointer->sprite->es_BitMap;
1642 /* Currently we don't work with non-hidd sprites */
1643 if (!IS_HIDD_BM(bm))
1644 return FALSE;
1646 res = HIDD_Gfx_SetCursorShape(data->handle->gfxhidd, HIDD_BM_OBJ(bm), msg->pointer->xoffset, msg->pointer->yoffset);
1647 DPOINTER(bug("[Monitor] %s: SetCursorShape() returned %d\n", __func__, res));
1648 if (res) {
1649 data->pointer = msg->pointer;
1650 /* This will fix up sprite position if hotspot changed */
1651 SetPointerPos(data, IntuitionBase);
1654 return res;
1657 void MonitorClass__MM_SetScreenGamma(Class *cl, Object *obj, struct msSetScreenGamma *msg)
1659 struct IMonitorNode *data = INST_DATA(cl, obj);
1661 if (data->gamma)
1663 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1664 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1665 struct GammaControl *gamma = msg->gamma;
1667 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->ViewLordLock);
1669 if (gamma->Active)
1671 UBYTE screengamma = 0;
1673 ResetGamma(data);
1674 if (gamma->UseGammaControl)
1676 if (gamma->GammaTableR)
1678 data->active_r = gamma->GammaTableR;
1679 screengamma++;
1681 if (gamma->GammaTableB)
1683 data->active_b = gamma->GammaTableB;
1684 screengamma++;
1686 if (gamma->GammaTableG)
1688 data->active_g = gamma->GammaTableG;
1689 screengamma++;
1694 * The condition here reflects the following variants:
1695 * 1. We used default gamma and switched to custom one.
1696 * 2. We used custom gamma and switched to default one.
1697 * 3. We changed custom gamma.
1699 if (data->screenGamma || screengamma || msg->force)
1701 data->screenGamma = screengamma;
1702 HIDD_Gfx_SetGamma(data->handle->gfxhidd, data->active_r, data->active_g, data->active_b);
1706 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->ViewLordLock);
1711 * Find the best (closest to the given) depth with 3D support.
1712 * This method will give the priority to hardware 3D.
1714 ULONG MonitorClass__MM_FindBest3dDepth(Class *cl, Object *obj, struct msFindBest3dDepth *msg)
1716 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1717 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1718 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1719 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1720 struct IMonitorNode *data = INST_DATA(cl, obj);
1721 ULONG swdepth = -1;
1722 ULONG i;
1724 for (i = 0; i < MONITOR_MAXPIXELFORMATS; i++)
1726 if (data->pfobjects[i])
1728 IPTR depth;
1730 OOP_GetAttr(data->pfobjects[i], aHidd_PixFmt_Depth, &depth);
1732 if (depth < msg->depth)
1734 /* Skip all pixelformats with depth less than requested */
1735 continue;
1738 if (HIDD_Gfx_QueryHardware3D(data->handle->gfxhidd, data->pfobjects[i]))
1740 /* Found hardware 3D ? Good. */
1741 return depth;
1744 if ((depth > 8) && (swdepth == -1))
1746 /* This remembers the first depth suitable for software 3D */
1747 swdepth = depth;
1752 return swdepth;
1756 * Calculate 3D capability index.
1757 * Used for finding the best 3D monitor.
1759 ULONG MonitorClass__MM_Calc3dCapability(Class *cl, Object *obj, Msg msg)
1761 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1762 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1763 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1764 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1765 struct IMonitorNode *data = INST_DATA(cl, obj);
1766 ULONG idx = 0;
1767 ULONG i;
1769 for (i = 0; i < MONITOR_MAXPIXELFORMATS; i++)
1771 if (data->pfobjects[i])
1773 if (HIDD_Gfx_QueryHardware3D(data->handle->gfxhidd, data->pfobjects[i]))
1776 * Each HW 3D mode scores 2.
1777 * As a result, monitor with one HW 3D mode will beat SW-only 3D.
1779 idx += 2;
1781 else if (OOP_GET(data->pfobjects[i], aHidd_PixFmt_Depth) > 8)
1783 /* Any number of SW 3D modes scores 1 */
1784 idx |= 1;
1789 return idx;