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 Ushort555Rgbx_h_Included
27 #define Ushort555Rgbx_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 "Ushort555Rgbx".
32  */
33 
34 typedef jushort Ushort555RgbxPixelType;
35 typedef jushort Ushort555RgbxDataType;
36 
37 #define Ushort555RgbxIsOpaque 1
38 
39 #define Ushort555RgbxPixelStride        2
40 
41 #define DeclareUshort555RgbxLoadVars(PREFIX)
42 #define DeclareUshort555RgbxStoreVars(PREFIX)
43 #define SetUshort555RgbxStoreVarsYPos(PREFIX, pRasInfo, y)
44 #define SetUshort555RgbxStoreVarsXPos(PREFIX, pRasInfo, x)
45 #define InitUshort555RgbxLoadVars(PREFIX, pRasInfo)
46 #define InitUshort555RgbxStoreVarsY(PREFIX, pRasInfo)
47 #define InitUshort555RgbxStoreVarsX(PREFIX, pRasInfo)
48 #define NextUshort555RgbxStoreVarsX(PREFIX)
49 #define NextUshort555RgbxStoreVarsY(PREFIX)
50 #define DeclareUshort555RgbxPixelData(PREFIX)
51 #define ExtractUshort555RgbxPixelData(PIXEL, PREFIX)
52 
53 #define Ushort555RgbxXparLutEntry               -1
54 #define Ushort555RgbxIsXparLutEntry(pix)        (pix < 0)
55 #define StoreUshort555RgbxNonXparFromArgb       StoreUshort555RgbxFrom1IntArgb
56 
57 
58 #define IntArgbToUshort555Rgbx(rgb) \
59     (Ushort555RgbxPixelType)((((rgb) >> (16 + 3 - 11)) & 0xf800) | \
60                              (((rgb) >> ( 8 + 3 -  6)) & 0x07c0) | \
61                              (((rgb) >> ( 0 + 3 -  1)) & 0x003e))
62 
63 #define Ushort555RgbxPixelFromArgb(pixel, rgb, pRasInfo) \
64     (pixel) = IntArgbToUshort555Rgbx(rgb)
65 
66 #define StoreUshort555RgbxPixel(pRas, x, pixel) \
67     ((pRas)[x] = (jushort) (pixel))
68 
69 #define StoreUshort555RgbxPixelData(pPix, x, pixel, PREFIX) \
70     StoreUshort555RgbxPixel(pPix, x, pixel)
71 
72 
73 #define LoadUshort555RgbxTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
74     do { \
75         jushort pixel = (pRas)[x]; \
76         (r) = ((pixel) >> 11) & 0x1f; \
77         (r) = ((r) << 3) | ((r) >> 2); \
78         (g) = ((pixel) >>  6) & 0x1f; \
79         (g) = ((g) << 3) | ((g) >> 2); \
80         (b) = ((pixel) >>  1) & 0x1f; \
81         (b) = ((b) << 3) | ((b) >> 2); \
82     } while (0)
83 
84 #define LoadUshort555RgbxTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
85     do { \
86         LoadUshort555RgbxTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
87         (a) = 0xff; \
88     } while (0)
89 
90 #define StoreUshort555RgbxFrom1IntArgb(pRas, PREFIX, x, rgb) \
91     (pRas)[x] = IntArgbToUshort555Rgbx(rgb)
92 
93 #define StoreUshort555RgbxFrom1IntRgb(pRas, PREFIX, x, rgb) \
94     StoreUshort555RgbxFrom1IntArgb(pRas, PREFIX, x, rgb)
95 
96 #define StoreUshort555RgbxFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
97     (pRas)[x] = (jushort) ((((r) >> 3) << 11) | \
98                            (((g) >> 3) <<  6) | \
99                            (((b) >> 3) <<  1))
100 
101 #define StoreUshort555RgbxFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
102     StoreUshort555RgbxFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
103 
104 #endif /* Ushort555Rgbx_h_Included */
105