J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2000-2004 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 FourByteAbgr_h_Included |
| 27 | #define FourByteAbgr_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 "FourByteAbgr". |
| 32 | */ |
| 33 | |
| 34 | typedef jint FourByteAbgrPixelType; |
| 35 | typedef jubyte FourByteAbgrDataType; |
| 36 | |
| 37 | #define FourByteAbgrPixelStride 4 |
| 38 | |
| 39 | #define DeclareFourByteAbgrLoadVars(PREFIX) |
| 40 | #define DeclareFourByteAbgrStoreVars(PREFIX) |
| 41 | #define SetFourByteAbgrStoreVarsYPos(PREFIX, pRasInfo, y) |
| 42 | #define SetFourByteAbgrStoreVarsXPos(PREFIX, pRasInfo, x) |
| 43 | #define InitFourByteAbgrLoadVars(PREFIX, pRasInfo) |
| 44 | #define InitFourByteAbgrStoreVarsY(PREFIX, pRasInfo) |
| 45 | #define InitFourByteAbgrStoreVarsX(PREFIX, pRasInfo) |
| 46 | #define NextFourByteAbgrStoreVarsX(PREFIX) |
| 47 | #define NextFourByteAbgrStoreVarsY(PREFIX) |
| 48 | |
| 49 | |
| 50 | #define FourByteAbgrPixelFromArgb(pixel, rgb, pRasInfo) \ |
| 51 | (pixel) = (((rgb) << 8) | (((juint) (rgb)) >> 24)) |
| 52 | |
| 53 | #define StoreFourByteAbgrPixel(pRas, x, pixel) \ |
| 54 | do { \ |
| 55 | (pRas)[4*(x)+0] = (jubyte) ((pixel) >> 0); \ |
| 56 | (pRas)[4*(x)+1] = (jubyte) ((pixel) >> 8); \ |
| 57 | (pRas)[4*(x)+2] = (jubyte) ((pixel) >> 16); \ |
| 58 | (pRas)[4*(x)+3] = (jubyte) ((pixel) >> 24); \ |
| 59 | } while (0) |
| 60 | |
| 61 | #define DeclareFourByteAbgrPixelData(PREFIX) \ |
| 62 | jubyte PREFIX ## 0, PREFIX ## 1, PREFIX ## 2, PREFIX ## 3; |
| 63 | |
| 64 | #define ExtractFourByteAbgrPixelData(PIXEL, PREFIX) \ |
| 65 | do { \ |
| 66 | PREFIX ## 0 = (jubyte) (PIXEL >> 0); \ |
| 67 | PREFIX ## 1 = (jubyte) (PIXEL >> 8); \ |
| 68 | PREFIX ## 2 = (jubyte) (PIXEL >> 16); \ |
| 69 | PREFIX ## 3 = (jubyte) (PIXEL >> 24); \ |
| 70 | } while (0) |
| 71 | |
| 72 | #define StoreFourByteAbgrPixelData(pPix, x, pixel, PREFIX) \ |
| 73 | do { \ |
| 74 | pPix[4*x+0] = PREFIX ## 0; \ |
| 75 | pPix[4*x+1] = PREFIX ## 1; \ |
| 76 | pPix[4*x+2] = PREFIX ## 2; \ |
| 77 | pPix[4*x+3] = PREFIX ## 3; \ |
| 78 | } while (0) |
| 79 | |
| 80 | |
| 81 | #define LoadFourByteAbgrTo1IntRgb(pRas, PREFIX, x, rgb) \ |
| 82 | (rgb) = (((pRas)[4*(x)+1] << 0) | \ |
| 83 | ((pRas)[4*(x)+2] << 8) | \ |
| 84 | ((pRas)[4*(x)+3] << 16)) |
| 85 | |
| 86 | #define LoadFourByteAbgrTo1IntArgb(pRas, PREFIX, x, argb) \ |
| 87 | (argb) = (((pRas)[4*(x)+0] << 24) | \ |
| 88 | ((pRas)[4*(x)+1] << 0) | \ |
| 89 | ((pRas)[4*(x)+2] << 8) | \ |
| 90 | ((pRas)[4*(x)+3] << 16)) |
| 91 | |
| 92 | #define LoadFourByteAbgrTo3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
| 93 | do { \ |
| 94 | (b) = (pRas)[4*(x)+1]; \ |
| 95 | (g) = (pRas)[4*(x)+2]; \ |
| 96 | (r) = (pRas)[4*(x)+3]; \ |
| 97 | } while (0) |
| 98 | |
| 99 | #define LoadFourByteAbgrTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
| 100 | do { \ |
| 101 | (a) = (pRas)[4*(x)+0]; \ |
| 102 | LoadFourByteAbgrTo3ByteRgb(pRas, PREFIX, x, r, g, b); \ |
| 103 | } while (0) |
| 104 | |
| 105 | #define StoreFourByteAbgrFrom1IntRgb(pRas, PREFIX, x, rgb) \ |
| 106 | do { \ |
| 107 | (pRas)[4*(x)+0] = (jubyte) 0xff; \ |
| 108 | (pRas)[4*(x)+1] = (jubyte) ((rgb) >> 0); \ |
| 109 | (pRas)[4*(x)+2] = (jubyte) ((rgb) >> 8); \ |
| 110 | (pRas)[4*(x)+3] = (jubyte) ((rgb) >> 16); \ |
| 111 | } while (0) |
| 112 | |
| 113 | #define StoreFourByteAbgrFrom1IntArgb(pRas, PREFIX, x, argb) \ |
| 114 | do { \ |
| 115 | (pRas)[4*(x)+0] = (jubyte) ((argb) >> 24); \ |
| 116 | (pRas)[4*(x)+1] = (jubyte) ((argb) >> 0); \ |
| 117 | (pRas)[4*(x)+2] = (jubyte) ((argb) >> 8); \ |
| 118 | (pRas)[4*(x)+3] = (jubyte) ((argb) >> 16); \ |
| 119 | } while (0) |
| 120 | |
| 121 | #define StoreFourByteAbgrFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \ |
| 122 | StoreFourByteAbgrFrom4ByteArgb(pRas, PREFIX, x, 0xff, r, g, b) |
| 123 | |
| 124 | #define StoreFourByteAbgrFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ |
| 125 | do { \ |
| 126 | (pRas)[4*(x)+0] = (jubyte) (a); \ |
| 127 | (pRas)[4*(x)+1] = (jubyte) (b); \ |
| 128 | (pRas)[4*(x)+2] = (jubyte) (g); \ |
| 129 | (pRas)[4*(x)+3] = (jubyte) (r); \ |
| 130 | } while (0) |
| 131 | |
| 132 | #define CopyFourByteAbgrToIntArgbPre(pRGB, i, PREFIX, pRow, x) \ |
| 133 | do { \ |
| 134 | jint a = (pRow)[4*(x)+0]; \ |
| 135 | if (a != 0) { \ |
| 136 | jint b = (pRow)[4*(x)+1]; \ |
| 137 | jint g = (pRow)[4*(x)+2]; \ |
| 138 | jint r = (pRow)[4*(x)+3]; \ |
| 139 | if (a < 0xff) { \ |
| 140 | b = MUL8(a, b); \ |
| 141 | g = MUL8(a, g); \ |
| 142 | r = MUL8(a, r); \ |
| 143 | } \ |
| 144 | a = ComposeIntDcmComponents1234(a, r, g, b); \ |
| 145 | } \ |
| 146 | (pRGB)[i] = a; \ |
| 147 | } while (0) |
| 148 | |
| 149 | |
| 150 | #define DeclareFourByteAbgrAlphaLoadData(PREFIX) |
| 151 | #define InitFourByteAbgrAlphaLoadData(PREFIX, pRasInfo) |
| 152 | |
| 153 | #define LoadAlphaFromFourByteAbgrFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \ |
| 154 | COMP_PREFIX ## A = (pRas)[0] |
| 155 | |
| 156 | #define Postload4ByteArgbFromFourByteAbgr(pRas, PREFIX, COMP_PREFIX) \ |
| 157 | LoadFourByteAbgrTo3ByteRgb(pRas, PREFIX, 0, COMP_PREFIX ## R, \ |
| 158 | COMP_PREFIX ## G, COMP_PREFIX ## B) |
| 159 | |
| 160 | |
| 161 | #define FourByteAbgrIsPremultiplied 0 |
| 162 | |
| 163 | #define DeclareFourByteAbgrBlendFillVars(PREFIX) \ |
| 164 | jubyte PREFIX ## 0, PREFIX ## 1, PREFIX ## 2, PREFIX ## 3; |
| 165 | |
| 166 | #define ClearFourByteAbgrBlendFillVars(PREFIX, argb) \ |
| 167 | (PREFIX ## 0 = PREFIX ## 1 = PREFIX ## 2 = PREFIX ## 3 = 0) |
| 168 | |
| 169 | #define InitFourByteAbgrBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \ |
| 170 | do { \ |
| 171 | PREFIX ## 0 = (jubyte) COMP_PREFIX ## A; \ |
| 172 | PREFIX ## 1 = (jubyte) COMP_PREFIX ## B; \ |
| 173 | PREFIX ## 2 = (jubyte) COMP_PREFIX ## G; \ |
| 174 | PREFIX ## 3 = (jubyte) COMP_PREFIX ## R; \ |
| 175 | } while (0) |
| 176 | |
| 177 | #define InitFourByteAbgrBlendFillVarsPre(PREFIX, argb, COMP_PREFIX) |
| 178 | |
| 179 | #define StoreFourByteAbgrBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \ |
| 180 | do { \ |
| 181 | (pRas)[4*x+0] = PREFIX ## 0; \ |
| 182 | (pRas)[4*x+1] = PREFIX ## 1; \ |
| 183 | (pRas)[4*x+2] = PREFIX ## 2; \ |
| 184 | (pRas)[4*x+3] = PREFIX ## 3; \ |
| 185 | } while (0) |
| 186 | |
| 187 | #define StoreFourByteAbgrFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \ |
| 188 | StoreFourByteAbgrFrom4ByteArgb(pRas, PREFIX, x, \ |
| 189 | COMP_PREFIX ## A, COMP_PREFIX ## R, \ |
| 190 | COMP_PREFIX ## G, COMP_PREFIX ## B) |
| 191 | |
| 192 | #endif /* FourByteAbgr_h_Included */ |