src/java.desktop/share/native/libfontmanager/DrawGlyphList.c
author ihse
Sat, 03 Mar 2018 08:21:47 +0100
branchihse-warnings-cflags-branch
changeset 56230 489867818774
parent 47216 71c04702a3d5
permissions -rw-r--r--
No longer disable E_OLD_STYLE_FUNC_DEF.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 12047
diff changeset
     2
 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
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 "jlong.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "math.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "string.h"
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 5506
diff changeset
    29
#include "stdlib.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "sunfontids.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "fontscalerdefs.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "glyphblitting.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "GraphicsPrimitiveMgr.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "sun_java2d_loops_DrawGlyphList.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "sun_java2d_loops_DrawGlyphListAA.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Need to account for the rare case when (eg) repainting damaged
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * areas results in the drawing location being negative, in which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * case (int) rounding always goes towards zero. We need to always
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * round down instead, so that we paint at the correct position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * We only call "floor" when value is < 0 (ie rarely).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * Storing the result of (eg) (x+ginfo->topLeftX) benchmarks is more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * expensive than repeating the calculation as we do here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * "floor" shows up as a significant cost in app-level microbenchmarks.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * This macro avoids calling it on positive values, instead using an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * (int) cast.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define FLOOR_ASSIGN(l, r)\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 if ((r)<0) (l) = ((int)floor(r)); else (l) = ((int)(r))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
GlyphBlitVector* setupBlitVector(JNIEnv *env, jobject glyphlist) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
25557
f9cb8492293a 8043508: JVM core dumps with very long text in tooltip
prr
parents: 23010
diff changeset
    55
    int g;
f9cb8492293a 8043508: JVM core dumps with very long text in tooltip
prr
parents: 23010
diff changeset
    56
    size_t bytesNeeded;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    jlong *imagePtrs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    jfloat* positions = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    GlyphInfo *ginfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    GlyphBlitVector *gbv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    jfloat x = (*env)->GetFloatField(env, glyphlist, sunFontIDs.glyphListX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    jfloat y = (*env)->GetFloatField(env, glyphlist, sunFontIDs.glyphListY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    jint len =  (*env)->GetIntField(env, glyphlist, sunFontIDs.glyphListLen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    jlongArray glyphImages = (jlongArray)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        (*env)->GetObjectField(env, glyphlist, sunFontIDs.glyphImages);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    jfloatArray glyphPositions =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
      (*env)->GetBooleanField(env, glyphlist, sunFontIDs.glyphListUsePos)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        ? (jfloatArray)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
      (*env)->GetObjectField(env, glyphlist, sunFontIDs.glyphListPos)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        : NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    bytesNeeded = sizeof(GlyphBlitVector)+sizeof(ImageRef)*len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    gbv = (GlyphBlitVector*)malloc(bytesNeeded);
25557
f9cb8492293a 8043508: JVM core dumps with very long text in tooltip
prr
parents: 23010
diff changeset
    75
    if (gbv == NULL) {
f9cb8492293a 8043508: JVM core dumps with very long text in tooltip
prr
parents: 23010
diff changeset
    76
        return NULL;
f9cb8492293a 8043508: JVM core dumps with very long text in tooltip
prr
parents: 23010
diff changeset
    77
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    gbv->numGlyphs = len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    gbv->glyphs = (ImageRef*)((unsigned char*)gbv+sizeof(GlyphBlitVector));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    imagePtrs = (*env)->GetPrimitiveArrayCritical(env, glyphImages, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    if (imagePtrs == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        free(gbv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        return (GlyphBlitVector*)NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /* Add 0.5 to x and y and then use floor (or an equivalent operation)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * to round down the glyph positions to integral pixel positions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    x += 0.5f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    y += 0.5f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    if (glyphPositions) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        int n = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        positions =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
          (*env)->GetPrimitiveArrayCritical(env, glyphPositions, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        if (positions == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            (*env)->ReleasePrimitiveArrayCritical(env, glyphImages,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                                                  imagePtrs, JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            free(gbv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            return (GlyphBlitVector*)NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        for (g=0; g<len; g++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            jfloat px = x + positions[++n];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            jfloat py = y + positions[++n];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            ginfo = (GlyphInfo*)imagePtrs[g];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            gbv->glyphs[g].glyphInfo = ginfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            gbv->glyphs[g].pixels = ginfo->image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            gbv->glyphs[g].width = ginfo->width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            gbv->glyphs[g].rowBytes = ginfo->rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            gbv->glyphs[g].height = ginfo->height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            FLOOR_ASSIGN(gbv->glyphs[g].x, px + ginfo->topLeftX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            FLOOR_ASSIGN(gbv->glyphs[g].y, py + ginfo->topLeftY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        (*env)->ReleasePrimitiveArrayCritical(env,glyphPositions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                                              positions, JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        for (g=0; g<len; g++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            ginfo = (GlyphInfo*)imagePtrs[g];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            gbv->glyphs[g].glyphInfo = ginfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            gbv->glyphs[g].pixels = ginfo->image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            gbv->glyphs[g].width = ginfo->width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            gbv->glyphs[g].rowBytes = ginfo->rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            gbv->glyphs[g].height = ginfo->height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            FLOOR_ASSIGN(gbv->glyphs[g].x, x + ginfo->topLeftX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            FLOOR_ASSIGN(gbv->glyphs[g].y, y + ginfo->topLeftY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            /* copy image data into this array at x/y locations */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            x += ginfo->advanceX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            y += ginfo->advanceY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    (*env)->ReleasePrimitiveArrayCritical(env, glyphImages, imagePtrs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                                          JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    return gbv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
jint RefineBounds(GlyphBlitVector *gbv, SurfaceDataBounds *bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    int index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    jint dx1, dy1, dx2, dy2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    ImageRef glyphImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    int num = gbv->numGlyphs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    SurfaceDataBounds glyphs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    glyphs.x1 = glyphs.y1 = 0x7fffffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    glyphs.x2 = glyphs.y2 = 0x80000000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    for (index = 0; index < num; index++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        glyphImage = gbv->glyphs[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        dx1 = (jint) glyphImage.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        dy1 = (jint) glyphImage.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        dx2 = dx1 + glyphImage.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        dy2 = dy1 + glyphImage.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        if (glyphs.x1 > dx1) glyphs.x1 = dx1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        if (glyphs.y1 > dy1) glyphs.y1 = dy1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        if (glyphs.x2 < dx2) glyphs.x2 = dx2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        if (glyphs.y2 < dy2) glyphs.y2 = dy2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    SurfaceData_IntersectBounds(bounds, &glyphs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    return (bounds->x1 < bounds->x2 && bounds->y1 < bounds->y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
/* since the AA and non-AA loop functions share a common method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 * signature, can call both through this common function since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 * there's no difference except for the inner loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 * This could be a macro but there's enough of those already.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
static void drawGlyphList(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                          jobject sg2d, jobject sData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                          GlyphBlitVector *gbv, jint pixel, jint color,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                          NativePrimitive *pPrim, DrawGlyphListFunc *func) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    SurfaceDataOps *sdOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    SurfaceDataRasInfo rasInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    CompositeInfo compInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    int clipLeft, clipRight, clipTop, clipBottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    int ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    sdOps = SurfaceData_GetOps(env, sData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    if (sdOps == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    if (pPrim->pCompType->getCompInfo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        GrPrim_Sg2dGetCompInfo(env, sg2d, pPrim, &compInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    GrPrim_Sg2dGetClip(env, sg2d, &rasInfo.bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    if (rasInfo.bounds.y2 <= rasInfo.bounds.y1 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        rasInfo.bounds.x2 <= rasInfo.bounds.x1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    ret = sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    if (ret != SD_SUCCESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        if (ret == SD_SLOWLOCK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            if (!RefineBounds(gbv, &rasInfo.bounds)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    sdOps->GetRasInfo(env, sdOps, &rasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    if (!rasInfo.rasBase) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    clipLeft    = rasInfo.bounds.x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    clipRight   = rasInfo.bounds.x2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    clipTop     = rasInfo.bounds.y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    clipBottom  = rasInfo.bounds.y2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    if (clipRight > clipLeft && clipBottom > clipTop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        (*func)(&rasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                gbv->glyphs, gbv->numGlyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                pixel, color,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                clipLeft, clipTop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                clipRight, clipBottom,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                pPrim, &compInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
static unsigned char* getLCDGammaLUT(int gamma);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
static unsigned char* getInvLCDGammaLUT(int gamma);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
static void drawGlyphListLCD(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                          jobject sg2d, jobject sData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                          GlyphBlitVector *gbv, jint pixel, jint color,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                          jboolean rgbOrder, int contrast,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                          NativePrimitive *pPrim,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                          DrawGlyphListLCDFunc *func) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    SurfaceDataOps *sdOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    SurfaceDataRasInfo rasInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    CompositeInfo compInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    int clipLeft, clipRight, clipTop, clipBottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    int ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    sdOps = SurfaceData_GetOps(env, sData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    if (sdOps == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    if (pPrim->pCompType->getCompInfo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        GrPrim_Sg2dGetCompInfo(env, sg2d, pPrim, &compInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    GrPrim_Sg2dGetClip(env, sg2d, &rasInfo.bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    if (rasInfo.bounds.y2 <= rasInfo.bounds.y1 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        rasInfo.bounds.x2 <= rasInfo.bounds.x1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    {
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    ret = sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    if (ret != SD_SUCCESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        if (ret == SD_SLOWLOCK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            if (!RefineBounds(gbv, &rasInfo.bounds)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    sdOps->GetRasInfo(env, sdOps, &rasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    if (!rasInfo.rasBase) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    clipLeft    = rasInfo.bounds.x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    clipRight   = rasInfo.bounds.x2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    clipTop     = rasInfo.bounds.y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    clipBottom  = rasInfo.bounds.y2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    if (clipRight > clipLeft && clipBottom > clipTop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        (*func)(&rasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                gbv->glyphs, gbv->numGlyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                pixel, color,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                clipLeft, clipTop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                clipRight, clipBottom, (jint)rgbOrder,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                getLCDGammaLUT(contrast), getInvLCDGammaLUT(contrast),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                pPrim, &compInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
 * Class:     sun_java2d_loops_DrawGlyphList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
 * Method:    DrawGlyphList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
 * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;Lsun/java2d/font/GlyphList;J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
Java_sun_java2d_loops_DrawGlyphList_DrawGlyphList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    (JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     jobject sg2d, jobject sData, jobject glyphlist) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    jint pixel, color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    GlyphBlitVector* gbv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    NativePrimitive *pPrim;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    if ((pPrim = GetNativePrim(env, self)) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    if ((gbv = setupBlitVector(env, glyphlist)) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    pixel = GrPrim_Sg2dGetPixel(env, sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    color = GrPrim_Sg2dGetEaRGB(env, sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    drawGlyphList(env, self, sg2d, sData, gbv, pixel, color,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                  pPrim, pPrim->funcs.drawglyphlist);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    free(gbv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
 * Class:     sun_java2d_loops_DrawGlyphListAA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
 * Method:    DrawGlyphListAA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
 * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;Lsun/java2d/font/GlyphList;J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
Java_sun_java2d_loops_DrawGlyphListAA_DrawGlyphListAA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    (JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     jobject sg2d, jobject sData, jobject glyphlist) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    jint pixel, color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    GlyphBlitVector* gbv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    NativePrimitive *pPrim;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    if ((pPrim = GetNativePrim(env, self)) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    if ((gbv = setupBlitVector(env, glyphlist)) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    pixel = GrPrim_Sg2dGetPixel(env, sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    color = GrPrim_Sg2dGetEaRGB(env, sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    drawGlyphList(env, self, sg2d, sData, gbv, pixel, color,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                  pPrim, pPrim->funcs.drawglyphlistaa);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    free(gbv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
 * Class:     sun_java2d_loops_DrawGlyphListLCD
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
 * Method:    DrawGlyphListLCD
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
 * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;Lsun/java2d/font/GlyphList;J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
Java_sun_java2d_loops_DrawGlyphListLCD_DrawGlyphListLCD
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    (JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     jobject sg2d, jobject sData, jobject glyphlist) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    jint pixel, color, contrast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    jboolean rgbOrder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    GlyphBlitVector* gbv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    NativePrimitive *pPrim;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    if ((pPrim = GetNativePrim(env, self)) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    if ((gbv = setupLCDBlitVector(env, glyphlist)) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    pixel = GrPrim_Sg2dGetPixel(env, sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    color = GrPrim_Sg2dGetEaRGB(env, sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    contrast = GrPrim_Sg2dGetLCDTextContrast(env, sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    rgbOrder = (*env)->GetBooleanField(env,glyphlist, sunFontIDs.lcdRGBOrder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    drawGlyphListLCD(env, self, sg2d, sData, gbv, pixel, color,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                     rgbOrder, contrast,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                     pPrim, pPrim->funcs.drawglyphlistlcd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    free(gbv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
 *  LCD text utilises a filter which spreads energy to adjacent subpixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
 *  So we add 3 bytes (one whole pixel) of padding at the start of every row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
 *  to hold energy from the very leftmost sub-pixel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
 *  This is to the left of the intended glyph image position so LCD text also
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
 *  adjusts the top-left X position of the padded image one pixel to the left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
 *  so a glyph image is drawn in the same place it would be if the padding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
 *  were not present.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
 *  So in the glyph cache for LCD text the first two bytes of every row are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
 *  zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
 *  We make use of this to be able to adjust the rendering position of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
 *  text when the client specifies a fractional metrics sub-pixel positioning
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
 *  rendering hint.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
 *  So the first 6 bytes in a cache row looks like :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
 *  00 00 Ex G0 G1 G2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
 *  where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
 *  00 are the always zero bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
 *  Ex is extra energy spread from the glyph into the left padding pixel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
 *  Gn are the RGB component bytes of the first pixel of the glyph image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
 *  For an RGB display G0 is the red component, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
 *  If a glyph is drawn at X=12 then the G0 G1 G2 pixel is placed at that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
 *  position : ie G0 is drawn in the first sub-pixel at X=12
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
 *  Draw at X=12,0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
 *  PIXEL POS 11 11 11 12 12 12 13 13 13
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
 *  SUBPX POS  0  1  2  0  1  2  0  1  2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
 *            00 00 Ex G0 G1 G2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
 *  If a sub-pixel rounded glyph position is calculated as being X=12.33 -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
 *  ie 12 and one-third pixels, we want the result to look like this :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
 *  Draw at X=12,1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
 *  PIXEL POS 11 11 11 12 12 12 13 13 13
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
 *  SUBPX POS  0  1  2  0  1  2  0  1  2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
 *               00 00 Ex G0 G1 G2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
 *  ie the G0 byte is moved one sub-pixel to the right.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
 *  To do this we need to make two adjustments :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
 *  - set X=X+1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
 *  - set start of scan row to start+2, ie index past the two zero bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
 *  ie we don't need the 00 00 bytes at all any more. Rendering start X
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
 *  can skip over those.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
 *  Lets look at the final case :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
 *  If a sub-pixel rounded glyph position is calculated as being X=12.67 -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
 *  ie 12 and two-third pixels, we want the result to look like this :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
 *  Draw at X=12,2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
 *  PIXEL POS 11 11 11 12 12 12 13 13 13
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
 *  SUBPX POS  0  1  2  0  1  2  0  1  2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
 *                  00 00 Ex G0 G1 G2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
 *  ie the G0 byte is moved two sub-pixels to the right, so that the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
 *  starts at 12.67
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
 *  To do this we need to make these two adjustments :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
 *  - set X=X+1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
 *  - set start of scan row to start+1, ie index past the first zero byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
 *  In this case the second of the 00 bytes is used as a no-op on the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
 *   red sub-pixel position.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
 *  The final adjustment needed to make all this work is note that if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
 *  we moved the start of row one or two bytes in we will go one or two bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
 *  past the end of the row. So the glyph cache needs to have 2 bytes of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
 *  zero padding at the end of each row. This is the extra memory cost to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
 *  accommodate this algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
 *  The resulting text is perhaps fractionally better in overall perception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
 *  than rounding to the whole pixel grid, as a few issues arise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
 *  * the improvement in inter-glyph spacing as well as being limited
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
 *  to 1/3 pixel resolution, is also limited because the glyphs were hinted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
 *  so they fit to the whole pixel grid. It may be worthwhile to pursue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
 *  disabling x-axis gridfitting.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
 *  * an LCD display may have gaps between the pixels that are greater
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
 *  than the subpixels. Thus for thin stemmed fonts, if the shift causes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
 *  the "heart" of a stem to span whole pixels it may appear more diffuse -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
 *  less sharp. Eliminating hinting would probably not make this worse - in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
 *  effect we have already doing that here. But it would improve the spacing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
 *  * perhaps contradicting the above point in some ways, more diffuse glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
 *  are better at reducing colour fringing, but what appears to be more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
 *  colour fringing in this FM case is more likely attributable to a greater
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
 *  likelihood for glyphs to abutt. In integer metrics or even whole pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
 *  rendered fractional metrics, there's typically more space between the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
 *  glyphs. Perhaps disabling X-axis grid-fitting will help with that.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
GlyphBlitVector* setupLCDBlitVector(JNIEnv *env, jobject glyphlist) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
25557
f9cb8492293a 8043508: JVM core dumps with very long text in tooltip
prr
parents: 23010
diff changeset
   486
    int g;
f9cb8492293a 8043508: JVM core dumps with very long text in tooltip
prr
parents: 23010
diff changeset
   487
    size_t bytesNeeded;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    jlong *imagePtrs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    jfloat* positions = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    GlyphInfo *ginfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    GlyphBlitVector *gbv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    jfloat x = (*env)->GetFloatField(env, glyphlist, sunFontIDs.glyphListX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    jfloat y = (*env)->GetFloatField(env, glyphlist, sunFontIDs.glyphListY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    jint len =  (*env)->GetIntField(env, glyphlist, sunFontIDs.glyphListLen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    jlongArray glyphImages = (jlongArray)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        (*env)->GetObjectField(env, glyphlist, sunFontIDs.glyphImages);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    jfloatArray glyphPositions =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
      (*env)->GetBooleanField(env, glyphlist, sunFontIDs.glyphListUsePos)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        ? (jfloatArray)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
      (*env)->GetObjectField(env, glyphlist, sunFontIDs.glyphListPos)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        : NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    jboolean subPixPos =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
      (*env)->GetBooleanField(env,glyphlist, sunFontIDs.lcdSubPixPos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    bytesNeeded = sizeof(GlyphBlitVector)+sizeof(ImageRef)*len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    gbv = (GlyphBlitVector*)malloc(bytesNeeded);
25557
f9cb8492293a 8043508: JVM core dumps with very long text in tooltip
prr
parents: 23010
diff changeset
   508
    if (gbv == NULL) {
f9cb8492293a 8043508: JVM core dumps with very long text in tooltip
prr
parents: 23010
diff changeset
   509
        return NULL;
f9cb8492293a 8043508: JVM core dumps with very long text in tooltip
prr
parents: 23010
diff changeset
   510
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    gbv->numGlyphs = len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    gbv->glyphs = (ImageRef*)((unsigned char*)gbv+sizeof(GlyphBlitVector));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    imagePtrs = (*env)->GetPrimitiveArrayCritical(env, glyphImages, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    if (imagePtrs == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        free(gbv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        return (GlyphBlitVector*)NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    /* The position of the start of the text is adjusted up so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * that we can round it to an integral pixel position for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * bitmap glyph or non-subpixel positioning, and round it to an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * integral subpixel position for that case, hence 0.5/3 = 0.166667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * Presently subPixPos means FM, and FM disables embedded bitmaps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * Therefore if subPixPos is true we should never get embedded bitmaps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * and the glyphlist will be homogenous. This test and the position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * adjustments will need to be per glyph once this case becomes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * heterogenous.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * Also set subPixPos=false if detect a B&W bitmap as we only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * need to test that on a per glyph basis once the list becomes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * heterogenous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    if (subPixPos && len > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        ginfo = (GlyphInfo*)imagePtrs[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        /* rowBytes==width tests if its a B&W or LCD glyph */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        if (ginfo->width == ginfo->rowBytes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            subPixPos = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    if (subPixPos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        x += 0.1666667f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        y += 0.1666667f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        x += 0.5f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        y += 0.5f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     if (glyphPositions) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        int n = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        positions =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
          (*env)->GetPrimitiveArrayCritical(env, glyphPositions, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        if (positions == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            (*env)->ReleasePrimitiveArrayCritical(env, glyphImages,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                                                  imagePtrs, JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            free(gbv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            return (GlyphBlitVector*)NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        for (g=0; g<len; g++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            jfloat px, py;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            ginfo = (GlyphInfo*)imagePtrs[g];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            gbv->glyphs[g].glyphInfo = ginfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            gbv->glyphs[g].pixels = ginfo->image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            gbv->glyphs[g].width = ginfo->width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            gbv->glyphs[g].rowBytes = ginfo->rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            gbv->glyphs[g].height = ginfo->height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            px = x + positions[++n];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            py = y + positions[++n];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
             * Subpixel positioning may be requested for LCD text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
             * Subpixel positioning can take place only in the direction in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
             * which the subpixels increase the resolution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
             * So this is useful for the typical case of vertical stripes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
             * increasing the resolution in the direction of the glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
             * advances - ie typical horizontally laid out text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
             * If the subpixel stripes are horizontal, subpixel positioning
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
             * can take place only in the vertical direction, which isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
             * as useful - you would have to be drawing rotated text on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
             * a display which actually had that organisation. A pretty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
             * unlikely combination.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
             * So this is supported only for vertical stripes which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
             * increase the horizontal resolution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
             * If in this case the client also rotates the text then there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
             * will still be some benefit for small rotations. For 90 degree
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
             * rotation there's no horizontal advance and less benefit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
             * from the subpixel rendering too.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
             * The test for width==rowBytes detects the case where the glyph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
             * is a B&W image obtained from an embedded bitmap. In that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
             * case we cannot apply sub-pixel positioning so ignore it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
             * This is handled on a per glyph basis.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            if (subPixPos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                int frac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                float pos = px + ginfo->topLeftX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                FLOOR_ASSIGN(gbv->glyphs[g].x, pos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                /* Calculate the fractional pixel position - ie the subpixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                 * position within the RGB/BGR triple. We are rounding to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                 * the nearest, even though we just do (int) since at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                 * start of the loop the position was already adjusted by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                 * 0.5 (sub)pixels to get rounding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                 * Thus the "fractional" position will be 0, 1 or 2.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                 * eg 0->0.32 is 0, 0.33->0.66 is 1, > 0.66->0.99 is 2.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                 * We can use an (int) cast here since the floor operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                 * above guarantees us that the value is positive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                frac = (int)((pos - gbv->glyphs[g].x)*3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                if (frac == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                    /* frac rounded down to zero, so this is equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                     * to no sub-pixel positioning.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                    gbv->glyphs[g].rowBytesOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                    /* In this case we need to adjust both the position at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                     * which the glyph will be positioned by one pixel to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                     * left and adjust the position in the glyph image row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                     * from which to extract the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                     * Every glyph image row has 2 bytes padding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                     * on the right to account for this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                    gbv->glyphs[g].rowBytesOffset = 3-frac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                    gbv->glyphs[g].x += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                FLOOR_ASSIGN(gbv->glyphs[g].x, px + ginfo->topLeftX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                gbv->glyphs[g].rowBytesOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            FLOOR_ASSIGN(gbv->glyphs[g].y, py + ginfo->topLeftY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        (*env)->ReleasePrimitiveArrayCritical(env,glyphPositions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                                              positions, JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        for (g=0; g<len; g++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            ginfo = (GlyphInfo*)imagePtrs[g];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            gbv->glyphs[g].glyphInfo = ginfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            gbv->glyphs[g].pixels = ginfo->image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            gbv->glyphs[g].width = ginfo->width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            gbv->glyphs[g].rowBytes = ginfo->rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            gbv->glyphs[g].height = ginfo->height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            if (subPixPos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                int frac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                float pos = x + ginfo->topLeftX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                FLOOR_ASSIGN(gbv->glyphs[g].x, pos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                frac = (int)((pos - gbv->glyphs[g].x)*3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                if (frac == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                    gbv->glyphs[g].rowBytesOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                    gbv->glyphs[g].rowBytesOffset = 3-frac;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                    gbv->glyphs[g].x += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                FLOOR_ASSIGN(gbv->glyphs[g].x, x + ginfo->topLeftX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                gbv->glyphs[g].rowBytesOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            FLOOR_ASSIGN(gbv->glyphs[g].y, y + ginfo->topLeftY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            /* copy image data into this array at x/y locations */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            x += ginfo->advanceX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
            y += ginfo->advanceY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    (*env)->ReleasePrimitiveArrayCritical(env, glyphImages, imagePtrs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                                          JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    return gbv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
/* LCD text needs to go through a gamma (contrast) adjustment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
 * Gamma is constrained to the range 1.0->2.2 with a quantization of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
 * 0.01 (more than good enough). Representing as an integer with that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
 * precision yields a range 100->250 thus we need to store up to 151 LUTs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
 * and inverse LUTs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
 * We allocate the actual LUTs on an as needed basis. Typically zero or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
 * one is what will be needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
 * Colour component values are in the range 0.0->1.0 represented as an integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
 * in the range 0->255 (ie in a byte). It is assumed that even if we have 5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
 * bit colour components these are presented mapped on to 8 bit components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
 * lcdGammaLUT references LUTs which convert linear colour components
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
 * to a gamma adjusted space, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
 * lcdInvGammaLUT references LUTs which convert gamma adjusted colour
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
 * components to a linear space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
#define MIN_GAMMA 100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
#define MAX_GAMMA 250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
#define LCDLUTCOUNT (MAX_GAMMA-MIN_GAMMA+1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
 UInt8 *lcdGammaLUT[LCDLUTCOUNT];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
 UInt8 *lcdInvGammaLUT[LCDLUTCOUNT];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
void initLUT(int gamma) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
  int i,index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
  double ig,g;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
  index = gamma-MIN_GAMMA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
  lcdGammaLUT[index] = (UInt8*)malloc(256);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
  lcdInvGammaLUT[index] = (UInt8*)malloc(256);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
  if (gamma==100) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    for (i=0;i<256;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
      lcdGammaLUT[index][i] = (UInt8)i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
      lcdInvGammaLUT[index][i] = (UInt8)i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
  ig = ((double)gamma)/100.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
  g = 1.0/ig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
  lcdGammaLUT[index][0] = (UInt8)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
  lcdInvGammaLUT[index][0] = (UInt8)0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
  lcdGammaLUT[index][255] = (UInt8)255;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
  lcdInvGammaLUT[index][255] = (UInt8)255;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
  for (i=1;i<255;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    double val = ((double)i)/255.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    double gval = pow(val, g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    double igval = pow(val, ig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    lcdGammaLUT[index][i] = (UInt8)(255*gval);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    lcdInvGammaLUT[index][i] = (UInt8)(255*igval);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
static unsigned char* getLCDGammaLUT(int gamma) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
  int index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
  if (gamma<MIN_GAMMA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     gamma = MIN_GAMMA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
  } else if (gamma>MAX_GAMMA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     gamma = MAX_GAMMA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
  index = gamma-MIN_GAMMA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
  if (!lcdGammaLUT[index]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    initLUT(gamma);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
  return (unsigned char*)lcdGammaLUT[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
static unsigned char* getInvLCDGammaLUT(int gamma) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
  int index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
   if (gamma<MIN_GAMMA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     gamma = MIN_GAMMA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
  } else if (gamma>MAX_GAMMA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     gamma = MAX_GAMMA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
  index = gamma-MIN_GAMMA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
  if (!lcdInvGammaLUT[index]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    initLUT(gamma);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
  return (unsigned char*)lcdInvGammaLUT[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
#if 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
void printDefaultTables(int gamma) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
  int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
  UInt8 *g, *ig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
  lcdGammaLUT[gamma-MIN_GAMMA] = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
  lcdInvGammaLUT[gamma-MIN_GAMMA] = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
  g = getLCDGammaLUT(gamma);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
  ig = getInvLCDGammaLUT(gamma);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
  printf("UInt8 defaultGammaLUT[256] = {\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
  for (i=0;i<256;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    if (i % 8 == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
      printf("    /* %3d */  ", i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    printf("%4d, ",(int)(g[i]&0xff));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    if ((i+1) % 8 == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
      printf("\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
  printf("};\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
  printf("UInt8 defaultInvGammaLUT[256] = {\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
  for (i=0;i<256;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    if (i % 8 == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
      printf("    /* %3d */  ", i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    printf("%4d, ",(int)(ig[i]&0xff));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    if ((i+1) % 8 == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
      printf("\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
  printf("};\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
/* These tables are generated for a Gamma adjustment of 1.4 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
UInt8 defaultGammaLUT[256] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    /*   0 */     0,    4,    7,   10,   13,   15,   17,   19,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
    /*   8 */    21,   23,   25,   27,   28,   30,   32,   33,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    /*  16 */    35,   36,   38,   39,   41,   42,   44,   45,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    /*  24 */    47,   48,   49,   51,   52,   53,   55,   56,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    /*  32 */    57,   59,   60,   61,   62,   64,   65,   66,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    /*  40 */    67,   69,   70,   71,   72,   73,   75,   76,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    /*  48 */    77,   78,   79,   80,   81,   83,   84,   85,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    /*  56 */    86,   87,   88,   89,   90,   91,   92,   93,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    /*  64 */    94,   96,   97,   98,   99,  100,  101,  102,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
    /*  72 */   103,  104,  105,  106,  107,  108,  109,  110,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    /*  80 */   111,  112,  113,  114,  115,  116,  117,  118,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    /*  88 */   119,  120,  121,  122,  123,  124,  125,  125,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    /*  96 */   126,  127,  128,  129,  130,  131,  132,  133,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
    /* 104 */   134,  135,  136,  137,  138,  138,  139,  140,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    /* 112 */   141,  142,  143,  144,  145,  146,  147,  147,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    /* 120 */   148,  149,  150,  151,  152,  153,  154,  154,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    /* 128 */   155,  156,  157,  158,  159,  160,  161,  161,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
    /* 136 */   162,  163,  164,  165,  166,  167,  167,  168,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    /* 144 */   169,  170,  171,  172,  172,  173,  174,  175,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    /* 152 */   176,  177,  177,  178,  179,  180,  181,  181,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    /* 160 */   182,  183,  184,  185,  186,  186,  187,  188,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    /* 168 */   189,  190,  190,  191,  192,  193,  194,  194,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    /* 176 */   195,  196,  197,  198,  198,  199,  200,  201,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    /* 184 */   201,  202,  203,  204,  205,  205,  206,  207,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    /* 192 */   208,  208,  209,  210,  211,  212,  212,  213,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    /* 200 */   214,  215,  215,  216,  217,  218,  218,  219,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    /* 208 */   220,  221,  221,  222,  223,  224,  224,  225,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    /* 216 */   226,  227,  227,  228,  229,  230,  230,  231,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    /* 224 */   232,  233,  233,  234,  235,  236,  236,  237,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    /* 232 */   238,  239,  239,  240,  241,  242,  242,  243,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    /* 240 */   244,  244,  245,  246,  247,  247,  248,  249,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    /* 248 */   249,  250,  251,  252,  252,  253,  254,  255,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
UInt8 defaultInvGammaLUT[256] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    /*   0 */     0,    0,    0,    0,    0,    1,    1,    1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    /*   8 */     2,    2,    2,    3,    3,    3,    4,    4,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    /*  16 */     5,    5,    6,    6,    7,    7,    8,    8,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    /*  24 */     9,    9,   10,   10,   11,   12,   12,   13,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    /*  32 */    13,   14,   15,   15,   16,   17,   17,   18,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    /*  40 */    19,   19,   20,   21,   21,   22,   23,   23,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    /*  48 */    24,   25,   26,   26,   27,   28,   29,   29,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    /*  56 */    30,   31,   32,   32,   33,   34,   35,   36,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    /*  64 */    36,   37,   38,   39,   40,   40,   41,   42,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
    /*  72 */    43,   44,   45,   45,   46,   47,   48,   49,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    /*  80 */    50,   51,   52,   52,   53,   54,   55,   56,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    /*  88 */    57,   58,   59,   60,   61,   62,   63,   64,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    /*  96 */    64,   65,   66,   67,   68,   69,   70,   71,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    /* 104 */    72,   73,   74,   75,   76,   77,   78,   79,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    /* 112 */    80,   81,   82,   83,   84,   85,   86,   87,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    /* 120 */    88,   89,   90,   91,   92,   93,   95,   96,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    /* 128 */    97,   98,   99,  100,  101,  102,  103,  104,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    /* 136 */   105,  106,  107,  109,  110,  111,  112,  113,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    /* 144 */   114,  115,  116,  117,  119,  120,  121,  122,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    /* 152 */   123,  124,  125,  127,  128,  129,  130,  131,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
    /* 160 */   132,  133,  135,  136,  137,  138,  139,  140,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    /* 168 */   142,  143,  144,  145,  146,  148,  149,  150,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    /* 176 */   151,  152,  154,  155,  156,  157,  159,  160,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    /* 184 */   161,  162,  163,  165,  166,  167,  168,  170,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    /* 192 */   171,  172,  173,  175,  176,  177,  178,  180,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    /* 200 */   181,  182,  184,  185,  186,  187,  189,  190,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    /* 208 */   191,  193,  194,  195,  196,  198,  199,  200,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    /* 216 */   202,  203,  204,  206,  207,  208,  210,  211,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    /* 224 */   212,  214,  215,  216,  218,  219,  220,  222,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    /* 232 */   223,  224,  226,  227,  228,  230,  231,  232,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    /* 240 */   234,  235,  236,  238,  239,  241,  242,  243,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    /* 248 */   245,  246,  248,  249,  250,  252,  253,  255,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
/* Since our default is 140, here we can populate that from pre-calculated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
 * data, it needs only 512 bytes - plus a few more of overhead - and saves
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
 * about that many intrinsic function calls plus other FP calculations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
 */
56230
489867818774 No longer disable E_OLD_STYLE_FUNC_DEF.
ihse
parents: 47216
diff changeset
   864
void initLCDGammaTables(void) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
   memset(lcdGammaLUT, 0,  LCDLUTCOUNT * sizeof(UInt8*));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
   memset(lcdInvGammaLUT, 0, LCDLUTCOUNT * sizeof(UInt8*));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
/*    printDefaultTables(140); */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
   lcdGammaLUT[40] = defaultGammaLUT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
   lcdInvGammaLUT[40] = defaultInvGammaLUT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
}