1 /* 2 * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.java2d.pipe; 27 28 import java.awt.AlphaComposite; 29 import java.awt.Composite; 30 import sun.font.GlyphList; 31 import sun.java2d.SunGraphics2D; 32 import sun.java2d.SurfaceData; 33 import static sun.java2d.pipe.BufferedOpCodes.*; 34 35 import javax.tools.annotation.GenerateNativeHeader; 36 37 /* No native methods here, but the constants are needed in the supporting JNI code */ 38 @GenerateNativeHeader 39 public abstract class BufferedTextPipe extends GlyphListPipe { 40 41 private static final int BYTES_PER_GLYPH_IMAGE = 8; 42 private static final int BYTES_PER_GLYPH_POSITION = 8; 43 44 /** 45 * The following offsets are used to pack the parameters in 46 * createPackedParams(). (They are also used at the native level when 47 * unpacking the params.) 48 */ 49 private static final int OFFSET_CONTRAST = 8; 50 private static final int OFFSET_RGBORDER = 2; 51 private static final int OFFSET_SUBPIXPOS = 1; 52 private static final int OFFSET_POSITIONS = 0; 53 54 /** 55 * Packs the given parameters into a single int value in order to save 56 * space on the rendering queue. Note that most of these parameters 57 * are only used for rendering LCD-optimized text, but conditionalizing 58 * this work wouldn't make any impact on performance, so we will pack 59 * those parameters even in the non-LCD case. 60 */ 61 private static int createPackedParams(SunGraphics2D sg2d, GlyphList gl) { 62 return 63 (((gl.usePositions() ? 1 : 0) << OFFSET_POSITIONS) | 64 ((gl.isSubPixPos() ? 1 : 0) << OFFSET_SUBPIXPOS) | 65 ((gl.isRGBOrder() ? 1 : 0) << OFFSET_RGBORDER ) | 66 ((sg2d.lcdTextContrast & 0xff) << OFFSET_CONTRAST )); 67 } 68 69 protected final RenderQueue rq; 70 71 protected BufferedTextPipe(RenderQueue rq) { 72 this.rq = rq; | 1 /* 2 * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.java2d.pipe; 27 28 import java.awt.AlphaComposite; 29 import java.awt.Composite; 30 import sun.font.GlyphList; 31 import sun.java2d.SunGraphics2D; 32 import sun.java2d.SurfaceData; 33 import static sun.java2d.pipe.BufferedOpCodes.*; 34 35 import java.lang.annotation.Native; 36 37 public abstract class BufferedTextPipe extends GlyphListPipe { 38 39 @Native private static final int BYTES_PER_GLYPH_IMAGE = 8; 40 @Native private static final int BYTES_PER_GLYPH_POSITION = 8; 41 42 /** 43 * The following offsets are used to pack the parameters in 44 * createPackedParams(). (They are also used at the native level when 45 * unpacking the params.) 46 */ 47 @Native private static final int OFFSET_CONTRAST = 8; 48 @Native private static final int OFFSET_RGBORDER = 2; 49 @Native private static final int OFFSET_SUBPIXPOS = 1; 50 @Native private static final int OFFSET_POSITIONS = 0; 51 52 /** 53 * Packs the given parameters into a single int value in order to save 54 * space on the rendering queue. Note that most of these parameters 55 * are only used for rendering LCD-optimized text, but conditionalizing 56 * this work wouldn't make any impact on performance, so we will pack 57 * those parameters even in the non-LCD case. 58 */ 59 private static int createPackedParams(SunGraphics2D sg2d, GlyphList gl) { 60 return 61 (((gl.usePositions() ? 1 : 0) << OFFSET_POSITIONS) | 62 ((gl.isSubPixPos() ? 1 : 0) << OFFSET_SUBPIXPOS) | 63 ((gl.isRGBOrder() ? 1 : 0) << OFFSET_RGBORDER ) | 64 ((sg2d.lcdTextContrast & 0xff) << OFFSET_CONTRAST )); 65 } 66 67 protected final RenderQueue rq; 68 69 protected BufferedTextPipe(RenderQueue rq) { 70 this.rq = rq; |