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