1 | /* |
2 | * Copyright (c) 2002, 2013, 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 Ushort4444Argb_h_Included |
27 | #define Ushort4444Argb_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 "Ushort4444Argb". |
32 | */ |
33 | |
34 | typedef jushort Ushort4444ArgbPixelType; |
35 | typedef jushort Ushort4444ArgbDataType; |
36 | |
37 | #define Ushort4444ArgbIsOpaque 0 |
38 | |
39 | #define Ushort4444ArgbPixelStride 2 |
40 | |
41 | #define DeclareUshort4444ArgbLoadVars(PREFIX) |
42 | #define DeclareUshort4444ArgbStoreVars(PREFIX) |
43 | #define SetUshort4444ArgbStoreVarsYPos(PREFIX, pRasInfo, y) |
44 | #define SetUshort4444ArgbStoreVarsXPos(PREFIX, pRasInfo, x) |
45 | #define InitUshort4444ArgbLoadVars(PREFIX, pRasInfo) |
46 | #define InitUshort4444ArgbStoreVarsY(PREFIX, pRasInfo) |
47 | #define InitUshort4444ArgbStoreVarsX(PREFIX, pRasInfo) |
48 | #define NextUshort4444ArgbStoreVarsX(PREFIX) |
49 | #define NextUshort4444ArgbStoreVarsY(PREFIX) |
50 | #define DeclareUshort4444ArgbPixelData(PREFIX) |
51 | #define (PIXEL, PREFIX) |
52 | |
53 | #define Ushort4444ArgbXparLutEntry -1 |
54 | #define Ushort4444ArgbIsXparLutEntry(pix) (pix < 0) |
55 | #define StoreUshort4444ArgbNonXparFromArgb StoreUshort4444ArgbFrom1IntArgb |
56 | |
57 | |
58 | #define ComposeUshort4444ArgbFrom3ByteRgb(r, g, b) |
59 | |
60 | #define IntArgbToUshort4444Argb(rgb) \ |
61 | (Ushort4444ArgbPixelType)((((rgb) << 8) & 0xf000) | \ |
62 | (((rgb) << 4) & 0x0f00) | \ |
63 | (((rgb) << 0) & 0x00f0) | \ |
64 | (((rgb) >> 4) & 0x000f)) |
65 | |
66 | #define Ushort4444ArgbPixelFromArgb(pixel, rgb, pRasInfo) \ |
67 | (pixel) = IntArgbToUshort4444Argb(rgb) |
68 | |
69 | #define StoreUshort4444ArgbPixel(pRas, x, pixel) \ |
70 | ((pRas)[x] = (jushort) (pixel)) |
71 | |
72 | #define StoreUshort4444ArgbPixelData(pPix, x, pixel, PREFIX) |
73 | |
74 | #define LoadUshort4444ArgbTo3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
75 | do { \ |
76 | jushort pixel = (pRas)[x]; \ |
77 | (r) = ((pixel) >> 8) & 0xf; \ |
78 | (r) = ((r) << 4) | (r); \ |
79 | (g) = ((pixel) >> 4) & 0xf; \ |
80 | (g) = ((g) << 4) | (g); \ |
81 | (b) = ((pixel) >> 0) & 0xf; \ |
82 | (b) = ((b) << 4) | (b); \ |
83 | } while (0) |
84 | |
85 | #define LoadUshort4444ArgbTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
86 | do { \ |
87 | jushort pixel = (pRas)[x]; \ |
88 | LoadUshort4444ArgbTo3ByteRgb(pRas, PREFIX, x, r, g, b); \ |
89 | (a) = ((pixel) >> 12) & 0xf; \ |
90 | (a) = ((a) << 4) | (a); \ |
91 | } while (0) |
92 | |
93 | #define LoadUshort4444ArgbTo1IntArgb(pRas, PREFIX, x, argb) \ |
94 | do { \ |
95 | jint a, r, g, b; \ |
96 | LoadUshort4444ArgbTo4ByteArgb(pRas, PREFIX, x, a, r, g, b); \ |
97 | (argb) = (a << 24) | (r << 16) | (g << 8) | (b << 0); \ |
98 | } while (0) |
99 | |
100 | #define LoadUshort4444ArgbTo1IntRgb(pRas, PREFIX, x, rgb) \ |
101 | do { \ |
102 | jint r, g, b; \ |
103 | LoadUshort4444ArgbTo3ByteRgb(pRas, PREFIX, x, r, g, b); \ |
104 | (rgb) = 0xff000000 | (r << 16) | (g << 8) | (b << 0); \ |
105 | } while (0) |
106 | |
107 | #define StoreUshort4444ArgbFrom1IntArgb(pRas, PREFIX, x, rgb) |
108 | #define StoreUshort4444ArgbFrom1IntRgb(pRas, PREFIX, x, rgb) |
109 | #define StoreUshort4444ArgbFrom3ByteRgb(pRas, PREFIX, x, r, g, b) |
110 | |
111 | #define StoreUshort4444ArgbFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
112 | do { \ |
113 | (pRas)[x] = (jushort)((((a) << 8) & 0xf000) | \ |
114 | (((r) << 4) & 0x0f00) | \ |
115 | (((g) << 0) & 0x00f0) | \ |
116 | (((b) >> 4) & 0x000f)); \ |
117 | } while (0) |
118 | |
119 | |
120 | #define DeclareUshort4444ArgbAlphaLoadData(PREFIX) \ |
121 | jint PREFIX; |
122 | |
123 | #define InitUshort4444ArgbAlphaLoadData(PREFIX, pRasInfo) \ |
124 | PREFIX = 0 |
125 | |
126 | #define LoadAlphaFromUshort4444ArgbFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \ |
127 | do { \ |
128 | PREFIX = (pRas)[0]; \ |
129 | COMP_PREFIX ## A = (((jushort) PREFIX) >> 12) & 0xf; \ |
130 | COMP_PREFIX ## A = ((COMP_PREFIX ## A) << 4) | (COMP_PREFIX ## A); \ |
131 | } while (0) |
132 | |
133 | #define Postload4ByteArgbFromUshort4444Argb(pRas, PREFIX, COMP_PREFIX) \ |
134 | LoadUshort4444ArgbTo4ByteArgb(pRas, PREFIX, 0, COMP_PREFIX ## A, COMP_PREFIX ## R, \ |
135 | COMP_PREFIX ## G, COMP_PREFIX ## B) |
136 | |
137 | #define Ushort4444ArgbIsPremultiplied 0 |
138 | |
139 | #define StoreUshort4444ArgbFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \ |
140 | StoreUshort4444ArgbFrom4ByteArgb(pRas, PREFIX, x, \ |
141 | COMP_PREFIX ## A, COMP_PREFIX ## R, \ |
142 | COMP_PREFIX ## G, COMP_PREFIX ## B) |
143 | |
144 | #endif /* Ushort4444Argb_h_Included */ |
145 | |