Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/java2d/loops/AlphaMath.c
38918 views
/*1* Copyright (c) 2000, 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#include "AlphaMath.h"2627unsigned char mul8table[256][256];28unsigned char div8table[256][256];2930void initAlphaTables()31{32unsigned int i;33unsigned int j;3435for (i = 1; i < 256; i++) { /* SCALE == (1 << 24) */36int inc = (i << 16) + (i<<8) + i; /* approx. SCALE * (i/255.0) */37int val = inc + (1 << 23); /* inc + SCALE*0.5 */38for (j = 1; j < 256; j++) {39mul8table[i][j] = (val >> 24); /* val / SCALE */40val += inc;41}42}4344for (i = 1; i < 256; i++) {45unsigned int inc;46unsigned int val;47inc = 0xff;48inc = ((inc << 24) + i/2) / i;49val = (1 << 23);50for (j = 0; j < i; j++) {51div8table[i][j] = (val >> 24);52val += inc;53}54for (j = i; j < 256; j++) {55div8table[i][j] = 255;56}57}58}596061