Updated PCI IDs to latest snapshot.
[tangerine.git] / rom / graphics / gfxfuncsupport.c
blobd55362b2d98c8d398949389c3fb5d94a9fd84e0b
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
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
9 if it is a HIDD bitmap
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"
24 #include "objcache.h"
25 #include "intregions.h"
26 #include "gfxfuncsupport.h"
28 #define DEBUG 0
29 #include <aros/debug.h>
31 /****************************************************************************************/
33 OOP_Object *get_planarbm_object(struct BitMap *bitmap, struct GfxBase *GfxBase)
35 OOP_Object *pbm_obj;
37 D(bug("get_planarbm_object()\n"));
38 pbm_obj = obtain_cache_object(SDD(GfxBase)->planarbm_cache, GfxBase);
40 if (NULL != pbm_obj)
43 D(bug("Got cache object %p, class=%s, domethod=%p, instoffset=%d\n"
44 , pbm_obj
45 , OOP_OCLASS(pbm_obj)->ClassNode.ln_Name
46 , OOP_OCLASS(pbm_obj)->DoMethod
47 , OOP_OCLASS(pbm_obj)->InstOffset
48 ));
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);
54 pbm_obj = NULL;
58 else
60 D(bug("!!! get_planarbm_object: obtain_cache_object FAILED !!!\n"));
63 return pbm_obj;
66 /****************************************************************************************/
68 ULONG do_render_func(struct RastPort *rp
69 , Point *src
70 , struct Rectangle *rr
71 , ULONG (*render_func)(APTR, LONG, LONG, OOP_Object *, OOP_Object *, LONG, LONG, LONG, LONG, struct GfxBase *)
72 , APTR funcdata
73 , BOOL get_special_info
74 , struct GfxBase *GfxBase)
77 struct BitMap *bm = rp->BitMap;
78 struct Layer *L = rp->Layer;
79 OOP_Object *gc;
80 struct Rectangle rp_clip_rectangle;
81 BOOL have_rp_cliprectangle;
82 ULONG width, height;
83 LONG srcx, srcy;
84 LONG pixwritten = 0;
86 gc = GetDriverData(rp)->dd_GC;
88 width = rr->MaxX - rr->MinX + 1;
89 height = rr->MaxY - rr->MinY + 1;
91 if (NULL != src)
93 srcx = src->x;
94 srcy = src->y;
95 } else
97 srcx = 0;
98 srcy = 0;
101 if (NULL == L)
103 struct Rectangle torender = *rr;
105 /* No layer, probably a screen, but may be a user inited bitmap */
106 OOP_Object *bm_obj;
108 have_rp_cliprectangle = GetRPClipRectangleForBitMap(rp, bm, &rp_clip_rectangle, GfxBase);
109 if (have_rp_cliprectangle && !(_AndRectRect(rr, &rp_clip_rectangle, &torender)))
111 return 0;
114 bm_obj = OBTAIN_HIDD_BM(bm);
115 if (NULL == bm_obj)
116 return 0;
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
130 , srcx, srcy
131 , bm_obj, gc
132 , torender.MinX, torender.MinY
133 , torender.MaxX, torender.MaxY
134 , GfxBase
137 RELEASE_HIDD_BM(bm_obj, bm);
140 else
142 struct ClipRect *CR;
143 WORD xrel;
144 WORD yrel;
145 struct Rectangle torender, intersect;
146 OOP_Object *bm_obj;
148 LockLayerRom(L);
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;
161 CR = L->ClipRect;
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,
167 CR->lobs));
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);
193 if(bm_obj)
195 pixwritten += render_func(funcdata
196 , srcx + xoffset
197 , srcy + yoffset
198 , bm_obj
199 , gc
200 , intersect.MinX
201 , intersect.MinY
202 , intersect.MaxX
203 , intersect.MaxY
204 , GfxBase
207 RELEASE_HIDD_BM(bm_obj, bm);
212 else
214 /* Render into offscreen cliprect bitmap */
215 if (L->Flags & LAYERSIMPLE)
216 continue;
217 else if (L->Flags & LAYERSUPER)
219 D(bug("do_render_func(): Superbitmap not handled yet\n"));
221 else
224 if (get_special_info)
226 RSI(funcdata)->curbm = CR->BitMap;
227 RSI(funcdata)->onscreen = FALSE;
230 bm_obj = OBTAIN_HIDD_BM(CR->BitMap);
231 if (bm_obj)
233 pixwritten += render_func(funcdata
234 , srcx + xoffset, srcy + yoffset
235 , bm_obj
236 , gc
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
241 , GfxBase
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) */
256 UnlockLayerRom(L);
257 } /* if (rp->Layer) */
260 return pixwritten;
264 /****************************************************************************************/
266 ULONG do_pixel_func(struct RastPort *rp
267 , LONG x, LONG y
268 , LONG (*render_func)(APTR, OOP_Object *, OOP_Object *, LONG, LONG, struct GfxBase *)
269 , APTR funcdata
270 , struct GfxBase *GfxBase)
272 struct BitMap *bm = rp->BitMap;
273 struct Layer *L = rp->Layer;
274 OOP_Object *gc;
275 struct Rectangle rp_clip_rectangle;
276 BOOL have_rp_cliprectangle;
277 ULONG retval = -1;
279 gc = GetDriverData(rp)->dd_GC;
281 if (NULL == L)
283 OOP_Object *bm_obj;
284 IPTR width, height;
286 bm_obj = OBTAIN_HIDD_BM(bm);
287 if (NULL == bm_obj)
288 return -1;
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 */
294 if ( x < 0
295 || x >= width
296 || y < 0
297 || y >= height)
300 RELEASE_HIDD_BM(bm_obj, bm);
301 return -1;
305 /* This is a screen */
306 retval = render_func(funcdata, bm_obj, gc, x, y, GfxBase);
308 RELEASE_HIDD_BM(bm_obj, bm);
311 else
313 struct ClipRect *CR;
314 LONG absx, absy;
315 OOP_Object *bm_obj;
317 LockLayerRom( L );
319 have_rp_cliprectangle = GetRPClipRectangleForLayer(rp, L, &rp_clip_rectangle, GfxBase);
321 CR = L->ClipRect;
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);
340 if (bm_obj)
342 retval = render_func(funcdata
343 , bm_obj, gc
344 , absx, absy
345 , GfxBase
348 RELEASE_HIDD_BM(bm_obj, bm);
351 else
353 /* This is the tricky one: render into offscreen cliprect bitmap */
354 if (L->Flags & LAYERSIMPLE)
356 /* We cannot do anything */
357 retval = 0;
360 else if (L->Flags & LAYERSUPER)
362 D(bug("driver_WriteRGBPixel(): Superbitmap not handled yet\n"));
364 else
366 bm_obj = OBTAIN_HIDD_BM(CR->BitMap);
367 if (bm_obj)
369 retval = render_func(funcdata
370 , bm_obj, gc
371 , absx - CR->bounds.MinX + ALIGN_OFFSET(CR->bounds.MinX)
372 , absy - CR->bounds.MinY
373 , GfxBase
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 */
388 break;
390 } /* if (cliprect intersects with area we want to draw to) */
392 } /* while (cliprects to examine) */
394 UnlockLayerRom( L );
398 return retval;
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)
419 LONG pixwritten = 0;
421 HIDDT_DrawMode old_drmd;
422 IPTR old_fg;
423 OOP_Object *gc;
424 struct Rectangle rr;
426 struct TagItem gc_tags[] =
428 { aHidd_GC_DrawMode , drmd },
429 { aHidd_GC_Foreground , pix },
430 { TAG_DONE }
434 if (!OBTAIN_DRIVERDATA(rp, GfxBase))
435 return 0;
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);
444 rr.MinX = x1;
445 rr.MinY = y1;
446 rr.MaxX = x2;
447 rr.MaxY = y2;
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);
458 return pixwritten;
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)
467 HIDDT_DrawMode drmd;
469 ULONG srcflags = 0;
470 ULONG dstflags = 0;
472 BOOL src_colmap_set = FALSE;
473 BOOL dst_colmap_set = FALSE;
474 BOOL success = TRUE;
475 BOOL colmaps_ok = TRUE;
477 drmd = MINTERM_TO_GCDRMD(minterm);
479 /* We must lock any HIDD_BM_SetColorMap calls */
480 LOCK_BLIT
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);
493 else
495 //bug("driver_intbltbitmap: source is amiga bitmap\n");
496 /* Amiga BM */
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);
510 else
512 //bug("driver_intbltbitmap: dest is amiga bitmap\n");
513 /* Amiga BM */
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"));
524 colmaps_ok = FALSE;
525 success = FALSE;
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;
537 bug("Colormap:\n");
539 ULONG idx;
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"));
553 colmaps_ok = FALSE;
554 success = FALSE;
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;
567 if (colmaps_ok)
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;
578 IPTR old_fg;
580 struct TagItem frtags[] =
582 { aHidd_GC_Foreground , 0 },
583 { aHidd_GC_DrawMode , vHidd_GC_DrawMode_Copy },
584 { TAG_DONE }
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
596 , xDest, yDest
597 , xDest + xSize - 1
598 , yDest + ySize - 1
601 frtags[0].ti_Data = old_fg;
602 frtags[1].ti_Data = old_drmd;
605 else
607 HIDDT_DrawMode old_drmd;
609 struct TagItem cbtags[] =
611 { aHidd_GC_DrawMode, 0 },
612 { TAG_DONE }
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
621 , srcbm_obj
622 , xSrc, ySrc
623 , dstbm_obj
624 , xDest, yDest
625 , xSize, ySize
626 , gc
629 cbtags[0].ti_Data = drmd;
630 OOP_SetAttrs(gc, cbtags);
633 } /* if (colmaps_ok) */
635 if (src_colmap_set)
636 HIDD_BM_SetColorMap(srcbm_obj, NULL);
638 if (dst_colmap_set)
639 HIDD_BM_SetColorMap(dstbm_obj, NULL);
641 ULOCK_BLIT
643 return success;
647 /****************************************************************************************/
649 struct wp8_render_data
651 UBYTE *array;
652 ULONG modulo;
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;
661 ULONG width, height;
663 wp8rd = (struct wp8_render_data *)wp8r_data;
665 width = x2 - x1 + 1;
666 height = y2 - y1 + 1;
668 HIDD_BM_PutImageLUT(dstbm_obj
669 , dst_gc
670 , wp8rd->array + CHUNKY8_COORD_TO_BYTEIDX(srcx, srcy, wp8rd->modulo)
671 , wp8rd->modulo
672 , x1, y1
673 , width, height
674 , wp8rd->pixlut
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)
686 LONG pixwritten = 0;
688 struct wp8_render_data wp8rd;
689 struct Rectangle rr;
691 OOP_Object *gc;
692 HIDDT_DrawMode old_drmd;
694 struct TagItem gc_tags[] =
696 { aHidd_GC_DrawMode, vHidd_GC_DrawMode_Copy},
697 { TAG_DONE, 0}
701 if (!OBTAIN_DRIVERDATA(rp, GfxBase))
702 return 0;
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;
710 wp8rd.array = array;
711 wp8rd.pixlut = pixlut;
713 rr.MinX = xstart;
714 rr.MinY = ystart;
715 rr.MaxX = xstop;
716 rr.MaxY = ystop;
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);
726 return pixwritten;
730 /****************************************************************************************/
732 struct wtp8_render_data
734 UBYTE *array;
735 ULONG modulo;
736 HIDDT_PixelLUT *pixlut;
737 UBYTE transparent;
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;
745 ULONG width, height;
747 wtp8rd = (struct wtp8_render_data *)wtp8r_data;
749 width = x2 - x1 + 1;
750 height = y2 - y1 + 1;
752 HIDD_BM_PutTranspImageLUT(dstbm_obj
753 , dst_gc
754 , wtp8rd->array + CHUNKY8_COORD_TO_BYTEIDX(srcx, srcy, wtp8rd->modulo)
755 , wtp8rd->modulo
756 , x1, y1
757 , width, height
758 , wtp8rd->pixlut
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)
772 LONG pixwritten = 0;
774 struct wtp8_render_data wtp8rd;
775 struct Rectangle rr;
777 OOP_Object *gc;
778 HIDDT_DrawMode old_drmd;
780 struct TagItem gc_tags[] =
782 { aHidd_GC_DrawMode, vHidd_GC_DrawMode_Copy},
783 { TAG_DONE, 0}
787 if (!OBTAIN_DRIVERDATA(rp, GfxBase))
788 return 0;
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;
800 rr.MinX = xstart;
801 rr.MinY = ystart;
802 rr.MaxX = xstop;
803 rr.MaxY = ystop;
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);
813 return pixwritten;
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 /****************************************************************************************/
827 #if 0
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)
836 ULONG tocopy_w,
837 tocopy_h;
839 LONG pixels_left_to_process = xsize * ysize;
841 LONG current_x, current_y, next_x, next_y;
842 OOP_Object *bm_obj;
844 next_x = 0;
845 next_y = 0;
847 bm_obj = OBTAIN_HIDD_BM(hidd_bm);
848 if (NULL == bm_obj)
849 return;
851 LOCK_PIXBUF
853 while (pixels_left_to_process)
856 /* Get some more pixels from the HIDD */
858 current_x = next_x;
859 current_y = next_y;
861 if (NUMPIX < xsize)
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 */
869 tocopy_w = NUMPIX;
870 next_x += NUMPIX;
872 else
873 { /* Start at a new line */
874 next_x = 0;
875 next_y ++;
877 tocopy_h = 1;
880 else /* We can copy one or several whole horizontal lines at a time */
882 tocopy_h = MIN(NUMPIX / xsize, ysize - current_y);
884 tocopy_w = xsize;
886 next_x = 0;
887 next_y += tocopy_h;
893 /* Get data */
894 fillbuf_hook(src_info
895 , current_x + x_src
896 , current_y + y_src
897 , current_x + x_dest
898 , current_y + y_dest
899 , tocopy_w, tocopy_h
900 , PrivGBase(GfxBase)->pixel_buf
901 , bm_obj
902 , IS_HIDD_BM(hidd_bm) ? HIDD_BM_PIXTAB(hidd_bm) : NULL
903 , GfxBase
906 /* Put it to the HIDD */
907 D(bug("Putting box\n"));
909 HIDD_BM_PutImage(bm_obj
910 , hidd_gc
911 , (UBYTE*)PrivGBase(GfxBase)->pixel_buf
912 , tocopy_w * sizeof (HIDDT_Pixel)
913 , x_dest + current_x
914 , y_dest + current_y
915 , tocopy_w, tocopy_h
916 , vHidd_StdPixFmt_Native32
919 D(bug("Box put\n"));
921 pixels_left_to_process -= (tocopy_w * tocopy_h);
924 } /* while (pixels left to copy) */
926 ULOCK_PIXBUF
928 RELEASE_HIDD_BM(bm_obj, hidd_bm);
930 return;
934 #endif
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
950 OOP_Object *bm_obj;
952 next_x = 0;
953 next_y = 0;
955 bm_obj = OBTAIN_HIDD_BM(hidd_bm);
956 if (NULL == bm_obj)
957 return;
959 LOCK_PIXBUF
961 while (pixels_left_to_process)
964 current_x = next_x;
965 current_y = next_y;
967 if (NUMPIX < xsize)
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 */
975 tocopy_w = NUMPIX;
976 next_x += NUMPIX;
978 else
979 { /* Start at a new line */
981 next_x = 0;
982 next_y ++;
984 tocopy_h = 1;
987 else
989 tocopy_h = MIN(NUMPIX / xsize, ysize - current_y);
990 tocopy_w = xsize;
992 next_x = 0;
993 next_y += tocopy_h;
998 /* Get some more pixels from the HIDD */
999 HIDD_BM_GetImage(bm_obj
1000 , (UBYTE *)PrivGBase(GfxBase)->pixel_buf
1001 , tocopy_w
1002 , x_src + current_x
1003 , y_src + current_y
1004 , tocopy_w, tocopy_h
1005 , vHidd_StdPixFmt_Native32);
1008 /* Write pixels to the destination */
1009 putbuf_hook(dest_info
1010 , current_x + x_src
1011 , current_y + y_src
1012 , current_x + x_dest
1013 , current_y + y_dest
1014 , tocopy_w, tocopy_h
1015 , (HIDDT_Pixel *)PrivGBase(GfxBase)->pixel_buf
1016 , bm_obj
1017 , IS_HIDD_BM(hidd_bm) ? HIDD_BM_PIXTAB(hidd_bm) : NULL
1020 pixels_left_to_process -= (tocopy_w * tocopy_h);
1024 ULOCK_PIXBUF
1026 RELEASE_HIDD_BM(bm_obj, hidd_bm);
1028 return;
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));
1040 switch (stdpf)
1042 case vHidd_StdPixFmt_RGB15:
1043 cpf = PIXFMT_RGB15;
1044 break;
1046 case vHidd_StdPixFmt_RGB15_LE:
1047 cpf = PIXFMT_RGB15PC;
1048 break;
1050 case vHidd_StdPixFmt_BGR15:
1051 cpf = PIXFMT_BGR15;
1052 break;
1054 case vHidd_StdPixFmt_BGR15_LE:
1055 cpf = PIXFMT_BGR15PC;
1056 break;
1058 case vHidd_StdPixFmt_RGB16:
1059 cpf = PIXFMT_RGB16;
1060 break;
1062 case vHidd_StdPixFmt_RGB16_LE:
1063 cpf = PIXFMT_RGB16PC;
1064 break;
1066 case vHidd_StdPixFmt_BGR16:
1067 cpf = PIXFMT_BGR16;
1068 break;
1070 case vHidd_StdPixFmt_BGR16_LE:
1071 cpf = PIXFMT_BGR16PC;
1072 break;
1074 case vHidd_StdPixFmt_RGB24:
1075 cpf = PIXFMT_RGB24;
1076 break;
1078 case vHidd_StdPixFmt_BGR24:
1079 cpf = PIXFMT_BGR24;
1080 break;
1082 case vHidd_StdPixFmt_0RGB32:
1083 cpf = PIXFMT_0RGB32;
1084 break;
1086 case vHidd_StdPixFmt_RGB032:
1087 cpf = PIXFMT_RGB032;
1088 break;
1090 case vHidd_StdPixFmt_BGR032:
1091 cpf = PIXFMT_BGR032;
1092 break;
1094 case vHidd_StdPixFmt_0BGR32:
1095 cpf = PIXFMT_0BGR32;
1097 case vHidd_StdPixFmt_ARGB32:
1098 cpf = PIXFMT_ARGB32;
1099 break;
1101 case vHidd_StdPixFmt_RGBA32:
1102 cpf = PIXFMT_RGBA32;
1103 break;
1105 case vHidd_StdPixFmt_BGRA32:
1106 cpf = PIXFMT_BGRA32;
1107 break;
1109 case vHidd_StdPixFmt_ABGR32:
1110 cpf = PIXFMT_ABGR32;
1111 break;
1113 case vHidd_StdPixFmt_LUT8:
1114 cpf = PIXFMT_LUT8;
1115 break;
1117 default:
1118 D(bug("UNKNOWN CYBERGRAPHICS PIXFMT IN cyber2hidd_pixfmt\n"));
1119 break;
1123 return cpf;
1127 /****************************************************************************************/
1129 HIDDT_StdPixFmt cyber2hidd_pixfmt(UWORD cpf, struct GfxBase *GfxBase)
1131 HIDDT_StdPixFmt stdpf = vHidd_StdPixFmt_Unknown;
1133 switch (cpf)
1135 case PIXFMT_RGB15:
1136 stdpf = vHidd_StdPixFmt_RGB15;
1137 break;
1139 case PIXFMT_RGB15PC:
1140 stdpf = vHidd_StdPixFmt_RGB15_LE;
1141 break;
1143 case PIXFMT_BGR15:
1144 stdpf = vHidd_StdPixFmt_BGR15;
1145 break;
1147 case PIXFMT_BGR15PC:
1148 stdpf = vHidd_StdPixFmt_BGR15_LE;
1149 break;
1151 case PIXFMT_RGB16:
1152 stdpf = vHidd_StdPixFmt_RGB16;
1153 break;
1155 case PIXFMT_RGB16PC:
1156 stdpf = vHidd_StdPixFmt_RGB16_LE;
1157 break;
1159 case PIXFMT_BGR16:
1160 stdpf = vHidd_StdPixFmt_BGR16;
1161 break;
1163 case PIXFMT_BGR16PC:
1164 stdpf = vHidd_StdPixFmt_BGR16_LE;
1165 break;
1167 case PIXFMT_RGB24:
1168 stdpf = vHidd_StdPixFmt_RGB24;
1169 break;
1171 case PIXFMT_BGR24:
1172 stdpf = vHidd_StdPixFmt_BGR24;
1173 break;
1175 case PIXFMT_ARGB32:
1176 stdpf = vHidd_StdPixFmt_ARGB32;
1177 break;
1179 case PIXFMT_RGBA32:
1180 stdpf = vHidd_StdPixFmt_RGBA32;
1181 break;
1183 case PIXFMT_BGRA32:
1184 stdpf = vHidd_StdPixFmt_BGRA32;
1185 break;
1187 case PIXFMT_ABGR32:
1188 stdpf = vHidd_StdPixFmt_ABGR32;
1189 break;
1191 case PIXFMT_0RGB32:
1192 stdpf = vHidd_StdPixFmt_0RGB32;
1193 break;
1195 case PIXFMT_RGB032:
1196 stdpf = vHidd_StdPixFmt_RGB032;
1197 break;
1199 case PIXFMT_BGR032:
1200 stdpf = vHidd_StdPixFmt_BGR032;
1201 break;
1203 case PIXFMT_0BGR32:
1204 stdpf = vHidd_StdPixFmt_0BGR32;
1205 break;
1207 case PIXFMT_LUT8:
1208 stdpf = vHidd_StdPixFmt_LUT8;
1209 break;
1211 default:
1212 D(bug("UNKNOWN CYBERGRAPHICS PIXFMT IN cyber2hidd_pixfmt\n"));
1213 break;
1216 return stdpf;
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; \
1234 rdtscll(_time1); \
1237 #define AROS_END_PROFILING \
1239 rdtscll(_time2); \
1240 kprintf("%s: Ticks count: %u\n", _text, (unsigned long)(_time2 - _time1)); \
1243 #else
1245 #define AROS_BEGIN_PROFILING(context)
1246 #define AROS_END_PROFILING
1248 #endif
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)
1258 return TRUE;
1260 if (!OBTAIN_DRIVERDATA(rp, GfxBase))
1261 return FALSE;
1263 ScrollRect.MinX = x1;
1264 ScrollRect.MinY = y1;
1265 ScrollRect.MaxX = x2;
1266 ScrollRect.MaxY = y2;
1268 if (!L)
1270 Rect = ScrollRect;
1271 TranslateRect(&Rect, -dx, -dy);
1272 if (_AndRectRect(&ScrollRect, &Rect, &Rect))
1274 BltBitMap(rp->BitMap,
1275 Rect.MinX + dx,
1276 Rect.MinY + dy,
1277 rp->BitMap,
1278 Rect.MinX,
1279 Rect.MinY,
1280 Rect.MaxX - Rect.MinX + 1,
1281 Rect.MaxY - Rect.MinY + 1,
1282 0xc0, /* copy */
1283 0xff,
1284 NULL );
1287 else
1289 struct ClipRect *SrcCR;
1291 LockLayerRom(L);
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
1306 scrolling area
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)
1315 Rect = ScrollRect;
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);
1323 if (Damage)
1327 ClearRegionRegion(L->VisibleRegion, Damage)
1329 Damage->RegionRectangle
1332 struct Region Tmp;
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,
1336 aren't we? ;-)
1339 Tmp = *Damage;
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);
1367 #undef LayersBase
1369 AROS_END_PROFILING
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;
1382 if (SrcCR->lobs)
1383 LastHiddenCR = SrcCR;
1388 for (SrcCR = L->ClipRect; SrcCR; SrcCR = SrcCR->Next)
1390 int cando = 0;
1392 if (SrcCR->lobs && (L->Flags & LAYERSIMPLE))
1394 continue;
1397 if (_AndRectRect(&ScrollRect, Bounds(SrcCR), &Rect))
1399 TranslateRect(&Rect, -dx, -dy);
1401 if (_AndRectRect(&ScrollRect, &Rect, &Rect))
1402 cando = 1;
1405 if (cando)
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*/
1412 BltBitMap
1414 rp->BitMap,
1415 Rect.MinX + dx,
1416 Rect.MinY + dy,
1417 rp->BitMap,
1418 Rect.MinX,
1419 Rect.MinY,
1420 Rect.MaxX - Rect.MinX + 1,
1421 Rect.MaxY - Rect.MinY + 1,
1422 0xc0, /* copy */
1423 0xff,
1424 NULL
1427 else
1429 struct BitMap *srcbm;
1430 struct RegionRectangle *rr;
1431 struct Region *RectRegion;
1432 struct Rectangle Tmp;
1433 struct ClipRect *HiddCR;
1434 WORD corrsrcx, corrsrcy;
1435 BOOL dosrcsrc;
1437 RectRegion = NewRectRegion(Rect.MinX, Rect.MinY, Rect.MaxX, Rect.MaxY);
1438 if (!RectRegion)
1439 goto failexit;
1441 if (SrcCR->lobs)
1443 if (L->Flags & LAYERSUPER)
1445 corrsrcx = - MinX(L) - L->Scroll_X;
1446 corrsrcy = - MinY(L) - L->Scroll_Y;
1448 else
1450 corrsrcx = - MinX(SrcCR) + ALIGN_OFFSET(MinX(SrcCR));
1451 corrsrcy = - MinY(SrcCR);
1453 srcbm = SrcCR->BitMap;
1455 else
1457 corrsrcx = 0;
1458 corrsrcy = 0;
1459 srcbm = rp->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;
1475 else
1477 /* Smart layer */
1478 corrdstx = - MinX(HiddCR) + ALIGN_OFFSET(MinX(HiddCR));
1479 corrdsty = - MinY(HiddCR);
1483 BltBitMap
1485 srcbm,
1486 Tmp.MinX + corrsrcx + dx,
1487 Tmp.MinY + corrsrcy + dy,
1488 HiddCR->BitMap,
1489 Tmp.MinX + corrdstx,
1490 Tmp.MinY + corrdsty,
1491 Tmp.MaxX - Tmp.MinX + 1,
1492 Tmp.MaxY - Tmp.MinY + 1,
1493 0xc0, /* copy */
1494 0xff,
1495 NULL
1499 if (!ClearRectRegion(RectRegion, &Tmp))
1501 DisposeRegion(RectRegion);
1502 goto failexit;
1507 if ((dosrcsrc = _AndRectRect(Bounds(SrcCR), &Rect, &Tmp)))
1509 if (!ClearRectRegion(RectRegion, &Tmp))
1511 DisposeRegion(RectRegion);
1512 goto failexit;
1516 for (rr = RectRegion->RegionRectangle; rr; rr = rr->Next)
1518 BltBitMap
1520 srcbm,
1521 MinX(rr) + MinX(RectRegion) + corrsrcx + dx,
1522 MinY(rr) + MinY(RectRegion) + corrsrcy + dy,
1523 rp->BitMap,
1524 MinX(rr) + MinX(RectRegion),
1525 MinY(rr) + MinY(RectRegion),
1526 Width(rr),
1527 Height(rr),
1528 0xc0, /* copy */
1529 0xff,
1530 NULL
1534 if (dosrcsrc)
1536 BltBitMap
1538 srcbm,
1539 Tmp.MinX + corrsrcx + dx,
1540 Tmp.MinY + corrsrcy + dy,
1541 srcbm,
1542 Tmp.MinX + corrsrcx,
1543 Tmp.MinY + corrsrcy,
1544 Tmp.MaxX - Tmp.MinX + 1,
1545 Tmp.MaxY - Tmp.MinY + 1,
1546 0xc0, /* copy */
1547 0xff,
1548 NULL
1553 DisposeRegion(RectRegion);
1558 #else
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;
1571 ULONG area;
1573 if (SrcCR->lobs)
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;
1582 else
1584 corrsrcx = - MinX(SrcCR) + ALIGN_OFFSET(MinX(SrcCR));
1585 corrsrcy = - MinY(SrcCR);
1587 srcbm = SrcCR->BitMap;
1589 else
1591 corrsrcx = 0;
1592 corrsrcy = 0;
1593 srcbm = rp->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);
1609 if (DstCR->lobs)
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;
1618 else
1620 corrdstx = - MinX(DstCR) + ALIGN_OFFSET(MinX(DstCR));
1621 corrdsty = - MinY(DstCR);
1623 dstbm = DstCR->BitMap;
1625 else
1627 corrdstx = 0;
1628 corrdsty = 0;
1629 dstbm = rp->BitMap;
1632 BltBitMap
1634 srcbm,
1635 Rect2.MinX + corrsrcx + dx,
1636 Rect2.MinY + corrsrcy + dy,
1637 dstbm,
1638 Rect2.MinX + corrdstx,
1639 Rect2.MinY + corrdsty,
1640 Rect2.MaxX - Rect2.MinX + 1,
1641 Rect2.MaxY - Rect2.MinY + 1,
1642 0xC0,
1643 0xFF,
1644 NULL
1651 #endif
1652 AROS_END_PROFILING
1654 UnlockLayerRom(L);
1657 RELEASE_DRIVERDATA(rp, GfxBase);
1659 return TRUE;
1662 /****************************************************************************************/
1664 BOOL GetRPClipRectangleForLayer(struct RastPort *rp, struct Layer *lay,
1665 struct Rectangle *r, struct GfxBase *GfxBase)
1667 (void)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;
1688 return TRUE;
1691 return FALSE;
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;
1718 return TRUE;
1721 return FALSE;
1724 /****************************************************************************************/