Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/java2d/jules/JulesShapePipe.java
32288 views
/*1* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.java2d.jules;2627import java.awt.*;28import sun.awt.*;29import sun.java2d.*;30import sun.java2d.pipe.*;31import sun.java2d.xr.*;3233public class JulesShapePipe implements ShapeDrawPipe {3435XRCompositeManager compMan;36JulesPathBuf buf = new JulesPathBuf();3738public JulesShapePipe(XRCompositeManager compMan) {39this.compMan = compMan;40}4142/**43* Common validate method, used by all XRRender functions to validate the44* destination context.45*/46private final void validateSurface(SunGraphics2D sg2d) {47XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData;48xrsd.validateAsDestination(sg2d, sg2d.getCompClip());49xrsd.maskBuffer.validateCompositeState(sg2d.composite, sg2d.transform,50sg2d.paint, sg2d);51}5253public void draw(SunGraphics2D sg2d, Shape s) {54try {55SunToolkit.awtLock();56validateSurface(sg2d);57XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData;5859BasicStroke bs;6061if (sg2d.stroke instanceof BasicStroke) {62bs = (BasicStroke) sg2d.stroke;63} else { //TODO: What happens in the case of a !BasicStroke??64s = sg2d.stroke.createStrokedShape(s);65bs = null;66}6768boolean adjust =69(bs != null && sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE);70boolean thin = (sg2d.strokeState <= SunGraphics2D.STROKE_THINDASHED);7172TrapezoidList traps =73buf.tesselateStroke(s, bs, thin, adjust, true,74sg2d.transform, sg2d.getCompClip());75compMan.XRCompositeTraps(xrsd.picture,76sg2d.transX, sg2d.transY, traps);7778buf.clear();7980} finally {81SunToolkit.awtUnlock();82}83}8485public void fill(SunGraphics2D sg2d, Shape s) {86try {87SunToolkit.awtLock();88validateSurface(sg2d);8990XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData;9192TrapezoidList traps = buf.tesselateFill(s, sg2d.transform,93sg2d.getCompClip());94compMan.XRCompositeTraps(xrsd.picture, 0, 0, traps);9596buf.clear();97} finally {98SunToolkit.awtUnlock();99}100}101}102103104