/jdk/src/share/native/sun/java2d/loops/ByteIndexed.h

https://github.com/Morriar/ProxyJDK · C Header · 228 lines · 151 code · 46 blank · 31 comment · 22 complexity · 329cb1d84cdb4506f6c2b8f320bd30b8 MD5 · raw file

  1. /*
  2. * Copyright (c) 2000, 2006, 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. #ifndef ByteIndexed_h_Included
  26. #define ByteIndexed_h_Included
  27. #include "IntDcm.h"
  28. /*
  29. * This file contains macro and type definitions used by the macros in
  30. * LoopMacros.h to manipulate a surface of type "ByteIndexed".
  31. */
  32. typedef jubyte ByteIndexedPixelType;
  33. typedef jubyte ByteIndexedDataType;
  34. #define ByteIndexedPixelStride 1
  35. #define ByteIndexedBitsPerPixel 8
  36. #define DeclareByteIndexedLoadVars(PREFIX) \
  37. jint *PREFIX ## Lut;
  38. #define DeclareByteIndexedStoreVars(PREFIX) \
  39. int PREFIX ## XDither, PREFIX ## YDither; \
  40. char *PREFIX ## rerr, *PREFIX ## gerr, *PREFIX ## berr; \
  41. unsigned char *PREFIX ## InvLut;
  42. #define SetByteIndexedStoreVarsYPos(PREFIX, pRasInfo, LOC) \
  43. do { \
  44. PREFIX ## YDither = ((LOC & 7) << 3); \
  45. } while (0)
  46. #define SetByteIndexedStoreVarsXPos(PREFIX, pRasInfo, LOC) \
  47. do { \
  48. PREFIX ## rerr = (pRasInfo)->redErrTable + PREFIX ## YDither; \
  49. PREFIX ## gerr = (pRasInfo)->grnErrTable + PREFIX ## YDither; \
  50. PREFIX ## berr = (pRasInfo)->bluErrTable + PREFIX ## YDither; \
  51. PREFIX ## XDither = (LOC & 7); \
  52. } while (0)
  53. #define InitByteIndexedLoadVars(PREFIX, pRasInfo) \
  54. PREFIX ## Lut = (pRasInfo)->lutBase
  55. /* REMIND Could collapse Init..Store..X and Init..Store..Y into one Init
  56. * and factor out the Set.. macros.
  57. */
  58. #define InitByteIndexedStoreVarsY(PREFIX, pRasInfo) \
  59. do { \
  60. SetByteIndexedStoreVarsYPos(PREFIX, pRasInfo, (pRasInfo)->bounds.y1); \
  61. PREFIX ## InvLut = (pRasInfo)->invColorTable; \
  62. } while (0)
  63. #define InitByteIndexedStoreVarsX(PREFIX, pRasInfo) \
  64. SetByteIndexedStoreVarsXPos(PREFIX, pRasInfo, (pRasInfo)->bounds.x1);
  65. #define NextByteIndexedStoreVarsX(PREFIX) \
  66. PREFIX ## XDither = (PREFIX ## XDither + 1) & 7
  67. #define NextByteIndexedStoreVarsY(PREFIX) \
  68. PREFIX ## YDither = (PREFIX ## YDither + (1 << 3)) & (7 << 3)
  69. typedef jubyte ByteIndexedBmPixelType;
  70. typedef jubyte ByteIndexedBmDataType;
  71. #define ByteIndexedBmPixelStride 1
  72. #define ByteIndexedBmBitsPerPixel 8
  73. #define DeclareByteIndexedBmLoadVars DeclareByteIndexedLoadVars
  74. #define DeclareByteIndexedBmStoreVars DeclareByteIndexedStoreVars
  75. #define InitByteIndexedBmLoadVars InitByteIndexedLoadVars
  76. #define InitByteIndexedBmStoreVarsY InitByteIndexedStoreVarsY
  77. #define InitByteIndexedBmStoreVarsX InitByteIndexedStoreVarsX
  78. #define NextByteIndexedBmStoreVarsX NextByteIndexedStoreVarsX
  79. #define NextByteIndexedBmStoreVarsY NextByteIndexedStoreVarsY
  80. #define LoadByteIndexedBmTo1IntArgb LoadByteIndexedTo1IntArgb
  81. #define CopyByteIndexedBmToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
  82. do { \
  83. jint argb = PREFIX ## Lut[pRow[x]]; \
  84. (pRGB)[i] = argb & (argb >> 24); \
  85. } while (0)
  86. #define ByteIndexedXparLutEntry -1
  87. #define ByteIndexedIsXparLutEntry(pix) (pix < 0)
  88. #define StoreByteIndexedNonXparFromArgb StoreByteIndexedFrom1IntArgb
  89. #define StoreByteIndexedPixel(pRas, x, pixel) \
  90. ((pRas)[x] = (jubyte) (pixel))
  91. #define DeclareByteIndexedPixelData(PREFIX)
  92. #define ExtractByteIndexedPixelData(PIXEL, PREFIX)
  93. #define StoreByteIndexedPixelData(pPix, x, pixel, PREFIX) \
  94. (pPix)[x] = (jubyte) (pixel)
  95. #define ByteIndexedPixelFromArgb(pixel, rgb, pRasInfo) \
  96. do { \
  97. jint r, g, b; \
  98. ExtractIntDcmComponentsX123(rgb, r, g, b); \
  99. (pixel) = SurfaceData_InvColorMap((pRasInfo)->invColorTable, \
  100. r, g, b); \
  101. } while (0)
  102. #define LoadByteIndexedTo1IntRgb(pRas, PREFIX, x, rgb) \
  103. (rgb) = PREFIX ## Lut[pRas[x]]
  104. #define LoadByteIndexedTo1IntArgb(pRas, PREFIX, x, argb) \
  105. (argb) = PREFIX ## Lut[pRas[x]]
  106. #define LoadByteIndexedTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
  107. do { \
  108. jint rgb = PREFIX ## Lut[pRas[x]]; \
  109. ExtractIntDcmComponentsX123(rgb, r, g, b); \
  110. } while (0)
  111. #define LoadByteIndexedTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
  112. do { \
  113. jint argb = PREFIX ## Lut[pRas[x]]; \
  114. ExtractIntDcmComponents1234(argb, a, r, g, b); \
  115. } while (0)
  116. #define ByteClamp1Component(X) \
  117. do { if (((X) >> 8) != 0) {X = (~(X >> 31)) & 255; } } while (0)
  118. #define ByteClamp3Components(R, G, B) \
  119. do { \
  120. if (((R|G|B) >> 8) != 0) { \
  121. ByteClamp1Component(R); \
  122. ByteClamp1Component(G); \
  123. ByteClamp1Component(B); \
  124. } \
  125. } while (0)
  126. #define StoreByteIndexedFrom1IntRgb(pRas, PREFIX, x, rgb) \
  127. do { \
  128. int r, g, b; \
  129. ExtractIntDcmComponentsX123(rgb, r, g, b); \
  130. StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \
  131. } while (0)
  132. #define StoreByteIndexedFrom1IntArgb(pRas, PREFIX, x, argb) \
  133. StoreByteIndexedFrom1IntRgb(pRas, PREFIX, x, argb)
  134. #define StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
  135. do { \
  136. r += PREFIX ## rerr[PREFIX ## XDither]; \
  137. g += PREFIX ## gerr[PREFIX ## XDither]; \
  138. b += PREFIX ## berr[PREFIX ## XDither]; \
  139. ByteClamp3Components(r, g, b); \
  140. (pRas)[x] = SurfaceData_InvColorMap(PREFIX ## InvLut, r, g, b); \
  141. } while (0)
  142. #define StoreByteIndexedFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
  143. StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
  144. #define CopyByteIndexedToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
  145. do { \
  146. jint argb = PREFIX ## Lut[pRow[x]]; \
  147. jint a = URShift(argb, 24); \
  148. if (a == 0) { \
  149. argb = 0; \
  150. } else if (a < 0xff) { \
  151. jint r = (argb >> 16) & 0xff; \
  152. jint g = (argb >> 8) & 0xff; \
  153. jint b = (argb ) & 0xff; \
  154. r = MUL8(a, r); \
  155. g = MUL8(a, g); \
  156. b = MUL8(a, b); \
  157. argb = ComposeIntDcmComponents1234(a, r, g, b); \
  158. } \
  159. (pRGB)[i] = argb; \
  160. } while (0)
  161. #define DeclareByteIndexedAlphaLoadData(PREFIX) \
  162. jint *PREFIX ## Lut; \
  163. jint PREFIX ## rgb;
  164. #define InitByteIndexedAlphaLoadData(PREFIX, pRasInfo) \
  165. PREFIX ## Lut = (pRasInfo)->lutBase
  166. #define LoadAlphaFromByteIndexedFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \
  167. do { \
  168. PREFIX ## rgb = PREFIX ## Lut[(pRas)[0]]; \
  169. COMP_PREFIX ## A = ((juint) PREFIX ## rgb) >> 24; \
  170. } while (0)
  171. #define Postload4ByteArgbFromByteIndexed(pRas, PREFIX, COMP_PREFIX) \
  172. do { \
  173. COMP_PREFIX ## R = (PREFIX ## rgb >> 16) & 0xff; \
  174. COMP_PREFIX ## G = (PREFIX ## rgb >> 8) & 0xff; \
  175. COMP_PREFIX ## B = (PREFIX ## rgb >> 0) & 0xff; \
  176. } while (0)
  177. #define ByteIndexedIsPremultiplied 0
  178. #define StoreByteIndexedFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \
  179. StoreByteIndexedFrom4ByteArgb(pRas, PREFIX, x, \
  180. COMP_PREFIX ## A, COMP_PREFIX ## R, \
  181. COMP_PREFIX ## G, COMP_PREFIX ## B)
  182. #endif /* ByteIndexed_h_Included */