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