blob: 26aa69a9369dfa7a3c3dd6e40fde676b8c3653c7 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000-2005 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 IntArgb_h_Included
27#define IntArgb_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 "IntArgb".
36 */
37
38typedef jint IntArgbPixelType;
39typedef jint IntArgbDataType;
40
41#define IntArgbPixelStride 4
42
43#define DeclareIntArgbLoadVars(PREFIX)
44#define DeclareIntArgbStoreVars(PREFIX)
45#define InitIntArgbLoadVars(PREFIX, pRasInfo)
46#define SetIntArgbStoreVarsYPos(PREFIX, pRasInfo, y)
47#define SetIntArgbStoreVarsXPos(PREFIX, pRasInfo, x)
48#define InitIntArgbStoreVarsY(PREFIX, pRasInfo)
49#define InitIntArgbStoreVarsX(PREFIX, pRasInfo)
50#define NextIntArgbStoreVarsX(PREFIX)
51#define NextIntArgbStoreVarsY(PREFIX)
52#define DeclareIntArgbInitialLoadVars(pRasInfo, pRas, PREFIX, x)
53#define InitialLoadIntArgb(pRas, PREFIX)
54#define ShiftBitsIntArgb(PREFIX)
55#define FinalStoreIntArgb(pRas, PREFIX)
56
57#define IntArgbPixelFromArgb(pixel, rgb, pRasInfo) \
58 (pixel) = (rgb)
59
60#define StoreIntArgbPixel(pRas, x, pixel) \
61 (pRas)[x] = (pixel)
62
63#define DeclareIntArgbPixelData(PREFIX)
64
65#define ExtractIntArgbPixelData(PIXEL, PREFIX)
66
67#define StoreIntArgbPixelData(pPix, x, pixel, PREFIX) \
68 (pPix)[x] = (pixel)
69
70
71#define LoadIntArgbTo1IntRgb(pRas, PREFIX, x, rgb) \
72 (rgb) = (pRas)[x]
73
74#define LoadIntArgbTo1IntArgb(pRas, PREFIX, x, argb) \
75 (argb) = (pRas)[x]
76
77#define LoadIntArgbTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
78 do { \
79 jint pixel = (pRas)[x]; \
80 ExtractIntDcmComponentsX123(pixel, r, g, b); \
81 } while (0)
82
83#define LoadIntArgbTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
84 do { \
85 jint pixel = (pRas)[x]; \
86 ExtractIntDcmComponents1234(pixel, a, r, g, b); \
87 } while (0)
88
89#define StoreIntArgbFrom1IntRgb(pRas, PREFIX, x, rgb) \
90 (pRas)[x] = 0xff000000 | (rgb)
91
92#define StoreIntArgbFrom1IntArgb(pRas, PREFIX, x, argb) \
93 (pRas)[x] = (argb)
94
95#define StoreIntArgbFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
96 StoreIntArgbFrom4ByteArgb(pRas, PREFIX, x, 0xff, r, g, b)
97
98#define StoreIntArgbFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
99 (pRas)[x] = ComposeIntDcmComponents1234(a, r, g, b)
100
101#define CopyIntArgbToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
102 do { \
103 jint argb = (pRow)[x]; \
104 jint a = URShift(argb, 24); \
105 if (a == 0) { \
106 argb = 0; \
107 } else if (a < 0xff) { \
108 jint r = (argb >> 16) & 0xff; \
109 jint g = (argb >> 8) & 0xff; \
110 jint b = (argb ) & 0xff; \
111 r = MUL8(a, r); \
112 g = MUL8(a, g); \
113 b = MUL8(a, b); \
114 argb = ComposeIntDcmComponents1234(a, r, g, b); \
115 } \
116 (pRGB)[i] = argb; \
117 } while (0)
118
119
120#define DeclareIntArgbAlphaLoadData(PREFIX) \
121 jint PREFIX;
122
123#define InitIntArgbAlphaLoadData(PREFIX, pRasInfo)
124
125#define LoadAlphaFromIntArgbFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \
126 do { \
127 PREFIX = (pRas)[0]; \
128 COMP_PREFIX ## A = ((juint) PREFIX) >> 24; \
129 } while (0)
130
131#define LoadAlphaFromIntArgbFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \
132 LoadAlphaFromIntArgbFor4ByteArgb(pRas, PREFIX, COMP_PREFIX)
133
134#define LoadAlphaFromIntArgbFor1ShortGray(pRas, PREFIX, COMP_PREFIX) \
135 do { \
136 LoadAlphaFromIntArgbFor4ByteArgb(pRas, PREFIX, COMP_PREFIX); \
137 COMP_PREFIX ## A = (COMP_PREFIX ## A << 8) + COMP_PREFIX ## A; \
138 } while (0)
139
140#define Postload4ByteArgbFromIntArgb(pRas, PREFIX, COMP_PREFIX) \
141 do { \
142 COMP_PREFIX ## R = (PREFIX >> 16) & 0xff; \
143 COMP_PREFIX ## G = (PREFIX >> 8) & 0xff; \
144 COMP_PREFIX ## B = (PREFIX >> 0) & 0xff; \
145 } while (0)
146
147#define Postload1ByteGrayFromIntArgb(pRas, PREFIX, COMP_PREFIX) \
148 do { \
149 int r, g, b; \
150 ExtractIntDcmComponentsX123(PREFIX, r, g, b); \
151 COMP_PREFIX ## G = ComposeByteGrayFrom3ByteRgb(r, g, b); \
152 } while (0)
153
154#define Postload1ShortGrayFromIntArgb(pRas, PREFIX, COMP_PREFIX) \
155 do { \
156 int r, g, b; \
157 ExtractIntDcmComponentsX123(PREFIX, r, g, b); \
158 COMP_PREFIX ## G = ComposeUshortGrayFrom3ByteRgb(r, g, b); \
159 } while (0)
160
161
162#define IntArgbIsPremultiplied 0
163
164#define DeclareIntArgbBlendFillVars(PREFIX)
165
166#define ClearIntArgbBlendFillVars(PREFIX, argb) \
167 argb = 0
168
169#define InitIntArgbBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \
170 argb = (COMP_PREFIX ## A << 24) | (argb & 0x00ffffff); \
171
172#define InitIntArgbBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)
173
174#define StoreIntArgbBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \
175 (pRas)[x] = (argb)
176
177#define StoreIntArgbFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \
178 StoreIntArgbFrom4ByteArgb(pRas, PREFIX, x, \
179 COMP_PREFIX ## A, COMP_PREFIX ## R, \
180 COMP_PREFIX ## G, COMP_PREFIX ## B)
181
182
183/*
184 * Extract ## STRATEGY ## CompsAndAlphaFromArgb(pixel, COMP_PREFIX)
185 */
186#define Extract3ByteRgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \
187 ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, COMP_PREFIX ## R, \
188 COMP_PREFIX ## G, COMP_PREFIX ## B)
189
190#define Extract4ByteArgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \
191 Extract3ByteRgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX)
192
193#define Extract1ByteGrayCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \
194 do { \
195 int r, g, b; \
196 ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, r, g, b); \
197 COMP_PREFIX ## G = ComposeByteGrayFrom3ByteRgb(r, g, b); \
198 } while (0)
199
200#define Extract1ShortGrayCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \
201 do { \
202 int r, g, b; \
203 ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, r, g, b); \
204 COMP_PREFIX ## G = ComposeUshortGrayFrom3ByteRgb(r, g, b); \
205 COMP_PREFIX ## A = (COMP_PREFIX ## A << 8) + COMP_PREFIX ## A; \
206 } while (0)
207
208#endif /* IntArgb_h_Included */