< 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                 MultiplyAndStore4ByteArgbComps(res, resA, SRC_PREFIX); \
1699             } else { \
1700                 if (SRC_PREFIX ## A == MaxValFor4ByteArgb) { \
1701                     Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
1702                                               FG_PIXEL, PREFIX); \
1703                     break; \
1704                 } \
1705                 resA = SRC_PREFIX ## A; \
1706                 MultiplyAndStore4ByteArgbComps(res, \
1707                                                SRC_PREFIX ## A, \
1708                                                SRC_PREFIX); \
1709             } \
1710             if (resA != MaxValFor4ByteArgb) { \
1711                 DeclareAndInvertAlphaVarFor4ByteArgb(dstF, resA) \
1712                 DeclareAndClearAlphaVarFor4ByteArgb(dstA) \
1713                 DeclareCompVarsFor4ByteArgb(dst) \
1714                 DeclareCompVarsFor4ByteArgb(tmp) \
1715                 if (!(DST ## IsPremultiplied)) { \
1716                     Load ## DST ## To4ByteArgb(DST_PTR, pix, PIXEL_INDEX, \
1717                                                dstA, dstR, dstG, dstB); \
1718                     Store4ByteArgbCompsUsingOp(tmp, =, dst); \
1719                 } else { \
1720                     Declare ## DST ## AlphaLoadData(DstPix) \
1721                     jint pixelOffset = PIXEL_INDEX * (DST ## PixelStride); \
1722                     DST ## DataType *pixelAddress = PtrAddBytes(DST_PTR, \
1723                                                                 pixelOffset); \
1724                     LoadAlphaFrom ## DST ## For4ByteArgb(pixelAddress, \
1725                                                          DstPix, \
1726                                                          dst); \
1727                     Postload4ByteArgbFrom ## DST(pixelAddress, \
1728                                                  DstPix, \
1729                                                  tmp); \
1730                 } \
1731                 if (dstA) { \
1732                     dstA = MultiplyAlphaFor4ByteArgb(dstF, dstA); \
1733                     resA += dstA; \
1734                     DeclareAndInit ## DST ## SrcOverDstBlendFactor(dstF, \
1735                                                                    dstA, \
1736                                                                    blendF); \
1737                     if (blendF != MaxValFor4ByteArgb) { \
1738                         MultiplyAndStore4ByteArgbComps(tmp, \
1739                                                        blendF, \
1740                                                        tmp); \
1741                     } \
1742                     Store4ByteArgbCompsUsingOp(res, +=, tmp); \
1743                 } \
1744             } \
1745             if (!(DST ## IsOpaque) && \
1746                 !(DST ## IsPremultiplied) && resA && \
1747                 resA < MaxValFor4ByteArgb) \
1748             { \
1749                 DivideAndStore4ByteArgbComps(res, res, resA); \
1750             } \
1751             Store ## DST ## From4ByteArgbComps(DST_PTR, pix, \
1752                                                PIXEL_INDEX, res); \




1753         } \
1754     } while (0);
1755 
1756 #define GlyphListAABlend1ByteGray(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
1757                                   FG_PIXEL, PREFIX, SRC_PREFIX) \
1758    do { \
1759         DeclareCompVarsFor1ByteGray(dst) \
1760         jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
1761         if (mixValSrc) { \
1762             if (mixValSrc < 255) { \
1763                 jint mixValDst = 255 - mixValSrc; \
1764                 Load ## DST ## To1ByteGray(DST_PTR, pix, PIXEL_INDEX, \
1765                                            dstG); \
1766                 MultMultAddAndStore1ByteGrayComps(dst, mixValDst, dst, \
1767                                                   mixValSrc, SRC_PREFIX); \
1768                 Store ## DST ## From1ByteGray(DST_PTR, pix, PIXEL_INDEX, \
1769                                               dstG); \
1770             } else { \
1771                 Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
1772                                           FG_PIXEL, PREFIX); \


< prev index next >