2370N/A/*
2685N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2370N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2370N/A *
2370N/A * This code is free software; you can redistribute it and/or modify it
2370N/A * under the terms of the GNU General Public License version 2 only, as
2685N/A * published by the Free Software Foundation. Oracle designates this
2370N/A * particular file as subject to the "Classpath" exception as provided
2685N/A * by Oracle in the LICENSE file that accompanied this code.
2370N/A *
2370N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2370N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2370N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2370N/A * version 2 for more details (a copy is included in the LICENSE file that
2370N/A * accompanied this code).
2370N/A *
2370N/A * You should have received a copy of the GNU General Public License version
2370N/A * 2 along with this work; if not, write to the Free Software Foundation,
2370N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2370N/A *
2685N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2685N/A * or visit www.oracle.com if you need additional information or have any
2685N/A * questions.
2370N/A */
2370N/A
2370N/Apackage sun.java2d.jules;
2370N/A
2370N/Aimport java.awt.*;
2370N/Aimport sun.awt.*;
2370N/Aimport sun.java2d.*;
2370N/Aimport sun.java2d.pipe.*;
2370N/Aimport sun.java2d.xr.*;
2370N/A
2370N/Apublic class JulesShapePipe implements ShapeDrawPipe {
2370N/A
2370N/A XRCompositeManager compMan;
2370N/A JulesPathBuf buf = new JulesPathBuf();
2370N/A
2370N/A public JulesShapePipe(XRCompositeManager compMan) {
2370N/A this.compMan = compMan;
2370N/A }
2370N/A
2370N/A /**
2370N/A * Common validate method, used by all XRRender functions to validate the
2370N/A * destination context.
2370N/A */
2370N/A private final void validateSurface(SunGraphics2D sg2d) {
2370N/A XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData;
2370N/A xrsd.validateAsDestination(sg2d, sg2d.getCompClip());
2370N/A xrsd.maskBuffer.validateCompositeState(sg2d.composite, sg2d.transform,
2370N/A sg2d.paint, sg2d);
2370N/A }
2370N/A
2370N/A public void draw(SunGraphics2D sg2d, Shape s) {
2370N/A try {
2370N/A SunToolkit.awtLock();
2370N/A validateSurface(sg2d);
2370N/A XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData;
2370N/A
2370N/A BasicStroke bs;
2370N/A
2370N/A if (sg2d.stroke instanceof BasicStroke) {
2370N/A bs = (BasicStroke) sg2d.stroke;
2370N/A } else { //TODO: What happens in the case of a !BasicStroke??
2370N/A s = sg2d.stroke.createStrokedShape(s);
2370N/A bs = null;
2370N/A }
2370N/A
2370N/A boolean adjust =
2370N/A (bs != null && sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE);
2370N/A boolean thin = (sg2d.strokeState <= SunGraphics2D.STROKE_THINDASHED);
2370N/A
2370N/A TrapezoidList traps =
2370N/A buf.tesselateStroke(s, bs, thin, adjust, true,
2370N/A sg2d.transform, sg2d.getCompClip());
2370N/A compMan.XRCompositeTraps(xrsd.picture,
2370N/A sg2d.transX, sg2d.transY, traps);
2370N/A
2370N/A buf.clear();
2370N/A
2370N/A } finally {
2370N/A SunToolkit.awtUnlock();
2370N/A }
2370N/A }
2370N/A
2370N/A public void fill(SunGraphics2D sg2d, Shape s) {
2370N/A try {
2370N/A SunToolkit.awtLock();
2370N/A validateSurface(sg2d);
2370N/A
2370N/A XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData;
2370N/A
2370N/A TrapezoidList traps = buf.tesselateFill(s, sg2d.transform,
2370N/A sg2d.getCompClip());
2370N/A compMan.XRCompositeTraps(xrsd.picture, 0, 0, traps);
2370N/A
2370N/A buf.clear();
2370N/A } finally {
2370N/A SunToolkit.awtUnlock();
2370N/A }
2370N/A }
2370N/A}