jdk/src/java.desktop/share/classes/sun/java2d/loops/DrawParallelogram.java
author prr
Sat, 19 Sep 2015 15:45:59 -0700
changeset 32865 f9cb6e427f9e
parent 25859 3317bb8137f4
permissions -rw-r--r--
8136783: Run blessed-modifier-order script on java.desktop Reviewed-by: martin, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 7487
diff changeset
     2
 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
     4
 *
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    10
 *
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    15
 * accompanied this code).
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    16
 *
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    20
 *
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    23
 * questions.
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    24
 */
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    25
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    26
/*
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    27
 * @author Jim Graham
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    28
 */
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    29
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    30
package sun.java2d.loops;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    31
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    32
import sun.java2d.loops.GraphicsPrimitive;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    33
import sun.java2d.SunGraphics2D;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    34
import sun.java2d.SurfaceData;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    35
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    36
/**
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    37
 * DrawParallelogram
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    38
 * 1) fill the area between the 4 edges of an outer parallelogram
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    39
 *    (as specified by an origin and 2 delta vectors)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    40
 *    but also outside the 4 edges of an inner parallelogram
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    41
 *    (as specified by proportional amounts of the outer delta vectors)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    42
 */
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    43
public class DrawParallelogram extends GraphicsPrimitive
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    44
{
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 25859
diff changeset
    45
    public static final String methodSignature =
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    46
        "DrawParallelogram(...)".toString();
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    47
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 25859
diff changeset
    48
    public static final int primTypeID = makePrimTypeID();
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    49
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    50
    public static DrawParallelogram locate(SurfaceType srctype,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    51
                                           CompositeType comptype,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    52
                                           SurfaceType dsttype)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    53
    {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    54
        return (DrawParallelogram)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    55
            GraphicsPrimitiveMgr.locate(primTypeID,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    56
                                        srctype, comptype, dsttype);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    57
    }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    58
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    59
    protected DrawParallelogram(SurfaceType srctype,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    60
                                CompositeType comptype,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    61
                                SurfaceType dsttype)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    62
    {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    63
        super(methodSignature, primTypeID,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    64
              srctype, comptype, dsttype);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    65
    }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    66
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    67
    public DrawParallelogram(long pNativePrim,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    68
                             SurfaceType srctype,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    69
                             CompositeType comptype,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    70
                             SurfaceType dsttype)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    71
    {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    72
        super(pNativePrim, methodSignature, primTypeID,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    73
              srctype, comptype, dsttype);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    74
    }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    75
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    76
    /**
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    77
     * All DrawParallelogram implementors must have this invoker method
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    78
     */
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    79
    public native void DrawParallelogram(SunGraphics2D sg, SurfaceData dest,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    80
                                         double x, double y,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    81
                                         double dx1, double dy1,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    82
                                         double dx2, double dy2,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    83
                                         double lw1, double lw2);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    84
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    85
    public GraphicsPrimitive makePrimitive(SurfaceType srctype,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    86
                                           CompositeType comptype,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    87
                                           SurfaceType dsttype)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    88
    {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    89
        // REMIND: iterate with a FillRect primitive?
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    90
        throw new InternalError("DrawParallelogram not implemented for "+
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    91
                                srctype+" with "+comptype);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    92
    }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    93
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    94
    public GraphicsPrimitive traceWrap() {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    95
        return new TraceDrawParallelogram(this);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    96
    }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    97
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    98
    private static class TraceDrawParallelogram extends DrawParallelogram {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
    99
        DrawParallelogram target;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   100
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   101
        public TraceDrawParallelogram(DrawParallelogram target) {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   102
            super(target.getSourceType(),
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   103
                  target.getCompositeType(),
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   104
                  target.getDestType());
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   105
            this.target = target;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   106
        }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   107
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   108
        public GraphicsPrimitive traceWrap() {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   109
            return this;
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   110
        }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   111
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   112
        public void DrawParallelogram(SunGraphics2D sg2d, SurfaceData dest,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   113
                                      double x, double y,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   114
                                      double dx1, double dy1,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   115
                                      double dx2, double dy2,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   116
                                      double lw1, double lw2)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   117
        {
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   118
            tracePrimitive(target);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   119
            target.DrawParallelogram(sg2d, dest,
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   120
                                     x, y, dx1, dy1, dx2, dy2, lw1, lw2);
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   121
        }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   122
    }
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents:
diff changeset
   123
}