revert between 56095 -> 55830 in arch
[AROS.git] / rom / graphics / draw.c
blobed0b6c1ad18a79f0f46b6555ef9641af8986d031
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function Draw()
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <clib/macros.h>
11 #include <graphics/rastport.h>
12 #include <proto/graphics.h>
14 #include "gfxfuncsupport.h"
15 #include "graphics_intern.h"
16 #include "graphics_driver.h"
17 #include "intregions.h"
19 /****************************************************************************************/
21 struct draw_render_data
23 WORD x1, y1, x2, y2;
26 static ULONG draw_render(APTR draw_rd, WORD srcx, WORD srcy,
27 OOP_Object *dstbm_obj, OOP_Object *dst_gc,
28 struct Rectangle *rect, struct GfxBase *GfxBase)
30 struct draw_render_data *drd = draw_rd;
33 * This is a quick way to install ClipRect on a GC. Just set one pointer.
34 * This is why we have a struct Rectangle * in the GC.
36 GC_DOCLIP(dst_gc) = rect;
38 HIDD_BM_DrawLine(dstbm_obj, dst_gc, drd->x1 + rect->MinX - srcx,
39 drd->y1 + rect->MinY - srcy,
40 drd->x2 + rect->MinX - srcx,
41 drd->y2 + rect->MinY - srcy);
44 * After we exit this routine, 'rect' will be not valid any more.
45 * So do not forget to reset the pointer!
47 GC_DOCLIP(dst_gc) = NULL;
49 return 0;
52 /*****************************************************************************
54 NAME */
56 AROS_LH3(void, Draw,
58 /* SYNOPSIS */
59 AROS_LHA(struct RastPort *, rp, A1),
60 AROS_LHA(WORD , x, D0),
61 AROS_LHA(WORD , y, D1),
63 /* LOCATION */
64 struct GfxBase *, GfxBase, 41, Graphics)
66 /* FUNCTION
67 Draw a line from the current pen position to the given coordinate.
69 INPUTS
70 rp - destination RastPort.
71 x,y - line end coordinate.
73 RESULT
75 NOTES
76 Not yet implemented:
78 - handle layer->Scroll_X/Scroll_Y.
80 - handle FRST_DOT which indicates whether to draw
81 or to don't draw first pixel of line. Important
82 for COMPLEMENT drawmode.
84 EXAMPLE
86 BUGS
88 SEE ALSO
90 INTERNALS
92 HISTORY
93 29-10-95 digulla automatically created from
94 graphics_lib.fd and clib/graphics_protos.h
96 *****************************************************************************/
98 AROS_LIBFUNC_INIT
100 struct Rectangle rr;
101 OOP_Object *gc;
102 struct draw_render_data drd;
103 WORD dx;
104 WORD x1, y1;
106 FIX_GFXCOORD(x);
107 FIX_GFXCOORD(y);
109 x1 = rp->cp_x;
110 y1 = rp->cp_y;
112 if (x1 > x)
114 rr.MinX = x;
115 rr.MaxX = x1;
117 else
119 rr.MinX = x1;
120 rr.MaxX = x;
123 if (y1 > y)
125 rr.MinY = y;
126 rr.MaxY = y1;
128 else
130 rr.MinY = y1;
131 rr.MaxY = y;
134 gc = GetDriverData(rp, GfxBase);
136 /* Only Draw() uses line pattern attributes, so we set them only here */
137 GC_LINEPAT(gc) = (rp->DrawMode & INVERSVID) ? ~rp->LinePtrn : rp->LinePtrn;
138 GC_LINEPATCNT(gc) = rp->linpatcnt;
140 drd.x1 = x1 - rr.MinX;
141 drd.y1 = y1 - rr.MinY;
142 drd.x2 = x - rr.MinX;
143 drd.y2 = y - rr.MinY;
145 D(bug("[Draw] (%d, %d) to (%d, %d)\n", rp->cp_x, rp->cp_y, x, y));
146 D(bug("[Draw] RastPort 0x%p, Flags 0x%04X, GC 0x%p, FG 0x%08lX, BG 0x%08lX\n", rp, rp->Flags, gc, GC_FG(gc), GC_BG(gc)));
148 do_render_with_gc(rp, NULL, &rr, draw_render, &drd, gc, TRUE, FALSE, GfxBase);
150 dx = (drd.x2 > drd.y2) ? drd.x2 : drd.y2;
152 rp->linpatcnt = ((LONG)rp->linpatcnt - dx) & 15;
154 rp->cp_x = x;
155 rp->cp_y = y;
157 AROS_LIBFUNC_EXIT
159 } /* Draw */