blob: 97d04d74e0bf888ef109f25ab0e527048d59e4af [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2000-2006 Sun Microsystems, Inc. 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. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package sun.font;
27
28import java.awt.Rectangle;
29import java.awt.font.FontRenderContext;
30import java.awt.font.GlyphVector;
31import sun.awt.SunHints;
32import sun.awt.SunToolkit;
33import sun.java2d.SunGraphics2D;
34import sun.java2d.SurfaceData;
35import sun.java2d.pipe.GlyphListPipe;
36import sun.java2d.pipe.Region;
37import sun.java2d.loops.FontInfo;
38import sun.java2d.loops.GraphicsPrimitive;
39import sun.java2d.x11.X11SurfaceData;
40
41/**
42 * A delegate pipe of SG2D for drawing text with
43 * a solid source colour to an X11 drawable destination.
44 */
45public class X11TextRenderer extends GlyphListPipe {
46 /*
47 * Override super class method to call the AA pipe if
48 * AA is specified in the GlyphVector's FontRenderContext
49 */
50 public void drawGlyphVector(SunGraphics2D sg2d, GlyphVector g,
51 float x, float y)
52 {
53 FontRenderContext frc = g.getFontRenderContext();
54 FontInfo info = sg2d.getGVFontInfo(g.getFont(), frc);
55 switch (info.aaHint) {
56 case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
57 super.drawGlyphVector(sg2d, g, x, y);
58 return;
59 case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
60 sg2d.surfaceData.aaTextRenderer.drawGlyphVector(sg2d, g, x, y);
61 return;
62 case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB:
63 case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB:
64 sg2d.surfaceData.lcdTextRenderer.drawGlyphVector(sg2d, g, x, y);
65 return;
66 default:
67 }
68 }
69
70 native void doDrawGlyphList(long dstData, long xgc,
71 Region clip, GlyphList gl);
72
73 protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
74 SunToolkit.awtLock();
75 try {
76 X11SurfaceData x11sd = (X11SurfaceData)sg2d.surfaceData;
77 Region clip = sg2d.getCompClip();
78 long xgc = x11sd.getRenderGC(clip, SunGraphics2D.COMP_ISCOPY,
79 null, sg2d.pixel);
80 doDrawGlyphList(x11sd.getNativeOps(), xgc, clip, gl);
81 } finally {
82 SunToolkit.awtUnlock();
83 }
84 }
85
86 public X11TextRenderer traceWrap() {
87 return new Tracer();
88 }
89
90 public static class Tracer extends X11TextRenderer {
91 void doDrawGlyphList(long dstData, long xgc,
92 Region clip, GlyphList gl)
93 {
94 GraphicsPrimitive.tracePrimitive("X11DrawGlyphs");
95 super.doDrawGlyphList(dstData, xgc, clip, gl);
96 }
97 }
98}