Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/java2d/loops/DrawRect.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* DrawRect40* 1) draw single-width line rectangle onto destination surface41* 2) must accept output area [x, y, dx, dy]42* from within the surface description data for clip rect43*/44public class DrawRect extends GraphicsPrimitive45{46public final static String methodSignature = "DrawRect(...)".toString();4748public final static int primTypeID = makePrimTypeID();4950public static DrawRect locate(SurfaceType srctype,51CompositeType comptype,52SurfaceType dsttype)53{54return (DrawRect)55GraphicsPrimitiveMgr.locate(primTypeID,56srctype, comptype, dsttype);57}5859protected DrawRect(SurfaceType srctype,60CompositeType comptype,61SurfaceType dsttype)62{63super(methodSignature, primTypeID, srctype, comptype, dsttype);64}6566public DrawRect(long pNativePrim,67SurfaceType srctype,68CompositeType comptype,69SurfaceType dsttype)70{71super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);72}7374/**75* All DrawRect implementors must have this invoker method76*/77public native void DrawRect(SunGraphics2D sg2d, SurfaceData dest,78int x1, int y1, int w, int h);7980public GraphicsPrimitive makePrimitive(SurfaceType srctype,81CompositeType comptype,82SurfaceType dsttype)83{84// REMIND: use FillSpans or converter object?85throw new InternalError("DrawRect not implemented for "+86srctype+" with "+comptype);87}8889public GraphicsPrimitive traceWrap() {90return new TraceDrawRect(this);91}9293private static class TraceDrawRect extends DrawRect {94DrawRect target;9596public TraceDrawRect(DrawRect target) {97super(target.getSourceType(),98target.getCompositeType(),99target.getDestType());100this.target = target;101}102103public GraphicsPrimitive traceWrap() {104return this;105}106107public void DrawRect(SunGraphics2D sg2d, SurfaceData dest,108int x1, int y1, int w, int h)109{110tracePrimitive(target);111target.DrawRect(sg2d, dest, x1, y1, w, h);112}113}114}115116117