[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: [OpenJDK 2D-Dev] [9] Review request for 8023794: [macosx] LCD Rendering hints seems not working 
From:       Andrew Brygin <andrew.brygin () oracle ! com>
Date:       2014-09-29 15:30:08
Message-ID: 54297B00.5020604 () oracle ! com
[Download RAW message or body]

Hello Denis,

  I am not sure whether we should use 'apple.awt.graphics.UseQuartz' 
property.
  Probably we have to change the text antialiasing defaults for macosx 
instead.

  I am working on the issue with software loops. I will update the thread
  with my findings.

Thanks,
Andrew

On 9/3/2014 3:32 PM, Denis Fokin wrote:
> Hi Sergey and 2d team,
>
> I have rewritten the fix. It works fine for text rendered on window 
> using OpenGL.
>
> http://web-dot.ru/openjdk/8023794/webrev.00/index.html
>
> It is incomplete though. It does not work for rendering in a buffered 
> image.
>
> Additionally, I have not tested the code on other platforms except 
> MacOS X.
>
> To enable the antialiasing you should pass
>
> -Dapple.awt.graphics.UseQuartz=true
>
> to java.
>
> The current issue now is the glyph info bytes that are passed from 
> CGGlyphImage to AATextRenderer.
>
> To render data we use DEFINE_SOLID_DRAWGLYPHLIST* macros. Basing on 
> the macros a set of functions is generated for the next loops.
>
> sun/java2d/loops/ByteGray.c
> sun/java2d/loops/ByteIndexed.c
> sun/java2d/loops/FourByteAbgr.c
> sun/java2d/loops/FourByteAbgrPre.c
> sun/java2d/loops/Index12Gray.c
> sun/java2d/loops/Index8Gray.c
> sun/java2d/loops/IntArgb.c
> sun/java2d/loops/IntArgbBm.c
> sun/java2d/loops/IntArgbPre.c
> sun/java2d/loops/IntBgr.c
> sun/java2d/loops/IntRgb.c
> sun/java2d/loops/IntRgbx.c
> sun/java2d/loops/LoopMacros.h
> sun/java2d/loops/ThreeByteBgr.c
> sun/java2d/loops/Ushort555Rgb.c
> sun/java2d/loops/Ushort555Rgbx.c
> sun/java2d/loops/Ushort565Rgb.c
> sun/java2d/loops/UshortGray.c
> sun/java2d/loops/UshortIndexed.c
>
> For instance, C preprocessor generates the next code for IntRgb.c
>
> voidIntRgbDrawGlyphListLCD(/*…*/){
>   jint glyphCounter, bpp;
>   jint scan = pRasInfo->scanStride;
> IntRgbDataType *pPix;
> fprintf(__stderrp, "NAME_SOLID_DRAWGLYPHLISTLC\n");
>   jint srcA;
>   jint srcR   , srcG, srcB;;;;
>   do {
> (srcB) = (argbcolor) & 0xff;
> (srcG) = ((argbcolor) >> 8) & 0xff;
> (srcR) = ((argbcolor) >> 16) & 0xff;
> (srcA) = ((argbcolor) >> 24) & 0xff;
>   } while (0);;
> // and so on…
>
> Looks like rgb loop expects to see 4 8-bit color channels per pixel.
>
> 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.
>
> May be it should be set somewhere in Java code.
>
> Could anyone share this knowledge with me?
>
> Thank you,
>     Denis.
>
>
> On 09 Jul 2014, at 19:22, Sergey Bylokhov <Sergey.Bylokhov@oracle.com 
> <mailto:Sergey.Bylokhov@oracle.com>> wrote:
>
>> Hello, Denis.
>> Thanks for this research!
>> On 09.07.2014 15:13, Denis Fokin wrote:
>>> The current version consist of three parts.
>>>
>>> 1. We are rendering glyphs in offscreen images using Quartz 
>>> functions. This does not work without kCGBitmapByteOrder32Host mask.
>> I assume LCD hint does not work? this looks good.
>>>
>>> 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.
>> 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.
>>>
>>> 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.
>> It seems __LITTLE_ENDIAN__usage in this file should be checked.
>>>
>>> Thank you,
>>>   Denis.
>>>
>>> diff -r f87c5be90e01 
>>> src/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java
>>>
>>> --- 
>>> a/src/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.javaFri 
>>> Jun 20 10:15:30 2014 -0700
>>>
>>> +++ 
>>> b/src/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.javaWed 
>>> Jul 09 14:50:09 2014 +0400
>>>
>>> @@ -108,7 +108,7 @@
>>>
>>>             } else {
>>>
>>>                 CGLGraphicsConfig gc =
>>>
>>> (CGLGraphicsConfig)vImg.getGraphicsConfig();
>>>
>>> -                ColorModel cm = 
>>> gc.getColorModel(vImg.getTransparency());
>>>
>>> +                ColorModel cm = gc.getColorModel(Transparency.OPAQUE);
>>>
>>>                 int type = vImg.getForcedAccelSurfaceType();
>>>
>>>                 // if acceleration type is forced (type != 
>>> UNDEFINED) then
>>>
>>>                 // use the forced type, otherwise choose one based 
>>> on caps
>>>
>>> diff -r f87c5be90e01 src/macosx/native/sun/font/CGGlyphImages.m
>>>
>>> --- a/src/macosx/native/sun/font/CGGlyphImages.mFri Jun 20 10:15:30 
>>> 2014 -0700
>>>
>>> +++ b/src/macosx/native/sun/font/    .mWed Jul 09 14:50:09 2014 +0400
>>>
>>> @@ -196,6 +196,8 @@
>>>
>>> #pragma mark --- Font Rendering Mode Descriptors ---
>>>
>>> +#undef __LITTLE_ENDIAN__
>>>
>>> +
>>>
>>> static inline void
>>>
>>> CGGI_CopyARGBPixelToRGBPixel(const UInt32 p, UInt8 *dst)
>>>
>>> {
>>>
>>> @@ -366,7 +368,8 @@
>>>
>>>     canvas->context = CGBitmapContextCreate(canvas->image->data,
>>>
>>> width, height, 8, bytesPerRow,
>>>
>>> colorSpace,
>>>
>>> - kCGImageAlphaPremultipliedFirst);
>>>
>>> + kCGImageAlphaPremultipliedFirst
>>>
>>> +                                            | 
>>> kCGBitmapByteOrder32Host);
>>>
>>> CGContextSetRGBFillColor(canvas->context, 0.0f, 0.0f, 0.0f, 1.0f);
>>>
>>>     CGContextSetFontSize(canvas->context, 1);
>>>
>>
>>
>> -- 
>> Best regards, Sergey.
>>
>


[Attachment #3 (text/html)]

<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-&gt;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) &amp; 0xff;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">   
              (srcG) = ((argbcolor) &gt;&gt; 8) &amp; 0xff;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">   
              (srcR) = ((argbcolor) &gt;&gt; 16) &amp; 0xff;</span></font></div>
        <div><font face="Menlo"><span style="font-size: 11px;">   
              (srcA) = ((argbcolor) &gt;&gt; 24) &amp; 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 &lt;<a
            moz-do-not-send="true"
            href="mailto:Sergey.Bylokhov@oracle.com">Sergey.Bylokhov@oracle.com</a>&gt;
  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-&gt;context =
            CGBitmapContextCreate(canvas-&gt;image-&gt;data,<br>
            <br>
            width, height, 8, bytesPerRow,<br>
            <br>
            colorSpace,<br>
            <br>
            - kCGImageAlphaPremultipliedFirst);<br>
            <br>
            + kCGImageAlphaPremultipliedFirst<br>
            <br>
            +                                            |
            kCGBitmapByteOrder32Host);<br>
            <br>
            CGContextSetRGBFillColor(canvas-&gt;context, 0.0f, 0.0f,
            0.0f, 1.0f);<br>
            <br>
                CGContextSetFontSize(canvas-&gt;context, 1);<br>
            <br>
          </blockquote>
          <br>
          <br>
          -- <br>
          Best regards, Sergey.<br>
          <br>
        </blockquote>
      </div>
      <br>
    </blockquote>
    <br>
  </body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic