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