jdk/src/share/native/sun/font/layout/GlyphIterator.cpp
author prr
Mon, 01 Jul 2013 12:39:26 -0700
changeset 18518 153791a0895c
parent 16891 91e99bed64ae
child 22330 cafb826672bd
permissions -rw-r--r--
8015144: Performance regression in ICU OpenType Layout library Reviewed-by: srl, jgodinez
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
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
#include "LETypes.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "OpenTypeTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "GlyphDefinitionTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "GlyphPositionAdjustments.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "GlyphIterator.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "LEGlyphStorage.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "Lookups.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "LESwaps.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    41
U_NAMESPACE_BEGIN
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    43
GlyphIterator::GlyphIterator(LEGlyphStorage &theGlyphStorage, GlyphPositionAdjustments *theGlyphPositionAdjustments, le_bool rightToLeft, le_uint16 theLookupFlags,
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    44
                             FeatureMask theFeatureMask, const LEReferenceTo<GlyphDefinitionTableHeader> &theGlyphDefinitionTableHeader)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  : direction(1), position(-1), nextLimit(-1), prevLimit(-1),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    glyphStorage(theGlyphStorage), glyphPositionAdjustments(theGlyphPositionAdjustments),
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    47
    srcIndex(-1), destIndex(-1), lookupFlags(theLookupFlags), featureMask(theFeatureMask), glyphGroup(0),
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    48
    glyphClassDefinitionTable(), markAttachClassDefinitionTable()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
{
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    51
  LEErrorCode success = LE_NO_ERROR; // TODO
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    le_int32 glyphCount = glyphStorage.getGlyphCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    54
    if (theGlyphDefinitionTableHeader.isValid()) {
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    55
      glyphClassDefinitionTable = theGlyphDefinitionTableHeader
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    56
        -> getGlyphClassDefinitionTable(theGlyphDefinitionTableHeader, success);
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    57
      markAttachClassDefinitionTable = theGlyphDefinitionTableHeader
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    58
        ->getMarkAttachClassDefinitionTable(theGlyphDefinitionTableHeader, success);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    nextLimit = glyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    if (rightToLeft) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        direction = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        position = glyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        nextLimit = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        prevLimit = glyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
    69
    filterResetCache();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
GlyphIterator::GlyphIterator(GlyphIterator &that)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
  : glyphStorage(that.glyphStorage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    direction    = that.direction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    position     = that.position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    nextLimit    = that.nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    prevLimit    = that.prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    glyphPositionAdjustments = that.glyphPositionAdjustments;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    srcIndex = that.srcIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    destIndex = that.destIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    lookupFlags = that.lookupFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    featureMask = that.featureMask;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    85
    glyphGroup  = that.glyphGroup;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    glyphClassDefinitionTable = that.glyphClassDefinitionTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
    88
    filterResetCache();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
GlyphIterator::GlyphIterator(GlyphIterator &that, FeatureMask newFeatureMask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
  : glyphStorage(that.glyphStorage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    direction    = that.direction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    position     = that.position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    nextLimit    = that.nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    prevLimit    = that.prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    glyphPositionAdjustments = that.glyphPositionAdjustments;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    srcIndex = that.srcIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    destIndex = that.destIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    lookupFlags = that.lookupFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    featureMask = newFeatureMask;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   104
    glyphGroup  = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    glyphClassDefinitionTable = that.glyphClassDefinitionTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   107
    filterResetCache();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
GlyphIterator::GlyphIterator(GlyphIterator &that, le_uint16 newLookupFlags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  : glyphStorage(that.glyphStorage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    direction    = that.direction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    position     = that.position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    nextLimit    = that.nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    prevLimit    = that.prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    glyphPositionAdjustments = that.glyphPositionAdjustments;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    srcIndex = that.srcIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    destIndex = that.destIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    lookupFlags = newLookupFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    featureMask = that.featureMask;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   123
    glyphGroup  = that.glyphGroup;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    glyphClassDefinitionTable = that.glyphClassDefinitionTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   126
    filterResetCache();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
GlyphIterator::~GlyphIterator()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    // nothing to do, right?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
void GlyphIterator::reset(le_uint16 newLookupFlags, FeatureMask newFeatureMask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    position     = prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    featureMask  = newFeatureMask;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   138
    glyphGroup   = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    lookupFlags  = newLookupFlags;
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   140
    filterResetCache();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   143
LEGlyphID *GlyphIterator::insertGlyphs(le_int32 count, LEErrorCode& success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
{
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   145
    return glyphStorage.insertGlyphs(position, count, success);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
le_int32 GlyphIterator::applyInsertions()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    le_int32 newGlyphCount = glyphStorage.applyInsertions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        prevLimit = newGlyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        nextLimit = newGlyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    return newGlyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
le_int32 GlyphIterator::getCurrStreamPosition() const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    return position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
le_bool GlyphIterator::isRightToLeft() const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    return direction < 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
le_bool GlyphIterator::ignoresMarks() const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    return (lookupFlags & lfIgnoreMarks) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
le_bool GlyphIterator::baselineIsLogicalEnd() const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    return (lookupFlags & lfBaselineIsLogicalEnd) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
LEGlyphID GlyphIterator::getCurrGlyphID() const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            return 0xFFFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            return 0xFFFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    return glyphStorage[position];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
void GlyphIterator::getCursiveEntryPoint(LEPoint &entryPoint) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    glyphPositionAdjustments->getEntryPoint(position, entryPoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
void GlyphIterator::getCursiveExitPoint(LEPoint &exitPoint) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    glyphPositionAdjustments->getExitPoint(position, exitPoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
void GlyphIterator::setCurrGlyphID(TTGlyphID glyphID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    LEGlyphID glyph = glyphStorage[position];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    glyphStorage[position] = LE_SET_GLYPH(glyph, glyphID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
void GlyphIterator::setCurrStreamPosition(le_int32 newPosition)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        if (newPosition >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            position = prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        if (newPosition <= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            position = nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        if (newPosition <= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            position = prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        if (newPosition >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            position = nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    position = newPosition - direction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
void GlyphIterator::setCurrGlyphBaseOffset(le_int32 baseOffset)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    glyphPositionAdjustments->setBaseOffset(position, baseOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   276
void GlyphIterator::adjustCurrGlyphPositionAdjustment(float xPlacementAdjust, float yPlacementAdjust,
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   277
                                                      float xAdvanceAdjust, float yAdvanceAdjust)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    glyphPositionAdjustments->adjustXPlacement(position, xPlacementAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    glyphPositionAdjustments->adjustYPlacement(position, yPlacementAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    glyphPositionAdjustments->adjustXAdvance(position, xAdvanceAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    glyphPositionAdjustments->adjustYAdvance(position, yAdvanceAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   295
void GlyphIterator::setCurrGlyphPositionAdjustment(float xPlacementAdjust, float yPlacementAdjust,
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   296
                                                      float xAdvanceAdjust, float yAdvanceAdjust)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    glyphPositionAdjustments->setXPlacement(position, xPlacementAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    glyphPositionAdjustments->setYPlacement(position, yPlacementAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    glyphPositionAdjustments->setXAdvance(position, xAdvanceAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    glyphPositionAdjustments->setYAdvance(position, yAdvanceAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   314
void GlyphIterator::clearCursiveEntryPoint()
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   315
{
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   316
    if (direction < 0) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   317
        if (position <= nextLimit || position >= prevLimit) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   318
            return;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   319
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   320
    } else {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   321
        if (position <= prevLimit || position >= nextLimit) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   322
            return;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   323
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   324
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   325
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   326
    glyphPositionAdjustments->clearEntryPoint(position);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   327
}
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   328
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   329
void GlyphIterator::clearCursiveExitPoint()
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   330
{
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   331
    if (direction < 0) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   332
        if (position <= nextLimit || position >= prevLimit) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   333
            return;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   334
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   335
    } else {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   336
        if (position <= prevLimit || position >= nextLimit) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   337
            return;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   338
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   339
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   340
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   341
    glyphPositionAdjustments->clearExitPoint(position);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   342
}
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   343
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
void GlyphIterator::setCursiveEntryPoint(LEPoint &entryPoint)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    glyphPositionAdjustments->setEntryPoint(position, entryPoint, baselineIsLogicalEnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
void GlyphIterator::setCursiveExitPoint(LEPoint &exitPoint)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    glyphPositionAdjustments->setExitPoint(position, exitPoint, baselineIsLogicalEnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
void GlyphIterator::setCursiveGlyph()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    glyphPositionAdjustments->setCursiveGlyph(position, baselineIsLogicalEnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   389
void GlyphIterator::filterResetCache(void) {
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   390
  filterCacheValid = FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   393
le_bool GlyphIterator::filterGlyph(le_uint32 index)
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   394
{
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   395
    LEGlyphID glyphID = glyphStorage[index];
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   396
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   397
    if (!filterCacheValid || filterCache.id != glyphID) {
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   398
      filterCache.id = glyphID;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   399
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   400
      le_bool &filterResult = filterCache.result;  // NB: Making this a reference to accept the updated value, in case
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   401
                                               // we want more fancy cacheing in the future.
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   402
    if (LE_GET_GLYPH(glyphID) >= 0xFFFE) {
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   403
        filterResult = TRUE;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   404
      } else {
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   405
        LEErrorCode success = LE_NO_ERROR;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   406
        le_int32 glyphClass = gcdNoGlyphClass;
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   407
    if (glyphClassDefinitionTable.isValid()) {
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   408
      glyphClass = glyphClassDefinitionTable->getGlyphClass(glyphClassDefinitionTable, glyphID, success);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    }
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   410
        switch (glyphClass) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    case gcdNoGlyphClass:
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   412
          filterResult = FALSE;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   413
          break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    case gcdSimpleGlyph:
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   416
          filterResult = (lookupFlags & lfIgnoreBaseGlyphs) != 0;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   417
          break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    case gcdLigatureGlyph:
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   420
          filterResult = (lookupFlags & lfIgnoreLigatures) != 0;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   421
          break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    case gcdMarkGlyph:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        if ((lookupFlags & lfIgnoreMarks) != 0) {
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   425
            filterResult = TRUE;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   426
          } else {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        le_uint16 markAttachType = (lookupFlags & lfMarkAttachTypeMask) >> lfMarkAttachTypeShift;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   429
        if ((markAttachType != 0) && (markAttachClassDefinitionTable.isValid())) {
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   430
              filterResult = (markAttachClassDefinitionTable
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   431
                          -> getGlyphClass(markAttachClassDefinitionTable, glyphID, success) != markAttachType);
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   432
            } else {
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   433
              filterResult = FALSE;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   434
        }
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   435
    }
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   436
          break;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   437
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   438
    case gcdComponentGlyph:
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   439
          filterResult = ((lookupFlags & lfIgnoreBaseGlyphs) != 0);
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   440
          break;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   441
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   442
    default:
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   443
          filterResult = FALSE;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   444
          break;
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   445
    }
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   446
      }
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   447
      filterCacheValid = TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
18518
153791a0895c 8015144: Performance regression in ICU OpenType Layout library
prr
parents: 16891
diff changeset
   450
    return filterCache.result;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   453
le_bool GlyphIterator::hasFeatureTag(le_bool matchGroup) const
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    if (featureMask == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    LEErrorCode success = LE_NO_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    FeatureMask fm = glyphStorage.getAuxData(position, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   462
    return ((fm & featureMask) == featureMask) && (!matchGroup || (le_int32)(fm & LE_GLYPH_GROUP_MASK) == glyphGroup);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
le_bool GlyphIterator::findFeatureTag()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
{
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   467
  //glyphGroup = 0;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   468
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    while (nextInternal()) {
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   470
        if (hasFeatureTag(FALSE)) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   471
            LEErrorCode success = LE_NO_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   472
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   473
            glyphGroup = (glyphStorage.getAuxData(position, success) & LE_GLYPH_GROUP_MASK);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
le_bool GlyphIterator::nextInternal(le_uint32 delta)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    le_int32 newPosition = position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    while (newPosition != nextLimit && delta > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            newPosition += direction;
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   489
            //fprintf(stderr,"%s:%d:%s: newPosition = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, newPosition, delta);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        } while (newPosition != nextLimit && filterGlyph(newPosition));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        delta -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    position = newPosition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   497
    //fprintf(stderr,"%s:%d:%s: exit position = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, position, delta);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    return position != nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
le_bool GlyphIterator::next(le_uint32 delta)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
{
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   503
    return nextInternal(delta) && hasFeatureTag(TRUE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
le_bool GlyphIterator::prevInternal(le_uint32 delta)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    le_int32 newPosition = position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    while (newPosition != prevLimit && delta > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            newPosition -= direction;
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   513
            //fprintf(stderr,"%s:%d:%s: newPosition = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, newPosition, delta);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        } while (newPosition != prevLimit && filterGlyph(newPosition));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        delta -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    position = newPosition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   521
    //fprintf(stderr,"%s:%d:%s: exit position = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, position, delta);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    return position != prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
le_bool GlyphIterator::prev(le_uint32 delta)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
{
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   527
    return prevInternal(delta) && hasFeatureTag(TRUE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
le_int32 GlyphIterator::getMarkComponent(le_int32 markPosition) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    le_int32 component = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    le_int32 posn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    for (posn = position; posn != markPosition; posn += direction) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        if (glyphStorage[posn] == 0xFFFE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            component += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    return component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
// This is basically prevInternal except that it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
// doesn't take a delta argument, and it doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
// filter out 0xFFFE glyphs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
le_bool GlyphIterator::findMark2Glyph()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    le_int32 newPosition = position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        newPosition -= direction;
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   553
    } while (newPosition != prevLimit && glyphStorage[newPosition] != 0xFFFE && filterGlyph(newPosition));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    position = newPosition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    return position != prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
}
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   559
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   560
U_NAMESPACE_END