1 | /* |
2 | * Copyright (c) 2001, 2016, 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 IntArgbBm_h_Included |
27 | #define IntArgbBm_h_Included |
28 | |
29 | #include "IntDcm.h" |
30 | #include "ByteGray.h" |
31 | #include "UshortGray.h" |
32 | |
33 | /* |
34 | * This file contains macro and type definitions used by the macros in |
35 | * LoopMacros.h to manipulate a surface of type "IntArgbBm". |
36 | */ |
37 | |
38 | typedef jint IntArgbBmPixelType; |
39 | typedef jint IntArgbBmDataType; |
40 | |
41 | #define IntArgbBmIsOpaque 0 |
42 | |
43 | #define IntArgbBmPixelStride 4 |
44 | |
45 | #define DeclareIntArgbBmLoadVars(PREFIX) |
46 | #define DeclareIntArgbBmStoreVars(PREFIX) |
47 | #define InitIntArgbBmLoadVars(PREFIX, pRasInfo) |
48 | #define SetIntArgbBmStoreVarsYPos(PREFIX, pRasInfo, y) |
49 | #define SetIntArgbBmStoreVarsXPos(PREFIX, pRasInfo, x) |
50 | #define InitIntArgbBmStoreVarsY(PREFIX, pRasInfo) |
51 | #define InitIntArgbBmStoreVarsX(PREFIX, pRasInfo) |
52 | #define NextIntArgbBmStoreVarsX(PREFIX) |
53 | #define NextIntArgbBmStoreVarsY(PREFIX) |
54 | #define DeclareIntArgbBmInitialLoadVars(pRasInfo, pRas, PREFIX, x) |
55 | #define InitialLoadIntArgbBm(pRas, PREFIX) |
56 | #define ShiftBitsIntArgbBm(PREFIX) |
57 | #define FinalStoreIntArgbBm(pRas, PREFIX) |
58 | |
59 | #define IntArgbBmXparLutEntry 0 |
60 | #define IntArgbBmIsXparLutEntry(pix) (pix == 0) |
61 | #define StoreIntArgbBmNonXparFromArgb(pRas, PREFIX, x, argb) \ |
62 | StoreIntArgbBmFrom1IntArgb(pRas, PREFIX, x, argb) |
63 | |
64 | #define DeclareIntArgbBmData(PREFIX) \ |
65 | jint PREFIX; |
66 | |
67 | #define LoadIntArgbBmData(pRas, LOADPREFIX, x, DATAPREFIX) \ |
68 | (DATAPREFIX) = (pRas)[x] |
69 | |
70 | #define IsIntArgbBmDataTransparent(DATAPREFIX) \ |
71 | (((DATAPREFIX) >> 24) == 0) |
72 | |
73 | #define ConvertIntArgbBmDataTo1IntRgb(DATAPREFIX, rgb) \ |
74 | (rgb) = (DATAPREFIX) |
75 | |
76 | #define IntArgbBmPixelFromArgb(pixel, rgb, pRasInfo) \ |
77 | (pixel) = ((rgb) | (((rgb) >> 31) << 24)) |
78 | |
79 | #define StoreIntArgbBmPixel(pRas, x, pixel) \ |
80 | (pRas)[x] = (pixel) |
81 | |
82 | #define DeclareIntArgbBmPixelData(PREFIX) |
83 | |
84 | #define (PIXEL, PREFIX) |
85 | |
86 | #define StoreIntArgbBmPixelData(pPix, x, pixel, PREFIX) \ |
87 | (pPix)[x] = (pixel) |
88 | |
89 | |
90 | #define LoadIntArgbBmTo1IntRgb(pRas, PREFIX, x, rgb) \ |
91 | (rgb) = (pRas)[x] |
92 | |
93 | #define LoadIntArgbBmTo1IntArgb(pRas, PREFIX, x, argb) \ |
94 | do { \ |
95 | (argb) = (pRas)[x]; \ |
96 | (argb) = (((argb) << 7) >> 7); \ |
97 | } while (0) |
98 | |
99 | #define LoadIntArgbBmTo3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
100 | do { \ |
101 | jint pixel = (pRas)[x]; \ |
102 | ExtractIntDcmComponentsX123(pixel, r, g, b); \ |
103 | } while (0) |
104 | |
105 | #define LoadIntArgbBmTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
106 | do { \ |
107 | jint pixel = (pRas)[x]; \ |
108 | pixel = ((pixel << 7) >> 7); \ |
109 | ExtractIntDcmComponents1234(pixel, a, r, g, b); \ |
110 | } while (0) |
111 | |
112 | #define StoreIntArgbBmFrom1IntRgb(pRas, PREFIX, x, rgb) \ |
113 | (pRas)[x] = 0x01000000 | (rgb) |
114 | |
115 | #define StoreIntArgbBmFrom1IntArgb(pRas, PREFIX, x, argb) \ |
116 | (pRas)[x] = ((argb) | (((argb) >> 31) << 24)) |
117 | |
118 | #define StoreIntArgbBmFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
119 | StoreIntArgbBmFrom4ByteArgb(pRas, PREFIX, x, 0x01, r, g, b) |
120 | |
121 | #define StoreIntArgbBmFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
122 | (pRas)[x] = ComposeIntDcmComponents1234((a >> 7), r, g, b) |
123 | |
124 | #define CopyIntArgbBmToIntArgbPre(pRGB, i, PREFIX, pRow, x) \ |
125 | do { \ |
126 | jint argb = (pRow)[x]; \ |
127 | argb = ((argb << 7) >> 7); /* Propagate alpha bit */ \ |
128 | argb &= (argb >> 24); /* Mask off colors if alpha=0 */ \ |
129 | (pRGB)[i] = argb; \ |
130 | } while (0) |
131 | |
132 | |
133 | #define DeclareIntArgbBmAlphaLoadData(PREFIX) \ |
134 | jint PREFIX; |
135 | |
136 | #define InitIntArgbBmAlphaLoadData(PREFIX, pRasInfo) \ |
137 | PREFIX = 0 |
138 | |
139 | #define LoadAlphaFromIntArgbBmFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \ |
140 | do { \ |
141 | PREFIX = (pRas)[0]; \ |
142 | PREFIX = ((PREFIX << 7) >> 7); \ |
143 | COMP_PREFIX ## A = ((juint) PREFIX) >> 24; \ |
144 | } while (0) |
145 | |
146 | #define LoadAlphaFromIntArgbBmFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \ |
147 | LoadAlphaFromIntArgbBmFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) |
148 | |
149 | #define LoadAlphaFromIntArgbBmFor1ShortGray(pRas, PREFIX, COMP_PREFIX) \ |
150 | do { \ |
151 | LoadAlphaFromIntArgbBmFor4ByteArgb(pRas, PREFIX, COMP_PREFIX); \ |
152 | COMP_PREFIX ## A = (COMP_PREFIX ## A << 8) + COMP_PREFIX ## A; \ |
153 | } while (0) |
154 | |
155 | #define Postload4ByteArgbFromIntArgbBm(pRas, PREFIX, COMP_PREFIX) \ |
156 | do { \ |
157 | COMP_PREFIX ## R = (PREFIX >> 16) & 0xff; \ |
158 | COMP_PREFIX ## G = (PREFIX >> 8) & 0xff; \ |
159 | COMP_PREFIX ## B = (PREFIX >> 0) & 0xff; \ |
160 | } while (0) |
161 | |
162 | #define Postload1ByteGrayFromIntArgb(pRas, PREFIX, COMP_PREFIX) \ |
163 | do { \ |
164 | int r, g, b; \ |
165 | ExtractIntDcmComponentsX123(PREFIX, r, g, b); \ |
166 | COMP_PREFIX ## G = ComposeByteGrayFrom3ByteRgb(r, g, b); \ |
167 | } while (0) |
168 | |
169 | #define Postload1ShortGrayFromIntArgb(pRas, PREFIX, COMP_PREFIX) \ |
170 | do { \ |
171 | int r, g, b; \ |
172 | ExtractIntDcmComponentsX123(PREFIX, r, g, b); \ |
173 | COMP_PREFIX ## G = ComposeUshortGrayFrom3ByteRgb(r, g, b); \ |
174 | } while (0) |
175 | |
176 | |
177 | #define IntArgbBmIsPremultiplied 0 |
178 | |
179 | #define StoreIntArgbBmFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \ |
180 | StoreIntArgbBmFrom4ByteArgb(pRas, PREFIX, x, \ |
181 | COMP_PREFIX ## A, COMP_PREFIX ## R, \ |
182 | COMP_PREFIX ## G, COMP_PREFIX ## B) |
183 | |
184 | /* |
185 | * Extract ## STRATEGY ## CompsAndAlphaFromArgb(pixel, COMP_PREFIX) |
186 | */ |
187 | #define Extract3ByteRgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ |
188 | ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, COMP_PREFIX ## R, \ |
189 | COMP_PREFIX ## G, COMP_PREFIX ## B) |
190 | |
191 | #define Extract4ByteArgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ |
192 | Extract3ByteRgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX) |
193 | |
194 | #define Extract1ByteGrayCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ |
195 | do { \ |
196 | int r, g, b; \ |
197 | ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, r, g, b); \ |
198 | COMP_PREFIX ## G = ComposeByteGrayFrom3ByteRgb(r, g, b); \ |
199 | } while (0) |
200 | |
201 | #define Extract1ShortGrayCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ |
202 | do { \ |
203 | int r, g, b; \ |
204 | ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, r, g, b); \ |
205 | COMP_PREFIX ## G = ComposeUshortGrayFrom3ByteRgb(r, g, b); \ |
206 | COMP_PREFIX ## A = (COMP_PREFIX ## A << 8) + COMP_PREFIX ## A; \ |
207 | } while (0) |
208 | |
209 | /* |
210 | * SrcOver ## TYPE ## BlendFactor |
211 | * Returns appropriate blend value for use in blending calculations. |
212 | */ |
213 | #define SrcOverIntArgbBmBlendFactor(dF, dA) \ |
214 | (dA) |
215 | |
216 | #endif /* IntArgbBm_h_Included */ |
217 | |