Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/font/X11TextRenderer.java
32287 views
/*1* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.font;2627import java.awt.Rectangle;28import java.awt.font.FontRenderContext;29import java.awt.font.GlyphVector;30import sun.awt.SunHints;31import sun.awt.SunToolkit;32import sun.java2d.SunGraphics2D;33import sun.java2d.SurfaceData;34import sun.java2d.pipe.GlyphListPipe;35import sun.java2d.pipe.Region;36import sun.java2d.loops.FontInfo;37import sun.java2d.loops.GraphicsPrimitive;38import sun.java2d.x11.X11SurfaceData;3940/**41* A delegate pipe of SG2D for drawing text with42* a solid source colour to an X11 drawable destination.43*/44public class X11TextRenderer extends GlyphListPipe {45/*46* Override super class method to call the AA pipe if47* AA is specified in the GlyphVector's FontRenderContext48*/49public void drawGlyphVector(SunGraphics2D sg2d, GlyphVector g,50float x, float y)51{52FontRenderContext frc = g.getFontRenderContext();53FontInfo info = sg2d.getGVFontInfo(g.getFont(), frc);54switch (info.aaHint) {55case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:56super.drawGlyphVector(sg2d, g, x, y);57return;58case SunHints.INTVAL_TEXT_ANTIALIAS_ON:59sg2d.surfaceData.aaTextRenderer.drawGlyphVector(sg2d, g, x, y);60return;61case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB:62case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB:63sg2d.surfaceData.lcdTextRenderer.drawGlyphVector(sg2d, g, x, y);64return;65default:66}67}6869native void doDrawGlyphList(long dstData, long xgc,70Region clip, GlyphList gl);7172protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {73SunToolkit.awtLock();74try {75X11SurfaceData x11sd = (X11SurfaceData)sg2d.surfaceData;76Region clip = sg2d.getCompClip();77long xgc = x11sd.getRenderGC(clip, SunGraphics2D.COMP_ISCOPY,78null, sg2d.pixel);79doDrawGlyphList(x11sd.getNativeOps(), xgc, clip, gl);80} finally {81SunToolkit.awtUnlock();82}83}8485public X11TextRenderer traceWrap() {86return new Tracer();87}8889public static class Tracer extends X11TextRenderer {90void doDrawGlyphList(long dstData, long xgc,91Region clip, GlyphList gl)92{93GraphicsPrimitive.tracePrimitive("X11DrawGlyphs");94super.doDrawGlyphList(dstData, xgc, clip, gl);95}96}97}9899100