2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Graphics function Draw()
9 #include <aros/debug.h>
10 #include <clib/macros.h>
11 #include <graphics/rastport.h>
12 #include <proto/graphics.h>
13 #include <proto/oop.h>
14 #include "gfxfuncsupport.h"
15 #include "graphics_intern.h"
16 #include "intregions.h"
19 /*****************************************************************************
26 AROS_LHA(struct RastPort
*, rp
, A1
),
27 AROS_LHA(LONG
, x
, D0
),
28 AROS_LHA(LONG
, y
, D1
),
31 struct GfxBase
*, GfxBase
, 41, Graphics
)
34 Draw a line from the current pen position to the given coordinate.
37 rp - destination RastPort.
38 x,y - line end coordinate.
45 - handle layer->Scroll_X/Scroll_Y.
47 - handle FRST_DOT which indicates whether to draw
48 or to don't draw first pixel of line. Important
49 for COMPLEMENT drawmode.
60 29-10-95 digulla automatically created from
61 graphics_lib.fd and clib/graphics_protos.h
63 *****************************************************************************/
70 struct Layer
*L
= rp
->Layer
;
71 struct BitMap
*bm
= rp
->BitMap
;
72 struct Rectangle rp_clip_rectangle
;
73 BOOL have_rp_cliprectangle
;
77 if (!OBTAIN_DRIVERDATA(rp
, GfxBase
))
86 gc
= GetDriverData(rp
)->dd_GC
;
111 UWORD lineptrn
= rp
->LinePtrn
;
113 if (rp
->DrawMode
& INVERSVID
) lineptrn
= ~lineptrn
;
116 struct TagItem gctags
[] =
118 {aHidd_GC_LinePattern
, lineptrn
},
119 {aHidd_GC_LinePatternCnt
, rp
->linpatcnt
},
123 OOP_SetAttrs( gc
, gctags
);
130 /* No layer, probably a screen, but may be a user inited bitmap */
133 bm_obj
= OBTAIN_HIDD_BM(bm
);
136 /* No need for clipping */
137 HIDD_BM_DrawLine(bm_obj
, gc
, x1
, y1
, x
, y
);
139 RELEASE_HIDD_BM(bm_obj
, bm
);
148 struct Rectangle torender
, intersect
;
158 have_rp_cliprectangle
= GetRPClipRectangleForLayer(rp
, L
, &rp_clip_rectangle
, GfxBase
);
160 xrel
= L
->bounds
.MinX
;
161 yrel
= L
->bounds
.MinY
;
163 torender
.MinX
= rr
.MinX
+ xrel
- L
->Scroll_X
;
164 torender
.MinY
= rr
.MinY
+ yrel
- L
->Scroll_Y
;
165 torender
.MaxX
= rr
.MaxX
+ xrel
- L
->Scroll_X
;
166 torender
.MaxY
= rr
.MaxY
+ yrel
- L
->Scroll_Y
;
170 for (;NULL
!= CR
; CR
= CR
->Next
)
172 D(bug("Cliprect (%d, %d, %d, %d), lobs=%p\n",
173 CR
->bounds
.MinX
, CR
->bounds
.MinY
, CR
->bounds
.MaxX
, CR
->bounds
.MaxY
,
176 /* Does this cliprect intersect with area to rectfill ? */
177 if (_AndRectRect(&CR
->bounds
, &torender
, &intersect
))
179 if (!have_rp_cliprectangle
|| _AndRectRect(&rp_clip_rectangle
, &intersect
, &intersect
))
181 if (NULL
== CR
->lobs
)
183 /* Set clip rectangle */
184 HIDD_GC_SetClipRect(gc
191 bm_obj
= OBTAIN_HIDD_BM(bm
);
194 HIDD_BM_DrawLine(bm_obj
202 RELEASE_HIDD_BM(bm_obj
, bm
);
205 HIDD_GC_UnsetClipRect(gc
);
210 /* Render into offscreen cliprect bitmap */
211 if (L
->Flags
& LAYERSIMPLE
)
213 else if (L
->Flags
& LAYERSUPER
)
215 D(bug("do_render_func(): Superbitmap not handled yet\n"));
219 LONG bm_rel_minx
, bm_rel_miny
, bm_rel_maxx
, bm_rel_maxy
;
220 LONG layer_rel_x
, layer_rel_y
;
222 layer_rel_x
= intersect
.MinX
- xrel
;
223 layer_rel_y
= intersect
.MinY
- yrel
;
226 bm_rel_minx
= intersect
.MinX
- CR
->bounds
.MinX
;
227 bm_rel_miny
= intersect
.MinY
- CR
->bounds
.MinY
;
228 bm_rel_maxx
= intersect
.MaxX
- CR
->bounds
.MinX
;
229 bm_rel_maxy
= intersect
.MaxY
- CR
->bounds
.MinY
;
231 HIDD_GC_SetClipRect(gc
232 , bm_rel_minx
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
234 , bm_rel_maxx
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
238 bm_obj
= OBTAIN_HIDD_BM(CR
->BitMap
);
241 HIDD_BM_DrawLine(bm_obj
243 , bm_rel_minx
- (layer_rel_x
- x1
) + ALIGN_OFFSET(CR
->bounds
.MinX
)
244 , bm_rel_miny
- (layer_rel_y
- y1
)
245 , bm_rel_minx
- (layer_rel_x
- x
) + ALIGN_OFFSET(CR
->bounds
.MinX
)
246 , bm_rel_miny
- (layer_rel_y
- y
)
249 RELEASE_HIDD_BM(bm_obj
, CR
->BitMap
);
251 HIDD_GC_UnsetClipRect(gc
);
254 } /* if (CR->lobs == NULL) */
256 } /* if it also intersects with possible rastport clip rectangle */
258 } /* if (cliprect intersects with area to render into) */
260 } /* for (each cliprect in the layer) */
264 } /* if (rp->Layer) */
268 if (dy
> dx
) dx
= dy
;
270 rp
->linpatcnt
= ((LONG
)rp
->linpatcnt
- dx
) & 15;
275 RELEASE_DRIVERDATA(rp
, GfxBase
);