01: /*
02: * Copyright 2005 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.java2d.d3d;
27:
28: import java.awt.AlphaComposite;
29: import sun.font.GlyphList;
30: import sun.java2d.SunGraphics2D;
31: import sun.java2d.SurfaceData;
32: import sun.java2d.loops.GraphicsPrimitive;
33: import sun.java2d.pipe.GlyphListPipe;
34: import sun.java2d.pipe.Region;
35:
36: public class D3DTextRenderer extends GlyphListPipe {
37:
38: protected native void doDrawGlyphList(long pData, long pCtx,
39: Region clip, GlyphList gl);
40:
41: protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
42: AlphaComposite comp = (AlphaComposite) sg2d.composite;
43: // We can only get here if the comp is Src or SrcOver (see
44: // pipeline validation in D3DSurfaceData, so we force
45: // it to be SrcOver.
46: if (comp.getRule() != AlphaComposite.SRC_OVER) {
47: comp = AlphaComposite.SrcOver;
48: }
49:
50: synchronized (D3DContext.LOCK) {
51: SurfaceData dstData = sg2d.surfaceData;
52: long pCtx = D3DContext.getContext(dstData, dstData, sg2d
53: .getCompClip(), comp, null, sg2d.eargb,
54: D3DContext.NO_CONTEXT_FLAGS);
55:
56: doDrawGlyphList(dstData.getNativeOps(), pCtx, sg2d
57: .getCompClip(), gl);
58: }
59: }
60:
61: public D3DTextRenderer traceWrap() {
62: return new Tracer();
63: }
64:
65: public static class Tracer extends D3DTextRenderer {
66: @Override
67: protected void doDrawGlyphList(long pData, long pCtx,
68: Region clip, GlyphList gl) {
69: GraphicsPrimitive.tracePrimitive("D3DDrawGlyphs");
70: super.doDrawGlyphList(pData, pCtx, clip, gl);
71: }
72: }
73: }
|