J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2001-2005 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 IntArgbBm_h_Included |
| 27 | #define IntArgbBm_h_Included |
| 28 | |
| 29 | #include "IntDcm.h" |
| 30 | #include "ByteGray.h" |
| 31 | #include "UshortGray.h" |
| 32 | |
| 33 | /* |
| 34 | * This file contains macro and type definitions used by the macros in |
| 35 | * LoopMacros.h to manipulate a surface of type "IntArgbBm". |
| 36 | */ |
| 37 | |
| 38 | typedef jint IntArgbBmPixelType; |
| 39 | typedef jint IntArgbBmDataType; |
| 40 | |
| 41 | #define IntArgbBmPixelStride 4 |
| 42 | |
| 43 | #define DeclareIntArgbBmLoadVars(PREFIX) |
| 44 | #define DeclareIntArgbBmStoreVars(PREFIX) |
| 45 | #define InitIntArgbBmLoadVars(PREFIX, pRasInfo) |
| 46 | #define SetIntArgbBmStoreVarsYPos(PREFIX, pRasInfo, y) |
| 47 | #define SetIntArgbBmStoreVarsXPos(PREFIX, pRasInfo, x) |
| 48 | #define InitIntArgbBmStoreVarsY(PREFIX, pRasInfo) |
| 49 | #define InitIntArgbBmStoreVarsX(PREFIX, pRasInfo) |
| 50 | #define NextIntArgbBmStoreVarsX(PREFIX) |
| 51 | #define NextIntArgbBmStoreVarsY(PREFIX) |
| 52 | #define DeclareIntArgbBmInitialLoadVars(pRasInfo, pRas, PREFIX, x) |
| 53 | #define InitialLoadIntArgbBm(pRas, PREFIX) |
| 54 | #define ShiftBitsIntArgbBm(PREFIX) |
| 55 | #define FinalStoreIntArgbBm(pRas, PREFIX) |
| 56 | |
| 57 | #define IntArgbBmXparLutEntry 0 |
| 58 | #define IntArgbBmIsXparLutEntry(pix) (pix == 0) |
| 59 | #define StoreIntArgbBmNonXparFromArgb(pRas, PREFIX, x, argb) \ |
| 60 | StoreIntArgbBmFrom1IntArgb(pRas, PREFIX, x, argb) |
| 61 | |
| 62 | #define DeclareIntArgbBmData(PREFIX) \ |
| 63 | jint PREFIX; |
| 64 | |
| 65 | #define LoadIntArgbBmData(pRas, LOADPREFIX, x, DATAPREFIX) \ |
| 66 | (DATAPREFIX) = (pRas)[x] |
| 67 | |
| 68 | #define IsIntArgbBmDataTransparent(DATAPREFIX) \ |
| 69 | (((DATAPREFIX) >> 24) == 0) |
| 70 | |
| 71 | #define ConvertIntArgbBmDataTo1IntRgb(DATAPREFIX, rgb) \ |
| 72 | (rgb) = (DATAPREFIX) |
| 73 | |
| 74 | #define IntArgbBmPixelFromArgb(pixel, rgb, pRasInfo) \ |
| 75 | (pixel) = ((rgb) | (((rgb) >> 31) << 24)) |
| 76 | |
| 77 | #define StoreIntArgbBmPixel(pRas, x, pixel) \ |
| 78 | (pRas)[x] = (pixel) |
| 79 | |
| 80 | #define DeclareIntArgbBmPixelData(PREFIX) |
| 81 | |
| 82 | #define ExtractIntArgbBmPixelData(PIXEL, PREFIX) |
| 83 | |
| 84 | #define StoreIntArgbBmPixelData(pPix, x, pixel, PREFIX) \ |
| 85 | (pPix)[x] = (pixel) |
| 86 | |
| 87 | |
| 88 | #define LoadIntArgbBmTo1IntRgb(pRas, PREFIX, x, rgb) \ |
| 89 | (rgb) = (pRas)[x] |
| 90 | |
| 91 | #define LoadIntArgbBmTo1IntArgb(pRas, PREFIX, x, argb) \ |
| 92 | do { \ |
| 93 | (argb) = (pRas)[x]; \ |
| 94 | (argb) = (((argb) << 7) >> 7); \ |
| 95 | } while (0) |
| 96 | |
| 97 | #define LoadIntArgbBmTo3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
| 98 | do { \ |
| 99 | jint pixel = (pRas)[x]; \ |
| 100 | ExtractIntDcmComponentsX123(pixel, r, g, b); \ |
| 101 | } while (0) |
| 102 | |
| 103 | #define LoadIntArgbBmTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
| 104 | do { \ |
| 105 | jint pixel = (pRas)[x]; \ |
| 106 | pixel = ((pixel << 7) >> 7); \ |
| 107 | ExtractIntDcmComponents1234(pixel, a, r, g, b); \ |
| 108 | } while (0) |
| 109 | |
| 110 | #define StoreIntArgbBmFrom1IntRgb(pRas, PREFIX, x, rgb) \ |
| 111 | (pRas)[x] = 0x01000000 | (rgb) |
| 112 | |
| 113 | #define StoreIntArgbBmFrom1IntArgb(pRas, PREFIX, x, argb) \ |
| 114 | (pRas)[x] = ((argb) | (((argb) >> 31) << 24)) |
| 115 | |
| 116 | #define StoreIntArgbBmFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
| 117 | StoreIntArgbBmFrom4ByteArgb(pRas, PREFIX, x, 0x01, r, g, b) |
| 118 | |
| 119 | #define StoreIntArgbBmFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
| 120 | (pRas)[x] = ComposeIntDcmComponents1234((a >> 7), r, g, b) |
| 121 | |
| 122 | #define CopyIntArgbBmToIntArgbPre(pRGB, i, PREFIX, pRow, x) \ |
| 123 | do { \ |
| 124 | jint argb = (pRow)[x]; \ |
| 125 | argb = ((argb << 7) >> 7); /* Propagate alpha bit */ \ |
| 126 | argb &= (argb >> 24); /* Mask off colors if alpha=0 */ \ |
| 127 | (pRGB)[i] = argb; \ |
| 128 | } while (0) |
| 129 | |
| 130 | |
| 131 | #define DeclareIntArgbBmAlphaLoadData(PREFIX) \ |
| 132 | jint PREFIX; |
| 133 | |
| 134 | #define InitIntArgbBmAlphaLoadData(PREFIX, pRasInfo) |
| 135 | |
| 136 | #define LoadAlphaFromIntArgbBmFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \ |
| 137 | do { \ |
| 138 | PREFIX = (pRas)[0]; \ |
| 139 | PREFIX = ((PREFIX << 7) >> 7); \ |
| 140 | COMP_PREFIX ## A = ((juint) PREFIX) >> 24; \ |
| 141 | } while (0) |
| 142 | |
| 143 | #define LoadAlphaFromIntArgbBmFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \ |
| 144 | LoadAlphaFromIntArgbBmFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) |
| 145 | |
| 146 | #define LoadAlphaFromIntArgbBmFor1ShortGray(pRas, PREFIX, COMP_PREFIX) \ |
| 147 | do { \ |
| 148 | LoadAlphaFromIntArgbBmFor4ByteArgb(pRas, PREFIX, COMP_PREFIX); \ |
| 149 | COMP_PREFIX ## A = (COMP_PREFIX ## A << 8) + COMP_PREFIX ## A; \ |
| 150 | } while (0) |
| 151 | |
| 152 | #define Postload4ByteArgbFromIntArgbBm(pRas, PREFIX, COMP_PREFIX) \ |
| 153 | do { \ |
| 154 | COMP_PREFIX ## R = (PREFIX >> 16) & 0xff; \ |
| 155 | COMP_PREFIX ## G = (PREFIX >> 8) & 0xff; \ |
| 156 | COMP_PREFIX ## B = (PREFIX >> 0) & 0xff; \ |
| 157 | } while (0) |
| 158 | |
| 159 | #define Postload1ByteGrayFromIntArgb(pRas, PREFIX, COMP_PREFIX) \ |
| 160 | do { \ |
| 161 | int r, g, b; \ |
| 162 | ExtractIntDcmComponentsX123(PREFIX, r, g, b); \ |
| 163 | COMP_PREFIX ## G = ComposeByteGrayFrom3ByteRgb(r, g, b); \ |
| 164 | } while (0) |
| 165 | |
| 166 | #define Postload1ShortGrayFromIntArgb(pRas, PREFIX, COMP_PREFIX) \ |
| 167 | do { \ |
| 168 | int r, g, b; \ |
| 169 | ExtractIntDcmComponentsX123(PREFIX, r, g, b); \ |
| 170 | COMP_PREFIX ## G = ComposeUshortGrayFrom3ByteRgb(r, g, b); \ |
| 171 | } while (0) |
| 172 | |
| 173 | |
| 174 | #define IntArgbBmIsPremultiplied 0 |
| 175 | |
| 176 | #define StoreIntArgbBmFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \ |
| 177 | StoreIntArgbBmFrom4ByteArgb(pRas, PREFIX, x, \ |
| 178 | COMP_PREFIX ## A, COMP_PREFIX ## R, \ |
| 179 | COMP_PREFIX ## G, COMP_PREFIX ## B) |
| 180 | |
| 181 | /* |
| 182 | * Extract ## STRATEGY ## CompsAndAlphaFromArgb(pixel, COMP_PREFIX) |
| 183 | */ |
| 184 | #define Extract3ByteRgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ |
| 185 | ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, COMP_PREFIX ## R, \ |
| 186 | COMP_PREFIX ## G, COMP_PREFIX ## B) |
| 187 | |
| 188 | #define Extract4ByteArgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ |
| 189 | Extract3ByteRgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX) |
| 190 | |
| 191 | #define Extract1ByteGrayCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ |
| 192 | do { \ |
| 193 | int r, g, b; \ |
| 194 | ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, r, g, b); \ |
| 195 | COMP_PREFIX ## G = ComposeByteGrayFrom3ByteRgb(r, g, b); \ |
| 196 | } while (0) |
| 197 | |
| 198 | #define Extract1ShortGrayCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ |
| 199 | do { \ |
| 200 | int r, g, b; \ |
| 201 | ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, r, g, b); \ |
| 202 | COMP_PREFIX ## G = ComposeUshortGrayFrom3ByteRgb(r, g, b); \ |
| 203 | COMP_PREFIX ## A = (COMP_PREFIX ## A << 8) + COMP_PREFIX ## A; \ |
| 204 | } while (0) |
| 205 | |
| 206 | #endif /* IntArgbBm_h_Included */ |