01: /*
02: * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * 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:
26: package sun.font;
27:
28: import java.awt.Rectangle;
29: import java.awt.font.FontRenderContext;
30: import java.awt.font.GlyphVector;
31: import sun.awt.SunHints;
32: import sun.awt.SunToolkit;
33: import sun.java2d.SunGraphics2D;
34: import sun.java2d.SurfaceData;
35: import sun.java2d.pipe.GlyphListPipe;
36: import sun.java2d.pipe.Region;
37: import sun.java2d.loops.FontInfo;
38: import sun.java2d.loops.GraphicsPrimitive;
39: import 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: */
45: public 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: FontRenderContext frc = g.getFontRenderContext();
53: FontInfo info = sg2d.getGVFontInfo(g.getFont(), frc);
54: switch (info.aaHint) {
55: case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
56: super .drawGlyphVector(sg2d, g, x, y);
57: return;
58: case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
59: sg2d.surfaceData.aaTextRenderer.drawGlyphVector(sg2d, g, x,
60: 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,
65: x, y);
66: return;
67: default:
68: }
69: }
70:
71: native void doDrawGlyphList(long dstData, long xgc, Region clip,
72: GlyphList gl);
73:
74: protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
75: SunToolkit.awtLock();
76: try {
77: X11SurfaceData x11sd = (X11SurfaceData) sg2d.surfaceData;
78: Region clip = sg2d.getCompClip();
79: long xgc = x11sd.getRenderGC(clip,
80: SunGraphics2D.COMP_ISCOPY, null, sg2d.pixel);
81: doDrawGlyphList(x11sd.getNativeOps(), xgc, clip, gl);
82: } finally {
83: SunToolkit.awtUnlock();
84: }
85: }
86:
87: public X11TextRenderer traceWrap() {
88: return new Tracer();
89: }
90:
91: public static class Tracer extends X11TextRenderer {
92: void doDrawGlyphList(long dstData, long xgc, Region clip,
93: GlyphList gl) {
94: GraphicsPrimitive.tracePrimitive("X11DrawGlyphs");
95: super.doDrawGlyphList(dstData, xgc, clip, gl);
96: }
97: }
98: }
|