use the locations specified in the bcm2708_boot header
[AROS.git] / rom / graphics / makevport.c
blobf0dd2b49f436a3bb4bf71cf7692cf3ff6319602c
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function MakeVPort()
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <graphics/view.h>
12 #include "graphics_intern.h"
13 #include "gfxfuncsupport.h"
15 /*****************************************************************************
17 NAME */
18 #include <proto/graphics.h>
20 AROS_LH2(ULONG, MakeVPort,
22 /* SYNOPSIS */
23 AROS_LHA(struct View *, view, A0),
24 AROS_LHA(struct ViewPort *, viewport, A1),
26 /* LOCATION */
27 struct GfxBase *, GfxBase, 36, Graphics)
29 /* FUNCTION
30 Prepare a ViewPort to be displayed. Calculate all necessary internal data.
31 For Amiga(tm) chipset bitmaps this includes calculating preliminary copperlists.
33 INPUTS
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
38 RESULT
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).
48 NOTES
50 EXAMPLE
52 BUGS
54 SEE ALSO
56 INTERNALS
58 HISTORY
61 ******************************************************************************/
63 AROS_LIBFUNC_INIT
65 struct ViewPortExtra *vpe;
66 struct HIDD_ViewPortData *vpd;
67 ULONG ret = MVP_OK;
68 BOOL own_vpe = FALSE;
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));
82 if (!vpe)
84 vpe = (struct ViewPortExtra *)GfxNew(VIEWPORT_EXTRA_TYPE);
85 if (!vpe)
86 return MVP_NO_VPE;
88 vpe->Flags = VPXF_FREE_ME;
89 GfxAssociate(viewport, &vpe->n);
90 own_vpe = TRUE;
93 /* Now make sure that ViewPortData is created */
94 if (!VPE_DATA(vpe))
95 vpe->DriverData[0] = AllocMem(sizeof(struct HIDD_ViewPortData), MEMF_PUBLIC|MEMF_CLEAR);
97 vpd = VPE_DATA(vpe);
98 if (vpd)
100 vpd->vpe = vpe;
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;
125 if (dih)
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.
153 if (vpd->Bitmap)
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);
166 else
167 ret = MVP_NO_MEM;
169 else
170 ret = MVP_NO_MEM;
172 if (ret == MVP_OK)
173 /* Use ScrollVPort() in order to validate offsets */
174 ScrollVPort(viewport);
175 else
177 if (own_vpe)
178 GfxFree(&vpe->n);
181 return ret;
183 AROS_LIBFUNC_EXIT
184 } /* MakeVPort */