src/share/classes/sun/java2d/loops/ProcessPath.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 263     /* Multipliers for the coefficients of the polynomial form of the cubic and
 264      * quad curves representation
 265      */
 266     private static final int CUB_A_SHIFT = FWD_PREC;
 267     private static final int CUB_B_SHIFT = (DF_CUB_STEPS + FWD_PREC + 1);
 268     private static final int CUB_C_SHIFT = (DF_CUB_STEPS*2 + FWD_PREC);
 269 
 270     private static final int CUB_A_MDP_MULT = (1<<CUB_A_SHIFT);
 271     private static final int CUB_B_MDP_MULT = (1<<CUB_B_SHIFT);
 272     private static final int CUB_C_MDP_MULT = (1<<CUB_C_SHIFT);
 273 
 274     private static final int QUAD_A_SHIFT = FWD_PREC;
 275     private static final int QUAD_B_SHIFT = (DF_QUAD_STEPS + FWD_PREC);
 276 
 277     private static final int QUAD_A_MDP_MULT = (1<<QUAD_A_SHIFT);
 278     private static final int QUAD_B_MDP_MULT = (1<<QUAD_B_SHIFT);
 279 
 280     /* Clipping macros for drawing and filling algorithms */
 281     private static float CLIP(float a1, float b1, float a2, float b2,
 282                               double t) {
 283         return (float)(b1 + (double)(t - a1)*(b2 - b1) / (a2 - a1));
 284     }
 285 
 286     private static int CLIP(int a1, int b1, int a2, int b2, double t) {
 287         return (int)(b1 + (double)(t - a1)*(b2 - b1) / (a2 - a1));
 288     }
 289 
 290 
 291     private static final int CRES_MIN_CLIPPED = 0;
 292     private static final int CRES_MAX_CLIPPED = 1;
 293     private static final int CRES_NOT_CLIPPED = 3;
 294     private static final int CRES_INVISIBLE = 4;
 295 
 296     private static boolean IS_CLIPPED(int res) {
 297         return res == CRES_MIN_CLIPPED || res == CRES_MAX_CLIPPED;
 298     }
 299 
 300     /* This is java implementation of the macro from ProcessGeneralPath.c.
 301      * To keep the logic of the java code similar to the native one
 302      * array and set of indexes are used to point out the data.
 303      */
 304     private static int TESTANDCLIP(float LINE_MIN, float LINE_MAX, float[] c,
 305                                    int a1, int b1, int a2, int b2) {
 306         double t;
 307         int res = CRES_NOT_CLIPPED;


   1 /*
   2  * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 263     /* Multipliers for the coefficients of the polynomial form of the cubic and
 264      * quad curves representation
 265      */
 266     private static final int CUB_A_SHIFT = FWD_PREC;
 267     private static final int CUB_B_SHIFT = (DF_CUB_STEPS + FWD_PREC + 1);
 268     private static final int CUB_C_SHIFT = (DF_CUB_STEPS*2 + FWD_PREC);
 269 
 270     private static final int CUB_A_MDP_MULT = (1<<CUB_A_SHIFT);
 271     private static final int CUB_B_MDP_MULT = (1<<CUB_B_SHIFT);
 272     private static final int CUB_C_MDP_MULT = (1<<CUB_C_SHIFT);
 273 
 274     private static final int QUAD_A_SHIFT = FWD_PREC;
 275     private static final int QUAD_B_SHIFT = (DF_QUAD_STEPS + FWD_PREC);
 276 
 277     private static final int QUAD_A_MDP_MULT = (1<<QUAD_A_SHIFT);
 278     private static final int QUAD_B_MDP_MULT = (1<<QUAD_B_SHIFT);
 279 
 280     /* Clipping macros for drawing and filling algorithms */
 281     private static float CLIP(float a1, float b1, float a2, float b2,
 282                               double t) {
 283         return (float)(b1 + (t - a1)*(b2 - b1) / (a2 - a1));
 284     }
 285 
 286     private static int CLIP(int a1, int b1, int a2, int b2, double t) {
 287         return (int)(b1 + (t - a1)*(b2 - b1) / (a2 - a1));
 288     }
 289 
 290 
 291     private static final int CRES_MIN_CLIPPED = 0;
 292     private static final int CRES_MAX_CLIPPED = 1;
 293     private static final int CRES_NOT_CLIPPED = 3;
 294     private static final int CRES_INVISIBLE = 4;
 295 
 296     private static boolean IS_CLIPPED(int res) {
 297         return res == CRES_MIN_CLIPPED || res == CRES_MAX_CLIPPED;
 298     }
 299 
 300     /* This is java implementation of the macro from ProcessGeneralPath.c.
 301      * To keep the logic of the java code similar to the native one
 302      * array and set of indexes are used to point out the data.
 303      */
 304     private static int TESTANDCLIP(float LINE_MIN, float LINE_MAX, float[] c,
 305                                    int a1, int b1, int a2, int b2) {
 306         double t;
 307         int res = CRES_NOT_CLIPPED;