2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Graphics function MakeVPort()
9 #include <aros/debug.h>
10 #include <graphics/view.h>
12 #include "graphics_intern.h"
13 #include "gfxfuncsupport.h"
15 /*****************************************************************************
18 #include <proto/graphics.h>
20 AROS_LH2(ULONG
, MakeVPort
,
23 AROS_LHA(struct View
*, view
, A0
),
24 AROS_LHA(struct ViewPort
*, viewport
, A1
),
27 struct GfxBase
*, GfxBase
, 36, Graphics
)
30 Prepare a ViewPort to be displayed. Calculate all necessary internal data.
31 For Amiga(tm) chipset bitmaps this includes calculating preliminary copperlists.
34 view - pointer to a View structure
35 viewport - pointer to a ViewPort structure
36 the viewport must have a valid pointer to a RasInfo
39 error - Result of the operation:
40 MVP_OK - Everything is OK, ViewPort is ready
41 MVP_NO_MEM - There was not enough memory for internal data
42 MVP_NO_VPE - There was no ViewPortExtra for this ViewPort and no memory to
43 allocate a temporary one.
44 MVP_NO_DSPINS - There was not enough memory for Amiga(tm) copperlist.
45 MVP_NO_DISPLAY - The BitMap can't be displayed using specified mode (for example,
46 misaligned or wrong depth).
61 ******************************************************************************/
65 struct ViewPortExtra
*vpe
;
66 struct HIDD_ViewPortData
*vpd
;
70 if (!viewport
|| !viewport
->RasInfo
|| !viewport
->RasInfo
->BitMap
)
71 return MVP_NO_DISPLAY
;
73 /* Non-HIDD bitmaps cannot be displayed */
74 if (!IS_HIDD_BM(viewport
->RasInfo
->BitMap
)) {
75 return MVP_NO_DISPLAY
;
78 /* Attach a temporary ViewPortExtra if needed */
79 vpe
= (struct ViewPortExtra
*)GfxLookUp(viewport
);
80 D(bug("[MakeVPort] ViewPort 0x%p, ViewPortExtra 0x%p\n", viewport
, vpe
));
84 vpe
= (struct ViewPortExtra
*)GfxNew(VIEWPORT_EXTRA_TYPE
);
88 vpe
->Flags
= VPXF_FREE_ME
;
89 GfxAssociate(viewport
, &vpe
->n
);
93 /* Now make sure that ViewPortData is created */
95 vpe
->DriverData
[0] = AllocMem(sizeof(struct HIDD_ViewPortData
), MEMF_PUBLIC
|MEMF_CLEAR
);
103 * MakeVPort() can be called repeatedly on the same ViewPort.
104 * However, each time we are called, the frontmost RastInfo
105 * BitMap may be different.
107 * Updated the cached frontmost BitMap object here.
108 * We don't need to use OBTAIN_HIDD_BM(), since we can
109 * only display HIDD bitmaps (and we have verified that above).
111 vpd
->Bitmap
= HIDD_BM_OBJ(viewport
->RasInfo
->BitMap
);
113 D(bug("[MakeVPort] Bitmap object: 0x%p\n", vpd
->Bitmap
));
115 if (IS_HIDD_BM(viewport
->RasInfo
->BitMap
))
118 * If we have a colormap attached to a HIDD bitmap, we can verify
119 * that bitmap and colormap modes do not differ.
121 if (viewport
->ColorMap
)
123 struct DisplayInfoHandle
*dih
= viewport
->ColorMap
->NormalDisplayInfo
;
127 if ((HIDD_BM_DRVDATA(viewport
->RasInfo
->BitMap
) != dih
->drv
) ||
128 (HIDD_BM_HIDDMODE(viewport
->RasInfo
->BitMap
) != dih
->id
))
131 D(bug("[MakeVPort] Bad NormalDisplayInfo\n"));
132 D(bug("[MakeVPort] Driverdata: ViewPort 0x%p, BitMap 0x%p\n", dih
->drv
, HIDD_BM_DRVDATA(viewport
->RasInfo
->BitMap
)));
133 D(bug("[MakeVPort] HIDD ModeID: ViewPort 0x%p, BitMap 0x%p\n", dih
->id
, HIDD_BM_HIDDMODE(viewport
->RasInfo
->BitMap
)));
134 ret
= MVP_NO_DISPLAY
;
138 if (viewport
->ColorMap
->VPModeID
!= INVALID_ID
)
140 if (GET_BM_MODEID(viewport
->RasInfo
->BitMap
) != viewport
->ColorMap
->VPModeID
)
142 D(bug("[MakeVPort] Bad ModeID, ViewPort 0x%08lX, BitMap 0x%08lX\n", viewport
->ColorMap
->VPModeID
, GET_BM_MODEID(viewport
->RasInfo
->BitMap
)));
143 ret
= MVP_NO_DISPLAY
;
150 * Ensure that we have a bitmap object.
151 * OBTAIN_HIDD_BM() may fail on planar bitmap in low memory situation.
155 struct monitor_driverdata
*mdd
= GET_VP_DRIVERDATA(viewport
);
158 * Store driverdata pointer in private ViewPortExtra field.
159 * It is needed because the caller can first free BitMap, then
160 * its ViewPort. In this case we won't be able to retrieve
161 * driver pointer from the bitmap in FreeVPortCopLists().
163 vpe
->DriverData
[1] = mdd
;
164 ret
= HIDD_Gfx_MakeViewPort(mdd
->gfxhidd
, vpd
);
173 /* Use ScrollVPort() in order to validate offsets */
174 ScrollVPort(viewport
);