New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / graphics / scrollraster.c
blob613014196f2a422b23200ba372277284f3fe9483
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$ $Log
5 Desc: Graphics function ScrollRaster()
6 Lang: english
7 */
8 #include "graphics_intern.h"
9 #include <graphics/rastport.h>
10 #include "gfxfuncsupport.h"
12 /*****************************************************************************
14 NAME */
15 #include <graphics/rastport.h>
16 #include <proto/graphics.h>
18 AROS_LH7(void, ScrollRaster,
20 /* SYNOPSIS */
21 AROS_LHA(struct RastPort *, rp, A1),
22 AROS_LHA(LONG , dx, D0),
23 AROS_LHA(LONG , dy, D1),
24 AROS_LHA(LONG , xMin, D2),
25 AROS_LHA(LONG , yMin, D3),
26 AROS_LHA(LONG , xMax, D4),
27 AROS_LHA(LONG , yMax, D5),
29 /* LOCATION */
30 struct GfxBase *, GfxBase, 66, Graphics)
32 /* FUNCTION
33 Scroll the contents of a rastport (dx,dy) towards (0,0).
34 The empty spaces is filled by a call to RectFill().
35 Only the pixel in the rectangle (xMin,yMin)-(xMax,yMax)
36 will be affected. The lower right corner (xMax, yMax) is
37 automatically adjusted to the lower right corner in case
38 it would be outside.
39 After this operation the Flags bit of the layer associated
40 with this rastport, if there is any layer, should be tested
41 for simple layers in case there has any damage been created.
44 INPUTS
45 rp - pointer to rastport
46 dx,dy - distance to move in x and y direction. Positive values go
47 towards (0,0)
48 xMin,yMin - upper left hand corner of the affected rectangle
49 xMax,yMax - lower right hand corner of the affected rectangle
51 RESULT
53 NOTES
55 EXAMPLE
57 BUGS
59 SEE ALSO
61 INTERNALS
63 HISTORY
64 29-10-95 digulla automatically created from
65 graphics_lib.fd and clib/graphics_protos.h
67 *****************************************************************************/
69 AROS_LIBFUNC_INIT
70 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
72 ULONG old_drmd = GetDrMd(rp);
73 LONG width, height, absdx, absdy;
75 FIX_GFXCOORD(xMin);
76 FIX_GFXCOORD(yMin);
77 FIX_GFXCOORD(xMax);
78 FIX_GFXCOORD(yMax);
80 if ((xMin > xMax) || (yMin > yMax)) return;
83 This function will simply call ScrollRaster() and fill the empty
84 space with calls to RectFill
87 /*
88 adjust xMax and yMax in case the lower right corner would be outside
89 the rastport
91 /* Is it a window's rastport ? */
92 if (NULL != rp->Layer)
94 struct Layer * L = rp->Layer;
96 if (xMax > (L->bounds.MaxX - L->bounds.MinX) )
97 xMax = (L->bounds.MaxX - L->bounds.MinX) ;
99 if (yMax > (L->bounds.MaxY - L->bounds.MinY) )
100 yMax = (L->bounds.MaxY - L->bounds.MinY) ;
103 else
105 /* this one belongs to a screen */
106 struct BitMap * bm = rp->BitMap;
107 ULONG width = GetBitMapAttr(bm, BMA_WIDTH);
108 ULONG height = GetBitMapAttr(bm, BMA_HEIGHT);
109 if ((ULONG)xMax >= width )
110 xMax = width - 1;
111 if ((ULONG)yMax >= height)
112 yMax = height - 1;
115 absdx = (dx >= 0) ? dx : -dx;
116 absdy = (dy >= 0) ? dy : -dy;
118 width = xMax - xMin + 1;
119 height = yMax - yMin + 1;
121 if ((width < 1) || (height < 1)) return;
123 if ((absdx >= width) || (absdy >= height))
125 SetDrMd(rp, old_drmd ^ INVERSVID);
126 RectFill(rp, xMin, yMin, xMax, yMax);
127 SetDrMd(rp, old_drmd);
129 return;
132 if (FALSE == MoveRaster(rp, dx, dy, xMin, yMin, xMax, yMax, TRUE, GfxBase))
133 return;
136 The raster is scrolled and I fill the empty area with the
137 RectFill()
140 SetDrMd(rp, old_drmd ^ INVERSVID);
142 /* was it scrolled left or right? */
143 if (0 != dx)
145 if (dx > 0)
147 /* scrolled towards left, clearing on the right */
148 RectFill (rp,
149 xMax - dx + 1,
150 yMin,
151 xMax,
152 yMax);
154 else
156 /* scrolled towards right, clearing on the left */
157 RectFill (rp,
158 xMin,
159 yMin,
160 xMin - dx - 1, /* a scroll by -1 should only erase a row of width 1 */
161 yMax);
165 if (0 != dy)
167 if (dy > 0)
169 /* scrolled up, clearing on the bottom */
170 RectFill (rp,
171 xMin,
172 yMax - dy + 1,
173 xMax,
174 yMax);
176 else
178 /* scrolled down, clearing on the top */
179 RectFill (rp,
180 xMin,
181 yMin,
182 xMax,
183 yMin - dy - 1);
187 SetDrMd(rp, old_drmd);
189 AROS_LIBFUNC_EXIT
190 } /* ScrollRaster */