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 Ushort555Rgb_h_Included |
27 | #define Ushort555Rgb_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 "Ushort555Rgb". |
32 | */ |
33 | |
34 | typedef jushort Ushort555RgbPixelType; |
35 | typedef jushort Ushort555RgbDataType; |
36 | |
37 | #define Ushort555RgbIsOpaque 1 |
38 | |
39 | #define Ushort555RgbPixelStride 2 |
40 | |
41 | #define DeclareUshort555RgbLoadVars(PREFIX) |
42 | #define DeclareUshort555RgbStoreVars(PREFIX) |
43 | #define SetUshort555RgbStoreVarsYPos(PREFIX, pRasInfo, y) |
44 | #define SetUshort555RgbStoreVarsXPos(PREFIX, pRasInfo, x) |
45 | #define InitUshort555RgbLoadVars(PREFIX, pRasInfo) |
46 | #define InitUshort555RgbStoreVarsY(PREFIX, pRasInfo) |
47 | #define InitUshort555RgbStoreVarsX(PREFIX, pRasInfo) |
48 | #define NextUshort555RgbStoreVarsX(PREFIX) |
49 | #define NextUshort555RgbStoreVarsY(PREFIX) |
50 | #define DeclareUshort555RgbPixelData(PREFIX) |
51 | #define (PIXEL, PREFIX) |
52 | |
53 | #define Ushort555RgbXparLutEntry -1 |
54 | #define Ushort555RgbIsXparLutEntry(pix) (pix < 0) |
55 | #define StoreUshort555RgbNonXparFromArgb StoreUshort555RgbFrom1IntArgb |
56 | |
57 | |
58 | #define ComposeUshort555RgbFrom3ByteRgb(r, g, b) \ |
59 | (Ushort555RgbPixelType)((((r) >> 3) << 10) | \ |
60 | (((g) >> 3) << 5) | \ |
61 | (((b) >> 3) << 0)) |
62 | |
63 | #define IntArgbToUshort555Rgb(rgb) \ |
64 | (Ushort555RgbPixelType)((((rgb) >> (16 + 3 - 10)) & 0x7c00) | \ |
65 | (((rgb) >> ( 8 + 3 - 5)) & 0x03e0) | \ |
66 | (((rgb) >> ( 0 + 3 - 0)) & 0x001f)) |
67 | |
68 | #define Ushort555RgbPixelFromArgb(pixel, rgb, pRasInfo) \ |
69 | (pixel) = IntArgbToUshort555Rgb(rgb) |
70 | |
71 | #define StoreUshort555RgbPixel(pRas, x, pixel) \ |
72 | ((pRas)[x] = (jushort) (pixel)) |
73 | |
74 | #define StoreUshort555RgbPixelData(pPix, x, pixel, PREFIX) \ |
75 | StoreUshort555RgbPixel(pPix, x, pixel) |
76 | |
77 | |
78 | #define LoadUshort555RgbTo3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
79 | do { \ |
80 | jushort pixel = (pRas)[x]; \ |
81 | (r) = ((pixel) >> 10) & 0x1f; \ |
82 | (r) = ((r) << 3) | ((r) >> 2); \ |
83 | (g) = ((pixel) >> 5) & 0x1f; \ |
84 | (g) = ((g) << 3) | ((g) >> 2); \ |
85 | (b) = ((pixel) >> 0) & 0x1f; \ |
86 | (b) = ((b) << 3) | ((b) >> 2); \ |
87 | } while (0) |
88 | |
89 | #define LoadUshort555RgbTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
90 | do { \ |
91 | LoadUshort555RgbTo3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
92 | (a) = 0xff; \ |
93 | } while (0) |
94 | |
95 | #define StoreUshort555RgbFrom1IntRgb(pRas, PREFIX, x, rgb) \ |
96 | StoreUshort555RgbFrom1IntArgb(pRas, PREFIX, x, rgb) |
97 | |
98 | #define StoreUshort555RgbFrom1IntArgb(pRas, PREFIX, x, rgb) \ |
99 | (pRas)[x] = IntArgbToUshort555Rgb(rgb) |
100 | |
101 | #define StoreUshort555RgbFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
102 | (pRas)[x] = (jushort) ComposeUshort555RgbFrom3ByteRgb(r, g, b) |
103 | |
104 | #define StoreUshort555RgbFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
105 | StoreUshort555RgbFrom3ByteRgb(pRas, PREFIX, x, r, g, b) |
106 | |
107 | |
108 | #define DeclareUshort555RgbAlphaLoadData(PREFIX) |
109 | #define InitUshort555RgbAlphaLoadData(PREFIX, pRasInfo) |
110 | |
111 | #define LoadAlphaFromUshort555RgbFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \ |
112 | COMP_PREFIX ## A = 0xff |
113 | |
114 | #define Postload4ByteArgbFromUshort555Rgb(pRas, PREFIX, COMP_PREFIX) \ |
115 | LoadUshort555RgbTo3ByteRgb(pRas, PREFIX, 0, COMP_PREFIX ## R, \ |
116 | COMP_PREFIX ## G, COMP_PREFIX ## B) |
117 | |
118 | |
119 | #define Ushort555RgbIsPremultiplied 0 |
120 | |
121 | #define DeclareUshort555RgbBlendFillVars(PREFIX) \ |
122 | jushort PREFIX; |
123 | |
124 | #define ClearUshort555RgbBlendFillVars(PREFIX, argb) \ |
125 | PREFIX = 0 |
126 | |
127 | #define InitUshort555RgbBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \ |
128 | PREFIX = (jushort) ComposeUshort555RgbFrom3ByteRgb(COMP_PREFIX ## R, \ |
129 | COMP_PREFIX ## G, \ |
130 | COMP_PREFIX ## B) |
131 | |
132 | #define InitUshort555RgbBlendFillVarsPre(PREFIX, argb, COMP_PREFIX) |
133 | |
134 | #define StoreUshort555RgbBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \ |
135 | (pRas)[x] = PREFIX |
136 | |
137 | #define StoreUshort555RgbFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \ |
138 | StoreUshort555RgbFrom4ByteArgb(pRas, PREFIX, x, \ |
139 | COMP_PREFIX ## A, COMP_PREFIX ## R, \ |
140 | COMP_PREFIX ## G, COMP_PREFIX ## B) |
141 | |
142 | #endif /* Ushort555Rgb_h_Included */ |
143 | |