blob: 8b4b9f7e59a6f3982a30be0f942d5176aeeb34ed [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000-2004 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#ifndef FourByteAbgrPre_h_Included
27#define FourByteAbgrPre_h_Included
28
29/*
30 * This file contains macro and type definitions used by the macros in
31 * LoopMacros.h to manipulate a surface of type "FourByteAbgrPre".
32 */
33
34typedef jint FourByteAbgrPrePixelType;
35typedef jubyte FourByteAbgrPreDataType;
36
37#define FourByteAbgrPrePixelStride 4
38
39#define DeclareFourByteAbgrPreLoadVars(PREFIX)
40#define DeclareFourByteAbgrPreStoreVars(PREFIX)
41#define SetFourByteAbgrPreStoreVarsYPos(PREFIX, pRasInfo, y)
42#define SetFourByteAbgrPreStoreVarsXPos(PREFIX, pRasInfo, x)
43#define InitFourByteAbgrPreLoadVars(PREFIX, pRasInfo)
44#define InitFourByteAbgrPreStoreVarsY(PREFIX, pRasInfo)
45#define InitFourByteAbgrPreStoreVarsX(PREFIX, pRasInfo)
46#define NextFourByteAbgrPreStoreVarsX(PREFIX)
47#define NextFourByteAbgrPreStoreVarsY(PREFIX)
48
49
50#define FourByteAbgrPrePixelFromArgb(pixel, rgb, pRasInfo) \
51 do { \
52 jint a, r, g, b; \
53 if (((rgb) >> 24) == -1) { \
54 (pixel) = (((rgb) << 8) | (((juint) (rgb)) >> 24)); \
55 } else { \
56 ExtractIntDcmComponents1234(rgb, a, r, g, b); \
57 r = MUL8(a, r); \
58 g = MUL8(a, g); \
59 b = MUL8(a, b); \
60 (pixel) = ComposeIntDcmComponents1234(r, g, b, a); \
61 } \
62 } while (0)
63
64#define StoreFourByteAbgrPrePixel(pRas, x, pixel) \
65 do { \
66 (pRas)[4*(x)+0] = (jubyte) ((pixel) >> 0); \
67 (pRas)[4*(x)+1] = (jubyte) ((pixel) >> 8); \
68 (pRas)[4*(x)+2] = (jubyte) ((pixel) >> 16); \
69 (pRas)[4*(x)+3] = (jubyte) ((pixel) >> 24); \
70 } while (0)
71
72#define DeclareFourByteAbgrPrePixelData(PREFIX) \
73 jubyte PREFIX ## 0, PREFIX ## 1, PREFIX ## 2, PREFIX ## 3;
74
75#define ExtractFourByteAbgrPrePixelData(PIXEL, PREFIX) \
76 do { \
77 PREFIX ## 0 = (jubyte) (PIXEL >> 0); \
78 PREFIX ## 1 = (jubyte) (PIXEL >> 8); \
79 PREFIX ## 2 = (jubyte) (PIXEL >> 16); \
80 PREFIX ## 3 = (jubyte) (PIXEL >> 24); \
81 } while (0)
82
83#define StoreFourByteAbgrPrePixelData(pPix, x, pixel, PREFIX) \
84 do { \
85 pPix[4*(x)+0] = PREFIX ## 0; \
86 pPix[4*(x)+1] = PREFIX ## 1; \
87 pPix[4*(x)+2] = PREFIX ## 2; \
88 pPix[4*(x)+3] = PREFIX ## 3; \
89 } while (0)
90
91
92#define LoadFourByteAbgrPreTo1IntRgb(pRas, PREFIX, x, rgb) \
93 LoadFourByteAbgrPreTo1IntArgb(pRas, PREFIX, x, rgb)
94
95#define LoadFourByteAbgrPreTo1IntArgb(pRas, PREFIX, x, argb) \
96 do { \
97 jint a = (pRas)[4*(x)+0]; \
98 if ((a == 0xff) || (a == 0)) { \
99 (argb) = (((pRas)[4*(x)+1] << 0) | \
100 ((pRas)[4*(x)+2] << 8) | \
101 ((pRas)[4*(x)+3] << 16) | \
102 (a << 24)); \
103 } else { \
104 jint r, g, b; \
105 b = DIV8((pRas)[4*(x)+1], a); \
106 g = DIV8((pRas)[4*(x)+2], a); \
107 r = DIV8((pRas)[4*(x)+3], a); \
108 (argb) = ComposeIntDcmComponents1234(a, r, g, b); \
109 } \
110 } while (0)
111
112#define LoadFourByteAbgrPreTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
113 do { \
114 jint a; \
115 LoadFourByteAbgrPreTo4ByteArgb(pRas, PREFIX, x, a, r, g, b); \
116 } while (0)
117
118#define LoadFourByteAbgrPreTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
119 do { \
120 (a) = (pRas)[4*(x)+0]; \
121 (b) = (pRas)[4*(x)+1]; \
122 (g) = (pRas)[4*(x)+2]; \
123 (r) = (pRas)[4*(x)+3]; \
124 if ((a != 0xff) && (a != 0)) { \
125 r = DIV8(r, a); \
126 g = DIV8(g, a); \
127 b = DIV8(b, a); \
128 } \
129 } while (0)
130
131#define StoreFourByteAbgrPreFrom1IntRgb(pRas, PREFIX, x, rgb) \
132 do { \
133 (pRas)[4*(x)+0] = (jubyte) 0xff; \
134 (pRas)[4*(x)+1] = (jubyte) ((rgb) >> 0); \
135 (pRas)[4*(x)+2] = (jubyte) ((rgb) >> 8); \
136 (pRas)[4*(x)+3] = (jubyte) ((rgb) >> 16); \
137 } while (0)
138
139#define StoreFourByteAbgrPreFrom1IntArgb(pRas, PREFIX, x, argb) \
140 do { \
141 if ((((argb) >> 24) + 1) == 0) { \
142 (pRas)[4*(x)+0] = (jubyte) ((argb) >> 24); \
143 (pRas)[4*(x)+1] = (jubyte) ((argb) >> 0); \
144 (pRas)[4*(x)+2] = (jubyte) ((argb) >> 8); \
145 (pRas)[4*(x)+3] = (jubyte) ((argb) >> 16); \
146 } else { \
147 jint a, r, g, b; \
148 ExtractIntDcmComponents1234(argb, a, r, g, b); \
149 (pRas)[4*(x)+0] = (jubyte) a; \
150 (pRas)[4*(x)+1] = MUL8(a, b); \
151 (pRas)[4*(x)+2] = MUL8(a, g); \
152 (pRas)[4*(x)+3] = MUL8(a, r); \
153 } \
154 } while (0)
155
156#define StoreFourByteAbgrPreFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
157 do { \
158 (pRas)[4*(x)+0] = (jubyte) 0xff; \
159 (pRas)[4*(x)+1] = (jubyte) (b); \
160 (pRas)[4*(x)+2] = (jubyte) (g); \
161 (pRas)[4*(x)+3] = (jubyte) (r); \
162 } while (0)
163
164#define StoreFourByteAbgrPreFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
165 do { \
166 if ((a) == 0xff) { \
167 StoreFourByteAbgrPreFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \
168 } else { \
169 (pRas)[4*(x)+0] = (jubyte) (a); \
170 (pRas)[4*(x)+1] = MUL8(a, b); \
171 (pRas)[4*(x)+2] = MUL8(a, g); \
172 (pRas)[4*(x)+3] = MUL8(a, r); \
173 } \
174 } while (0)
175
176#define CopyFourByteAbgrPreToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
177 (pRGB)[i] = (((pRow)[4*(x)+0] << 24) | \
178 ((pRow)[4*(x)+1] << 0) | \
179 ((pRow)[4*(x)+2] << 8) | \
180 ((pRow)[4*(x)+3] << 16))
181
182
183#define DeclareFourByteAbgrPreAlphaLoadData(PREFIX)
184#define InitFourByteAbgrPreAlphaLoadData(PREFIX, pRasInfo)
185
186#define LoadAlphaFromFourByteAbgrPreFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \
187 COMP_PREFIX ## A = (pRas)[0]
188
189#define Postload4ByteArgbFromFourByteAbgrPre(pRas, PREFIX, COMP_PREFIX) \
190 do { \
191 COMP_PREFIX ## B = (pRas)[1]; \
192 COMP_PREFIX ## G = (pRas)[2]; \
193 COMP_PREFIX ## R = (pRas)[3]; \
194 } while (0)
195
196
197#define FourByteAbgrPreIsPremultiplied 1
198
199#define DeclareFourByteAbgrPreBlendFillVars(PREFIX)
200
201#define ClearFourByteAbgrPreBlendFillVars(PREFIX, argb)
202
203#define InitFourByteAbgrPreBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX)
204
205#define InitFourByteAbgrPreBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)
206
207#define StoreFourByteAbgrPreBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \
208 StoreFourByteAbgrPreFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX)
209
210#define StoreFourByteAbgrPreFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX)\
211 do { \
212 (pRas)[4*(x)+0] = (jubyte) COMP_PREFIX ## A; \
213 (pRas)[4*(x)+1] = (jubyte) COMP_PREFIX ## B; \
214 (pRas)[4*(x)+2] = (jubyte) COMP_PREFIX ## G; \
215 (pRas)[4*(x)+3] = (jubyte) COMP_PREFIX ## R; \
216 } while (0)
217
218#endif /* FourByteAbgrPre_h_Included */