1 /* 2 * Copyright (c) 2010, Oracle and/or its affiliates. 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. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.java2d.jules; 27 28 import java.awt.*; 29 import sun.awt.*; 30 import sun.java2d.*; 31 import sun.java2d.pipe.*; 32 import sun.java2d.xr.*; 33 34 public class JulesShapePipe implements ShapeDrawPipe { 35 36 XRCompositeManager compMan; 37 JulesPathBuf buf = new JulesPathBuf(); 38 39 public JulesShapePipe(XRCompositeManager compMan) { 40 this.compMan = compMan; 41 } 42 43 /** 44 * Common validate method, used by all XRRender functions to validate the 45 * destination context. 46 */ 47 private void validateSurface(SunGraphics2D sg2d) { 48 XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData; 49 xrsd.validateAsDestination(sg2d, sg2d.getCompClip()); 50 xrsd.maskBuffer.validateCompositeState(sg2d.composite, sg2d.transform, 51 sg2d.paint, sg2d); 52 } 53 54 public void draw(SunGraphics2D sg2d, Shape s) { 55 try { 56 SunToolkit.awtLock(); 57 validateSurface(sg2d); 58 XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData; 59 60 BasicStroke bs; 61 62 if (sg2d.stroke instanceof BasicStroke) { 63 bs = (BasicStroke) sg2d.stroke; 64 } else { //TODO: What happens in the case of a !BasicStroke?? 65 s = sg2d.stroke.createStrokedShape(s); 66 bs = null; 67 } 68 69 boolean adjust = 70 (bs != null && sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE); 71 boolean thin = (sg2d.strokeState <= SunGraphics2D.STROKE_THINDASHED); 72 73 TrapezoidList traps = 74 buf.tesselateStroke(s, bs, thin, adjust, true, 75 sg2d.transform, sg2d.getCompClip()); 76 compMan.XRCompositeTraps(xrsd.picture, 77 sg2d.transX, sg2d.transY, traps); 78 79 buf.clear(); 80 81 } finally { 82 SunToolkit.awtUnlock(); 83 } 84 } 85 86 public void fill(SunGraphics2D sg2d, Shape s) { 87 try { 88 SunToolkit.awtLock(); 89 validateSurface(sg2d); 90 91 XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData; 92 93 TrapezoidList traps = buf.tesselateFill(s, sg2d.transform, 94 sg2d.getCompClip()); 95 compMan.XRCompositeTraps(xrsd.picture, 0, 0, traps); 96 97 buf.clear(); 98 } finally { 99 SunToolkit.awtUnlock(); 100 } 101 } 102 }