Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / cgfx / blttemplatealpha.c
blob1901c1d92328fd5ebe9b95cb7be5011753636774
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <hidd/graphics.h>
11 #include <proto/cybergraphics.h>
13 #include "cybergraphics_intern.h"
15 struct render_data
17 UBYTE *array;
18 ULONG modulo;
19 UBYTE invertalpha;
22 static ULONG RenderHook(struct render_data *data, LONG srcx, LONG srcy,
23 OOP_Object *dstbm_obj, OOP_Object *dst_gc, struct Rectangle *rect,
24 struct GfxBase *GfxBase);
26 /*****************************************************************************
28 NAME */
29 #include <proto/cybergraphics.h>
31 AROS_LH8(void, BltTemplateAlpha,
33 /* SYNOPSIS */
34 AROS_LHA(APTR , src , A0),
35 AROS_LHA(LONG , srcx , D0),
36 AROS_LHA(LONG , srcmod , D1),
37 AROS_LHA(struct RastPort *, rp , A1),
38 AROS_LHA(LONG , destx , D2),
39 AROS_LHA(LONG , desty , D3),
40 AROS_LHA(LONG , width , D4),
41 AROS_LHA(LONG , height , D5),
43 /* LOCATION */
44 struct Library *, CyberGfxBase, 37, Cybergraphics)
46 /* FUNCTION
47 Alpha blends the current foreground colour into a rectangular portion
48 of a RastPort. The source alpha channel to use for each pixel is taken
49 from an array of 8-bit alpha values. This alpha template may be any
50 rectangle within a larger array/rectangle of alpha values.
52 INPUTS
53 src - pointer to an array of source alpha values.
54 srcx - byte/pixel offset of top-lefthand corner of alpha template.
55 srcmod - the number of bytes in each row of the source array.
56 rp - the RastPort to write to.
57 destx, desty - top-lefthand corner of portion of destination RastPort
58 to write to (in pixels).
59 width, height - size of the area to copy (in pixels).
61 RESULT
62 None.
64 NOTES
65 The size and destination coordinates may be outside the RastPort
66 boundaries, in which case the affected area is safely truncated.
68 EXAMPLE
70 BUGS
72 SEE ALSO
74 INTERNALS
76 *****************************************************************************/
78 AROS_LIBFUNC_INIT
80 struct render_data data;
81 struct Rectangle rr;
83 if (width == 0 || height == 0)
84 return;
86 /* This is cybergraphx. We only work wih HIDD bitmaps */
87 if (!IS_HIDD_BM(rp->BitMap)) {
88 D(bug("!!!!! Trying to use CGFX call on non-hidd bitmap "
89 "in BltTemplateAlpha() !!!\n"));
90 return;
93 /* Compute the start of the array */
95 data.array = src + srcx;
96 data.modulo = srcmod;
97 data.invertalpha = (rp->DrawMode & INVERSVID) ? TRUE : FALSE;
98 rr.MinX = destx;
99 rr.MinY = desty;
100 rr.MaxX = destx + width - 1;
101 rr.MaxY = desty + height - 1;
103 DoRenderFunc(rp, NULL, &rr, RenderHook, &data, TRUE);
105 AROS_LIBFUNC_EXIT
106 } /* BltTemplateAlpha */
108 static ULONG RenderHook(struct render_data *data, LONG srcx, LONG srcy,
109 OOP_Object *dstbm_obj, OOP_Object *dst_gc, struct Rectangle *rect,
110 struct GfxBase *GfxBase)
112 ULONG width = rect->MaxX - rect->MinX + 1;
113 ULONG height = rect->MaxY - rect->MinY + 1;
114 UBYTE *array = data->array + data->modulo * srcy + srcx;
116 HIDD_BM_PutAlphaTemplate(dstbm_obj, dst_gc, array, data->modulo,
117 rect->MinX, rect->MinY, width, height, data->invertalpha);
119 return width * height;