< prev index next >

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

Print this page




1651                                  FG_PIXEL, PREFIX, SRC_PREFIX) \
1652    do { \
1653         DeclareCompVarsFor3ByteRgb(dst) \
1654         jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
1655         if (mixValSrc) { \
1656             if (mixValSrc < 255) { \
1657                 jint mixValDst = 255 - mixValSrc; \
1658                 Load ## DST ## To3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
1659                                           dstR, dstG, dstB); \
1660                 MultMultAddAndStore3ByteRgbComps(dst, mixValDst, dst, \
1661                                                  mixValSrc, SRC_PREFIX); \
1662                 Store ## DST ## From3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
1663                                              dstR, dstG, dstB); \
1664             } else { \
1665                 Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
1666                                           FG_PIXEL, PREFIX); \
1667             } \
1668         } \
1669     } while (0);
1670 

















1671 #define GlyphListAABlend4ByteArgb(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
1672                                   FG_PIXEL, PREFIX, SRC_PREFIX) \
1673    do { \
1674         DeclareAlphaVarFor4ByteArgb(dstA) \
1675         DeclareCompVarsFor4ByteArgb(dst) \
1676         jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
1677         if (mixValSrc) { \
1678             if (mixValSrc < 255) { \
1679                 jint mixValDst = 255 - mixValSrc; \











1680                 Load ## DST ## To4ByteArgb(DST_PTR, pix, PIXEL_INDEX, \
1681                                            dstA, dstR, dstG, dstB); \
1682                 dstA = MUL8(dstA, mixValDst) + \
1683                        MUL8(SRC_PREFIX ## A, mixValSrc); \
1684                 MultMultAddAndStore4ByteArgbComps(dst, mixValDst, dst, \
1685                                                   mixValSrc, SRC_PREFIX); \
1686                 if (!(DST ## IsOpaque) && \
1687                     !(DST ## IsPremultiplied) && dstA && dstA < 255) { \
1688                     DivideAndStore4ByteArgbComps(dst, dst, dstA); \

















1689                 } \
1690                 Store ## DST ## From4ByteArgbComps(DST_PTR, pix, \
1691                                                    PIXEL_INDEX, dst); \
1692             } else { \
1693                 Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
1694                                           FG_PIXEL, PREFIX); \

1695             } \








1696         } \
1697     } while (0);
1698 
1699 #define GlyphListAABlend1ByteGray(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
1700                                   FG_PIXEL, PREFIX, SRC_PREFIX) \
1701    do { \
1702         DeclareCompVarsFor1ByteGray(dst) \
1703         jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
1704         if (mixValSrc) { \
1705             if (mixValSrc < 255) { \
1706                 jint mixValDst = 255 - mixValSrc; \
1707                 Load ## DST ## To1ByteGray(DST_PTR, pix, PIXEL_INDEX, \
1708                                            dstG); \
1709                 MultMultAddAndStore1ByteGrayComps(dst, mixValDst, dst, \
1710                                                   mixValSrc, SRC_PREFIX); \
1711                 Store ## DST ## From1ByteGray(DST_PTR, pix, PIXEL_INDEX, \
1712                                               dstG); \
1713             } else { \
1714                 Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
1715                                           FG_PIXEL, PREFIX); \




1651                                  FG_PIXEL, PREFIX, SRC_PREFIX) \
1652    do { \
1653         DeclareCompVarsFor3ByteRgb(dst) \
1654         jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
1655         if (mixValSrc) { \
1656             if (mixValSrc < 255) { \
1657                 jint mixValDst = 255 - mixValSrc; \
1658                 Load ## DST ## To3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
1659                                           dstR, dstG, dstB); \
1660                 MultMultAddAndStore3ByteRgbComps(dst, mixValDst, dst, \
1661                                                  mixValSrc, SRC_PREFIX); \
1662                 Store ## DST ## From3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
1663                                              dstR, dstG, dstB); \
1664             } else { \
1665                 Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
1666                                           FG_PIXEL, PREFIX); \
1667             } \
1668         } \
1669     } while (0);
1670 
1671 /*
1672  * Antialiased glyph drawing results in artifacts around the character edges
1673  * when text is drawn ontop of translucent background color. The standard
1674  * blending equation for two colors:
1675  * destColor = srcColor * glyphAlpha + destColor * (1 - glyphAlpha)
1676  * works only when srcColor and destColor are opaque. For translucent srcColor
1677  * and destColor, the respective alpha components in each color will influence
1678  * the visibility of the color and the visibility of the color below it. Hence
1679  * the equation for blending is given as:
1680  * resA = srcAlpha + dstAlpha * (1 - srcAlpha)
1681  * resCol = (srcColor * srcAlpha + destColor * destAlpha * (1- srcAlpha))/resA
1682  * In addition, srcAlpha is multiplied with the glyphAlpha- that indicates the
1683  * grayscale mask value of the glyph being drawn. The combined result provides
1684  * smooth antialiased text on the buffer without any artifacts. Since the
1685  * logic is executed for every pixel in a glyph, the implementation is further
1686  * optimized to reduce computation and improve execution time.
1687  */
1688 #define GlyphListAABlend4ByteArgb(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
1689                                   FG_PIXEL, PREFIX, SRC_PREFIX) \
1690     do { \
1691         DeclareAlphaVarFor4ByteArgb(resA) \
1692         DeclareCompVarsFor4ByteArgb(res) \
1693         jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
1694         if (mixValSrc) { \
1695             if (mixValSrc != 0xff) { \
1696                 PromoteByteAlphaFor4ByteArgb(mixValSrc); \
1697                 resA = MultiplyAlphaFor4ByteArgb(mixValSrc, SRC_PREFIX ## A); \
1698             } else { \
1699                 resA = SRC_PREFIX ## A; \
1700             } \
1701             if (resA != MaxValFor4ByteArgb) { \
1702                 DeclareAndInvertAlphaVarFor4ByteArgb(dstF, resA) \
1703                 DeclareAndClearAlphaVarFor4ByteArgb(dstA) \
1704                 DeclareCompVarsFor4ByteArgb(dst) \
1705                 DeclareCompVarsFor4ByteArgb(tmp) \
1706                 MultiplyAndStore4ByteArgbComps(res, resA, SRC_PREFIX); \
1707                 if (!(DST ## IsPremultiplied)) { \
1708                     Load ## DST ## To4ByteArgb(DST_PTR, pix, PIXEL_INDEX, \
1709                                                dstA, dstR, dstG, dstB); \
1710                     Store4ByteArgbCompsUsingOp(tmp, =, dst); \
1711                 } else { \
1712                     Declare ## DST ## AlphaLoadData(DstPix) \
1713                     jint pixelOffset = PIXEL_INDEX * (DST ## PixelStride); \
1714                     DST ## DataType *pixelAddress = PtrAddBytes(DST_PTR, \
1715                                                                 pixelOffset); \
1716                     LoadAlphaFrom ## DST ## For4ByteArgb(pixelAddress, \
1717                                                          DstPix, \
1718                                                          dst); \
1719                     Postload4ByteArgbFrom ## DST(pixelAddress, \
1720                                                  DstPix, \
1721                                                  tmp); \
1722                 } \
1723                 if (dstA) { \
1724                     DeclareAlphaVarFor4ByteArgb(blendF) \
1725                     dstA = MultiplyAlphaFor4ByteArgb(dstF, dstA); \
1726                     resA += dstA; \
1727                     blendF = SrcOver ## DST ## BlendFactor(dstF, dstA); \
1728                     if (blendF != MaxValFor4ByteArgb) { \
1729                         MultiplyAndStore4ByteArgbComps(tmp, \
1730                                                        blendF, \
1731                                                        tmp); \
1732                     } \
1733                     Store4ByteArgbCompsUsingOp(res, +=, tmp); \
1734                 } \


1735             } else { \
1736                 Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
1737                                           FG_PIXEL, PREFIX); \
1738                 break; \
1739             } \
1740             if (!(DST ## IsOpaque) && \
1741                 !(DST ## IsPremultiplied) && resA && \
1742                 resA < MaxValFor4ByteArgb) \
1743             { \
1744                 DivideAndStore4ByteArgbComps(res, res, resA); \
1745             } \
1746             Store ## DST ## From4ByteArgbComps(DST_PTR, pix, \
1747                                                PIXEL_INDEX, res); \
1748         } \
1749     } while (0);
1750 
1751 #define GlyphListAABlend1ByteGray(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
1752                                   FG_PIXEL, PREFIX, SRC_PREFIX) \
1753    do { \
1754         DeclareCompVarsFor1ByteGray(dst) \
1755         jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
1756         if (mixValSrc) { \
1757             if (mixValSrc < 255) { \
1758                 jint mixValDst = 255 - mixValSrc; \
1759                 Load ## DST ## To1ByteGray(DST_PTR, pix, PIXEL_INDEX, \
1760                                            dstG); \
1761                 MultMultAddAndStore1ByteGrayComps(dst, mixValDst, dst, \
1762                                                   mixValSrc, SRC_PREFIX); \
1763                 Store ## DST ## From1ByteGray(DST_PTR, pix, PIXEL_INDEX, \
1764                                               dstG); \
1765             } else { \
1766                 Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
1767                                           FG_PIXEL, PREFIX); \


< prev index next >