Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/java2d/loops/DrawLine.java
38918 views
/*1* Copyright (c) 1997, 2002, 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*/2425/*26* @author Charlton Innovations, Inc.27*/2829package sun.java2d.loops;3031import sun.java2d.loops.GraphicsPrimitive;32import java.awt.Color;33import java.awt.image.ColorModel;34import java.awt.image.Raster;35import sun.java2d.SunGraphics2D;36import sun.java2d.SurfaceData;3738/**39* DrawLine40* 1) draw solid color single width line onto destination surface41* 2) must accept output area [x, y, dx, dy]42* from within the surface description data for clip rect43*/44public class DrawLine extends GraphicsPrimitive45{46public final static String methodSignature = "DrawLine(...)".toString();4748public final static int primTypeID = makePrimTypeID();4950public static DrawLine locate(SurfaceType srctype,51CompositeType comptype,52SurfaceType dsttype)53{54return (DrawLine) GraphicsPrimitiveMgr.locate(primTypeID,55srctype, comptype, dsttype);56}5758protected DrawLine(SurfaceType srctype,59CompositeType comptype,60SurfaceType dsttype)61{62super(methodSignature, primTypeID, srctype, comptype, dsttype);63}6465public DrawLine(long pNativePrim,66SurfaceType srctype,67CompositeType comptype,68SurfaceType dsttype)69{70super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);71}7273/**74* All DrawLine implementors must have this invoker method75*/76public native void DrawLine(SunGraphics2D sg2d, SurfaceData dest,77int x1, int y1, int x2, int y2);7879public GraphicsPrimitive makePrimitive(SurfaceType srctype,80CompositeType comptype,81SurfaceType dsttype)82{83// REMIND: use FillSpans or converter object?84throw new InternalError("DrawLine not implemented for "+85srctype+" with "+comptype);86}8788public GraphicsPrimitive traceWrap() {89return new TraceDrawLine(this);90}9192private static class TraceDrawLine extends DrawLine {93DrawLine target;9495public TraceDrawLine(DrawLine target) {96super(target.getSourceType(),97target.getCompositeType(),98target.getDestType());99this.target = target;100}101102public GraphicsPrimitive traceWrap() {103return this;104}105106public void DrawLine(SunGraphics2D sg2d, SurfaceData dest,107int x1, int y1, int x2, int y2)108{109tracePrimitive(target);110target.DrawLine(sg2d, dest, x1, y1, x2, y2);111}112}113}114115116