2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
9 #include <aros/debug.h>
10 #include <hidd/graphics.h>
11 #include <proto/cybergraphics.h>
13 #include "cybergraphics_intern.h"
14 #include "gfxfuncsupport.h"
19 HIDDT_StdPixFmt pixfmt
;
24 static ULONG
RenderHook(struct render_data
*data
, LONG srcx
, LONG srcy
,
25 OOP_Object
*dstbm_obj
, OOP_Object
*dst_gc
, struct Rectangle
*rect
,
26 struct GfxBase
*GfxBase
);
28 /*****************************************************************************
31 #include <proto/cybergraphics.h>
33 AROS_LH10(ULONG
, WritePixelArray
,
36 AROS_LHA(APTR
, src
, A0
),
37 AROS_LHA(UWORD
, srcx
, D0
),
38 AROS_LHA(UWORD
, srcy
, D1
),
39 AROS_LHA(UWORD
, srcmod
, D2
),
40 AROS_LHA(struct RastPort
*, rp
, A1
),
41 AROS_LHA(UWORD
, destx
, D3
),
42 AROS_LHA(UWORD
, desty
, D4
),
43 AROS_LHA(UWORD
, width
, D5
),
44 AROS_LHA(UWORD
, height
, D6
),
45 AROS_LHA(UBYTE
, srcformat
, D7
),
48 struct Library
*, CyberGfxBase
, 21, Cybergraphics
)
51 Copies all or part of a rectangular block of raw pixel values to a
55 srcRect - pointer to the pixel values.
56 srcx, srcy - top-lefthand corner of portion of source rectangle to
58 srcmod - the number of bytes in each row of the source rectangle.
59 rp - the RastPort to write to.
60 destx, desty - top-lefthand corner of portion of destination RastPort
61 to write to (in pixels).
62 width, height - size of the area to copy (in pixels).
63 srcformat - the format of the source pixels. The following format
65 RECTFMT_RGB - 3 bytes per pixel: 1 byte per component, in
66 the order red, green, blue.
67 RECTFMT_RGBA - 4 bytes per pixel: 1 byte per component, in
68 the order red, green, blue, alpha.
69 RECTFMT_ARGB - 4 bytes per pixel: 1 byte per component, in
70 the order alpha, red, green, blue.
71 RECTFMT_LUT8 - 1 byte per pixel: each byte is a pen number
72 rather than a direct colour value.
73 RECTFMT_GREY8 - 1 byte per pixel: each byte is a greyscale
75 RECTFMT_RAW - the same pixel format as the destination
77 RECTFMT_RGB15 - 2 bytes per pixel: one unused bit, then 5 bits
78 per component, in the order red, green, blue (AROS
80 RECTFMT_BGR15 - 2 bytes per pixel: 1 unused bit, then 5 bits
81 per component, in the order blue, green, red (AROS
83 RECTFMT_RGB15PC - 2 bytes per pixel, accessed as a little
84 endian value: 1 unused bit, then 5 bits per component, in
85 the order red, green, blue (AROS extension).
86 RECTFMT_BGR15PC - 2 bytes per pixel, accessed as a little
87 endian value: 1 unused bit, then 5 bits per component, in
88 the order blue, green, red (AROS extension).
89 RECTFMT_RGB16 - 2 bytes per pixel: 5 bits for red, then 6 bits
90 for green, then 5 bits for blue (AROS extension).
91 RECTFMT_BGR16 - 2 bytes per pixel: 5 bits for blue, then 6 bits
92 for green, then 5 bits for red (AROS extension).
93 RECTFMT_RGB16PC - 2 bytes per pixel, accessed as a little
94 endian value: 5 bits for red, then 6 bits for green, then
95 5 bits for blue (AROS extension).
96 RECTFMT_BGR16PC - 2 bytes per pixel, accessed as a little
97 endian value: 5 bits for blue, then 6 bits for green, then
98 5 bits for red (AROS extension).
99 RECTFMT_RGB24 - the same as RECTFMT_RGB (AROS extension).
100 RECTFMT_BGR24 - 3 bytes per pixel: 1 byte per component, in
101 the order blue, green, red (AROS extension).
102 RECTFMT_ARGB32 - the same as RECTFMT_ARGB (AROS extension).
103 RECTFMT_BGRA32 - 4 bytes per pixel: 1 byte per component, in
104 the order blue, green, red, alpha (AROS extension).
105 RECTFMT_RGBA32 - the same as RECTFMT_RGBA (AROS extension).
106 RECTFMT_ABGR32 - 4 bytes per pixel: 1 byte per component, in
107 the order alpha, blue, green, red (AROS extension).
108 RECTFMT_0RGB32 - 4 bytes per pixel: 1 unused byte, then 1 byte
109 per component, in the order red, green, blue (AROS
111 RECTFMT_BGR032 - 4 bytes per pixel: 1 byte per component, in
112 the order blue, green, red, followed by 1 unused byte
114 RECTFMT_RGB032 - 4 bytes per pixel: 1 byte per component, in
115 the order red, green, blue, followed by 1 unused byte
117 RECTFMT_0BGR32 - 4 bytes per pixel: 1 unused byte, then 1 byte
118 per component, in the order blue, green, red (AROS
122 count - the number of pixels written to.
125 Because of the X11 driver you have to set the drawmode
126 to JAM1 with SetDrMd().
133 WritePixelArrayAlpha(), graphics.library/SetDrMd()
137 *****************************************************************************/
143 struct render_data data
;
146 if ((!width
) || (!height
))
149 if (RECTFMT_GREY8
== srcformat
)
151 /* This just uses our builtin palette */
152 return WriteLUTPixelArray(src
, srcx
, srcy
, srcmod
,
153 rp
, GetCGFXBase(CyberGfxBase
)->greytab
,
154 destx
, desty
, width
, height
, CTABFMT_XRGB8
);
157 /* This is cybergraphx. We only work wih HIDD bitmaps */
158 if (!IS_HIDD_BM(rp
->BitMap
))
160 D(bug("!!!!! Trying to use CGFX call on non-hidd bitmap in WritePixelArray() !!!\n"));
164 if (RECTFMT_LUT8
== srcformat
)
166 /* Actually this is the same as WriteChunkyPixels() with return value */
167 return WritePixels8(rp
, src
, srcmod
,
169 destx
+ width
- 1, desty
+ height
- 1,
173 bppix
= GetRectFmtBytesPerPixel(srcformat
, rp
, CyberGfxBase
);
174 start_offset
= ((ULONG
)srcy
) * srcmod
+ srcx
* bppix
;
175 data
.array
= ((UBYTE
*)src
) + start_offset
;
176 data
.pixfmt
= GetHIDDRectFmt(srcformat
, rp
, CyberGfxBase
);
177 data
.modulo
= srcmod
;
182 rr
.MaxX
= destx
+ width
- 1;
183 rr
.MaxY
= desty
+ height
- 1;
185 return DoRenderFunc(rp
, NULL
, &rr
, RenderHook
, &data
, TRUE
);
188 } /* WritePixelArray */
190 static ULONG
RenderHook(struct render_data
*data
, LONG srcx
, LONG srcy
,
191 OOP_Object
*dstbm_obj
, OOP_Object
*dst_gc
, struct Rectangle
*rect
,
192 struct GfxBase
*GfxBase
)
194 ULONG width
= rect
->MaxX
- rect
->MinX
+ 1;
195 ULONG height
= rect
->MaxY
- rect
->MinY
+ 1;
196 UBYTE
*array
= data
->array
+ data
->modulo
* srcy
+ data
->bppix
* srcx
;
198 HIDD_BM_PutImage(dstbm_obj
, dst_gc
, array
, data
->modulo
,
199 rect
->MinX
, rect
->MinY
, width
, height
, data
->pixfmt
);
201 return width
* height
;