Fixed support for vbcc
[AROS.git] / rom / graphics / scrollvport.c
blobe64565e9f813f8dc0cbec432cda37a2b56c729d9
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function ScrollVPort()
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <proto/oop.h>
12 #include "graphics_intern.h"
13 #include "compositor_driver.h"
14 #include "gfxfuncsupport.h"
16 /*****************************************************************************
18 NAME */
19 #include <proto/graphics.h>
21 AROS_LH1(void, ScrollVPort,
23 /* SYNOPSIS */
24 AROS_LHA(struct ViewPort *, vp, A0),
26 /* LOCATION */
27 struct GfxBase *, GfxBase, 98, Graphics)
29 /* FUNCTION
30 Move the ViewPort to the position specified in DxOffset and DyOffset
31 members of the ViewPort structure.
33 INPUTS
35 RESULT
36 None.
38 NOTES
39 AROS video drivers can perform a validation of offsets, and may refuse
40 to scroll the screen too far (if they somehow can't provide the requested
41 offset). In this case offset values in the ViewPort will be updated in
42 order to reflect the real result of the operation.
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 INTERNALS
52 HISTORY
54 ******************************************************************************/
56 AROS_LIBFUNC_INIT
59 * Bitmap object pointer is contained in struct ViewPortData,
60 * connected to a ViewPortExtra.
61 * This is true even for planar Amiga bitmaps.
63 struct ViewPortExtra *vpe = (struct ViewPortExtra *)GfxLookUp(vp);
65 if (vpe)
67 OOP_Object *bm = VPE_DATA(vpe)->Bitmap;
68 struct monitor_driverdata *mdd = VPE_DRIVER(vpe);
69 IPTR x = vp->DxOffset;
70 IPTR y = vp->DyOffset;
71 BOOL compositing = FALSE;
73 D(bug("[ScrollVPort] ViewPort 0x%p, Extra 0x%p, compositor 0x%p, offset (%ld, %ld)\n", vp, vpe, mdd->compositor, x, y));
76 * First we actually move the bitmap.
77 * If we are using software composition, this will update bitmap's offsets, for
78 * the case if this move will cause the screen to be completely covered with this
79 * bitmap (while previously it was not). In this case the compositor will dispose
80 * own working bitmap and display our bitmap instead. In effect of position update
81 * it will appear already in correct position. This will improve visual appearance
82 * of the scrolling.
84 OOP_SetAttrsTags(bm, aHidd_BitMap_LeftEdge, x, aHidd_BitMap_TopEdge, y, TAG_DONE);
86 if (mdd->compositor)
89 * Perform the operation via software compositor.
90 * x and y will be updated to the validated values.
92 compositing = compositor_ScrollBitMap(mdd->compositor, bm, &x, &y, GfxBase);
94 if (compositing)
97 * Composition is active.
98 * Uninstall the framebuffer from the frontmost bitmap
100 UninstallFB(mdd, GfxBase);
102 else if (!mdd->bm_bak)
105 * Composition is inactive. Install the framebuffer into the frontmost
106 * bitmap, if not already done.
107 * This will actually trigger only once, when composition switched from
108 * active to inactive state.
110 InstallFB(mdd, GfxBase);
114 /* The bitmap may fail to move. Fix up offsets now. */
115 if (!compositing)
118 * If software composition is inactive, we have our bitmap on display.
119 * Get validated offsets from it.
121 OOP_GetAttr(bm, aHidd_BitMap_LeftEdge, &x);
122 OOP_GetAttr(bm, aHidd_BitMap_TopEdge, &y);
125 D(bug("[ScrollVPort] Resulting offset (%ld, %ld), composition %d\n", x, y, compositing));
127 vp->DxOffset = x;
128 vp->DyOffset = y;
131 AROS_LIBFUNC_EXIT
132 } /* ScrollVPort */