jdk/src/share/native/sun/font/AccelGlyphCache.c
author tdv
Tue, 22 Jul 2008 11:24:32 -0700
changeset 888 c7009cf0001f
parent 887 0aab8d3fa11a
child 5506 202f599c92aa
child 5579 1a5e995a710b
permissions -rw-r--r--
6728492: typo in copyrights in some files touched by the d3d pipeline port Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
888
c7009cf0001f 6728492: typo in copyrights in some files touched by the d3d pipeline port
tdv
parents: 887
diff changeset
     2
 * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <malloc.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "jni.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "AccelGlyphCache.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "Trace.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * When the cache is full, we will try to reuse the cache cells that have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * been used relatively less than the others (and we will save the cells that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * have been rendered more than the threshold defined here).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#define TIMES_RENDERED_THRESHOLD 5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Creates a new GlyphCacheInfo structure, fills in the initial values, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * then returns a pointer to the GlyphCacheInfo record.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * Note that this method only sets up a data structure describing a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * rectangular region of accelerated memory, containing "virtual" cells of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * the requested size.  The cell information is added lazily to the linked
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * list describing the cache as new glyphs are added.  Platform specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * glyph caching code is responsible for actually creating the accelerated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * memory surface that will contain the individual glyph images.
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    48
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    49
 * Each glyph contains a reference to a list of cell infos - one per glyph
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    50
 * cache. There may be multiple glyph caches (for example, one per graphics
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    51
 * adapter), so if the glyph is cached on two devices its cell list will
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    52
 * consists of two elements corresponding to different glyph caches.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    53
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    54
 * The platform-specific glyph caching code is supposed to use
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    55
 * GetCellInfoForCache method for retrieving cache infos from the glyph's list.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    56
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    57
 * Note that if it is guaranteed that there will be only one global glyph
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    58
 * cache then it one does not have to use AccelGlyphCache_GetCellInfoForCache
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    59
 * for retrieving cell info for the glyph, but instead just use the struct's
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    60
 * field directly.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
GlyphCacheInfo *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
AccelGlyphCache_Init(jint width, jint height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                     jint cellWidth, jint cellHeight,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                     FlushFunc *func)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    GlyphCacheInfo *gcinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    J2dTraceLn(J2D_TRACE_INFO, "AccelGlyphCache_Init");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    gcinfo = (GlyphCacheInfo *)malloc(sizeof(GlyphCacheInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    if (gcinfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            "AccelGlyphCache_Init: could not allocate GlyphCacheInfo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    gcinfo->head = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    gcinfo->tail = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    gcinfo->width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    gcinfo->height = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    gcinfo->cellWidth = cellWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    gcinfo->cellHeight = cellHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    gcinfo->isFull = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    gcinfo->Flush = func;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    return gcinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * Attempts to add the provided glyph to the specified cache.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * operation is successful, a pointer to the newly occupied cache cell is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * stored in the glyph's cellInfo field; otherwise, its cellInfo field is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * set to NULL, indicating that the glyph's original bits should be rendered
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * instead.  If the cache is full, the least-recently-used glyph is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * invalidated and its cache cell is reassigned to the new glyph being added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * Note that this method only ensures that a rectangular region in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * "virtual" glyph cache is available for the glyph image.  Platform specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * glyph caching code is responsible for actually caching the glyph image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * in the associated accelerated memory surface.
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   102
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   103
 * Returns created cell info if it was successfully created and added to the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   104
 * cache and glyph's cell lists, NULL otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   106
CacheCellInfo *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
AccelGlyphCache_AddGlyph(GlyphCacheInfo *cache, GlyphInfo *glyph)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    CacheCellInfo *cellinfo = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    jint w = glyph->width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    jint h = glyph->height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    J2dTraceLn(J2D_TRACE_INFO, "AccelGlyphCache_AddGlyph");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    if ((glyph->width > cache->cellWidth) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        (glyph->height > cache->cellHeight))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   118
        return NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    if (!cache->isFull) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        jint x, y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (cache->head == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            x = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            x = cache->tail->x + cache->cellWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            y = cache->tail->y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            if ((x + cache->cellWidth) > cache->width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                x = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                y += cache->cellHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                if ((y + cache->cellHeight) > cache->height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                    // no room left for a new cell; we'll go through the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                    // isFull path below
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                    cache->isFull = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (!cache->isFull) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            // create new CacheCellInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            cellinfo = (CacheCellInfo *)malloc(sizeof(CacheCellInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            if (cellinfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                J2dTraceLn(J2D_TRACE_ERROR, "could not allocate CellInfo");
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   146
                return NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            cellinfo->cacheInfo = cache;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            cellinfo->glyphInfo = glyph;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            cellinfo->timesRendered = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            cellinfo->x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            cellinfo->y = y;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   154
            cellinfo->leftOff = 0;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   155
            cellinfo->rightOff = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            cellinfo->tx1 = (jfloat)cellinfo->x / cache->width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            cellinfo->ty1 = (jfloat)cellinfo->y / cache->height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            cellinfo->tx2 = cellinfo->tx1 + ((jfloat)w / cache->width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            cellinfo->ty2 = cellinfo->ty1 + ((jfloat)h / cache->height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            if (cache->head == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                // initialize the head cell
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                cache->head = cellinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                // update existing tail cell
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                cache->tail->next = cellinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            // add the new cell to the end of the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            cache->tail = cellinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            cellinfo->next = NULL;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   172
            cellinfo->nextGCI = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    if (cache->isFull) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
         * Search through the cells, and for each cell:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
         *   - reset its timesRendered counter to zero
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
         *   - toss it to the end of the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
         * Eventually we will find a cell that either:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
         *   - is empty, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
         *   - has been used less than the threshold
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
         * When we find such a cell, we will:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
         *   - break out of the loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
         *   - invalidate any glyph that may be residing in that cell
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
         *   - update the cell with the new resident glyph's information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
         * The goal here is to keep the glyphs rendered most often in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
         * cache, while younger glyphs hang out near the end of the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
         * Those young glyphs that have only been used a few times will move
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
         * towards the head of the list and will eventually be kicked to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
         * the curb.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
         * In the worst-case scenario, all cells will be occupied and they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
         * will all have timesRendered counts above the threshold, so we will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
         * end up iterating through all the cells exactly once.  Since we are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
         * resetting their counters along the way, we are guaranteed to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
         * eventually hit the original "head" cell, whose counter is now zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
         * This avoids the possibility of an infinite loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            // the head cell will be updated on each iteration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            CacheCellInfo *current = cache->head;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            if ((current->glyphInfo == NULL) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                (current->timesRendered < TIMES_RENDERED_THRESHOLD))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                // all bow before the chosen one (we will break out of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                // loop now that we've found an appropriate cell)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                cellinfo = current;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            // move cell to the end of the list; update existing head and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            // tail pointers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            cache->head = current->next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            cache->tail->next = current;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            cache->tail = current;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            current->next = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            current->timesRendered = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        } while (cellinfo == NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        if (cellinfo->glyphInfo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            // flush in case any pending vertices are depending on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            // glyph that is about to be kicked out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            if (cache->Flush != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                cache->Flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   231
            // if the cell is occupied, notify the base glyph that the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   232
            // cached version for this cache is about to be kicked out
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   233
            AccelGlyphCache_RemoveCellInfo(cellinfo->glyphInfo, cellinfo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        // update cellinfo with glyph's occupied region information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        cellinfo->glyphInfo = glyph;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        cellinfo->tx2 = cellinfo->tx1 + ((jfloat)w / cache->width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        cellinfo->ty2 = cellinfo->ty1 + ((jfloat)h / cache->height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   242
    // add cache cell to the glyph's cells list
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   243
    AccelGlyphCache_AddCellInfo(glyph, cellinfo);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   244
    return cellinfo;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
 * Invalidates all cells in the cache.  Note that this method does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
 * attempt to compact the cache in any way; it just invalidates any cells
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
 * that already exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
AccelGlyphCache_Invalidate(GlyphCacheInfo *cache)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    CacheCellInfo *cellinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    J2dTraceLn(J2D_TRACE_INFO, "AccelGlyphCache_Invalidate");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    if (cache == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    // flush any pending vertices that may be depending on the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    // glyph cache layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    if (cache->Flush != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        cache->Flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    cellinfo = cache->head;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    while (cellinfo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        if (cellinfo->glyphInfo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            // if the cell is occupied, notify the base glyph that its
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   273
            // cached version for this cache is about to be invalidated
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   274
            AccelGlyphCache_RemoveCellInfo(cellinfo->glyphInfo, cellinfo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        cellinfo = cellinfo->next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
}
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   279
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   280
/**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   281
 * Invalidates and frees all cells and the cache itself. The "cache" pointer
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   282
 * becomes invalid after this function returns.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   283
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   284
void
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   285
AccelGlyphCache_Free(GlyphCacheInfo *cache)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   286
{
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   287
    CacheCellInfo *cellinfo;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   288
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   289
    J2dTraceLn(J2D_TRACE_INFO, "AccelGlyphCache_Free");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   290
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   291
    if (cache == NULL) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   292
        return;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   293
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   294
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   295
    // flush any pending vertices that may be depending on the current
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   296
    // glyph cache
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   297
    if (cache->Flush != NULL) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   298
        cache->Flush();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   299
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   300
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   301
    while (cache->head != NULL) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   302
        cellinfo = cache->head;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   303
        if (cellinfo->glyphInfo != NULL) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   304
            // if the cell is occupied, notify the base glyph that its
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   305
            // cached version for this cache is about to be invalidated
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   306
            AccelGlyphCache_RemoveCellInfo(cellinfo->glyphInfo, cellinfo);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   307
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   308
        cache->head = cellinfo->next;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   309
        free(cellinfo);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   310
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   311
    free(cache);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   312
}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   313
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   314
/**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   315
 * Add cell info to the head of the glyph's list of cached cells.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   316
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   317
void
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   318
AccelGlyphCache_AddCellInfo(GlyphInfo *glyph, CacheCellInfo *cellInfo)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   319
{
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   320
    // assert (glyph != NULL && cellInfo != NULL)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   321
    J2dTraceLn(J2D_TRACE_INFO, "AccelGlyphCache_AddCellInfo");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   322
    J2dTraceLn2(J2D_TRACE_VERBOSE, "  glyph 0x%x: adding cell 0x%x to the list",
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   323
                glyph, cellInfo);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   324
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   325
    cellInfo->glyphInfo = glyph;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   326
    cellInfo->nextGCI = glyph->cellInfo;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   327
    glyph->cellInfo = cellInfo;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   328
}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   329
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   330
/**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   331
 * Removes cell info from the glyph's list of cached cells.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   332
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   333
void
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   334
AccelGlyphCache_RemoveCellInfo(GlyphInfo *glyph, CacheCellInfo *cellInfo)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   335
{
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   336
    CacheCellInfo *currCellInfo = glyph->cellInfo;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   337
    CacheCellInfo *prevInfo = NULL;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   338
    // assert (glyph!= NULL && glyph->cellInfo != NULL && cellInfo != NULL)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   339
    J2dTraceLn(J2D_TRACE_INFO, "AccelGlyphCache_RemoveCellInfo");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   340
    do {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   341
        if (currCellInfo == cellInfo) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   342
            J2dTraceLn2(J2D_TRACE_VERBOSE,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   343
                        "  glyph 0x%x: removing cell 0x%x from glyph's list",
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   344
                        glyph, currCellInfo);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   345
            if (prevInfo == NULL) { // it's the head, chop-chop
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   346
                glyph->cellInfo = currCellInfo->nextGCI;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   347
            } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   348
                prevInfo->nextGCI = currCellInfo->nextGCI;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   349
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   350
            currCellInfo->glyphInfo = NULL;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   351
            currCellInfo->nextGCI = NULL;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   352
            return;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   353
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   354
        prevInfo = currCellInfo;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   355
        currCellInfo = currCellInfo->nextGCI;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   356
    } while (currCellInfo != NULL);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   357
    J2dTraceLn2(J2D_TRACE_WARNING, "AccelGlyphCache_RemoveCellInfo: "\
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   358
                "no cell 0x%x in glyph 0x%x's cell list",
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   359
                cellInfo, glyph);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   360
}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   361
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   362
/**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   363
 * Removes cell info from the glyph's list of cached cells.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   364
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   365
JNIEXPORT void
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   366
AccelGlyphCache_RemoveAllCellInfos(GlyphInfo *glyph)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   367
{
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   368
    CacheCellInfo *currCell, *prevCell;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   369
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   370
    J2dTraceLn(J2D_TRACE_INFO, "AccelGlyphCache_RemoveAllCellInfos");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   371
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   372
    if (glyph == NULL || glyph->cellInfo == NULL) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   373
        return;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   374
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   375
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   376
    // invalidate all of this glyph's accelerated cache cells
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   377
    currCell = glyph->cellInfo;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   378
    do {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   379
        currCell->glyphInfo = NULL;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   380
        prevCell = currCell;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   381
        currCell = currCell->nextGCI;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   382
        prevCell->nextGCI = NULL;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   383
    } while (currCell != NULL);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   384
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   385
    glyph->cellInfo = NULL;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   386
}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   387
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   388
/**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   389
 * Returns cell info associated with particular cache from the glyph's list of
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   390
 * cached cells.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   391
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   392
CacheCellInfo *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   393
AccelGlyphCache_GetCellInfoForCache(GlyphInfo *glyph, GlyphCacheInfo *cache)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   394
{
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   395
    // assert (glyph != NULL && cache != NULL)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   396
    J2dTraceLn(J2D_TRACE_VERBOSE2, "AccelGlyphCache_GetCellInfoForCache");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   397
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   398
    if (glyph->cellInfo != NULL) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   399
        CacheCellInfo *cellInfo = glyph->cellInfo;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   400
        do {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   401
            if (cellInfo->cacheInfo == cache) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   402
                J2dTraceLn3(J2D_TRACE_VERBOSE2,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   403
                            "  glyph 0x%x: found cell 0x%x for cache 0x%x",
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   404
                            glyph, cellInfo, cache);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   405
                return cellInfo;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   406
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   407
            cellInfo = cellInfo->nextGCI;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   408
        } while (cellInfo != NULL);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   409
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   410
    J2dTraceLn2(J2D_TRACE_VERBOSE2, "  glyph 0x%x: no cell for cache 0x%x",
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   411
                glyph, cache);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   412
    return NULL;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   413
}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   414