blob: 055015796b6fe3d9fced3238aca914e8324b65e7 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26#if !defined(JAVA2D_NO_MLIB) || defined(MLIB_ADD_SUFF)
27
28#include <vis_proto.h>
29#include "java2d_Mlib.h"
30
31/***************************************************************/
32
33#define SET_PIX(index, chan) \
34 pPix[chan] = pix##chan
35
36#define XOR_PIX(index, chan) \
37 pPix[chan] ^= pix##chan
38
39/***************************************************************/
40
41#define EXTRA_1(FUNC, ANYTYPE, NCHAN, DO_PIX)
42#define EXTRA_3(FUNC, ANYTYPE, NCHAN, DO_PIX)
43#define EXTRA_4(FUNC, ANYTYPE, NCHAN, DO_PIX) \
44 if ((((jint)pPix | scan) & 3) == 0) { \
45 mlib_s32 s_pixel = pixel, r_pixel; \
46 *(mlib_f32*)&r_pixel = vis_ldfa_ASI_PL(&s_pixel); \
47 ADD_SUFF(AnyInt##FUNC)(pRasInfo, x1, y1, r_pixel, steps, error, \
48 bumpmajormask, errmajor, bumpminormask, \
49 errminor, pPrim, pCompInfo); \
50 return; \
51 }
52
53/***************************************************************/
54
55#define GET_PIXEL(pix) \
56 mlib_s32 pix = pixel
57
58/***************************************************************/
59
60#define DEFINE_SET_LINE(FUNC, ANYTYPE, NCHAN, DO_PIX) \
61void ADD_SUFF(ANYTYPE##FUNC)(SurfaceDataRasInfo * pRasInfo, \
62 jint x1, \
63 jint y1, \
64 jint pixel, \
65 jint steps, \
66 jint error, \
67 jint bumpmajormask, \
68 jint errmajor, \
69 jint bumpminormask, \
70 jint errminor, \
71 NativePrimitive * pPrim, \
72 CompositeInfo * pCompInfo) \
73{ \
74 ANYTYPE##DataType *pPix = (void *)(pRasInfo->rasBase); \
75 mlib_s32 scan = pRasInfo->scanStride; \
76 mlib_s32 bumpmajor, bumpminor, mask; \
77 GET_PIXEL(pix); \
78 EXTRACT_CONST_##NCHAN(pix); \
79 \
80 EXTRA_##NCHAN(FUNC, AnyInt, NCHAN, DO_PIX); \
81 \
82 PTR_ADD(pPix, y1 * scan + x1 * ANYTYPE##PixelStride); \
83 \
84 errminor += errmajor; \
85 \
86 if (bumpmajormask & 0x1) bumpmajor = ANYTYPE##PixelStride; else \
87 if (bumpmajormask & 0x2) bumpmajor = -ANYTYPE##PixelStride; else \
88 if (bumpmajormask & 0x4) bumpmajor = scan; else \
89 bumpmajor = - scan; \
90 \
91 if (bumpminormask & 0x1) bumpminor = ANYTYPE##PixelStride; else \
92 if (bumpminormask & 0x2) bumpminor = -ANYTYPE##PixelStride; else \
93 if (bumpminormask & 0x4) bumpminor = scan; else \
94 if (bumpminormask & 0x8) bumpminor = -scan; else \
95 bumpminor = 0; \
96 \
97 if (errmajor == 0) { \
98 do { \
99 PROCESS_PIX_##NCHAN(DO_PIX); \
100 PTR_ADD(pPix, bumpmajor); \
101 } while (--steps > 0); \
102 return; \
103 } \
104 \
105 do { \
106 PROCESS_PIX_##NCHAN(DO_PIX); \
107 mask = error >> 31; \
108 PTR_ADD(pPix, bumpmajor + (bumpminor &~ mask)); \
109 error += errmajor - (errminor &~ mask); \
110 } while (--steps > 0); \
111}
112
113DEFINE_SET_LINE(SetLine, AnyInt, 1, SET_PIX)
114DEFINE_SET_LINE(SetLine, AnyShort, 1, SET_PIX)
115DEFINE_SET_LINE(SetLine, AnyByte, 1, SET_PIX)
116DEFINE_SET_LINE(SetLine, Any3Byte, 3, SET_PIX)
117DEFINE_SET_LINE(SetLine, Any4Byte, 4, SET_PIX)
118
119/***************************************************************/
120
121#undef GET_PIXEL
122#define GET_PIXEL(pix) \
123 mlib_s32 xorpixel = pCompInfo->details.xorPixel; \
124 mlib_s32 alphamask = pCompInfo->alphaMask; \
125 mlib_s32 pix = (pixel ^ xorpixel) &~ alphamask
126
127#undef EXTRA_4
128#define EXTRA_4(FUNC, ANYTYPE, NCHAN, DO_PIX)
129
130DEFINE_SET_LINE(XorLine, AnyInt, 1, XOR_PIX)
131DEFINE_SET_LINE(XorLine, AnyShort, 1, XOR_PIX)
132DEFINE_SET_LINE(XorLine, AnyByte, 1, XOR_PIX)
133DEFINE_SET_LINE(XorLine, Any3Byte, 3, XOR_PIX)
134DEFINE_SET_LINE(XorLine, Any4Byte, 4, XOR_PIX)
135
136/***************************************************************/
137
138#endif