< prev index next >

src/java.desktop/share/native/libawt/java2d/loops/ByteIndexed.h

Print this page




  26 #ifndef ByteIndexed_h_Included
  27 #define ByteIndexed_h_Included
  28 
  29 #include "IntDcm.h"
  30 
  31 /*
  32  * This file contains macro and type definitions used by the macros in
  33  * LoopMacros.h to manipulate a surface of type "ByteIndexed".
  34  */
  35 
  36 typedef jubyte  ByteIndexedPixelType;
  37 typedef jubyte  ByteIndexedDataType;
  38 
  39 #define ByteIndexedPixelStride          1
  40 #define ByteIndexedBitsPerPixel         8
  41 
  42 #define DeclareByteIndexedLoadVars(PREFIX) \
  43     jint *PREFIX ## Lut;
  44 
  45 #define DeclareByteIndexedStoreVars(PREFIX) \
  46     int PREFIX ## XDither, PREFIX ## YDither; \
  47     char *PREFIX ## rerr, *PREFIX ## gerr, *PREFIX ## berr; \
  48     unsigned char *PREFIX ## InvLut;
  49 
  50 #define SetByteIndexedStoreVarsYPos(PREFIX, pRasInfo, LOC) \
  51     do { \
  52          PREFIX ## YDither = ((LOC & 7) << 3); \
  53     } while (0)
  54 
  55 #define SetByteIndexedStoreVarsXPos(PREFIX, pRasInfo, LOC) \
  56     do { \
  57         PREFIX ## rerr = (pRasInfo)->redErrTable + PREFIX ## YDither; \
  58         PREFIX ## gerr = (pRasInfo)->grnErrTable + PREFIX ## YDither; \
  59         PREFIX ## berr = (pRasInfo)->bluErrTable + PREFIX ## YDither; \
  60         PREFIX ## XDither = (LOC & 7); \
  61     } while (0)
  62 
  63 #define InitByteIndexedLoadVars(PREFIX, pRasInfo) \
  64     PREFIX ## Lut = (pRasInfo)->lutBase
  65 
  66 /* REMIND Could collapse Init..Store..X and Init..Store..Y into one Init
  67  * and factor out the Set.. macros.
  68  */
  69 #define InitByteIndexedStoreVarsY(PREFIX, pRasInfo) \
  70     do { \
  71         SetByteIndexedStoreVarsYPos(PREFIX, pRasInfo, (pRasInfo)->bounds.y1); \
  72         PREFIX ## InvLut = (pRasInfo)->invColorTable; \

  73     } while (0)
  74 
  75 #define InitByteIndexedStoreVarsX(PREFIX, pRasInfo) \
  76     SetByteIndexedStoreVarsXPos(PREFIX, pRasInfo, (pRasInfo)->bounds.x1);
  77 
  78 
  79 #define NextByteIndexedStoreVarsX(PREFIX) \
  80     PREFIX ## XDither = (PREFIX ## XDither + 1) & 7
  81 
  82 #define NextByteIndexedStoreVarsY(PREFIX) \
  83     PREFIX ## YDither = (PREFIX ## YDither + (1 << 3)) & (7 << 3)
  84 
  85 typedef jubyte  ByteIndexedBmPixelType;
  86 typedef jubyte  ByteIndexedBmDataType;
  87 
  88 #define ByteIndexedBmPixelStride        1
  89 #define ByteIndexedBmBitsPerPixel       8
  90 
  91 #define DeclareByteIndexedBmLoadVars    DeclareByteIndexedLoadVars
  92 #define DeclareByteIndexedBmStoreVars   DeclareByteIndexedStoreVars


 151     do { \
 152         if (((R|G|B) >> 8) != 0) { \
 153             ByteClamp1Component(R); \
 154             ByteClamp1Component(G); \
 155             ByteClamp1Component(B); \
 156         } \
 157     } while (0)
 158 
 159 #define StoreByteIndexedFrom1IntRgb(pRas, PREFIX, x, rgb) \
 160     do { \
 161         int r, g, b; \
 162         ExtractIntDcmComponentsX123(rgb, r, g, b); \
 163         StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \
 164     } while (0)
 165 
 166 #define StoreByteIndexedFrom1IntArgb(pRas, PREFIX, x, argb) \
 167     StoreByteIndexedFrom1IntRgb(pRas, PREFIX, x, argb)
 168 
 169 #define StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
 170     do { \




 171         r += PREFIX ## rerr[PREFIX ## XDither]; \
 172         g += PREFIX ## gerr[PREFIX ## XDither]; \
 173         b += PREFIX ## berr[PREFIX ## XDither]; \

 174         ByteClamp3Components(r, g, b); \
 175         (pRas)[x] = SurfaceData_InvColorMap(PREFIX ## InvLut, r, g, b); \
 176     } while (0)
 177 
 178 #define StoreByteIndexedFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
 179     StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
 180 
 181 #define CopyByteIndexedToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
 182     do { \
 183         jint argb = PREFIX ## Lut[pRow[x]]; \
 184         jint a = URShift(argb, 24); \
 185         if (a == 0) { \
 186             argb = 0; \
 187         } else if (a < 0xff) { \
 188             jint r = (argb >> 16) & 0xff; \
 189             jint g = (argb >>  8) & 0xff; \
 190             jint b = (argb      ) & 0xff; \
 191             r = MUL8(a, r); \
 192             g = MUL8(a, g); \
 193             b = MUL8(a, b); \




  26 #ifndef ByteIndexed_h_Included
  27 #define ByteIndexed_h_Included
  28 
  29 #include "IntDcm.h"
  30 
  31 /*
  32  * This file contains macro and type definitions used by the macros in
  33  * LoopMacros.h to manipulate a surface of type "ByteIndexed".
  34  */
  35 
  36 typedef jubyte  ByteIndexedPixelType;
  37 typedef jubyte  ByteIndexedDataType;
  38 
  39 #define ByteIndexedPixelStride          1
  40 #define ByteIndexedBitsPerPixel         8
  41 
  42 #define DeclareByteIndexedLoadVars(PREFIX) \
  43     jint *PREFIX ## Lut;
  44 
  45 #define DeclareByteIndexedStoreVars(PREFIX) \
  46     int PREFIX ## XDither, PREFIX ## YDither, PREFIX ## RepPrims; \
  47     char *PREFIX ## rerr, *PREFIX ## gerr, *PREFIX ## berr; \
  48     unsigned char *PREFIX ## InvLut;
  49 
  50 #define SetByteIndexedStoreVarsYPos(PREFIX, pRasInfo, LOC) \
  51     do { \
  52          PREFIX ## YDither = ((LOC & 7) << 3); \
  53     } while (0)
  54 
  55 #define SetByteIndexedStoreVarsXPos(PREFIX, pRasInfo, LOC) \
  56     do { \
  57         PREFIX ## rerr = (pRasInfo)->redErrTable + PREFIX ## YDither; \
  58         PREFIX ## gerr = (pRasInfo)->grnErrTable + PREFIX ## YDither; \
  59         PREFIX ## berr = (pRasInfo)->bluErrTable + PREFIX ## YDither; \
  60         PREFIX ## XDither = (LOC & 7); \
  61     } while (0)
  62 
  63 #define InitByteIndexedLoadVars(PREFIX, pRasInfo) \
  64     PREFIX ## Lut = (pRasInfo)->lutBase
  65 
  66 /* REMIND Could collapse Init..Store..X and Init..Store..Y into one Init
  67  * and factor out the Set.. macros.
  68  */
  69 #define InitByteIndexedStoreVarsY(PREFIX, pRasInfo) \
  70     do { \
  71         SetByteIndexedStoreVarsYPos(PREFIX, pRasInfo, (pRasInfo)->bounds.y1); \
  72         PREFIX ## InvLut = (pRasInfo)->invColorTable; \
  73         PREFIX ## RepPrims = (pRasInfo)->representsPrimaries; \
  74     } while (0)
  75 
  76 #define InitByteIndexedStoreVarsX(PREFIX, pRasInfo) \
  77     SetByteIndexedStoreVarsXPos(PREFIX, pRasInfo, (pRasInfo)->bounds.x1);
  78 
  79 
  80 #define NextByteIndexedStoreVarsX(PREFIX) \
  81     PREFIX ## XDither = (PREFIX ## XDither + 1) & 7
  82 
  83 #define NextByteIndexedStoreVarsY(PREFIX) \
  84     PREFIX ## YDither = (PREFIX ## YDither + (1 << 3)) & (7 << 3)
  85 
  86 typedef jubyte  ByteIndexedBmPixelType;
  87 typedef jubyte  ByteIndexedBmDataType;
  88 
  89 #define ByteIndexedBmPixelStride        1
  90 #define ByteIndexedBmBitsPerPixel       8
  91 
  92 #define DeclareByteIndexedBmLoadVars    DeclareByteIndexedLoadVars
  93 #define DeclareByteIndexedBmStoreVars   DeclareByteIndexedStoreVars


 152     do { \
 153         if (((R|G|B) >> 8) != 0) { \
 154             ByteClamp1Component(R); \
 155             ByteClamp1Component(G); \
 156             ByteClamp1Component(B); \
 157         } \
 158     } while (0)
 159 
 160 #define StoreByteIndexedFrom1IntRgb(pRas, PREFIX, x, rgb) \
 161     do { \
 162         int r, g, b; \
 163         ExtractIntDcmComponentsX123(rgb, r, g, b); \
 164         StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \
 165     } while (0)
 166 
 167 #define StoreByteIndexedFrom1IntArgb(pRas, PREFIX, x, argb) \
 168     StoreByteIndexedFrom1IntRgb(pRas, PREFIX, x, argb)
 169 
 170 #define StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
 171     do { \
 172         if (!(((r == 0) || (r == 255)) && \
 173               ((g == 0) || (g == 255)) && \
 174               ((b == 0) || (b == 255)) && \
 175               PREFIX ## RepPrims)) { \
 176             r += PREFIX ## rerr[PREFIX ## XDither]; \
 177             g += PREFIX ## gerr[PREFIX ## XDither]; \
 178             b += PREFIX ## berr[PREFIX ## XDither]; \
 179         } \
 180         ByteClamp3Components(r, g, b); \
 181         (pRas)[x] = SurfaceData_InvColorMap(PREFIX ## InvLut, r, g, b); \
 182     } while (0)
 183 
 184 #define StoreByteIndexedFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
 185     StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
 186 
 187 #define CopyByteIndexedToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
 188     do { \
 189         jint argb = PREFIX ## Lut[pRow[x]]; \
 190         jint a = URShift(argb, 24); \
 191         if (a == 0) { \
 192             argb = 0; \
 193         } else if (a < 0xff) { \
 194             jint r = (argb >> 16) & 0xff; \
 195             jint g = (argb >>  8) & 0xff; \
 196             jint b = (argb      ) & 0xff; \
 197             r = MUL8(a, r); \
 198             g = MUL8(a, g); \
 199             b = MUL8(a, b); \


< prev index next >