1 /* 2 * Copyright (c) 2000, 2013, 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 IntArgb_h_Included 27 #define IntArgb_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 "IntArgb". 36 */ 37 38 typedef jint IntArgbPixelType; 39 typedef jint IntArgbDataType; 40 41 #define IntArgbIsOpaque 0 42 43 #define IntArgbPixelStride 4 44 45 #define DeclareIntArgbLoadVars(PREFIX) 46 #define DeclareIntArgbStoreVars(PREFIX) 47 #define InitIntArgbLoadVars(PREFIX, pRasInfo) 48 #define SetIntArgbStoreVarsYPos(PREFIX, pRasInfo, y) 49 #define SetIntArgbStoreVarsXPos(PREFIX, pRasInfo, x) 50 #define InitIntArgbStoreVarsY(PREFIX, pRasInfo) 51 #define InitIntArgbStoreVarsX(PREFIX, pRasInfo) 52 #define NextIntArgbStoreVarsX(PREFIX) 53 #define NextIntArgbStoreVarsY(PREFIX) 54 #define DeclareIntArgbInitialLoadVars(pRasInfo, pRas, PREFIX, x) 55 #define InitialLoadIntArgb(pRas, PREFIX) 56 #define ShiftBitsIntArgb(PREFIX) 57 #define FinalStoreIntArgb(pRas, PREFIX) 58 59 #define IntArgbPixelFromArgb(pixel, rgb, pRasInfo) \ 60 (pixel) = (rgb) 61 62 #define StoreIntArgbPixel(pRas, x, pixel) \ 63 (pRas)[x] = (pixel) 64 65 #define DeclareIntArgbPixelData(PREFIX) 66 67 #define ExtractIntArgbPixelData(PIXEL, PREFIX) 68 69 #define StoreIntArgbPixelData(pPix, x, pixel, PREFIX) \ 70 (pPix)[x] = (pixel) 71 72 73 #define LoadIntArgbTo1IntRgb(pRas, PREFIX, x, rgb) \ 74 (rgb) = (pRas)[x] 75 76 #define LoadIntArgbTo1IntArgb(pRas, PREFIX, x, argb) \ 77 (argb) = (pRas)[x] 78 79 #define LoadIntArgbTo3ByteRgb(pRas, PREFIX, x, r, g, b) \ 80 do { \ 81 jint pixel = (pRas)[x]; \ 82 ExtractIntDcmComponentsX123(pixel, r, g, b); \ 83 } while (0) 84 85 #define LoadIntArgbTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ 86 do { \ 87 jint pixel = (pRas)[x]; \ 88 ExtractIntDcmComponents1234(pixel, a, r, g, b); \ 89 } while (0) 90 91 #define StoreIntArgbFrom1IntRgb(pRas, PREFIX, x, rgb) \ 92 (pRas)[x] = 0xff000000 | (rgb) 93 94 #define StoreIntArgbFrom1IntArgb(pRas, PREFIX, x, argb) \ 95 (pRas)[x] = (argb) 96 97 #define StoreIntArgbFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \ 98 StoreIntArgbFrom4ByteArgb(pRas, PREFIX, x, 0xff, r, g, b) 99 100 #define StoreIntArgbFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \ 101 (pRas)[x] = ComposeIntDcmComponents1234(a, r, g, b) 102 103 #define CopyIntArgbToIntArgbPre(pRGB, i, PREFIX, pRow, x) \ 104 do { \ 105 jint argb = (pRow)[x]; \ 106 jint a = URShift(argb, 24); \ 107 if (a == 0) { \ 108 argb = 0; \ 109 } else if (a < 0xff) { \ 110 jint r = (argb >> 16) & 0xff; \ 111 jint g = (argb >> 8) & 0xff; \ 112 jint b = (argb ) & 0xff; \ 113 r = MUL8(a, r); \ 114 g = MUL8(a, g); \ 115 b = MUL8(a, b); \ 116 argb = ComposeIntDcmComponents1234(a, r, g, b); \ 117 } \ 118 (pRGB)[i] = argb; \ 119 } while (0) 120 121 122 #define DeclareIntArgbAlphaLoadData(PREFIX) \ 123 jint PREFIX; 124 125 #define InitIntArgbAlphaLoadData(PREFIX, pRasInfo) \ 126 PREFIX = 0 127 128 #define LoadAlphaFromIntArgbFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \ 129 do { \ 130 PREFIX = (pRas)[0]; \ 131 COMP_PREFIX ## A = ((juint) PREFIX) >> 24; \ 132 } while (0) 133 134 #define LoadAlphaFromIntArgbFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \ 135 LoadAlphaFromIntArgbFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) 136 137 #define LoadAlphaFromIntArgbFor1ShortGray(pRas, PREFIX, COMP_PREFIX) \ 138 do { \ 139 LoadAlphaFromIntArgbFor4ByteArgb(pRas, PREFIX, COMP_PREFIX); \ 140 COMP_PREFIX ## A = (COMP_PREFIX ## A << 8) + COMP_PREFIX ## A; \ 141 } while (0) 142 143 #define Postload4ByteArgbFromIntArgb(pRas, PREFIX, COMP_PREFIX) \ 144 do { \ 145 COMP_PREFIX ## R = (PREFIX >> 16) & 0xff; \ 146 COMP_PREFIX ## G = (PREFIX >> 8) & 0xff; \ 147 COMP_PREFIX ## B = (PREFIX >> 0) & 0xff; \ 148 } while (0) 149 150 #define Postload1ByteGrayFromIntArgb(pRas, PREFIX, COMP_PREFIX) \ 151 do { \ 152 int r, g, b; \ 153 ExtractIntDcmComponentsX123(PREFIX, r, g, b); \ 154 COMP_PREFIX ## G = ComposeByteGrayFrom3ByteRgb(r, g, b); \ 155 } while (0) 156 157 #define Postload1ShortGrayFromIntArgb(pRas, PREFIX, COMP_PREFIX) \ 158 do { \ 159 int r, g, b; \ 160 ExtractIntDcmComponentsX123(PREFIX, r, g, b); \ 161 COMP_PREFIX ## G = ComposeUshortGrayFrom3ByteRgb(r, g, b); \ 162 } while (0) 163 164 165 #define IntArgbIsPremultiplied 0 166 167 #define DeclareIntArgbBlendFillVars(PREFIX) 168 169 #define ClearIntArgbBlendFillVars(PREFIX, argb) \ 170 argb = 0 171 172 #define InitIntArgbBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \ 173 argb = (COMP_PREFIX ## A << 24) | (argb & 0x00ffffff); \ 174 175 #define InitIntArgbBlendFillVarsPre(PREFIX, argb, COMP_PREFIX) 176 177 #define StoreIntArgbBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \ 178 (pRas)[x] = (argb) 179 180 #define StoreIntArgbFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \ 181 StoreIntArgbFrom4ByteArgb(pRas, PREFIX, x, \ 182 COMP_PREFIX ## A, COMP_PREFIX ## R, \ 183 COMP_PREFIX ## G, COMP_PREFIX ## B) 184 185 186 /* 187 * Extract ## STRATEGY ## CompsAndAlphaFromArgb(pixel, COMP_PREFIX) 188 */ 189 #define Extract3ByteRgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ 190 ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, COMP_PREFIX ## R, \ 191 COMP_PREFIX ## G, COMP_PREFIX ## B) 192 193 #define Extract4ByteArgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ 194 Extract3ByteRgbCompsAndAlphaFromArgb(pixel, COMP_PREFIX) 195 196 #define Extract1ByteGrayCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ 197 do { \ 198 int r, g, b; \ 199 ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, r, g, b); \ 200 COMP_PREFIX ## G = ComposeByteGrayFrom3ByteRgb(r, g, b); \ 201 } while (0) 202 203 #define Extract1ShortGrayCompsAndAlphaFromArgb(pixel, COMP_PREFIX) \ 204 do { \ 205 int r, g, b; \ 206 ExtractIntDcmComponents1234(pixel, COMP_PREFIX ## A, r, g, b); \ 207 COMP_PREFIX ## G = ComposeUshortGrayFrom3ByteRgb(r, g, b); \ 208 COMP_PREFIX ## A = (COMP_PREFIX ## A << 8) + COMP_PREFIX ## A; \ 209 } while (0) 210 211 #endif /* IntArgb_h_Included */