2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
6 /* !!!! ONLY USE THE BELOW MACROS IF YOU ARE 100% SURE
7 THAT IT IS A HIDD BITMAP AND NOT ONE THE USER
8 HAS CREATED BY HAND !!!. You can use IS_HIDD_BM(bitmap) to test
12 /****************************************************************************************/
14 #include <cybergraphx/cybergraphics.h>
15 #include <graphics/rpattr.h>
16 #include <proto/exec.h>
17 #include <proto/graphics.h>
18 #include <proto/layers.h>
19 //#include <proto/cybergraphics.h>
20 #include <proto/oop.h>
21 #include <clib/macros.h>
23 #include "graphics_intern.h"
25 #include "intregions.h"
26 #include "gfxfuncsupport.h"
29 #include <aros/debug.h>
31 /****************************************************************************************/
33 OOP_Object
*get_planarbm_object(struct BitMap
*bitmap
, struct GfxBase
*GfxBase
)
37 D(bug("get_planarbm_object()\n"));
38 pbm_obj
= obtain_cache_object(SDD(GfxBase
)->planarbm_cache
, GfxBase
);
43 D(bug("Got cache object %p, class=%s, domethod=%p, instoffset=%d\n"
45 , OOP_OCLASS(pbm_obj
)->ClassNode
.ln_Name
46 , OOP_OCLASS(pbm_obj
)->DoMethod
47 , OOP_OCLASS(pbm_obj
)->InstOffset
50 if (!HIDD_PlanarBM_SetBitMap(pbm_obj
, bitmap
))
52 D(bug("!!! get_planarbm_object: HIDD_PlanarBM_SetBitMap FAILED !!!\n"));
53 release_cache_object(SDD(GfxBase
)->planarbm_cache
, pbm_obj
, GfxBase
);
60 D(bug("!!! get_planarbm_object: obtain_cache_object FAILED !!!\n"));
66 /****************************************************************************************/
68 ULONG
do_render_func(struct RastPort
*rp
70 , struct Rectangle
*rr
71 , ULONG (*render_func
)(APTR
, LONG
, LONG
, OOP_Object
*, OOP_Object
*, LONG
, LONG
, LONG
, LONG
, struct GfxBase
*)
73 , BOOL get_special_info
74 , struct GfxBase
*GfxBase
)
77 struct BitMap
*bm
= rp
->BitMap
;
78 struct Layer
*L
= rp
->Layer
;
80 struct Rectangle rp_clip_rectangle
;
81 BOOL have_rp_cliprectangle
;
86 gc
= GetDriverData(rp
)->dd_GC
;
88 width
= rr
->MaxX
- rr
->MinX
+ 1;
89 height
= rr
->MaxY
- rr
->MinY
+ 1;
103 struct Rectangle torender
= *rr
;
105 /* No layer, probably a screen, but may be a user inited bitmap */
108 have_rp_cliprectangle
= GetRPClipRectangleForBitMap(rp
, bm
, &rp_clip_rectangle
, GfxBase
);
109 if (have_rp_cliprectangle
&& !(_AndRectRect(rr
, &rp_clip_rectangle
, &torender
)))
114 bm_obj
= OBTAIN_HIDD_BM(bm
);
118 srcx
+= (torender
.MinX
- rr
->MinX
);
119 srcy
+= (torender
.MinY
- rr
->MinY
);
121 if (get_special_info
)
123 RSI(funcdata
)->curbm
= rp
->BitMap
;
124 RSI(funcdata
)->onscreen
= TRUE
;
125 RSI(funcdata
)->layer_rel_srcx
= srcx
;
126 RSI(funcdata
)->layer_rel_srcy
= srcy
;
129 pixwritten
= render_func(funcdata
132 , torender
.MinX
, torender
.MinY
133 , torender
.MaxX
, torender
.MaxY
137 RELEASE_HIDD_BM(bm_obj
, bm
);
145 struct Rectangle torender
, intersect
;
150 have_rp_cliprectangle
= GetRPClipRectangleForLayer(rp
, L
, &rp_clip_rectangle
, GfxBase
);
152 xrel
= L
->bounds
.MinX
;
153 yrel
= L
->bounds
.MinY
;
155 torender
.MinX
= rr
->MinX
+ xrel
- L
->Scroll_X
;
156 torender
.MinY
= rr
->MinY
+ yrel
- L
->Scroll_Y
;
157 torender
.MaxX
= rr
->MaxX
+ xrel
- L
->Scroll_X
;
158 torender
.MaxY
= rr
->MaxY
+ yrel
- L
->Scroll_Y
;
163 for (;NULL
!= CR
; CR
= CR
->Next
)
165 D(bug("Cliprect (%d, %d, %d, %d), lobs=%p\n",
166 CR
->bounds
.MinX
, CR
->bounds
.MinY
, CR
->bounds
.MaxX
, CR
->bounds
.MaxY
,
169 /* Does this cliprect intersect with area to rectfill ? */
170 if (_AndRectRect(&CR
->bounds
, &torender
, &intersect
))
172 if (!have_rp_cliprectangle
|| _AndRectRect(&rp_clip_rectangle
, &intersect
, &intersect
))
174 LONG xoffset
, yoffset
;
176 xoffset
= intersect
.MinX
- torender
.MinX
;
177 yoffset
= intersect
.MinY
- torender
.MinY
;
179 if (get_special_info
) {
180 RSI(funcdata
)->layer_rel_srcx
= intersect
.MinX
- L
->bounds
.MinX
+ L
->Scroll_X
;
181 RSI(funcdata
)->layer_rel_srcy
= intersect
.MinY
- L
->bounds
.MinY
+ L
->Scroll_Y
;
184 if (NULL
== CR
->lobs
)
186 if (get_special_info
)
188 RSI(funcdata
)->curbm
= bm
;
189 RSI(funcdata
)->onscreen
= TRUE
;
192 bm_obj
= OBTAIN_HIDD_BM(bm
);
195 pixwritten
+= render_func(funcdata
207 RELEASE_HIDD_BM(bm_obj
, bm
);
214 /* Render into offscreen cliprect bitmap */
215 if (L
->Flags
& LAYERSIMPLE
)
217 else if (L
->Flags
& LAYERSUPER
)
219 D(bug("do_render_func(): Superbitmap not handled yet\n"));
224 if (get_special_info
)
226 RSI(funcdata
)->curbm
= CR
->BitMap
;
227 RSI(funcdata
)->onscreen
= FALSE
;
230 bm_obj
= OBTAIN_HIDD_BM(CR
->BitMap
);
233 pixwritten
+= render_func(funcdata
234 , srcx
+ xoffset
, srcy
+ yoffset
237 , intersect
.MinX
- CR
->bounds
.MinX
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
238 , intersect
.MinY
- CR
->bounds
.MinY
239 , intersect
.MaxX
- CR
->bounds
.MinX
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
240 , intersect
.MaxY
- CR
->bounds
.MinY
244 RELEASE_HIDD_BM(bm_obj
, CR
->BitMap
);
248 } /* if (CR->lobs == NULL) */
250 } /* if it also intersects with possible rastport clip rectangle */
252 } /* if (cliprect intersects with area to render into) */
254 } /* for (each cliprect in the layer) */
257 } /* if (rp->Layer) */
264 /****************************************************************************************/
266 ULONG
do_pixel_func(struct RastPort
*rp
268 , LONG (*render_func
)(APTR
, OOP_Object
*, OOP_Object
*, LONG
, LONG
, struct GfxBase
*)
270 , struct GfxBase
*GfxBase
)
272 struct BitMap
*bm
= rp
->BitMap
;
273 struct Layer
*L
= rp
->Layer
;
275 struct Rectangle rp_clip_rectangle
;
276 BOOL have_rp_cliprectangle
;
279 gc
= GetDriverData(rp
)->dd_GC
;
286 bm_obj
= OBTAIN_HIDD_BM(bm
);
290 OOP_GetAttr(bm_obj
, aHidd_BitMap_Width
, &width
);
291 OOP_GetAttr(bm_obj
, aHidd_BitMap_Height
, &height
);
293 /* Check whether we it is inside the rastport */
300 RELEASE_HIDD_BM(bm_obj
, bm
);
305 /* This is a screen */
306 retval
= render_func(funcdata
, bm_obj
, gc
, x
, y
, GfxBase
);
308 RELEASE_HIDD_BM(bm_obj
, bm
);
319 have_rp_cliprectangle
= GetRPClipRectangleForLayer(rp
, L
, &rp_clip_rectangle
, GfxBase
);
323 absx
= x
+ L
->bounds
.MinX
- L
->Scroll_X
;
324 absy
= y
+ L
->bounds
.MinY
- L
->Scroll_Y
;
326 for (;NULL
!= CR
; CR
= CR
->Next
)
329 if ( absx
>= CR
->bounds
.MinX
330 && absy
>= CR
->bounds
.MinY
331 && absx
<= CR
->bounds
.MaxX
332 && absy
<= CR
->bounds
.MaxY
)
335 if (!have_rp_cliprectangle
|| _IsPointInRect(&rp_clip_rectangle
, absx
, absy
))
337 if (NULL
== CR
->lobs
)
339 bm_obj
= OBTAIN_HIDD_BM(bm
);
342 retval
= render_func(funcdata
348 RELEASE_HIDD_BM(bm_obj
, bm
);
353 /* This is the tricky one: render into offscreen cliprect bitmap */
354 if (L
->Flags
& LAYERSIMPLE
)
356 /* We cannot do anything */
360 else if (L
->Flags
& LAYERSUPER
)
362 D(bug("driver_WriteRGBPixel(): Superbitmap not handled yet\n"));
366 bm_obj
= OBTAIN_HIDD_BM(CR
->BitMap
);
369 retval
= render_func(funcdata
371 , absx
- CR
->bounds
.MinX
+ ALIGN_OFFSET(CR
->bounds
.MinX
)
372 , absy
- CR
->bounds
.MinY
376 RELEASE_HIDD_BM(bm_obj
, CR
->BitMap
);
380 } /* If (SMARTREFRESH cliprect) */
383 } /* if (intersecton inside hidden cliprect) */
385 } /* if point is also inside possible rastport clip rectangle */
387 /* The pixel was found and put inside one of the cliprects, just exit */
390 } /* if (cliprect intersects with area we want to draw to) */
392 } /* while (cliprects to examine) */
401 /****************************************************************************************/
403 static ULONG
fillrect_render(APTR funcdata
, LONG srcx
, LONG srcy
,
404 OOP_Object
*dstbm_obj
, OOP_Object
*dst_gc
,
405 LONG x1
, LONG y1
, LONG x2
, LONG y2
,
406 struct GfxBase
*GfxBase
)
409 HIDD_BM_FillRect(dstbm_obj
, dst_gc
, x1
, y1
, x2
, y2
);
411 return (x2
- x1
+ 1) * (y2
- y1
+ 1);
414 /****************************************************************************************/
416 LONG
fillrect_pendrmd(struct RastPort
*rp
, LONG x1
, LONG y1
, LONG x2
, LONG y2
,
417 HIDDT_Pixel pix
, HIDDT_DrawMode drmd
, struct GfxBase
*GfxBase
)
421 HIDDT_DrawMode old_drmd
;
426 struct TagItem gc_tags
[] =
428 { aHidd_GC_DrawMode
, drmd
},
429 { aHidd_GC_Foreground
, pix
},
434 if (!OBTAIN_DRIVERDATA(rp
, GfxBase
))
437 gc
= GetDriverData(rp
)->dd_GC
;
439 OOP_GetAttr(gc
, aHidd_GC_DrawMode
, (IPTR
*)&old_drmd
);
440 OOP_GetAttr(gc
, aHidd_GC_Foreground
,(IPTR
*)&old_fg
);
442 OOP_SetAttrs(gc
, gc_tags
);
449 pixwritten
= do_render_func(rp
, NULL
, &rr
, fillrect_render
, NULL
, FALSE
, GfxBase
);
451 /* Restore old GC values */
452 gc_tags
[0].ti_Data
= (IPTR
)old_drmd
;
453 gc_tags
[1].ti_Data
= (IPTR
)old_fg
;
454 OOP_SetAttrs(gc
, gc_tags
);
456 RELEASE_DRIVERDATA(rp
, GfxBase
);
461 /****************************************************************************************/
463 BOOL
int_bltbitmap(struct BitMap
*srcBitMap
, OOP_Object
*srcbm_obj
, LONG xSrc
, LONG ySrc
,
464 struct BitMap
*dstBitMap
, OOP_Object
*dstbm_obj
, LONG xDest
, LONG yDest
,
465 LONG xSize
, LONG ySize
, ULONG minterm
, OOP_Object
*gc
, struct GfxBase
*GfxBase
)
472 BOOL src_colmap_set
= FALSE
;
473 BOOL dst_colmap_set
= FALSE
;
475 BOOL colmaps_ok
= TRUE
;
477 drmd
= MINTERM_TO_GCDRMD(minterm
);
479 /* We must lock any HIDD_BM_SetColorMap calls */
482 /* Try to get a CLUT for the bitmaps */
483 if (IS_HIDD_BM(srcBitMap
))
485 //bug("driver_intbltbitmap: source is hidd bitmap\n");
486 if (NULL
!= HIDD_BM_COLMAP(srcBitMap
))
488 //bug("driver_intbltbitmap: source has colormap\n");
489 srcflags
|= FLG_HASCOLMAP
;
491 srcflags
|= GET_COLMOD_FLAGS(srcBitMap
);
495 //bug("driver_intbltbitmap: source is amiga bitmap\n");
497 srcflags
|= FLG_PALETTE
;
500 if (IS_HIDD_BM(dstBitMap
))
502 //bug("driver_intbltbitmap: dest is hidd bitmap\n");
503 if (NULL
!= HIDD_BM_COLMAP(dstBitMap
))
505 //bug("driver_intbltbitmap: dest has colormap\n");
506 dstflags
|= FLG_HASCOLMAP
;
508 dstflags
|= GET_COLMOD_FLAGS(dstBitMap
);
512 //bug("driver_intbltbitmap: dest is amiga bitmap\n");
514 dstflags
|= FLG_PALETTE
;
517 if ( (srcflags
== FLG_PALETTE
|| srcflags
== FLG_STATICPALETTE
))
519 /* palettized with no colmap. Neew to get a colmap from dest*/
520 if (dstflags
== FLG_TRUECOLOR
)
523 D(bug("!!! NO WAY GETTING PALETTE FOR src IN BltBitMap\n"));
528 else if (dstflags
== (FLG_TRUECOLOR
| FLG_HASCOLMAP
))
531 /* Use the dest colmap for src */
532 HIDD_BM_SetColorMap(srcbm_obj
, HIDD_BM_COLMAP(dstBitMap
));
534 src_colmap_set
= TRUE
;
540 for (idx = 0; idx < 256; idx ++)
541 bug("[%d]=%d ", idx, HIDD_CM_GetPixel(HIDD_BM_COLMAP(dstBitMap), idx));
547 if ( (dstflags
== FLG_PALETTE
|| dstflags
== FLG_STATICPALETTE
))
549 /* palettized with no pixtab. Nees to get a pixtab from dest*/
550 if (srcflags
== FLG_TRUECOLOR
)
552 D(bug("!!! NO WAY GETTING PALETTE FOR dst IN BltBitMap\n"));
557 else if (srcflags
== (FLG_TRUECOLOR
| FLG_HASCOLMAP
))
560 /* Use the src colmap for dst */
561 HIDD_BM_SetColorMap(dstbm_obj
, HIDD_BM_COLMAP(srcBitMap
));
563 dst_colmap_set
= TRUE
;
569 /* We need special treatment with drawmode Clear and
570 truecolor bitmaps, in order to set it to
571 colormap[0] instead of just 0
573 if ( (drmd
== vHidd_GC_DrawMode_Clear
)
574 && ( (dstflags
& (FLG_TRUECOLOR
| FLG_HASCOLMAP
)) == (FLG_TRUECOLOR
| FLG_HASCOLMAP
) ))
577 HIDDT_DrawMode old_drmd
;
580 struct TagItem frtags
[] =
582 { aHidd_GC_Foreground
, 0 },
583 { aHidd_GC_DrawMode
, vHidd_GC_DrawMode_Copy
},
587 OOP_GetAttr(gc
, aHidd_GC_DrawMode
, &old_drmd
);
588 OOP_GetAttr(gc
, aHidd_GC_Foreground
, &old_fg
);
590 frtags
[0].ti_Data
= HIDD_BM_PIXTAB(dstBitMap
)[0];
591 frtags
[1].ti_Data
= vHidd_GC_DrawMode_Copy
;
593 OOP_SetAttrs(gc
, frtags
);
595 HIDD_BM_FillRect(dstbm_obj
, gc
601 frtags
[0].ti_Data
= old_fg
;
602 frtags
[1].ti_Data
= old_drmd
;
607 HIDDT_DrawMode old_drmd
;
609 struct TagItem cbtags
[] =
611 { aHidd_GC_DrawMode
, 0 },
615 OOP_GetAttr(gc
, aHidd_GC_DrawMode
, &old_drmd
);
617 cbtags
[0].ti_Data
= drmd
;
619 OOP_SetAttrs(gc
, cbtags
);
620 HIDD_Gfx_CopyBox(SDD(GfxBase
)->gfxhidd
629 cbtags
[0].ti_Data
= drmd
;
630 OOP_SetAttrs(gc
, cbtags
);
633 } /* if (colmaps_ok) */
636 HIDD_BM_SetColorMap(srcbm_obj
, NULL
);
639 HIDD_BM_SetColorMap(dstbm_obj
, NULL
);
647 /****************************************************************************************/
649 struct wp8_render_data
653 HIDDT_PixelLUT
*pixlut
;
656 static ULONG
wp8_render(APTR wp8r_data
, LONG srcx
, LONG srcy
, OOP_Object
*dstbm_obj
,
657 OOP_Object
*dst_gc
, LONG x1
, LONG y1
, LONG x2
, LONG y2
,
658 struct GfxBase
*GfxBase
)
660 struct wp8_render_data
*wp8rd
;
663 wp8rd
= (struct wp8_render_data
*)wp8r_data
;
666 height
= y2
- y1
+ 1;
668 HIDD_BM_PutImageLUT(dstbm_obj
670 , wp8rd
->array
+ CHUNKY8_COORD_TO_BYTEIDX(srcx
, srcy
, wp8rd
->modulo
)
677 return width
* height
;
679 /****************************************************************************************/
681 LONG
write_pixels_8(struct RastPort
*rp
, UBYTE
*array
, ULONG modulo
,
682 LONG xstart
, LONG ystart
, LONG xstop
, LONG ystop
,
683 HIDDT_PixelLUT
*pixlut
, struct GfxBase
*GfxBase
)
688 struct wp8_render_data wp8rd
;
692 HIDDT_DrawMode old_drmd
;
694 struct TagItem gc_tags
[] =
696 { aHidd_GC_DrawMode
, vHidd_GC_DrawMode_Copy
},
701 if (!OBTAIN_DRIVERDATA(rp
, GfxBase
))
704 gc
= GetDriverData(rp
)->dd_GC
;
706 OOP_GetAttr(gc
, aHidd_GC_DrawMode
, &old_drmd
);
707 OOP_SetAttrs(gc
, gc_tags
);
709 wp8rd
.modulo
= modulo
;
711 wp8rd
.pixlut
= pixlut
;
718 pixwritten
= do_render_func(rp
, NULL
, &rr
, wp8_render
, &wp8rd
, FALSE
, GfxBase
);
720 /* Reset to preserved drawmode */
721 gc_tags
[0].ti_Data
= old_drmd
;
722 OOP_SetAttrs(gc
, gc_tags
);
724 RELEASE_DRIVERDATA(rp
, GfxBase
);
730 /****************************************************************************************/
732 struct wtp8_render_data
736 HIDDT_PixelLUT
*pixlut
;
740 static ULONG
wtp8_render(APTR wtp8r_data
, LONG srcx
, LONG srcy
, OOP_Object
*dstbm_obj
,
741 OOP_Object
*dst_gc
, LONG x1
, LONG y1
, LONG x2
, LONG y2
,
742 struct GfxBase
*GfxBase
)
744 struct wtp8_render_data
*wtp8rd
;
747 wtp8rd
= (struct wtp8_render_data
*)wtp8r_data
;
750 height
= y2
- y1
+ 1;
752 HIDD_BM_PutTranspImageLUT(dstbm_obj
754 , wtp8rd
->array
+ CHUNKY8_COORD_TO_BYTEIDX(srcx
, srcy
, wtp8rd
->modulo
)
759 , wtp8rd
->transparent
762 return width
* height
;
764 /****************************************************************************************/
766 LONG
write_transp_pixels_8(struct RastPort
*rp
, UBYTE
*array
, ULONG modulo
,
767 LONG xstart
, LONG ystart
, LONG xstop
, LONG ystop
,
768 HIDDT_PixelLUT
*pixlut
, UBYTE transparent
,
769 struct GfxBase
*GfxBase
)
774 struct wtp8_render_data wtp8rd
;
778 HIDDT_DrawMode old_drmd
;
780 struct TagItem gc_tags
[] =
782 { aHidd_GC_DrawMode
, vHidd_GC_DrawMode_Copy
},
787 if (!OBTAIN_DRIVERDATA(rp
, GfxBase
))
790 gc
= GetDriverData(rp
)->dd_GC
;
792 OOP_GetAttr(gc
, aHidd_GC_DrawMode
, &old_drmd
);
793 OOP_SetAttrs(gc
, gc_tags
);
795 wtp8rd
.modulo
= modulo
;
796 wtp8rd
.array
= array
;
797 wtp8rd
.pixlut
= pixlut
;
798 wtp8rd
.transparent
= transparent
;
805 pixwritten
= do_render_func(rp
, NULL
, &rr
, wtp8_render
, &wtp8rd
, FALSE
, GfxBase
);
807 /* Reset to preserved drawmode */
808 gc_tags
[0].ti_Data
= old_drmd
;
809 OOP_SetAttrs(gc
, gc_tags
);
811 RELEASE_DRIVERDATA(rp
, GfxBase
);
817 /****************************************************************************************/
820 ** General functions for moving blocks of data to or from HIDDs, be it pixelarrays
821 ** or bitmaps. They use a callback-function to get data from amiga/put data to amiga
822 ** bitmaps/pixelarrays
825 /****************************************************************************************/
829 void amiga2hidd_fast(APTR src_info
, OOP_Object
*hidd_gc
, LONG x_src
, LONG y_src
,
830 struct BitMap
*hidd_bm
, LONG x_dest
, LONG y_dest
,
831 ULONG xsize
, ULONG ysize
, VOID (*fillbuf_hook
)(),
832 struct GfxBase
* GfxBase
)
839 LONG pixels_left_to_process
= xsize
* ysize
;
841 LONG current_x
, current_y
, next_x
, next_y
;
847 bm_obj
= OBTAIN_HIDD_BM(hidd_bm
);
853 while (pixels_left_to_process
)
856 /* Get some more pixels from the HIDD */
863 /* buffer can't hold a single horizontal line, and must
864 divide each line into several copy-operations */
865 tocopy_w
= xsize
- current_x
;
866 if (tocopy_w
> NUMPIX
)
868 /* Not quite finished with current horizontal pixel line */
873 { /* Start at a new line */
880 else /* We can copy one or several whole horizontal lines at a time */
882 tocopy_h
= MIN(NUMPIX
/ xsize
, ysize
- current_y
);
894 fillbuf_hook(src_info
900 , PrivGBase(GfxBase
)->pixel_buf
902 , IS_HIDD_BM(hidd_bm
) ? HIDD_BM_PIXTAB(hidd_bm
) : NULL
906 /* Put it to the HIDD */
907 D(bug("Putting box\n"));
909 HIDD_BM_PutImage(bm_obj
911 , (UBYTE
*)PrivGBase(GfxBase
)->pixel_buf
912 , tocopy_w
* sizeof (HIDDT_Pixel
)
916 , vHidd_StdPixFmt_Native32
921 pixels_left_to_process
-= (tocopy_w
* tocopy_h
);
924 } /* while (pixels left to copy) */
928 RELEASE_HIDD_BM(bm_obj
, hidd_bm
);
936 /****************************************************************************************/
938 void hidd2buf_fast(struct BitMap
*hidd_bm
, LONG x_src
, LONG y_src
, APTR dest_info
,
939 LONG x_dest
, LONG y_dest
, ULONG xsize
, ULONG ysize
, VOID (*putbuf_hook
)(),
940 struct GfxBase
* GfxBase
)
943 ULONG tocopy_w
, tocopy_h
;
945 LONG pixels_left_to_process
= xsize
* ysize
;
946 ULONG current_x
, current_y
, next_x
, next_y
;
948 #warning Src bitmap migh be user initialized so we should not use HIDD_BM_PIXTAB() below
955 bm_obj
= OBTAIN_HIDD_BM(hidd_bm
);
961 while (pixels_left_to_process
)
969 /* buffer cant hold a single horizontal line, and must
970 divide each line into copies */
971 tocopy_w
= xsize
- current_x
;
972 if (tocopy_w
> NUMPIX
)
974 /* Not quite finished with current horizontal pixel line */
979 { /* Start at a new line */
989 tocopy_h
= MIN(NUMPIX
/ xsize
, ysize
- current_y
);
998 /* Get some more pixels from the HIDD */
999 HIDD_BM_GetImage(bm_obj
1000 , (UBYTE
*)PrivGBase(GfxBase
)->pixel_buf
1004 , tocopy_w
, tocopy_h
1005 , vHidd_StdPixFmt_Native32
);
1008 /* Write pixels to the destination */
1009 putbuf_hook(dest_info
1012 , current_x
+ x_dest
1013 , current_y
+ y_dest
1014 , tocopy_w
, tocopy_h
1015 , (HIDDT_Pixel
*)PrivGBase(GfxBase
)->pixel_buf
1017 , IS_HIDD_BM(hidd_bm
) ? HIDD_BM_PIXTAB(hidd_bm
) : NULL
1020 pixels_left_to_process
-= (tocopy_w
* tocopy_h
);
1026 RELEASE_HIDD_BM(bm_obj
, hidd_bm
);
1032 /****************************************************************************************/
1034 UWORD
hidd2cyber_pixfmt(HIDDT_StdPixFmt stdpf
, struct GfxBase
*GfxBase
)
1036 UWORD cpf
= (UWORD
)-1;
1038 D(bug("hidd2cyber stdpf = %d [%d]\n", stdpf
, vHidd_StdPixFmt_BGR032
));
1042 case vHidd_StdPixFmt_RGB15
:
1046 case vHidd_StdPixFmt_RGB15_LE
:
1047 cpf
= PIXFMT_RGB15PC
;
1050 case vHidd_StdPixFmt_BGR15
:
1054 case vHidd_StdPixFmt_BGR15_LE
:
1055 cpf
= PIXFMT_BGR15PC
;
1058 case vHidd_StdPixFmt_RGB16
:
1062 case vHidd_StdPixFmt_RGB16_LE
:
1063 cpf
= PIXFMT_RGB16PC
;
1066 case vHidd_StdPixFmt_BGR16
:
1070 case vHidd_StdPixFmt_BGR16_LE
:
1071 cpf
= PIXFMT_BGR16PC
;
1074 case vHidd_StdPixFmt_RGB24
:
1078 case vHidd_StdPixFmt_BGR24
:
1082 case vHidd_StdPixFmt_0RGB32
:
1083 cpf
= PIXFMT_0RGB32
;
1086 case vHidd_StdPixFmt_RGB032
:
1087 cpf
= PIXFMT_RGB032
;
1090 case vHidd_StdPixFmt_BGR032
:
1091 cpf
= PIXFMT_BGR032
;
1094 case vHidd_StdPixFmt_0BGR32
:
1095 cpf
= PIXFMT_0BGR32
;
1097 case vHidd_StdPixFmt_ARGB32
:
1098 cpf
= PIXFMT_ARGB32
;
1101 case vHidd_StdPixFmt_RGBA32
:
1102 cpf
= PIXFMT_RGBA32
;
1105 case vHidd_StdPixFmt_BGRA32
:
1106 cpf
= PIXFMT_BGRA32
;
1109 case vHidd_StdPixFmt_ABGR32
:
1110 cpf
= PIXFMT_ABGR32
;
1113 case vHidd_StdPixFmt_LUT8
:
1118 D(bug("UNKNOWN CYBERGRAPHICS PIXFMT IN cyber2hidd_pixfmt\n"));
1127 /****************************************************************************************/
1129 HIDDT_StdPixFmt
cyber2hidd_pixfmt(UWORD cpf
, struct GfxBase
*GfxBase
)
1131 HIDDT_StdPixFmt stdpf
= vHidd_StdPixFmt_Unknown
;
1136 stdpf
= vHidd_StdPixFmt_RGB15
;
1139 case PIXFMT_RGB15PC
:
1140 stdpf
= vHidd_StdPixFmt_RGB15_LE
;
1144 stdpf
= vHidd_StdPixFmt_BGR15
;
1147 case PIXFMT_BGR15PC
:
1148 stdpf
= vHidd_StdPixFmt_BGR15_LE
;
1152 stdpf
= vHidd_StdPixFmt_RGB16
;
1155 case PIXFMT_RGB16PC
:
1156 stdpf
= vHidd_StdPixFmt_RGB16_LE
;
1160 stdpf
= vHidd_StdPixFmt_BGR16
;
1163 case PIXFMT_BGR16PC
:
1164 stdpf
= vHidd_StdPixFmt_BGR16_LE
;
1168 stdpf
= vHidd_StdPixFmt_RGB24
;
1172 stdpf
= vHidd_StdPixFmt_BGR24
;
1176 stdpf
= vHidd_StdPixFmt_ARGB32
;
1180 stdpf
= vHidd_StdPixFmt_RGBA32
;
1184 stdpf
= vHidd_StdPixFmt_BGRA32
;
1188 stdpf
= vHidd_StdPixFmt_ABGR32
;
1192 stdpf
= vHidd_StdPixFmt_0RGB32
;
1196 stdpf
= vHidd_StdPixFmt_RGB032
;
1200 stdpf
= vHidd_StdPixFmt_BGR032
;
1204 stdpf
= vHidd_StdPixFmt_0BGR32
;
1208 stdpf
= vHidd_StdPixFmt_LUT8
;
1212 D(bug("UNKNOWN CYBERGRAPHICS PIXFMT IN cyber2hidd_pixfmt\n"));
1219 /****************************************************************************************/
1221 #define ENABLE_PROFILING 0
1222 #define USE_OLD_MoveRaster 0
1224 #define rdtscll(val) \
1225 __asm__ __volatile__("rdtsc" : "=A" (val))
1227 #if ENABLE_PROFILING && defined(__i386__)
1230 #define AROS_BEGIN_PROFILING(context) \
1232 unsigned long long _time1, _time2; \
1233 char *_text = #context; \
1237 #define AROS_END_PROFILING \
1240 kprintf("%s: Ticks count: %u\n", _text, (unsigned long)(_time2 - _time1)); \
1245 #define AROS_BEGIN_PROFILING(context)
1246 #define AROS_END_PROFILING
1250 BOOL
MoveRaster (struct RastPort
* rp
, LONG dx
, LONG dy
, LONG x1
, LONG y1
,
1251 LONG x2
, LONG y2
, BOOL UpdateDamageList
, struct GfxBase
* GfxBase
)
1253 struct Layer
*L
= rp
->Layer
;
1254 struct Rectangle ScrollRect
;
1255 struct Rectangle Rect
;
1257 if (0 == dx
&& 0 == dy
)
1260 if (!OBTAIN_DRIVERDATA(rp
, GfxBase
))
1263 ScrollRect
.MinX
= x1
;
1264 ScrollRect
.MinY
= y1
;
1265 ScrollRect
.MaxX
= x2
;
1266 ScrollRect
.MaxY
= y2
;
1271 TranslateRect(&Rect
, -dx
, -dy
);
1272 if (_AndRectRect(&ScrollRect
, &Rect
, &Rect
))
1274 BltBitMap(rp
->BitMap
,
1280 Rect
.MaxX
- Rect
.MinX
+ 1,
1281 Rect
.MaxY
- Rect
.MinY
+ 1,
1289 struct ClipRect
*SrcCR
;
1293 if (L
->Flags
& LAYERSIMPLE
&& UpdateDamageList
)
1295 /* Scroll the old damagelist within the scroll area */
1296 ScrollRegion(L
->DamageList
, &ScrollRect
, -dx
, -dy
);
1299 /* The scrolling area is relative to the Layer, so make it relative to the screen */
1300 TranslateRect(&ScrollRect
, MinX(L
), MinY(L
));
1302 /* The damage list will be formed by the now hidden layer's parts that will become visible due
1303 to the scrolling procedure, thus we procede this way:
1305 1) Calculate the invisible region out of the visible one, subtracting it from the
1308 2) Scroll the invisible region by (-dx, -dy) and then subtract from it the not scrolled equivalent
1310 The regions that we obtain after (2) is the new damage list
1313 if (L
->Flags
& LAYERSIMPLE
&& UpdateDamageList
)
1316 TranslateRect(&Rect
, dx
, dy
);
1318 if (_AndRectRect(&ScrollRect
, &Rect
, &Rect
))
1320 struct Region
*Damage
;
1322 Damage
= NewRectRegion(Rect
.MinX
, Rect
.MinY
, Rect
.MaxX
, Rect
.MaxY
);
1327 ClearRegionRegion(L
->VisibleRegion
, Damage
)
1329 Damage
->RegionRectangle
1334 We play sort of dirty here, by making assumptions about the internals of the
1335 Region structure and the region handling functions, but we are allowed to do that,
1341 TranslateRect(Bounds(Damage
), -dx
, -dy
);
1345 ClearRegionRegion(&Tmp
, Damage
)
1347 Damage
->RegionRectangle
1350 /* Join the new damage list with the old one */
1351 TranslateRect(Bounds(Damage
), -MinX(L
), -MinY(L
));
1352 OrRegionRegion(Damage
, L
->DamageList
);
1354 L
->Flags
|= LAYERREFRESH
;
1358 DisposeRegion(Damage
);
1363 AROS_BEGIN_PROFILING(SortLayerCR
)
1365 #define LayersBase (struct LayersBase *)(GfxBase->gb_LayersBase)
1366 SortLayerCR(L
, dx
, dy
);
1371 AROS_BEGIN_PROFILING(Blitting loop
)
1373 #if USE_OLDMoveRaster
1376 struct ClipRect
*LastHiddenCR
;
1378 for (LastHiddenCR
= NULL
, SrcCR
= L
->ClipRect
; SrcCR
; SrcCR
= SrcCR
->Next
)
1380 SrcCR
->_p1
= LastHiddenCR
;
1383 LastHiddenCR
= SrcCR
;
1388 for (SrcCR
= L
->ClipRect
; SrcCR
; SrcCR
= SrcCR
->Next
)
1392 if (SrcCR
->lobs
&& (L
->Flags
& LAYERSIMPLE
))
1397 if (_AndRectRect(&ScrollRect
, Bounds(SrcCR
), &Rect
))
1399 TranslateRect(&Rect
, -dx
, -dy
);
1401 if (_AndRectRect(&ScrollRect
, &Rect
, &Rect
))
1407 /* Rect.Min(X|Y) are the coordinates to wich the rectangle has to be moved
1408 Rect.Max(X|Y) - Rect.Max(X|Y) - 1 are the dimensions of this rectangle */
1409 if (!SrcCR
->_p1
&& !SrcCR
->lobs
)
1411 /* there are no hidden/obscured rectangles this recrtangle has to deal with*/
1420 Rect
.MaxX
- Rect
.MinX
+ 1,
1421 Rect
.MaxY
- Rect
.MinY
+ 1,
1429 struct BitMap
*srcbm
;
1430 struct RegionRectangle
*rr
;
1431 struct Region
*RectRegion
;
1432 struct Rectangle Tmp
;
1433 struct ClipRect
*HiddCR
;
1434 WORD corrsrcx
, corrsrcy
;
1437 RectRegion
= NewRectRegion(Rect
.MinX
, Rect
.MinY
, Rect
.MaxX
, Rect
.MaxY
);
1443 if (L
->Flags
& LAYERSUPER
)
1445 corrsrcx
= - MinX(L
) - L
->Scroll_X
;
1446 corrsrcy
= - MinY(L
) - L
->Scroll_Y
;
1450 corrsrcx
= - MinX(SrcCR
) + ALIGN_OFFSET(MinX(SrcCR
));
1451 corrsrcy
= - MinY(SrcCR
);
1453 srcbm
= SrcCR
->BitMap
;
1462 for (HiddCR
= SrcCR
->_p1
; HiddCR
; HiddCR
= HiddCR
->_p1
)
1464 if (_AndRectRect(Bounds(RectRegion
), Bounds(HiddCR
), &Tmp
))
1466 if (!(L
->Flags
& LAYERSIMPLE
))
1468 WORD corrdstx
, corrdsty
;
1470 if (L
->Flags
& LAYERSUPER
)
1472 corrdstx
= - MinX(L
) - L
->Scroll_X
;
1473 corrdsty
= - MinY(L
) - L
->Scroll_Y
;
1478 corrdstx
= - MinX(HiddCR
) + ALIGN_OFFSET(MinX(HiddCR
));
1479 corrdsty
= - MinY(HiddCR
);
1486 Tmp
.MinX
+ corrsrcx
+ dx
,
1487 Tmp
.MinY
+ corrsrcy
+ dy
,
1489 Tmp
.MinX
+ corrdstx
,
1490 Tmp
.MinY
+ corrdsty
,
1491 Tmp
.MaxX
- Tmp
.MinX
+ 1,
1492 Tmp
.MaxY
- Tmp
.MinY
+ 1,
1499 if (!ClearRectRegion(RectRegion
, &Tmp
))
1501 DisposeRegion(RectRegion
);
1507 if ((dosrcsrc
= _AndRectRect(Bounds(SrcCR
), &Rect
, &Tmp
)))
1509 if (!ClearRectRegion(RectRegion
, &Tmp
))
1511 DisposeRegion(RectRegion
);
1516 for (rr
= RectRegion
->RegionRectangle
; rr
; rr
= rr
->Next
)
1521 MinX(rr
) + MinX(RectRegion
) + corrsrcx
+ dx
,
1522 MinY(rr
) + MinY(RectRegion
) + corrsrcy
+ dy
,
1524 MinX(rr
) + MinX(RectRegion
),
1525 MinY(rr
) + MinY(RectRegion
),
1539 Tmp
.MinX
+ corrsrcx
+ dx
,
1540 Tmp
.MinY
+ corrsrcy
+ dy
,
1542 Tmp
.MinX
+ corrsrcx
,
1543 Tmp
.MinY
+ corrsrcy
,
1544 Tmp
.MaxX
- Tmp
.MinX
+ 1,
1545 Tmp
.MaxY
- Tmp
.MinY
+ 1,
1553 DisposeRegion(RectRegion
);
1560 for (SrcCR
= L
->ClipRect
; SrcCR
; SrcCR
= SrcCR
->Next
)
1562 if (_AndRectRect(&ScrollRect
, Bounds(SrcCR
), &Rect
))
1564 TranslateRect(&Rect
, -dx
, -dy
);
1566 if (_AndRectRect(&ScrollRect
, &Rect
, &Rect
))
1568 struct BitMap
*srcbm
;
1569 struct ClipRect
*DstCR
;
1570 LONG corrsrcx
, corrsrcy
;
1575 if (L
->Flags
& LAYERSIMPLE
) continue;
1577 if (L
->Flags
& LAYERSUPER
)
1579 corrsrcx
= - MinX(L
) - L
->Scroll_X
;
1580 corrsrcy
= - MinY(L
) - L
->Scroll_Y
;
1584 corrsrcx
= - MinX(SrcCR
) + ALIGN_OFFSET(MinX(SrcCR
));
1585 corrsrcy
= - MinY(SrcCR
);
1587 srcbm
= SrcCR
->BitMap
;
1596 area
= (ULONG
)(Rect
.MaxX
- Rect
.MinX
+ 1) * (ULONG
)(Rect
.MaxY
- Rect
.MinY
+ 1);
1598 for (DstCR
= L
->ClipRect
; area
&& DstCR
; DstCR
= DstCR
->Next
)
1600 struct Rectangle Rect2
;
1602 if (_AndRectRect(Bounds(DstCR
), &Rect
, &Rect2
))
1604 struct BitMap
*dstbm
;
1605 LONG corrdstx
, corrdsty
;
1607 area
-= (ULONG
)(Rect2
.MaxX
- Rect2
.MinX
+ 1) * (ULONG
)(Rect2
.MaxY
- Rect2
.MinY
+ 1);
1611 if (L
->Flags
& LAYERSIMPLE
) continue;
1613 if (L
->Flags
& LAYERSUPER
)
1615 corrdstx
= - MinX(L
) - L
->Scroll_X
;
1616 corrdsty
= - MinY(L
) - L
->Scroll_Y
;
1620 corrdstx
= - MinX(DstCR
) + ALIGN_OFFSET(MinX(DstCR
));
1621 corrdsty
= - MinY(DstCR
);
1623 dstbm
= DstCR
->BitMap
;
1635 Rect2
.MinX
+ corrsrcx
+ dx
,
1636 Rect2
.MinY
+ corrsrcy
+ dy
,
1638 Rect2
.MinX
+ corrdstx
,
1639 Rect2
.MinY
+ corrdsty
,
1640 Rect2
.MaxX
- Rect2
.MinX
+ 1,
1641 Rect2
.MaxY
- Rect2
.MinY
+ 1,
1657 RELEASE_DRIVERDATA(rp
, GfxBase
);
1662 /****************************************************************************************/
1664 BOOL
GetRPClipRectangleForLayer(struct RastPort
*rp
, struct Layer
*lay
,
1665 struct Rectangle
*r
, struct GfxBase
*GfxBase
)
1669 if (RP_DRIVERDATA(rp
)->dd_ClipRectangleFlags
& RPCRF_VALID
)
1671 *r
= RP_DRIVERDATA(rp
)->dd_ClipRectangle
;
1673 if (RP_DRIVERDATA(rp
)->dd_ClipRectangleFlags
& RPCRF_RELRIGHT
)
1675 r
->MaxX
+= (lay
->bounds
.MaxX
- lay
->bounds
.MinX
+ 1) - 1;
1678 if (RP_DRIVERDATA(rp
)->dd_ClipRectangleFlags
& RPCRF_RELBOTTOM
)
1680 r
->MaxY
+= (lay
->bounds
.MaxY
- lay
->bounds
.MinY
+ 1) - 1;
1683 r
->MinX
+= lay
->bounds
.MinX
;
1684 r
->MinY
+= lay
->bounds
.MinY
;
1685 r
->MaxX
+= lay
->bounds
.MinX
;
1686 r
->MaxY
+= lay
->bounds
.MinY
;
1694 /****************************************************************************************/
1696 BOOL
GetRPClipRectangleForBitMap(struct RastPort
*rp
, struct BitMap
*bm
,
1697 struct Rectangle
*r
, struct GfxBase
*GfxBase
)
1699 if (RP_DRIVERDATA(rp
)->dd_ClipRectangleFlags
& RPCRF_VALID
)
1702 *r
= RP_DRIVERDATA(rp
)->dd_ClipRectangle
;
1704 if (RP_DRIVERDATA(rp
)->dd_ClipRectangleFlags
& RPCRF_RELRIGHT
)
1706 LONG width
= GetBitMapAttr(bm
, BMA_WIDTH
);
1708 r
->MaxX
+= width
- 1;
1711 if (RP_DRIVERDATA(rp
)->dd_ClipRectangleFlags
& RPCRF_RELBOTTOM
)
1713 LONG height
= GetBitMapAttr(bm
, BMA_HEIGHT
);
1715 r
->MaxY
+= height
- 1;
1724 /****************************************************************************************/