J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2005 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 | |
| 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, |
| 53 | sg2d.getCompClip(), comp, |
| 54 | null, sg2d.eargb, |
| 55 | D3DContext.NO_CONTEXT_FLAGS); |
| 56 | |
| 57 | doDrawGlyphList(dstData.getNativeOps(), pCtx, |
| 58 | sg2d.getCompClip(), gl); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | public D3DTextRenderer traceWrap() { |
| 63 | return new Tracer(); |
| 64 | } |
| 65 | |
| 66 | public static class Tracer extends D3DTextRenderer { |
| 67 | @Override |
| 68 | protected void doDrawGlyphList(long pData, long pCtx, |
| 69 | Region clip, GlyphList gl) |
| 70 | { |
| 71 | GraphicsPrimitive.tracePrimitive("D3DDrawGlyphs"); |
| 72 | super.doDrawGlyphList(pData, pCtx, clip, gl); |
| 73 | } |
| 74 | } |
| 75 | } |