jdk/src/share/native/sun/font/layout/StateTables.h
author kvn
Tue, 28 Jan 2014 14:57:41 -0800
changeset 22607 ba232b417248
parent 16891 91e99bed64ae
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    22
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
    28
 * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#ifndef __STATETABLES_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#define __STATETABLES_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    35
/**
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    36
 * \file
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    37
 * \internal
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    38
 */
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    39
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "LETypes.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#include "LayoutTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    43
U_NAMESPACE_BEGIN
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    44
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    45
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    46
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    47
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    48
/*
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    49
 * State table loop detection.
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    50
 * Detects if too many ( LE_STATE_PATIENCE_COUNT ) state changes occur without moving the glyph index 'g'.
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    51
 *
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    52
 * Usage (pseudocode):
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    53
 *
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    54
 * {
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    55
 *   LE_STATE_PATIENCE_INIT();
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    56
 *
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    57
 *   int g=0; // the glyph index - expect it to be moving
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    58
 *
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    59
 *   for(;;) {
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    60
 *     if(LE_STATE_PATIENCE_DECR()) { // decrements the patience counter
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    61
 *        // ran out of patience, get out.
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    62
 *        break;
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    63
 *     }
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    64
 *
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    65
 *     LE_STATE_PATIENCE_CURR(int, g); // store the 'current'
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    66
 *     state = newState(state,g);
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    67
 *     g+= <something, could be zero>;
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    68
 *     LE_STATE_PATIENCE_INCR(g);  // if g has moved, increment the patience counter. Otherwise leave it.
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    69
 *   }
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    70
 *
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    71
 */
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    72
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    73
#define LE_STATE_PATIENCE_COUNT 4096 /**< give up if a state table doesn't move the glyph after this many iterations */
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    74
#define LE_STATE_PATIENCE_INIT()  le_uint32 le_patience_count = LE_STATE_PATIENCE_COUNT
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    75
#define LE_STATE_PATIENCE_DECR()  --le_patience_count==0
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    76
#define LE_STATE_PATIENCE_CURR(type,x)  type le_patience_curr=(x)
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    77
#define LE_STATE_PATIENCE_INCR(x)    if((x)!=le_patience_curr) ++le_patience_count;
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    78
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    79
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
struct StateTableHeader
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    le_int16 stateSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    ByteOffset classTableOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    ByteOffset stateArrayOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    ByteOffset entryTableOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
    88
struct StateTableHeader2
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
    89
{
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
    90
    le_uint32 nClasses;
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
    91
    le_uint32 classTableOffset;
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
    92
    le_uint32 stateArrayOffset;
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
    93
    le_uint32 entryTableOffset;
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
    94
};
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
    95
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
enum ClassCodes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    classCodeEOT = 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    classCodeOOB = 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    classCodeDEL = 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    classCodeEOL = 3,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    classCodeFirstFree = 4,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    classCodeMAX = 0xFF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
typedef le_uint8 ClassCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
struct ClassTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    TTGlyphID firstGlyph;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    le_uint16 nGlyphs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    ClassCode classArray[ANY_NUMBER];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
};
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   114
LE_VAR_ARRAY(ClassTable, classArray)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
enum StateNumber
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    stateSOT        = 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    stateSOL        = 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    stateFirstFree  = 2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    stateMAX        = 0xFF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
typedef le_uint8 EntryTableIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
struct StateEntry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    ByteOffset  newStateOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    le_int16    flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
   132
typedef le_uint16 EntryTableIndex2;
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
   133
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
   134
struct StateEntry2 // same struct different interpretation
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
   135
{
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
   136
    le_uint16    newStateIndex;
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
   137
    le_uint16    flags;
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
   138
};
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 5506
diff changeset
   139
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   140
U_NAMESPACE_END
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
#endif
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   142