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