3265N/A/*
3909N/A * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
3265N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3265N/A *
3265N/A * This code is free software; you can redistribute it and/or modify it
3265N/A * under the terms of the GNU General Public License version 2 only, as
3265N/A * published by the Free Software Foundation. Oracle designates this
3265N/A * particular file as subject to the "Classpath" exception as provided
3265N/A * by Oracle in the LICENSE file that accompanied this code.
3265N/A *
3265N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3265N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3265N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3265N/A * version 2 for more details (a copy is included in the LICENSE file that
3265N/A * accompanied this code).
3265N/A *
3265N/A * You should have received a copy of the GNU General Public License version
3265N/A * 2 along with this work; if not, write to the Free Software Foundation,
3265N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3265N/A *
3265N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3265N/A * or visit www.oracle.com if you need additional information or have any
3265N/A * questions.
3265N/A */
3265N/A
3265N/A#ifndef ParallelogramUtils_h_Included
3265N/A#define ParallelogramUtils_h_Included
3265N/A
3265N/A#ifdef __cplusplus
3265N/Aextern "C" {
3265N/A#endif
3265N/A
3265N/A#define PGRAM_MIN_MAX(bmin, bmax, v0, dv1, dv2, AA) \
3265N/A do { \
3265N/A double vmin, vmax; \
3265N/A if (dv1 < 0) { \
3265N/A vmin = v0+dv1; \
3265N/A vmax = v0; \
3265N/A } else { \
3265N/A vmin = v0; \
3265N/A vmax = v0+dv1; \
3265N/A } \
3265N/A if (dv2 < 0) { \
3265N/A vmin += dv2; \
3265N/A } else { \
3265N/A vmax += dv2; \
3265N/A } \
3265N/A if (AA) { \
3265N/A bmin = (jint) floor(vmin); \
3265N/A bmax = (jint) ceil(vmax); \
3265N/A } else { \
3265N/A bmin = (jint) floor(vmin + 0.5); \
3265N/A bmax = (jint) floor(vmax + 0.5); \
3265N/A } \
3265N/A } while(0)
3265N/A
3265N/A#define PGRAM_INIT_X(starty, x, y, slope) \
3265N/A (DblToLong((x) + (slope) * ((starty)+0.5 - (y))) + LongOneHalf - 1)
3265N/A
3265N/A/*
3265N/A * Sort parallelogram by y values, ensure that each delta vector
3265N/A * has a non-negative y delta.
3265N/A */
3265N/A#define SORT_PGRAM(x0, y0, dx1, dy1, dx2, dy2, OTHER_SWAP_CODE) \
3265N/A do { \
3265N/A if (dy1 < 0) { \
3265N/A x0 += dx1; y0 += dy1; \
3265N/A dx1 = -dx1; dy1 = -dy1; \
3265N/A } \
3265N/A if (dy2 < 0) { \
3265N/A x0 += dx2; y0 += dy2; \
3265N/A dx2 = -dx2; dy2 = -dy2; \
3265N/A } \
3265N/A /* Sort delta vectors so dxy1 is left of dxy2. */ \
3265N/A if (dx1 * dy2 > dx2 * dy1) { \
3265N/A double v; \
3265N/A v = dx1; dx1 = dx2; dx2 = v; \
3265N/A v = dy1; dy1 = dy2; dy2 = v; \
3265N/A OTHER_SWAP_CODE \
3265N/A } \
3265N/A } while(0)
3265N/A
3265N/A#endif /* ParallelogramUtils_h_Included */