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