|
1 /* |
|
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. 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. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 #ifndef IntArgbPre_h_Included |
|
27 #define IntArgbPre_h_Included |
|
28 |
|
29 #include "IntDcm.h" |
|
30 |
|
31 /* |
|
32 * This file contains macro and type definitions used by the macros in |
|
33 * LoopMacros.h to manipulate a surface of type "IntArgbPre". |
|
34 */ |
|
35 |
|
36 typedef jint IntArgbPrePixelType; |
|
37 typedef jint IntArgbPreDataType; |
|
38 |
|
39 #define IntArgbPreIsOpaque 0 |
|
40 |
|
41 #define IntArgbPrePixelStride 4 |
|
42 |
|
43 #define DeclareIntArgbPreLoadVars(PREFIX) |
|
44 #define DeclareIntArgbPreStoreVars(PREFIX) |
|
45 #define InitIntArgbPreLoadVars(PREFIX, pRasInfo) |
|
46 #define SetIntArgbPreStoreVarsYPos(PREFIX, pRasInfo, y) |
|
47 #define SetIntArgbPreStoreVarsXPos(PREFIX, pRasInfo, x) |
|
48 #define InitIntArgbPreStoreVarsY(PREFIX, pRasInfo) |
|
49 #define InitIntArgbPreStoreVarsX(PREFIX, pRasInfo) |
|
50 #define NextIntArgbPreStoreVarsX(PREFIX) |
|
51 #define NextIntArgbPreStoreVarsY(PREFIX) |
|
52 |
|
53 |
|
54 #define IntArgbPrePixelFromArgb(pixel, rgb, pRasInfo) \ |
|
55 do { \ |
|
56 if ((((rgb) >> 24) + 1) == 0) { \ |
|
57 (pixel) = (rgb); \ |
|
58 } else { \ |
|
59 jint a, r, g, b; \ |
|
60 ExtractIntDcmComponents1234(rgb, a, r, g, b); \ |
|
61 r = MUL8(a, r); \ |
|
62 g = MUL8(a, g); \ |
|
63 b = MUL8(a, b); \ |
|
64 (pixel) = ComposeIntDcmComponents1234(a, r, g, b); \ |
|
65 } \ |
|
66 } while (0) |
|
67 |
|
68 #define StoreIntArgbPrePixel(pRas, x, pixel) \ |
|
69 (pRas)[x] = (pixel) |
|
70 |
|
71 #define DeclareIntArgbPrePixelData(PREFIX) |
|
72 |
|
73 #define ExtractIntArgbPrePixelData(PIXEL, PREFIX) |
|
74 |
|
75 #define StoreIntArgbPrePixelData(pPix, x, pixel, PREFIX) \ |
|
76 (pPix)[x] = (pixel) |
|
77 |
|
78 |
|
79 /* |
|
80 * REMIND: we delegate to the ...To1IntArgb macro here, although it does |
|
81 * slightly more work (may pack the alpha value into the RGB result) |
|
82 */ |
|
83 #define LoadIntArgbPreTo1IntRgb(pRas, PREFIX, x, rgb) \ |
|
84 LoadIntArgbPreTo1IntArgb(pRas, PREFIX, x, rgb) |
|
85 |
|
86 #define LoadIntArgbPreTo1IntArgb(pRas, PREFIX, x, argb) \ |
|
87 do { \ |
|
88 jint pixel = (pRas)[x]; \ |
|
89 jint a = ((juint) pixel) >> 24; \ |
|
90 if ((a == 0xff) || (a == 0)) { \ |
|
91 (argb) = pixel; \ |
|
92 } else { \ |
|
93 jint r, g, b; \ |
|
94 ExtractIntDcmComponentsX123(pixel, r, g, b); \ |
|
95 r = DIV8(r, a); \ |
|
96 g = DIV8(g, a); \ |
|
97 b = DIV8(b, a); \ |
|
98 (argb) = ComposeIntDcmComponents1234(a, r, g, b); \ |
|
99 } \ |
|
100 } while (0) |
|
101 |
|
102 #define LoadIntArgbPreTo3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
|
103 do { \ |
|
104 jint a; \ |
|
105 LoadIntArgbPreTo4ByteArgb(pRas, PREFIX, x, a, r, g, b); \ |
|
106 } while (0) |
|
107 |
|
108 #define LoadIntArgbPreTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
|
109 do { \ |
|
110 jint pixel = (pRas)[x]; \ |
|
111 ExtractIntDcmComponents1234(pixel, a, r, g, b); \ |
|
112 if (((a) != 0xff) && ((a) != 0)) { \ |
|
113 (r) = DIV8(r, a); \ |
|
114 (g) = DIV8(g, a); \ |
|
115 (b) = DIV8(b, a); \ |
|
116 } \ |
|
117 } while (0) |
|
118 |
|
119 #define StoreIntArgbPreFrom1IntRgb(pRas, PREFIX, x, rgb) \ |
|
120 (pRas)[x] = 0xff000000 | (rgb) |
|
121 |
|
122 #define StoreIntArgbPreFrom1IntArgb(pRas, PREFIX, x, argb) \ |
|
123 do { \ |
|
124 if ((((argb) >> 24) + 1) == 0) { \ |
|
125 (pRas)[x] = (argb); \ |
|
126 } else { \ |
|
127 jint a, r, g, b; \ |
|
128 ExtractIntDcmComponents1234(argb, a, r, g, b); \ |
|
129 r = MUL8(a, r); \ |
|
130 g = MUL8(a, g); \ |
|
131 b = MUL8(a, b); \ |
|
132 (pRas)[x] = ComposeIntDcmComponents1234(a, r, g, b); \ |
|
133 } \ |
|
134 } while (0) |
|
135 |
|
136 #define StoreIntArgbPreFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
|
137 (pRas)[x] = ComposeIntDcmComponents1234(0xff, r, g, b) |
|
138 |
|
139 #define StoreIntArgbPreFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
|
140 do { \ |
|
141 if ((a) != 0xff) { \ |
|
142 (r) = MUL8(a, r); \ |
|
143 (g) = MUL8(a, g); \ |
|
144 (b) = MUL8(a, b); \ |
|
145 } \ |
|
146 (pRas)[x] = ComposeIntDcmComponents1234(a, r, g, b); \ |
|
147 } while (0) |
|
148 |
|
149 #define CopyIntArgbPreToIntArgbPre(pRGB, i, PREFIX, pRow, x) \ |
|
150 (pRGB)[i] = (pRow)[x] |
|
151 |
|
152 |
|
153 #define DeclareIntArgbPreAlphaLoadData(PREFIX) \ |
|
154 jint PREFIX; |
|
155 |
|
156 #define InitIntArgbPreAlphaLoadData(PREFIX, pRasInfo) \ |
|
157 PREFIX = 0 |
|
158 |
|
159 #define LoadAlphaFromIntArgbPreFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \ |
|
160 do { \ |
|
161 PREFIX = (pRas)[0]; \ |
|
162 COMP_PREFIX ## A = ((juint) PREFIX) >> 24; \ |
|
163 } while (0) |
|
164 |
|
165 #define LoadAlphaFromIntArgbPreFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \ |
|
166 LoadAlphaFromIntArgbPreFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) |
|
167 |
|
168 #define LoadAlphaFromIntArgbPreFor1ShortGray(pRas, PREFIX, COMP_PREFIX) \ |
|
169 do { \ |
|
170 LoadAlphaFromIntArgbFor4ByteArgb(pRas, PREFIX, COMP_PREFIX); \ |
|
171 COMP_PREFIX ## A = (COMP_PREFIX ## A << 8) + COMP_PREFIX ## A; \ |
|
172 } while (0) |
|
173 |
|
174 #define Postload4ByteArgbFromIntArgbPre(pRas, PREFIX, COMP_PREFIX) \ |
|
175 do { \ |
|
176 ExtractIntDcmComponentsX123(PREFIX, COMP_PREFIX ## R, \ |
|
177 COMP_PREFIX ## G, COMP_PREFIX ## B); \ |
|
178 } while (0) |
|
179 |
|
180 #define Postload1ByteGrayFromIntArgbPre(pRas, PREFIX, COMP_PREFIX) \ |
|
181 do { \ |
|
182 int r, g, b; \ |
|
183 ExtractIntDcmComponentsX123(PREFIX, r, g, b); \ |
|
184 COMP_PREFIX ## G = ComposeByteGrayFrom3ByteRgb(r, g, b); \ |
|
185 } while (0) |
|
186 |
|
187 #define Postload1ShortGrayFromIntArgbPre(pRas, PREFIX, COMP_PREFIX) \ |
|
188 do { \ |
|
189 int r, g, b; \ |
|
190 ExtractIntDcmComponentsX123(PREFIX, r, g, b); \ |
|
191 COMP_PREFIX ## G = ComposeUshortGrayFrom3ByteRgb(r, g, b); \ |
|
192 } while (0) |
|
193 |
|
194 |
|
195 #define IntArgbPreIsPremultiplied 1 |
|
196 |
|
197 #define DeclareIntArgbPreBlendFillVars(PREFIX) |
|
198 |
|
199 #define ClearIntArgbPreBlendFillVars(PREFIX, argb) \ |
|
200 argb = 0 |
|
201 |
|
202 #define InitIntArgbPreBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) |
|
203 |
|
204 #define InitIntArgbPreBlendFillVarsPre(PREFIX, argb, COMP_PREFIX) \ |
|
205 argb = ComposeIntDcmComponents1234(COMP_PREFIX ## A, \ |
|
206 COMP_PREFIX ## R, \ |
|
207 COMP_PREFIX ## G, \ |
|
208 COMP_PREFIX ## B) |
|
209 |
|
210 #define StoreIntArgbPreBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \ |
|
211 (pRas)[x] = (argb) |
|
212 |
|
213 #define StoreIntArgbPreFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \ |
|
214 (pRas)[x] = ComposeIntDcmComponents1234(COMP_PREFIX ## A, \ |
|
215 COMP_PREFIX ## R, \ |
|
216 COMP_PREFIX ## G, \ |
|
217 COMP_PREFIX ## B) |
|
218 |
|
219 #endif /* IntArgbPre_h_Included */ |