jdk/src/solaris/native/sun/java2d/x11/X11TextRenderer_md.c
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2001, 2005, 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 "GlyphImageRef.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "SurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "X11SurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "GraphicsPrimitiveMgr.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include <jlong.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#define TEXT_BM_WIDTH   1024
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#define TEXT_BM_HEIGHT  32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
static jboolean checkPixmap(JNIEnv *env, AwtGraphicsConfigDataPtr cData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    XImage *img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    int image_size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    Window root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    if (cData->monoImage == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        img = XCreateImage(awt_display, NULL, 1, XYBitmap, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
                                   TEXT_BM_WIDTH, TEXT_BM_HEIGHT, 32, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        if (img != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
            image_size = img->bytes_per_line * TEXT_BM_HEIGHT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            // assert(BM_W and BM_H are not large enough to overflow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
            img->data = (char *) malloc(image_size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            if (img->data == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                XFree(img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                // Force same bit/byte ordering
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                img->bitmap_bit_order = img->byte_order;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                cData->monoImage = img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        if (cData->monoImage == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            JNU_ThrowOutOfMemoryError(env, "Cannot allocate bitmap for text");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
            return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    if (cData->monoPixmap == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        cData->monoPixmapGC == NULL ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        cData->monoPixmapWidth != TEXT_BM_WIDTH ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        cData->monoPixmapHeight != TEXT_BM_HEIGHT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        if (cData->monoPixmap != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            XFreePixmap(awt_display, cData->monoPixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            cData->monoPixmap = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        if (cData->monoPixmapGC != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            XFreeGC(awt_display, cData->monoPixmapGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            cData->monoPixmapGC = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        root = RootWindow(awt_display, cData->awt_visInfo.screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        cData->monoPixmap = XCreatePixmap(awt_display, root,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                                          TEXT_BM_WIDTH, TEXT_BM_HEIGHT, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        if (cData->monoPixmap == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            JNU_ThrowOutOfMemoryError(env, "Cannot allocate pixmap for text");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        cData->monoPixmapGC = XCreateGC(awt_display, cData->monoPixmap,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                                        0, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        if (cData->monoPixmapGC == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            XFreePixmap(awt_display, cData->monoPixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            cData->monoPixmap = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            JNU_ThrowOutOfMemoryError(env, "Cannot allocate pixmap for text");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        XSetForeground(awt_display, cData->monoPixmapGC, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        XSetBackground(awt_display, cData->monoPixmapGC, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        cData->monoPixmapWidth = TEXT_BM_WIDTH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        cData->monoPixmapHeight = TEXT_BM_HEIGHT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
static void FillBitmap(XImage *theImage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                       ImageRef *glyphs, jint totalGlyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                       jint clipLeft, jint clipTop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                       jint clipRight, jint clipBottom)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    int glyphCounter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    int scan = theImage->bytes_per_line;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    int y, left, top, right, bottom, width, height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    jubyte *pPix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    const jubyte *pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    unsigned int rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    pPix = (jubyte *) theImage->data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    glyphCounter = ((clipRight - clipLeft) + 7) >> 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    for (y = clipTop; y < clipBottom; y++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        memset(pPix, 0, glyphCounter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        pPix += scan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        pixels = (const jubyte *)glyphs[glyphCounter].pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (!pixels) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        rowBytes = glyphs[glyphCounter].width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        left     = glyphs[glyphCounter].x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        top      = glyphs[glyphCounter].y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        width    = glyphs[glyphCounter].width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        height   = glyphs[glyphCounter].height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        /* if any clipping required, modify parameters now */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        right  = left + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        bottom = top + height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        if (left < clipLeft) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            pixels += clipLeft - left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            left = clipLeft;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        if (top < clipTop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            pixels += (clipTop - top) * rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            top = clipTop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        if (right > clipRight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            right = clipRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        if (bottom > clipBottom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            bottom = clipBottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        if (right <= left || bottom <= top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        width = right - left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        height = bottom - top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        top -= clipTop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        left -= clipLeft;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        pPix = ((jubyte *) theImage->data) + (left >> 3) + top * scan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        left &= 0x07;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        if (theImage->bitmap_bit_order == MSBFirst) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            left = 0x80 >> left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                int x = 0, bx = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                int pix = pPix[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                int bit = left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                    if (bit == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                        pPix[bx] = (jubyte) pix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                        pix = pPix[++bx];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                        bit = 0x80;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                    if (pixels[x]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                        pix |= bit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                    bit >>= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                } while (++x < width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                pPix[bx] = (jubyte) pix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                pPix += scan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                pixels += rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            } while (--height > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            left = 1 << left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                int x = 0, bx = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                int pix = pPix[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                int bit = left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                    if ((bit >> 8) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                        pPix[bx] = (jubyte) pix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                        pix = pPix[++bx];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                        bit = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                    if (pixels[x]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                        pix |= bit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                    bit <<= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                } while (++x < width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                pPix[bx] = (jubyte) pix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                pPix += scan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                pixels += rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            } while (--height > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
AWTDrawGlyphList(JNIEnv *env, jobject xtr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                 jlong dstData, jlong gc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                 SurfaceDataBounds *bounds, ImageRef *glyphs, jint totalGlyphs)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    GC xgc, theGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    XImage *theImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    Pixmap thePixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    XGCValues xgcv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    int scan, screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    AwtGraphicsConfigDataPtr cData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    X11SDOps *xsdo = (X11SDOps *)jlong_to_ptr(dstData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    jint cx1, cy1, cx2, cy2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    xgc = (GC)gc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    if (xgc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    screen = xsdo->configData->awt_visInfo.screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    cData = getDefaultConfig(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    if (!checkPixmap(env, cData)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    theImage = cData->monoImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    thePixmap = cData->monoPixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    theGC = cData->monoPixmapGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    scan = theImage->bytes_per_line;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    xgcv.fill_style = FillStippled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    xgcv.stipple = thePixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    xgcv.ts_x_origin = bounds->x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    xgcv.ts_y_origin = bounds->y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    XChangeGC(awt_display, xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
              GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
              &xgcv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    cy1 = bounds->y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    while (cy1 < bounds->y2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        cy2 = cy1 + TEXT_BM_HEIGHT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        if (cy2 > bounds->y2) cy2 = bounds->y2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        cx1 = bounds->x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        while (cx1 < bounds->x2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            cx2 = cx1 + TEXT_BM_WIDTH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            if (cx2 > bounds->x2) cx2 = bounds->x2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            FillBitmap(theImage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                       glyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                       totalGlyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                       cx1, cy1, cx2, cy2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            // NOTE: Since we are tiling around by BM_W, BM_H offsets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            // and thePixmap is BM_W x BM_H, we do not have to move
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            // the TSOrigin at each step since the stipple repeats
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            // every BM_W, BM_H units
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            XPutImage(awt_display, thePixmap, theGC, theImage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                      0, 0, 0, 0, cx2 - cx1, cy2 - cy1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            /* MGA on Linux doesn't pick up the new stipple image data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
             * probably because it caches the image as a hardware pixmap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
             * and doesn't update it when the pixmap image data is changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
             * So if the loop is executed more than once, update the GC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
             * which triggers the required behaviour. This extra XChangeGC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
             * call only happens on large or rotated text so isn't a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
             * significant new overhead..
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
             * This code needs to execute on a Solaris client too, in case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
             * we are remote displaying to a MGA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            if (cy1 != bounds->y1 || cx1 != bounds->x1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                XChangeGC(awt_display, xgc, GCStipple, &xgcv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            XFillRectangle(awt_display, xsdo->drawable, xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                           cx1, cy1, cx2 - cx1, cy2 - cy1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            cx1 = cx2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        cy1 = cy2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    XSetFillStyle(awt_display, xgc, FillSolid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
}