blob: 7bb4944f520726cd44de380e8bb244ea783f6528 [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 ThreeByteBgr_h_Included
27#define ThreeByteBgr_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 "ThreeByteBgr".
32 */
33
34typedef jint ThreeByteBgrPixelType;
35typedef jubyte ThreeByteBgrDataType;
36
37#define ThreeByteBgrPixelStride 3
38
39#define DeclareThreeByteBgrLoadVars(PREFIX)
40#define DeclareThreeByteBgrStoreVars(PREFIX)
41#define SetThreeByteBgrStoreVarsYPos(PREFIX, pRasInfo, y)
42#define SetThreeByteBgrStoreVarsXPos(PREFIX, pRasInfo, x)
43#define InitThreeByteBgrLoadVars(PREFIX, pRasInfo)
44#define InitThreeByteBgrStoreVarsY(PREFIX, pRasInfo)
45#define InitThreeByteBgrStoreVarsX(PREFIX, pRasInfo)
46#define NextThreeByteBgrStoreVarsX(PREFIX)
47#define NextThreeByteBgrStoreVarsY(PREFIX)
48
49
50#define ThreeByteBgrPixelFromArgb(pixel, rgb, pRasInfo) \
51 (pixel) = (rgb)
52
53#define StoreThreeByteBgrPixel(pRas, x, pixel) \
54 do { \
55 (pRas)[3*(x)+0] = (jubyte) ((pixel) >> 0); \
56 (pRas)[3*(x)+1] = (jubyte) ((pixel) >> 8); \
57 (pRas)[3*(x)+2] = (jubyte) ((pixel) >> 16); \
58 } while (0)
59
60#define DeclareThreeByteBgrPixelData(PREFIX) \
61 jubyte PREFIX ## 0, PREFIX ## 1, PREFIX ## 2;
62
63#define ExtractThreeByteBgrPixelData(PIXEL, PREFIX) \
64 do { \
65 PREFIX ## 0 = (jubyte) (PIXEL); \
66 PREFIX ## 1 = (jubyte) (PIXEL >> 8); \
67 PREFIX ## 2 = (jubyte) (PIXEL >> 16); \
68 } while (0)
69
70#define StoreThreeByteBgrPixelData(pPix, x, pixel, PREFIX) \
71 do { \
72 pPix[3*x+0] = PREFIX ## 0; \
73 pPix[3*x+1] = PREFIX ## 1; \
74 pPix[3*x+2] = PREFIX ## 2; \
75 } while (0)
76
77
78#define LoadThreeByteBgrTo1IntRgb(pRas, PREFIX, x, rgb) \
79 (rgb) = (((pRas)[3*(x)+0] << 0) | \
80 ((pRas)[3*(x)+1] << 8) | \
81 ((pRas)[3*(x)+2] << 16))
82
83#define LoadThreeByteBgrTo1IntArgb(pRas, PREFIX, x, argb) \
84 (argb) = (((pRas)[3*(x)+0] << 0) | \
85 ((pRas)[3*(x)+1] << 8) | \
86 ((pRas)[3*(x)+2] << 16) | \
87 0xff000000)
88
89#define LoadThreeByteBgrTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
90 do { \
91 (b) = (pRas)[3*(x)+0]; \
92 (g) = (pRas)[3*(x)+1]; \
93 (r) = (pRas)[3*(x)+2]; \
94 } while (0)
95
96#define LoadThreeByteBgrTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
97 do { \
98 LoadThreeByteBgrTo3ByteRgb(pRas, PREFIX, x, r, g, b); \
99 (a) = 0xff; \
100 } while (0)
101
102#define StoreThreeByteBgrFrom1IntRgb(pRas, PREFIX, x, rgb) \
103 do { \
104 (pRas)[3*(x)+0] = (jubyte) ((rgb) >> 0); \
105 (pRas)[3*(x)+1] = (jubyte) ((rgb) >> 8); \
106 (pRas)[3*(x)+2] = (jubyte) ((rgb) >> 16); \
107 } while (0)
108
109#define StoreThreeByteBgrFrom1IntArgb(pRas, PREFIX, x, argb) \
110 StoreThreeByteBgrFrom1IntRgb(pRas, PREFIX, x, argb)
111
112#define StoreThreeByteBgrFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
113 do { \
114 (pRas)[3*(x)+0] = (jubyte) (b); \
115 (pRas)[3*(x)+1] = (jubyte) (g); \
116 (pRas)[3*(x)+2] = (jubyte) (r); \
117 } while (0)
118
119#define StoreThreeByteBgrFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
120 StoreThreeByteBgrFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
121
122#define CopyThreeByteBgrToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
123 LoadThreeByteBgrTo1IntArgb(pRow, PREFIX, x, (pRGB)[i])
124
125
126#define DeclareThreeByteBgrAlphaLoadData(PREFIX)
127#define InitThreeByteBgrAlphaLoadData(PREFIX, pRasInfo)
128
129#define LoadAlphaFromThreeByteBgrFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \
130 COMP_PREFIX ## A = 0xff
131
132#define Postload4ByteArgbFromThreeByteBgr(pRas, PREFIX, COMP_PREFIX) \
133 LoadThreeByteBgrTo3ByteRgb(pRas, PREFIX, 0, COMP_PREFIX ## R, \
134 COMP_PREFIX ## G, COMP_PREFIX ## B)
135
136
137#define ThreeByteBgrIsPremultiplied 0
138
139#define DeclareThreeByteBgrBlendFillVars(PREFIX) \
140 jubyte PREFIX ## 0, PREFIX ## 1, PREFIX ## 2;
141
142#define ClearThreeByteBgrBlendFillVars(PREFIX, argb) \
143 (PREFIX ## 0 = PREFIX ## 1 = PREFIX ## 2 = 0)
144
145#define InitThreeByteBgrBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \
146 do { \
147 PREFIX ## 0 = (jubyte) COMP_PREFIX ## B; \
148 PREFIX ## 1 = (jubyte) COMP_PREFIX ## G; \
149 PREFIX ## 2 = (jubyte) COMP_PREFIX ## R; \
150 } while (0)
151
152#define InitThreeByteBgrBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)
153
154#define StoreThreeByteBgrBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \
155 do { \
156 pRas[3*x+0] = PREFIX ## 0; \
157 pRas[3*x+1] = PREFIX ## 1; \
158 pRas[3*x+2] = PREFIX ## 2; \
159 } while (0)
160
161#define StoreThreeByteBgrFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \
162 StoreThreeByteBgrFrom4ByteArgb(pRas, PREFIX, x, \
163 COMP_PREFIX ## A, COMP_PREFIX ## R, \
164 COMP_PREFIX ## G, COMP_PREFIX ## B)
165
166#endif /* ThreeByteBgr_h_Included */