[OpenJDK 2D-Dev] [9] Review request for 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON

Denis Fokin denis.fokin at gmail.com
Wed Jul 9 11:13:25 UTC 2014

Hi Java 2D team,

I recently discovered that it is possible to enable subpixel antialiasing
with Java2D OpenGL pipeline. Today I realised, that I cannot use
cr.openjdk.java.net anymore, so I would like to propose a fix as a diff.

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.

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.

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.

Thank you,

diff -r f87c5be90e01

--- a/src/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java Fri
Jun 20 10:15:30 2014 -0700

+++ b/src/macosx/classes/sun/java2d/opengl/CGLVolatileSurfaceManager.java Wed
Jul 09 14:50:09 2014 +0400

@@ -108,7 +108,7 @@

             } else {

                 CGLGraphicsConfig gc =


-                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.m Fri Jun 20 10:15:30 2014

+++ b/src/macosx/native/sun/font/CGGlyphImages.m Wed Jul 09 14:50:09 2014

@@ -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,



+                                            kCGImageAlphaPremultipliedFirst

+                                            | kCGBitmapByteOrder32Host);

     CGContextSetRGBFillColor(canvas->context, 0.0f, 0.0f, 0.0f, 1.0f);

     CGContextSetFontSize(canvas->context, 1);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20140709/8ee62f94/attachment.html>

More information about the 2d-dev mailing list