Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/font/layout/DeviceTables.cpp
38918 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425/*26*27*28* (C) Copyright IBM Corp. 1998 - 2005 - All Rights Reserved29*30*/3132#include "LETypes.h"33#include "OpenTypeTables.h"34#include "DeviceTables.h"35#include "LESwaps.h"3637U_NAMESPACE_BEGIN3839const le_uint16 DeviceTable::fieldMasks[] = {0x0003, 0x000F, 0x00FF};40const le_uint16 DeviceTable::fieldSignBits[] = {0x0002, 0x0008, 0x0080};41const le_uint16 DeviceTable::fieldBits[] = { 2, 4, 8};4243#define FORMAT_COUNT LE_ARRAY_SIZE(fieldBits)4445le_int16 DeviceTable::getAdjustment(const LEReferenceTo<DeviceTable>&base, le_uint16 ppem, LEErrorCode &success) const46{47le_int16 result = 0;48if (LE_FAILURE(success)) {49return result;50}51le_uint16 start = SWAPW(startSize);52le_uint16 format = SWAPW(deltaFormat) - 1;5354if (ppem >= start && ppem <= SWAPW(endSize) && format < FORMAT_COUNT) {55le_uint16 sizeIndex = ppem - start;56le_uint16 bits = fieldBits[format];57le_uint16 count = 16 / bits;5859LEReferenceToArrayOf<le_uint16> deltaValuesRef(base, success, deltaValues, (sizeIndex / count));6061if(LE_FAILURE(success)) {62return result;63}6465le_uint16 word = SWAPW(deltaValues[sizeIndex / count]);66le_uint16 fieldIndex = sizeIndex % count;67le_uint16 shift = 16 - (bits * (fieldIndex + 1));68le_uint16 field = (word >> shift) & fieldMasks[format];6970result = field;7172if ((field & fieldSignBits[format]) != 0) {73result |= ~ fieldMasks[format];74}75}7677return result;78}7980U_NAMESPACE_END818283