rom/graphics: -Wall cleanup
[AROS.git] / rom / graphics / mrgcop.c
blob5adfe0b15720b71962338f22c36a36a2b4c56501
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function MrgCop()
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <exec/memory.h>
11 #include <graphics/gfxbase.h>
12 #include <graphics/view.h>
13 #include <graphics/rastport.h>
14 #include <oop/oop.h>
15 #include <proto/exec.h>
16 #include <proto/oop.h>
18 #include "graphics_intern.h"
19 #include "gfxfuncsupport.h"
21 /*****************************************************************************
23 NAME */
24 #include <proto/graphics.h>
26 AROS_LH1(ULONG, MrgCop,
28 /* SYNOPSIS */
29 AROS_LHA(struct View *, view, A1),
31 /* LOCATION */
32 struct GfxBase *, GfxBase, 35, Graphics)
34 /* FUNCTION
35 Prepare the view for being displayed. Calculate necessary internal data.
36 For Amiga(tm) chipset this function also merges together the display, color, sprite and user
37 coprocessor instructions into a single coprocessor instruction stream.
39 INPUTS
40 view - a pointer to the view structure to prepare
42 RESULT
43 error - ULONG error value indicating either lack of memory to build the system data,
44 or that MrgCop() has no work to do - ie there where no viewPorts in the list.
46 NOTES
47 Pre-v39 AmigaOS returns void.
49 If the given view is already on display, changes appear immediately.
51 EXAMPLE
53 BUGS
55 SEE ALSO
57 INTERNALS
59 HISTORY
62 ******************************************************************************/
64 AROS_LIBFUNC_INIT
66 struct ViewPort *first, *vp;
67 struct HIDD_ViewPortData *vpd;
68 struct HIDD_ViewPortData *prev_vpd;
69 struct monitor_driverdata *mdd;
70 struct monitor_driverdata *prev_mdd = NULL;
72 /* Build lists of displayed bitmaps, one list per display.
73 Lists are embedded in ViewPortExtra.DriverData field. Start of
74 the list is the first ViewPort for this display. */
75 for (first = view->ViewPort; first; first = first->Next) {
76 /* Ignore hidden ViewPorts */
77 if (!(first->Modes & VP_HIDE)) {
79 mdd = GET_VP_DRIVERDATA(first);
80 /* Ignore next ViewPort if it belongs to the same display.
81 This makes us slightly faster */
82 if (mdd == prev_mdd)
83 continue;
84 prev_mdd = mdd;
86 /* We don't check GfxLookUp() result against NULL because MakeVPort() has
87 already took care about this. If MrgCop() was called with some mailformed
88 ViewPorts, it's not our problem */
89 prev_vpd = VPE_DATA((struct ViewPortExtra *)GfxLookUp(first));
90 prev_vpd->Next = NULL;
91 D(bug("[MrgCop] First ViewPort: 0x%p, data 0x%p\n", first, prev_vpd));
93 /* Now we look down the list for ViewPorts with the same display driver as
94 current ViewPort and add them to a list */
95 for (vp = first->Next; vp; vp = vp->Next) {
96 if (!(vp->Modes & VP_HIDE)) {
98 if (GET_VP_DRIVERDATA(vp) == mdd) {
99 vpd = VPE_DATA((struct ViewPortExtra *)GfxLookUp(vp));
100 D(bug("[MrgCop] Attaching ViewPort 0x%p, data 0x%p\n", vp, vpd));
102 vpd->Next = NULL;
103 prev_vpd->Next = vpd;
104 prev_vpd = vpd;
111 ObtainSemaphore(GfxBase->ActiViewCprSemaphore);
113 /* If the given view is a currently displayed one, refresh immediately */
114 if (GfxBase->ActiView == view)
115 driver_LoadView(view, GfxBase);
117 ReleaseSemaphore(GfxBase->ActiViewCprSemaphore);
119 return prev_mdd ? MCOP_OK : MCOP_NOP;
121 AROS_LIBFUNC_EXIT
122 } /* MrgCop */