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 IntRgb_h_Included
27 #define IntRgb_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 "IntRgb".
36  */
37 
38 typedef jint    IntRgbPixelType;
39 typedef jint    IntRgbDataType;
40 
41 #define IntRgbIsOpaque 1
42 
43 #define IntRgbPixelStride       4
44 
45 #define DeclareIntRgbLoadVars(PREFIX)
46 #define DeclareIntRgbStoreVars(PREFIX)
47 #define InitIntRgbLoadVars(PREFIX, pRasInfo)
48 #define SetIntRgbStoreVarsYPos(PREFIX, pRasInfo, y)
49 #define SetIntRgbStoreVarsXPos(PREFIX, pRasInfo, x)
50 #define InitIntRgbStoreVarsY(PREFIX, pRasInfo)
51 #define InitIntRgbStoreVarsX(PREFIX, pRasInfo)
52 #define NextIntRgbStoreVarsX(PREFIX)
53 #define NextIntRgbStoreVarsY(PREFIX)
54 
55 #define IntRgbPixelFromArgb(pixel, rgb, pRasInfo) \
56     (pixel) = (rgb)
57 
58 #define StoreIntRgbPixel(pRas, x, pixel) \
59     (pRas)[x] = (pixel)
60 
61 #define DeclareIntRgbPixelData(PREFIX)
62 
63 #define ExtractIntRgbPixelData(PIXEL, PREFIX)
64 
65 #define StoreIntRgbPixelData(pPix, x, pixel, PREFIX) \
66     StoreIntRgbPixel(pPix, x, pixel)
67 
68 
69 #define LoadIntRgbTo1IntRgb(pRas, PREFIX, x, rgb) \
70     (rgb) = (pRas)[x]
71 
72 #define LoadIntRgbTo1IntArgb(pRas, PREFIX, x, argb) \
73     (argb) = 0xff000000 | (pRas)[x]
74 
75 #define LoadIntRgbTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
76     do { \
77         jint pixel = (pRas)[x]; \
78         ExtractIntDcmComponentsX123(pixel, r, g, b); \
79     } while (0)
80 
81 #define LoadIntRgbTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
82     do { \
83         LoadIntRgbTo3ByteRgb(pRas, PREFIX, x, r, g, b); \
84         (a) = 0xff; \
85     } while (0)
86 
87 #define StoreIntRgbFrom1IntRgb(pRas, PREFIX, x, rgb) \
88     (pRas)[x] = (rgb)
89 
90 #define StoreIntRgbFrom1IntArgb(pRas, PREFIX, x, argb) \
91     (pRas)[x] = (argb)
92 
93 #define StoreIntRgbFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
94     (pRas)[x] = ComposeIntDcmComponentsX123(r, g, b)
95 
96 #define StoreIntRgbFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
97     StoreIntRgbFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
98 
99 #define CopyIntRgbToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
100     LoadIntRgbTo1IntArgb(pRow, PREFIX, x, (pRGB)[i])
101 
102 #define DeclareIntRgbAlphaLoadData(PREFIX)
103 
104 #define InitIntRgbAlphaLoadData(PREFIX, pRasInfo)
105 
106 #define LoadAlphaFromIntRgbFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \
107     COMP_PREFIX ## A = 0xff
108 
109 #define LoadAlphaFromIntRgbFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \
110     COMP_PREFIX ## A = 0xff
111 
112 #define LoadAlphaFromIntRgbFor1ShortGray(pRas, PREFIX, COMP_PREFIX) \
113     COMP_PREFIX ## A = 0xffff
114 
115 #define Postload4ByteArgbFromIntRgb(pRas, PREFIX, COMP_PREFIX) \
116     LoadIntRgbTo3ByteRgb(pRas, PREFIX, 0, COMP_PREFIX ## R, \
117                          COMP_PREFIX ## G, COMP_PREFIX ## B)
118 
119 #define Postload1ByteGrayFromIntRgb(pRas, PREFIX, COMP_PREFIX) \
120     do { \
121         int r, g, b; \
122         ExtractIntDcmComponentsX123(pRas[0], r, g, b); \
123         COMP_PREFIX ## G = ComposeByteGrayFrom3ByteRgb(r, g, b); \
124     } while (0)
125 
126 #define Postload1ShortGrayFromIntRgb(pRas, PREFIX, COMP_PREFIX) \
127     do { \
128         int r, g, b; \
129         ExtractIntDcmComponentsX123(pRas[0], r, g, b); \
130         COMP_PREFIX ## G = ComposeUshortGrayFrom3ByteRgb(r, g, b); \
131     } while (0)
132 
133 
134 #define IntRgbIsPremultiplied   0
135 
136 #define DeclareIntRgbBlendFillVars(PREFIX)
137 
138 #define ClearIntRgbBlendFillVars(PREFIX, argb) \
139     argb = 0
140 
141 #define InitIntRgbBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX)
142 
143 #define InitIntRgbBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)
144 
145 #define StoreIntRgbBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \
146     (pRas)[x] = (argb)
147 
148 #define StoreIntRgbFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \
149     StoreIntRgbFrom4ByteArgb(pRas, PREFIX, x, \
150                              COMP_PREFIX ## A, COMP_PREFIX ## R, \
151                              COMP_PREFIX ## G, COMP_PREFIX ## B)
152 
153 #endif /* IntRgb_h_Included */
154