2362N/A * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A /* integer overflow */ 0N/A /* integer overflow */ 0N/A * "Small" math here will be done if the coordinates are less 0N/A * than 15 bits in range (-16384 => 16383). This could be 0N/A * expanded to 16 bits if we rearrange some of the math in 0N/A * the normal version of SetupBresenham. 0N/A * "Big" math here will be done with coordinates with 30 bits 0N/A * of total range - 2 bits less than a jint holds. 0N/A * Intermediate calculations for "Big" coordinates will be 0N/A * done using jlong variables. 0N/A ax = -
ax;
/* For clipping adjustment below */ \
0N/A ay = -
ay;
/* For clipping adjustment below */ \
0N/A * Part of calculating the Bresenham parameters for line stepping 0N/A * involves being able to store numbers that are twice the magnitude 0N/A * of the biggest absolute difference in coordinates. Since we 0N/A * want the stepping parameters to be stored in jints, we then need 0N/A * to avoid any absolute differences more than 30 bits. Thus, we 0N/A * need to preprocess the coordinates to reduce their range to 30 0N/A * bits regardless of clipping. We need to cut their range back 0N/A * before we do the clipping because the Bresenham stepping values 0N/A * need to be calculated based on the "unclipped" coordinates. 0N/A * Thus, first we perform a "pre-clipping" stage to bring the 0N/A * coordinates within the 30-bit range and then we proceed to the 0N/A * regular clipping procedure, pretending that these were the 0N/A * original coordinates all along. Since this operation occurs 0N/A * based on a constant "pre-clip" rectangle of +/- 30 bits without 0N/A * any consideration for the final clip, the rounding errors that 0N/A * occur here will depend only on the line coordinates and be 0N/A * rectangles in effect at the time. Thus, rendering a given 0N/A * large-range line will be consistent under a variety of 0N/A * clipping conditions. 0N/A * Use doubles to get us into range for "Big" arithmetic. 0N/A * The math of adjusting an endpoint for clipping can involve 0N/A * an intermediate result with twice the number of bits as the 0N/A * original coordinate range. Since we want to maintain as 0N/A * much as 30 bits of precision in the resulting coordinates, 0N/A * we will get roundoff here even using IEEE double-precision 0N/A * arithmetic which cannot carry 60 bits of mantissa. Since 0N/A * the rounding errors will be consistent for a given set 0N/A * of input coordinates the potential roundoff error should 0N/A * not affect the consistency of our rendering. 0N/A /* Use Y1d instead of _y1 for testing now as we may have modified it */ 0N/A /* Use Y2d instead of _y2 for testing now as we may have modified it */ 0N/A * Class: sun_java2d_loops_DrawLine