blob: 68008b3a500f0034648de6e2273f783a9dd5a723 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000-2003 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 Ushort565Rgb_h_Included
27#define Ushort565Rgb_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 "Ushort565Rgb".
32 */
33
34typedef jushort Ushort565RgbPixelType;
35typedef jushort Ushort565RgbDataType;
36
37#define Ushort565RgbPixelStride 2
38
39#define DeclareUshort565RgbLoadVars(PREFIX)
40#define DeclareUshort565RgbStoreVars(PREFIX)
41#define SetUshort565RgbStoreVarsYPos(PREFIX, pRasInfo, y)
42#define SetUshort565RgbStoreVarsXPos(PREFIX, pRasInfo, x)
43#define InitUshort565RgbLoadVars(PREFIX, pRasInfo)
44#define InitUshort565RgbStoreVarsY(PREFIX, pRasInfo)
45#define InitUshort565RgbStoreVarsX(PREFIX, pRasInfo)
46#define NextUshort565RgbStoreVarsX(PREFIX)
47#define NextUshort565RgbStoreVarsY(PREFIX)
48#define DeclareUshort565RgbPixelData(PREFIX)
49#define ExtractUshort565RgbPixelData(PIXEL, PREFIX)
50
51#define Ushort565RgbXparLutEntry -1
52#define Ushort565RgbIsXparLutEntry(pix) (pix < 0)
53#define StoreUshort565RgbNonXparFromArgb StoreUshort565RgbFrom1IntArgb
54
55
56#define ComposeUshort565RgbFrom3ByteRgb(r, g, b) \
57 (Ushort565RgbPixelType)((((r) >> 3) << 11) | \
58 (((g) >> 2) << 5) | \
59 (((b) >> 3) << 0))
60
61#define IntArgbToUshort565Rgb(rgb) \
62 (Ushort565RgbPixelType)((((rgb) >> (16 + 3 - 11)) & 0xf800) | \
63 (((rgb) >> ( 8 + 2 - 5)) & 0x07e0) | \
64 (((rgb) >> ( 0 + 3 - 0)) & 0x001f))
65
66#define Ushort565RgbPixelFromArgb(pixel, rgb, pRasInfo) \
67 (pixel) = IntArgbToUshort565Rgb(rgb)
68
69#define StoreUshort565RgbPixel(pRas, x, pixel) \
70 ((pRas)[x] = (jushort) (pixel))
71
72#define StoreUshort565RgbPixelData(pPix, x, pixel, PREFIX) \
73 StoreUshort565RgbPixel(pPix, x, pixel)
74
75
76#define LoadUshort565RgbTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
77 do { \
78 jushort pixel = (pRas)[x]; \
79 (r) = ((pixel) >> 11) & 0x1f; \
80 (r) = ((r) << 3) | ((r) >> 2); \
81 (g) = ((pixel) >> 5) & 0x3f; \
82 (g) = ((g) << 2) | ((g) >> 4); \
83 (b) = ((pixel) >> 0) & 0x1f; \
84 (b) = ((b) << 3) | ((b) >> 2); \
85 } while (0)
86
87#define LoadUshort565RgbTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
88 do { \
89 LoadUshort565RgbTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
90 (a) = 0xff; \
91 } while (0)
92
93#define StoreUshort565RgbFrom1IntArgb(pRas, PREFIX, x, rgb) \
94 (pRas)[x] = IntArgbToUshort565Rgb(rgb)
95
96#define StoreUshort565RgbFrom1IntRgb(pRas, PREFIX, x, rgb) \
97 StoreUshort565RgbFrom1IntArgb(pRas, PREFIX, x, rgb)
98
99#define StoreUshort565RgbFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
100 (pRas)[x] = (jushort) ComposeUshort565RgbFrom3ByteRgb(r, g, b)
101
102#define StoreUshort565RgbFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
103 StoreUshort565RgbFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
104
105
106#define DeclareUshort565RgbAlphaLoadData(PREFIX)
107#define InitUshort565RgbAlphaLoadData(PREFIX, pRasInfo)
108
109#define LoadAlphaFromUshort565RgbFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \
110 COMP_PREFIX ## A = 0xff
111
112#define Postload4ByteArgbFromUshort565Rgb(pRas, PREFIX, COMP_PREFIX) \
113 LoadUshort565RgbTo3ByteRgb(pRas, PREFIX, 0, COMP_PREFIX ## R, \
114 COMP_PREFIX ## G, COMP_PREFIX ## B)
115
116
117#define Ushort565RgbIsPremultiplied 0
118
119#define DeclareUshort565RgbBlendFillVars(PREFIX) \
120 jushort PREFIX;
121
122#define ClearUshort565RgbBlendFillVars(PREFIX, argb) \
123 PREFIX = 0
124
125#define InitUshort565RgbBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \
126 PREFIX = (jushort) ComposeUshort565RgbFrom3ByteRgb(COMP_PREFIX ## R, \
127 COMP_PREFIX ## G, \
128 COMP_PREFIX ## B)
129
130#define InitUshort565RgbBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)
131
132#define StoreUshort565RgbBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \
133 (pRas)[x] = PREFIX
134
135#define StoreUshort565RgbFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \
136 StoreUshort565RgbFrom4ByteArgb(pRas, PREFIX, x, \
137 COMP_PREFIX ## A, COMP_PREFIX ## R, \
138 COMP_PREFIX ## G, COMP_PREFIX ## B)
139
140#endif /* Ushort565Rgb_h_Included */