2 Copyright © 1995-2001, 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 *****************************************************************************/
66 AROS_LIBBASE_EXT_DECL(struct GfxBase
*,GfxBase
)
71 struct Layer
*L
= rp
->Layer
;
72 struct BitMap
*bm
= rp
->BitMap
;
73 struct Rectangle rp_clip_rectangle
;
74 BOOL have_rp_cliprectangle
;
78 if (!OBTAIN_DRIVERDATA(rp
, GfxBase
))
87 gc
= GetDriverData(rp
)->dd_GC
;
112 UWORD lineptrn
= rp
->LinePtrn
;
114 if (rp
->DrawMode
& INVERSVID
) lineptrn
= ~lineptrn
;
117 struct TagItem gctags
[] =
119 {aHidd_GC_LinePattern
, lineptrn
},
120 {aHidd_GC_LinePatternCnt
, rp
->linpatcnt
},
124 OOP_SetAttrs( gc
, gctags
);
131 /* No layer, probably a screen, but may be a user inited bitmap */
134 bm_obj
= OBTAIN_HIDD_BM(bm
);
137 /* No need for clipping */
138 HIDD_BM_DrawLine(bm_obj
, gc
, x1
, y1
, x
, y
);
140 RELEASE_HIDD_BM(bm_obj
, bm
);
149 struct Rectangle torender
, intersect
;
159 have_rp_cliprectangle
= GetRPClipRectangleForLayer(rp
, L
, &rp_clip_rectangle
, GfxBase
);
161 xrel
= L
->bounds
.MinX
;
162 yrel
= L
->bounds
.MinY
;
164 torender
.MinX
= rr
.MinX
+ xrel
- L
->Scroll_X
;
165 torender
.MinY
= rr
.MinY
+ yrel
- L
->Scroll_Y
;
166 torender
.MaxX
= rr
.MaxX
+ xrel
- L
->Scroll_X
;
167 torender
.MaxY
= rr
.MaxY
+ yrel
- L
->Scroll_Y
;
171 for (;NULL
!= CR
; CR
= CR
->Next
)
173 D(bug("Cliprect (%d, %d, %d, %d), lobs=%p\n",
174 CR
->bounds
.MinX
, CR
->bounds
.MinY
, CR
->bounds
.MaxX
, CR
->bounds
.MaxY
,
177 /* Does this cliprect intersect with area to rectfill ? */
178 if (_AndRectRect(&CR
->bounds
, &torender
, &intersect
))
180 if (!have_rp_cliprectangle
|| _AndRectRect(&rp_clip_rectangle
, &intersect
, &intersect
))
182 if (NULL
== CR
->lobs
)
184 /* Set clip rectangle */
185 HIDD_GC_SetClipRect(gc
192 bm_obj
= OBTAIN_HIDD_BM(bm
);
195 HIDD_BM_DrawLine(bm_obj
203 RELEASE_HIDD_BM(bm_obj
, bm
);
206 HIDD_GC_UnsetClipRect(gc
);
211 /* Render into offscreen cliprect bitmap */
212 if (L
->Flags
& LAYERSIMPLE
)
214 else if (L
->Flags
& LAYERSUPER
)
216 D(bug("do_render_func(): Superbitmap not handled yet\n"));
220 LONG bm_rel_minx
, bm_rel_miny
, bm_rel_maxx
, bm_rel_maxy
;
221 LONG layer_rel_x
, layer_rel_y
;
223 layer_rel_x
= intersect
.MinX
- xrel
;
224 layer_rel_y
= intersect
.MinY
- yrel
;
227 bm_rel_minx
= intersect
.MinX
- CR
->bounds
.MinX
;
228 bm_rel_miny
= intersect
.MinY
- CR
->bounds
.MinY
;
229 bm_rel_maxx
= intersect
.MaxX
- CR
->bounds
.MinX
;
230 bm_rel_maxy
= intersect
.MaxY
- CR
->bounds
.MinY
;
232 HIDD_GC_SetClipRect(gc
233 , bm_rel_minx
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
235 , bm_rel_maxx
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
239 bm_obj
= OBTAIN_HIDD_BM(CR
->BitMap
);
242 HIDD_BM_DrawLine(bm_obj
244 , bm_rel_minx
- (layer_rel_x
- x1
) + ALIGN_OFFSET(CR
->bounds
.MinX
)
245 , bm_rel_miny
- (layer_rel_y
- y1
)
246 , bm_rel_minx
- (layer_rel_x
- x
) + ALIGN_OFFSET(CR
->bounds
.MinX
)
247 , bm_rel_miny
- (layer_rel_y
- y
)
250 RELEASE_HIDD_BM(bm_obj
, CR
->BitMap
);
252 HIDD_GC_UnsetClipRect(gc
);
255 } /* if (CR->lobs == NULL) */
257 } /* if it also intersects with possible rastport clip rectangle */
259 } /* if (cliprect intersects with area to render into) */
261 } /* for (each cliprect in the layer) */
265 } /* if (rp->Layer) */
269 if (dy
> dx
) dx
= dy
;
271 rp
->linpatcnt
= ((LONG
)rp
->linpatcnt
- dx
) & 15;
276 RELEASE_DRIVERDATA(rp
, GfxBase
);