revert - libatomic is still needed for target code.
[AROS.git] / rom / graphics / mrgcop.c
blob71b0e162d79a36f8514bf5a6720097f324e4a788
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;
71 ULONG ret;
73 /* Build lists of displayed bitmaps, one list per display.
74 Lists are embedded in ViewPortExtra.DriverData field. Start of
75 the list is the first ViewPort for this display. */
76 for (first = view->ViewPort; first; first = first->Next) {
77 /* Ignore hidden ViewPorts */
78 if (!(first->Modes & VP_HIDE)) {
80 mdd = GET_VP_DRIVERDATA(first);
81 /* Ignore next ViewPort if it belongs to the same display.
82 This makes us slightly faster */
83 if (mdd == prev_mdd)
84 continue;
85 prev_mdd = mdd;
87 /* We don't check GfxLookUp() result against NULL because MakeVPort() has
88 already took care about this. If MrgCop() was called with some mailformed
89 ViewPorts, it's not our problem */
90 prev_vpd = VPE_DATA((struct ViewPortExtra *)GfxLookUp(first));
91 prev_vpd->Next = NULL;
92 D(bug("[MrgCop] First ViewPort: 0x%p, data 0x%p\n", first, prev_vpd));
94 /* Now we look down the list for ViewPorts with the same display driver as
95 current ViewPort and add them to a list */
96 for (vp = first->Next; vp; vp = vp->Next) {
97 if (!(vp->Modes & VP_HIDE)) {
99 if (GET_VP_DRIVERDATA(vp) == mdd) {
100 vpd = VPE_DATA((struct ViewPortExtra *)GfxLookUp(vp));
101 D(bug("[MrgCop] Attaching ViewPort 0x%p, data 0x%p\n", vp, vpd));
103 vpd->Next = NULL;
104 prev_vpd->Next = vpd;
105 prev_vpd = vpd;
112 if (prev_mdd)
114 ret = DoViewFunction(view, driver_PrepareViewPorts, GfxBase);
116 if (ret == MCOP_OK)
118 ObtainSemaphore(GfxBase->ActiViewCprSemaphore);
120 /* If the given view is a currently displayed one, refresh immediately */
121 if (GfxBase->ActiView == view)
122 DoViewFunction(view, driver_LoadViewPorts, GfxBase);
124 ReleaseSemaphore(GfxBase->ActiViewCprSemaphore);
127 else
128 ret = MCOP_NOP;
130 return ret;
132 AROS_LIBFUNC_EXIT
133 } /* MrgCop */