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