grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / hidds / graphics / chunkybm.c
blob4d05563e51031c04b4af2551931dc8fce15ae6d6
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics chunky bitmap class implementation.
6 Lang: english
7 */
9 /****************************************************************************************/
11 #include <proto/exec.h>
12 #include <proto/utility.h>
13 #include <proto/oop.h>
15 #include <exec/memory.h>
16 #include <utility/tagitem.h>
17 #include <oop/oop.h>
19 #include <hidd/graphics.h>
21 #include "graphics_intern.h"
23 #include <string.h>
25 #define DEBUG 0
26 #include <aros/debug.h>
28 /****************************************************************************************/
30 OOP_Object *CBM__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
32 struct Library *OOPBase = CSD(cl)->cs_OOPBase;
33 struct Library *UtilityBase = CSD(cl)->cs_UtilityBase;
34 struct chunkybm_data *data;
35 OOP_Object *pf;
36 IPTR bytesperrow, bytesperpixel;
37 struct TagItem *tag;
38 OOP_MethodID dispose_mid;
40 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
41 if (NULL == o)
42 return NULL;
44 /* Initialize the instance data to 0 */
45 data = OOP_INST_DATA(cl, o);
46 memset(data, 0, sizeof (*data));
48 OOP_GetAttr(o, aHidd_BitMap_PixFmt, (APTR)&pf);
49 OOP_GetAttr(o, aHidd_BitMap_GfxHidd, (APTR)&data->gfxhidd);
50 /* Get some dimensions of the bitmap */
51 OOP_GetAttr(o, aHidd_BitMap_BytesPerRow, &bytesperrow);
52 OOP_GetAttr(pf, aHidd_PixFmt_BytesPerPixel, &bytesperpixel);
54 data->bytesperpixel = bytesperpixel;
55 data->bytesperrow = bytesperrow;
57 tag = FindTagItem(aHidd_ChunkyBM_Buffer, msg->attrList);
58 if (tag)
61 * NULL user-supplied buffer is valid.
62 * In this case we create a bitmap with no buffer. We can attach it later.
64 data->own_buffer = FALSE;
65 data->buffer = (APTR)tag->ti_Data;
67 return o;
69 else
71 IPTR height;
73 OOP_GetAttr(o, aHidd_BitMap_Height, &height);
75 data->own_buffer = TRUE;
76 data->buffer = AllocVec(height * bytesperrow, MEMF_ANY | MEMF_CLEAR);
78 if (data->buffer)
79 return o;
82 /* free all on error */
83 dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
85 OOP_CoerceMethod(cl, o, (OOP_Msg)&dispose_mid);
86 return NULL;
89 /****************************************************************************************/
91 void CBM__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
93 struct chunkybm_data *data;
95 data = OOP_INST_DATA(cl, o);
97 if (data->own_buffer)
98 FreeVec(data->buffer);
100 OOP_DoSuperMethod(cl, o, msg);
102 return;
105 /****************************************************************************************/
107 VOID CBM__Hidd_BitMap__PutPixel(OOP_Class *cl, OOP_Object *o,
108 struct pHidd_BitMap_PutPixel *msg)
110 UBYTE *dest;
112 struct chunkybm_data *data;
114 data = OOP_INST_DATA(cl, o);
116 /* bitmap in chunky-mode */
117 dest = data->buffer + msg->x * data->bytesperpixel + msg->y * data->bytesperrow;
119 switch(data->bytesperpixel)
121 case 1:
122 *((UBYTE *) dest) = (UBYTE) msg->pixel;
123 break;
125 case 2:
126 *((UWORD *) dest) = (UWORD) msg->pixel;
127 break;
129 case 3:
130 #if AROS_BIG_ENDIAN
131 dest[0] = (UBYTE)(msg->pixel >> 16) & 0x000000FF;
132 dest[1] = (UBYTE)(msg->pixel >> 8) & 0x000000FF;
133 dest[2] = (UBYTE)msg->pixel & 0x000000FF;
134 #else
135 dest[0] = (UBYTE)msg->pixel & 0x000000FF;
136 dest[1] = (UBYTE)(msg->pixel >> 8) & 0x000000FF;
137 dest[2] = (UBYTE)(msg->pixel >> 16) & 0x000000FF;
138 #endif
139 break;
141 /* if (1 == ( ((IPTR)dest) & 1) )
143 *((UBYTE *) dest++) = (UBYTE) msg->pixel >> 16;
144 *((UWORD *) dest ) = (UWORD) msg->pixel;
146 else
148 *((UWORD *) dest++) = (UWORD) msg->pixel >> 8;
149 *((UBYTE *) dest ) = (UBYTE) msg->pixel;
151 break;
153 case 4:
154 *((ULONG *) dest) = (ULONG) msg->pixel;
155 break;
160 /****************************************************************************************/
162 ULONG CBM__Hidd_BitMap__GetPixel(OOP_Class *cl, OOP_Object *o,
163 struct pHidd_BitMap_GetPixel *msg)
165 HIDDT_Pixel retval = 0;
166 UBYTE *src;
167 struct chunkybm_data *data;
169 data = OOP_INST_DATA(cl, o);
171 src = data->buffer + msg->x * data->bytesperpixel + msg->y * data->bytesperrow;
173 switch(data->bytesperpixel)
175 case 1:
176 retval = (HIDDT_Pixel) *((UBYTE *) src);
177 break;
179 case 2:
180 retval = (HIDDT_Pixel) *((UWORD *) src);
181 break;
183 case 3:
184 #if AROS_BIG_ENDIAN
185 retval = (HIDDT_Pixel) (src[0] << 16) + (src[1] << 8) + src[2];
186 #else
187 retval = (HIDDT_Pixel) (src[2] << 16) + (src[1] << 8) + src[0];
188 #endif
189 break;
191 //(*((UBYTE *) src++) << 16) | *((UWORD *) src));
192 //break;
194 case 4:
195 retval = ((ULONG) *((ULONG *) src));
196 break;
199 return retval;
202 /****************************************************************************************/
204 VOID CBM__Hidd_BitMap__FillRect(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_DrawRect *msg)
206 struct chunkybm_data *data =OOP_INST_DATA(cl, o);
207 HIDDT_Pixel fg = GC_FG(msg->gc);
208 HIDDT_DrawMode mode = GC_DRMD(msg->gc);
209 ULONG mod;
211 mod = data->bytesperrow;
213 switch(mode)
215 case vHidd_GC_DrawMode_Copy:
216 switch(data->bytesperpixel)
218 case 1:
219 HIDD_BM_FillMemRect8(o,
220 data->buffer,
221 msg->minX,
222 msg->minY,
223 msg->maxX,
224 msg->maxY,
225 mod,
226 fg);
227 break;
229 case 2:
230 HIDD_BM_FillMemRect16(o,
231 data->buffer,
232 msg->minX,
233 msg->minY,
234 msg->maxX,
235 msg->maxY,
236 mod,
237 fg);
238 break;
240 case 3:
241 HIDD_BM_FillMemRect24(o,
242 data->buffer,
243 msg->minX,
244 msg->minY,
245 msg->maxX,
246 msg->maxY,
247 mod,
248 fg);
249 break;
251 case 4:
252 HIDD_BM_FillMemRect32(o,
253 data->buffer,
254 msg->minX,
255 msg->minY,
256 msg->maxX,
257 msg->maxY,
258 mod,
259 fg);
260 break;
263 break;
265 case vHidd_GC_DrawMode_Invert:
266 HIDD_BM_InvertMemRect(o,
267 data->buffer,
268 msg->minX * data->bytesperpixel,
269 msg->minY,
270 msg->maxX * data->bytesperpixel + data->bytesperpixel - 1,
271 msg->maxY,
272 mod);
273 break;
275 default:
276 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
277 break;
279 } /* switch(mode) */
283 /****************************************************************************************/
285 VOID CBM__Hidd_BitMap__PutImage(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_PutImage *msg)
287 struct chunkybm_data *data = OOP_INST_DATA(cl, o);
288 APTR dst_pixels, src_pixels;
289 OOP_Object *srcpf;
291 switch(msg->pixFmt)
293 case vHidd_StdPixFmt_Native:
294 switch(data->bytesperpixel)
296 case 1:
297 HIDD_BM_CopyMemBox8(o,
298 msg->pixels,
301 data->buffer,
302 msg->x,
303 msg->y,
304 msg->width,
305 msg->height,
306 msg->modulo,
307 data->bytesperrow);
308 break;
310 case 2:
311 HIDD_BM_CopyMemBox16(o,
312 msg->pixels,
315 data->buffer,
316 msg->x,
317 msg->y,
318 msg->width,
319 msg->height,
320 msg->modulo,
321 data->bytesperrow);
322 break;
324 case 3:
325 HIDD_BM_CopyMemBox24(o,
326 msg->pixels,
329 data->buffer,
330 msg->x,
331 msg->y,
332 msg->width,
333 msg->height,
334 msg->modulo,
335 data->bytesperrow);
336 break;
338 case 4:
339 HIDD_BM_CopyMemBox32(o,
340 msg->pixels,
343 data->buffer,
344 msg->x,
345 msg->y,
346 msg->width,
347 msg->height,
348 msg->modulo,
349 data->bytesperrow);
350 break;
352 } /* switch(data->bytesperpixel) */
353 break;
355 case vHidd_StdPixFmt_Native32:
356 switch(data->bytesperpixel)
358 case 1:
359 HIDD_BM_PutMem32Image8(o,
360 msg->pixels,
361 data->buffer,
362 msg->x,
363 msg->y,
364 msg->width,
365 msg->height,
366 msg->modulo,
367 data->bytesperrow);
368 break;
370 case 2:
371 HIDD_BM_PutMem32Image16(o,
372 msg->pixels,
373 data->buffer,
374 msg->x,
375 msg->y,
376 msg->width,
377 msg->height,
378 msg->modulo,
379 data->bytesperrow);
380 break;
382 case 3:
383 HIDD_BM_PutMem32Image24(o,
384 msg->pixels,
385 data->buffer,
386 msg->x,
387 msg->y,
388 msg->width,
389 msg->height,
390 msg->modulo,
391 data->bytesperrow);
392 break;
394 case 4:
395 HIDD_BM_CopyMemBox32(o,
396 msg->pixels,
399 data->buffer,
400 msg->x,
401 msg->y,
402 msg->width,
403 msg->height,
404 msg->modulo,
405 data->bytesperrow);
406 break;
408 } /* switch(data->bytesperpixel) */
409 break;
411 default:
412 src_pixels = msg->pixels;
413 dst_pixels = data->buffer + msg->y * data->bytesperrow
414 + msg->x * data->bytesperpixel;
415 srcpf = HIDD_Gfx_GetPixFmt(data->gfxhidd, msg->pixFmt);
417 HIDD_BM_ConvertPixels(o, &src_pixels,
418 (HIDDT_PixelFormat *)srcpf, msg->modulo, &dst_pixels,
419 BM_PIXFMT(o), data->bytesperrow, msg->width, msg->height,
420 NULL);
422 } /* switch(msg->pixFmt) */
426 /**************************************************************************/
428 int static inline
429 __attribute__((always_inline, const)) do_alpha(int a, int v)
431 int tmp = a * v;
432 return (tmp + (tmp >> 8) + 0x80) >> 8;
435 VOID CBM__Hidd_BitMap__PutAlphaImage(OOP_Class *cl, OOP_Object *o,
436 struct pHidd_BitMap_PutAlphaImage *msg)
438 struct chunkybm_data *data = OOP_INST_DATA(cl, o);
439 HIDDT_StdPixFmt pixFmt = BM_PIXFMT(o)->stdpixfmt;
440 WORD x, y, src_step, dst_step;
441 UBYTE *p, *q;
442 UBYTE src_red, src_green, src_blue, src_alpha;
443 UBYTE dst_red, dst_green, dst_blue;
445 switch(pixFmt)
447 case vHidd_StdPixFmt_BGR032:
449 p = msg->pixels;
450 q = data->buffer + msg->y * data->bytesperrow
451 + msg->x * data->bytesperpixel;
452 src_step = msg->modulo - msg->width * 4;
453 dst_step = data->bytesperrow - data->bytesperpixel * msg->width;
455 for(y = 0; y < msg->height; y++)
457 for(x = 0; x < msg->width; x++)
459 src_alpha = *p++;
460 src_red = *p++;
461 src_green = *p++;
462 src_blue = *p++;
464 switch(src_alpha)
466 case 0:
467 q += 4;
468 break;
470 case 0xff:
471 *q++ = src_blue;
472 *q++ = src_green;
473 *q++ = src_red;
474 *q++ = 0;
475 break;
477 default:
478 dst_blue = *q;
479 dst_blue += do_alpha(src_alpha, src_blue - dst_blue);
480 *q++ = dst_blue;
482 dst_green = *q;
483 dst_green += do_alpha(src_alpha, src_green - dst_green);
484 *q++ = dst_green;
486 dst_red = *q;
487 dst_red += do_alpha(src_alpha, src_red - dst_red);
488 *q++ = dst_red;
490 *q++ = 0;
493 p += src_step;
494 q += dst_step;
496 break;
498 case vHidd_StdPixFmt_RGB16_LE:
500 p = msg->pixels;
501 q = data->buffer + msg->y * data->bytesperrow
502 + msg->x * data->bytesperpixel;
503 src_step = msg->modulo - msg->width * 4;
504 dst_step = data->bytesperrow - data->bytesperpixel * msg->width;
506 for(y = 0; y < msg->height; y++)
508 for(x = 0; x < msg->width; x++)
510 src_alpha = *p++;
511 src_red = *p++;
512 src_green = *p++;
513 src_blue = *p++;
515 switch(src_alpha)
517 case 0:
518 q += 2;
519 break;
521 case 0xff:
522 *q++ = (src_green << 3) & 0xe0 | src_blue >> 3;
523 *q++ = src_red & 0xf8 | src_green >> 5;
524 break;
526 default:
527 dst_blue = *q;
528 dst_red = *(q + 1);
529 dst_green = dst_red << 5 | dst_blue >> 3 & 0x1c;
530 dst_blue <<= 3;
531 dst_red &= 0xf8;
533 dst_blue += do_alpha(src_alpha, src_blue - dst_blue);
534 dst_green += do_alpha(src_alpha, src_green - dst_green);
535 dst_red += do_alpha(src_alpha, src_red - dst_red);
537 *q++ = (dst_green << 3) & 0xe0 | dst_blue >> 3;
538 *q++ = dst_red & 0xf8 | dst_green >> 5;
541 p += src_step;
542 q += dst_step;
544 break;
546 default:
547 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
548 break;
552 /****************************************************************************************/
554 VOID CBM__Hidd_BitMap__GetImage(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_GetImage *msg)
556 struct chunkybm_data *data = OOP_INST_DATA(cl, o);
557 APTR src_pixels, dst_pixels;
558 OOP_Object *dstpf;
560 switch(msg->pixFmt)
562 case vHidd_StdPixFmt_Native:
563 switch(data->bytesperpixel)
565 case 1:
566 HIDD_BM_CopyMemBox8(o,
567 data->buffer,
568 msg->x,
569 msg->y,
570 msg->pixels,
573 msg->width,
574 msg->height,
575 data->bytesperrow,
576 msg->modulo);
577 break;
579 case 2:
580 HIDD_BM_CopyMemBox16(o,
581 data->buffer,
582 msg->x,
583 msg->y,
584 msg->pixels,
587 msg->width,
588 msg->height,
589 data->bytesperrow,
590 msg->modulo);
591 break;
593 case 3:
594 HIDD_BM_CopyMemBox24(o,
595 data->buffer,
596 msg->x,
597 msg->y,
598 msg->pixels,
601 msg->width,
602 msg->height,
603 data->bytesperrow,
604 msg->modulo);
605 break;
607 case 4:
608 HIDD_BM_CopyMemBox32(o,
609 data->buffer,
610 msg->x,
611 msg->y,
612 msg->pixels,
615 msg->width,
616 msg->height,
617 data->bytesperrow,
618 msg->modulo);
619 break;
621 } /* switch(data->bytesperpix) */
622 break;
624 case vHidd_StdPixFmt_Native32:
625 switch(data->bytesperpixel)
627 case 1:
628 HIDD_BM_GetMem32Image8(o,
629 data->buffer,
630 msg->x,
631 msg->y,
632 msg->pixels,
633 msg->width,
634 msg->height,
635 data->bytesperrow,
636 msg->modulo);
637 break;
639 case 2:
640 HIDD_BM_GetMem32Image16(o,
641 data->buffer,
642 msg->x,
643 msg->y,
644 msg->pixels,
645 msg->width,
646 msg->height,
647 data->bytesperrow,
648 msg->modulo);
649 break;
651 case 3:
652 HIDD_BM_GetMem32Image24(o,
653 data->buffer,
654 msg->x,
655 msg->y,
656 msg->pixels,
657 msg->width,
658 msg->height,
659 data->bytesperrow,
660 msg->modulo);
661 break;
663 case 4:
664 HIDD_BM_CopyMemBox32(o,
665 data->buffer,
666 msg->x,
667 msg->y,
668 msg->pixels,
671 msg->width,
672 msg->height,
673 data->bytesperrow,
674 msg->modulo);
675 break;
677 } /* switch(data->bytesperpixel) */
678 break;
680 default:
681 src_pixels = data->buffer + msg->y * data->bytesperrow
682 + msg->x * data->bytesperpixel;
683 dst_pixels = msg->pixels;
684 dstpf = HIDD_Gfx_GetPixFmt(data->gfxhidd, msg->pixFmt);
686 HIDD_BM_ConvertPixels(o, &src_pixels, BM_PIXFMT(o),
687 data->bytesperrow, &dst_pixels, (HIDDT_PixelFormat *)dstpf,
688 msg->modulo, msg->width, msg->height, NULL);
690 } /* switch(msg->pixFmt) */
694 /****************************************************************************************/
696 VOID CBM__Hidd_BitMap__PutImageLUT(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_PutImageLUT *msg)
698 struct chunkybm_data *data = OOP_INST_DATA(cl, o);
700 switch(data->bytesperpixel)
702 case 2:
703 HIDD_BM_CopyLUTMemBox16(o,
704 msg->pixels,
707 data->buffer,
708 msg->x,
709 msg->y,
710 msg->width,
711 msg->height,
712 msg->modulo,
713 data->bytesperrow,
714 msg->pixlut);
715 break;
717 case 3:
718 HIDD_BM_CopyLUTMemBox24(o,
719 msg->pixels,
722 data->buffer,
723 msg->x,
724 msg->y,
725 msg->width,
726 msg->height,
727 msg->modulo,
728 data->bytesperrow,
729 msg->pixlut);
730 break;
732 case 4:
733 HIDD_BM_CopyLUTMemBox32(o,
734 msg->pixels,
737 data->buffer,
738 msg->x,
739 msg->y,
740 msg->width,
741 msg->height,
742 msg->modulo,
743 data->bytesperrow,
744 msg->pixlut);
745 break;
747 default:
748 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
750 } /* switch(data->bytesperpixel) */
754 /****************************************************************************************/
756 VOID CBM__Hidd_BitMap__PutTemplate(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_PutTemplate *msg)
758 struct chunkybm_data *data = OOP_INST_DATA(cl, o);
760 switch(data->bytesperpixel)
762 case 1:
763 HIDD_BM_PutMemTemplate8(o,
764 msg->gc,
765 msg->masktemplate,
766 msg->modulo,
767 msg->srcx,
768 data->buffer,
769 data->bytesperrow,
770 msg->x,
771 msg->y,
772 msg->width,
773 msg->height,
774 msg->inverttemplate);
775 break;
777 case 2:
778 HIDD_BM_PutMemTemplate16(o,
779 msg->gc,
780 msg->masktemplate,
781 msg->modulo,
782 msg->srcx,
783 data->buffer,
784 data->bytesperrow,
785 msg->x,
786 msg->y,
787 msg->width,
788 msg->height,
789 msg->inverttemplate);
790 break;
792 case 3:
793 HIDD_BM_PutMemTemplate24(o,
794 msg->gc,
795 msg->masktemplate,
796 msg->modulo,
797 msg->srcx,
798 data->buffer,
799 data->bytesperrow,
800 msg->x,
801 msg->y,
802 msg->width,
803 msg->height,
804 msg->inverttemplate);
805 break;
807 case 4:
808 HIDD_BM_PutMemTemplate32(o,
809 msg->gc,
810 msg->masktemplate,
811 msg->modulo,
812 msg->srcx,
813 data->buffer,
814 data->bytesperrow,
815 msg->x,
816 msg->y,
817 msg->width,
818 msg->height,
819 msg->inverttemplate);
820 break;
822 default:
823 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
824 break;
826 } /* switch(data->bytesperpixel) */
830 /****************************************************************************************/
832 VOID CBM__Hidd_BitMap__PutPattern(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_PutPattern *msg)
834 struct chunkybm_data *data = OOP_INST_DATA(cl, o);
836 switch(data->bytesperpixel)
838 case 1:
839 HIDD_BM_PutMemPattern8(o,
840 msg->gc,
841 msg->pattern,
842 msg->patternsrcx,
843 msg->patternsrcy,
844 msg->patternheight,
845 msg->patterndepth,
846 msg->patternlut,
847 msg->invertpattern,
848 msg->mask,
849 msg->maskmodulo,
850 msg->masksrcx,
851 data->buffer,
852 data->bytesperrow,
853 msg->x,
854 msg->y,
855 msg->width,
856 msg->height);
857 break;
859 case 2:
860 HIDD_BM_PutMemPattern16(o,
861 msg->gc,
862 msg->pattern,
863 msg->patternsrcx,
864 msg->patternsrcy,
865 msg->patternheight,
866 msg->patterndepth,
867 msg->patternlut,
868 msg->invertpattern,
869 msg->mask,
870 msg->maskmodulo,
871 msg->masksrcx,
872 data->buffer,
873 data->bytesperrow,
874 msg->x,
875 msg->y,
876 msg->width,
877 msg->height);
878 break;
880 case 3:
881 HIDD_BM_PutMemPattern24(o,
882 msg->gc,
883 msg->pattern,
884 msg->patternsrcx,
885 msg->patternsrcy,
886 msg->patternheight,
887 msg->patterndepth,
888 msg->patternlut,
889 msg->invertpattern,
890 msg->mask,
891 msg->maskmodulo,
892 msg->masksrcx,
893 data->buffer,
894 data->bytesperrow,
895 msg->x,
896 msg->y,
897 msg->width,
898 msg->height);
899 break;
901 case 4:
902 HIDD_BM_PutMemPattern32(o,
903 msg->gc,
904 msg->pattern,
905 msg->patternsrcx,
906 msg->patternsrcy,
907 msg->patternheight,
908 msg->patterndepth,
909 msg->patternlut,
910 msg->invertpattern,
911 msg->mask,
912 msg->maskmodulo,
913 msg->masksrcx,
914 data->buffer,
915 data->bytesperrow,
916 msg->x,
917 msg->y,
918 msg->width,
919 msg->height);
920 break;
922 default:
923 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
924 break;
926 } /* switch(data->bytesperpixel) */
930 /****************************************************************************************/
932 BOOL CBM__Hidd_BitMap__ObtainDirectAccess(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_ObtainDirectAccess *msg)
934 struct Library *OOPBase = CSD(cl)->cs_OOPBase;
935 struct chunkybm_data *data = OOP_INST_DATA(cl, o);
937 IPTR width, height;
939 OOP_GetAttr(o, aHidd_BitMap_Width, &width);
940 OOP_GetAttr(o, aHidd_BitMap_Height, &height);
942 *msg->addressReturn = data->buffer;
943 *msg->widthReturn = width;
944 *msg->heightReturn = height;
945 *msg->bankSizeReturn = *msg->memSizeReturn = data->bytesperrow * height;
947 return TRUE;
950 /****************************************************************************************/
952 VOID CBM__Hidd_BitMap__ReleaseDirectAccess(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_ReleaseDirectAccess *msg)
956 /****************************************************************************************/
958 VOID CBM__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
960 struct chunkybm_data *data = OOP_INST_DATA(cl, o);
961 ULONG idx;
963 EnterFunc(bug("BitMap::Get() attrID: %i storage: %p\n", msg->attrID, msg->storage));
965 if (IS_CHUNKYBM_ATTR(msg->attrID, idx))
967 switch (idx)
969 case aoHidd_ChunkyBM_Buffer:
970 *msg->storage = (IPTR)data->buffer;
971 return;
975 OOP_DoSuperMethod(cl, o, &msg->mID);
978 /****************************************************************************************/
980 VOID CBM__Root__Set(OOP_Class *cl, OOP_Object *o, struct pRoot_Set *msg)
982 struct Library *UtilityBase = CSD(cl)->cs_UtilityBase;
983 struct chunkybm_data *data = OOP_INST_DATA(cl, o);
984 struct TagItem *tag, *tstate;
985 ULONG idx;
987 tstate = msg->attrList;
988 while((tag = NextTagItem(&tstate)))
990 if(IS_CHUNKYBM_ATTR(tag->ti_Tag, idx))
992 switch(idx)
994 case aoHidd_ChunkyBM_Buffer:
995 if (data->own_buffer)
997 FreeVec(data->buffer);
998 data->own_buffer = FALSE;
1000 data->buffer = (UBYTE *)tag->ti_Data;
1001 D(bug("[CBM] New buffer now 0x%p\n", data->buffer));
1002 break;
1007 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);