<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hello Denis,<br>
      <br>
       I am not sure whether we should use
      'apple.awt.graphics.UseQuartz' property.<br>
       Probably we have to change the text antialiasing defaults for
      macosx instead.<br>
      <br>
       I am working on the issue with software loops. I will update the
      thread<br>
       with my findings.<br>
      <br>
      Thanks,<br>
      Andrew<br>
        <br>
      On 9/3/2014 3:32 PM, Denis Fokin wrote:<br>
    </div>
    <blockquote
      cite="mid:9A5D5D1C-F58F-4DFC-B327-9A9DB18B155E@gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <div>Hi Sergey and 2d team,</div>
      <div><br>
      </div>
      <div>I have rewritten the fix. It works fine for text rendered on
        window using OpenGL.</div>
      <div><br>
      </div>
      <div><a moz-do-not-send="true"
          href="http://web-dot.ru/openjdk/8023794/webrev.00/index.html">http://web-dot.ru/openjdk/8023794/webrev.00/index.html</a></div>
      <div><br>
      </div>
      <div>It is incomplete though. It does not work for rendering in a
        buffered image.</div>
      <div><br>
      </div>
      <div>Additionally, I have not tested the code on other platforms
        except MacOS X.</div>
      <div><br>
      </div>
      <div>To enable the antialiasing you should pass</div>
      <div><br>
      </div>
      <div>-Dapple.awt.graphics.UseQuartz=true</div>
      <div><br>
      </div>
      <div>to java.</div>
      <div><br>
      </div>
      <div>The current issue now is the glyph info bytes that are passed
        from CGGlyphImage to AATextRenderer.</div>
      <div><br>
      </div>
      <div>To render data we use DEFINE_SOLID_DRAWGLYPHLIST* macros.
        Basing on the macros a set of functions is generated for the
        next loops.</div>
      <div><span style="font-family: Menlo; font-size: 11px;"><br>
        </span></div>
      <div><span style="font-family: Menlo; font-size: 11px;">sun/java2d/loops/ByteGray.c</span></div>
      <div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/ByteIndexed.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/FourByteAbgr.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/FourByteAbgrPre.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/Index12Gray.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/Index8Gray.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/IntArgb.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/IntArgbBm.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/IntArgbPre.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/IntBgr.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/IntRgb.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/IntRgbx.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/LoopMacros.h</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/ThreeByteBgr.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/Ushort555Rgb.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/Ushort555Rgbx.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/Ushort565Rgb.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/UshortGray.c</div>
        <div style="margin: 0px; font-size: 11px; font-family: Menlo;">sun/java2d/loops/UshortIndexed.c</div>
      </div>
      <div><br>
      </div>
      <div>For instance, C preprocessor generates the next code for <span
          style="font-family: Menlo; font-size: 11px;">IntRgb.c</span></div>
      <div><span style="font-family: Menlo; font-size: 11px;"><br>
        </span></div>
      <div>
        <div><font face="Menlo"><span style="font-size: 11px;">void</span><span
              class="Apple-tab-span" style="font-size: 11px;
              white-space: pre;"> </span><span style="font-size: 11px;">IntRgbDrawGlyphListLCD(/*…*/</span></font><span
            style="font-size: 11px; font-family: Menlo;">){</span></div>
        <div><font face="Menlo"><span style="font-size: 11px;">  jint<span
                class="Apple-tab-span" style="white-space:pre"> </span>
               glyphCounter, bpp;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">  jint<span
                class="Apple-tab-span" style="white-space:pre"> </span>
               scan = pRasInfo->scanStride;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;"> 
              IntRgbDataType *pPix;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;"> 
              fprintf(__stderrp, "NAME_SOLID_DRAWGLYPHLISTLC\n");</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">  jint<span
                class="Apple-tab-span" style="white-space:pre"> </span>
               srcA;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">  jint<span
                class="Apple-tab-span" style="white-space:pre"> </span>
               srcR   , srcG, srcB;;;;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">  do {</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">   
              (srcB) = (argbcolor) & 0xff;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">   
              (srcG) = ((argbcolor) >> 8) & 0xff;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">   
              (srcR) = ((argbcolor) >> 16) & 0xff;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">   
              (srcA) = ((argbcolor) >> 24) & 0xff;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">  } while
              (0);;</span></font></div>
      </div>
      <div>// and so on…</div>
      <div><br>
      </div>
      <div>Looks like rgb loop expects to see 4 8-bit color channels per
        pixel.</div>
      <div><br>
      </div>
      <div>For now, I do not understand which contract should be
        honoured to meet DEFINE_SOLID_DRAWGLYPHLIST* expectations, i.e.
        how should I place bytes in GlyphInfo.</div>
      <div><br>
      </div>
      <div>May be it should be set somewhere in Java code.</div>
      <div><br>
      </div>
      <div>Could anyone share this knowledge with me?</div>
      <div><br>
      </div>
      <div>Thank you,</div>
      <div>    Denis.</div>
      <div><br>
      </div>
      <br>
      <div>
        <div>On 09 Jul 2014, at 19:22, Sergey Bylokhov <<a
            moz-do-not-send="true"
            href="mailto:Sergey.Bylokhov@oracle.com">Sergey.Bylokhov@oracle.com</a>>
          wrote:</div>
        <br class="Apple-interchange-newline">
        <blockquote type="cite">Hello, Denis.<br>
          Thanks for this research!<br>
          On 09.07.2014 15:13, Denis Fokin wrote:<br>
          <blockquote type="cite">The current version consist of three
            parts.<br>
            <br>
            1. We are rendering glyphs in offscreen images using Quartz
            functions. This does not work without
            kCGBitmapByteOrder32Host mask.<br>
          </blockquote>
          I assume LCD hint does not work? this looks good.<br>
          <blockquote type="cite"><br>
            2. We assume that subpixel antialiasing should not be  used
            on a non-opaque surface. As I understand the vImage  in
            CGLVolatileSurfaceManager is not related directly to our
            window. For a start, I have hardcoded Transparency.OPAQUE,
            but it requires much better understanding of the
            architecture to make a more proper solution.<br>
          </blockquote>
          It is related to the CGLOffScreenSurfaceData, which is used as
          a surface for VolatileImages. I check this code and looks like
          we ignore type of the ColorModel and create a transparent
          native texture anyway.<br>
          <blockquote type="cite"><br>
            3. When I started using CGGI_CopyImageFromCanvasToRGBInfo as
            a rendering mode, I had found that the little endian mode
            should be undefined. Again, it might be an improper way to
            do this.<br>
          </blockquote>
          It seems __LITTLE_ENDIAN__usage in this file should be
          checked.<br>
          <blockquote type="cite"><br>
            Thank you,<br>
              Denis.<br>
            <br>
            diff -r f87c5be90e01
            src/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java<br>
            <br>
            ---
            a/src/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.javaFri
            Jun 20 10:15:30 2014 -0700<br>
            <br>
            +++
            b/src/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.javaWed
            Jul 09 14:50:09 2014 +0400<br>
            <br>
            @@ -108,7 +108,7 @@<br>
            <br>
                        } else {<br>
            <br>
                            CGLGraphicsConfig gc =<br>
            <br>
            (CGLGraphicsConfig)vImg.getGraphicsConfig();<br>
            <br>
            -                ColorModel cm =
            gc.getColorModel(vImg.getTransparency());<br>
            <br>
            +                ColorModel cm =
            gc.getColorModel(Transparency.OPAQUE);<br>
            <br>
                            int type = vImg.getForcedAccelSurfaceType();<br>
            <br>
                            // if acceleration type is forced (type !=
            UNDEFINED) then<br>
            <br>
                            // use the forced type, otherwise choose one
            based on caps<br>
            <br>
            diff -r f87c5be90e01
            src/macosx/native/sun/font/CGGlyphImages.m<br>
            <br>
            --- a/src/macosx/native/sun/font/CGGlyphImages.mFri Jun 20
            10:15:30 2014 -0700<br>
            <br>
            +++ b/src/macosx/native/sun/font/    .mWed Jul 09 14:50:09
            2014 +0400<br>
            <br>
            @@ -196,6 +196,8 @@<br>
            <br>
            #pragma mark --- Font Rendering Mode Descriptors ---<br>
            <br>
            +#undef __LITTLE_ENDIAN__<br>
            <br>
            +<br>
            <br>
            static inline void<br>
            <br>
            CGGI_CopyARGBPixelToRGBPixel(const UInt32 p, UInt8 *dst)<br>
            <br>
            {<br>
            <br>
            @@ -366,7 +368,8 @@<br>
            <br>
                canvas->context =
            CGBitmapContextCreate(canvas->image->data,<br>
            <br>
            width, height, 8, bytesPerRow,<br>
            <br>
            colorSpace,<br>
            <br>
            - kCGImageAlphaPremultipliedFirst);<br>
            <br>
            + kCGImageAlphaPremultipliedFirst<br>
            <br>
            +                                            |
            kCGBitmapByteOrder32Host);<br>
            <br>
            CGContextSetRGBFillColor(canvas->context, 0.0f, 0.0f,
            0.0f, 1.0f);<br>
            <br>
                CGContextSetFontSize(canvas->context, 1);<br>
            <br>
          </blockquote>
          <br>
          <br>
          -- <br>
          Best regards, Sergey.<br>
          <br>
        </blockquote>
      </div>
      <br>
    </blockquote>
    <br>
  </body>
</html>