Java Code Examples for sun.font.GlyphList#getNumGlyphs()

The following examples show how to use sun.font.GlyphList#getNumGlyphs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlyphListLoopPipe.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl,
                             int aaHint) {
    int prevBorder = 0;
    boolean isColor = false;
    int len = gl.getNumGlyphs();
    gl.startGlyphIteration();
    if (SunFontManager.getInstance().areColorGlyphsSupported()) {
        for (int i = 0; i < len; i++) {
            boolean newIsColor = gl.isColorGlyph(i);
            if (newIsColor != isColor) {
                drawGlyphListSegment(sg2d, gl, prevBorder, i, aaHint, isColor);
                prevBorder = i;
                isColor = newIsColor;
            }
        }
    }
    drawGlyphListSegment(sg2d, gl, prevBorder, len, aaHint, isColor);
}
 
Example 2
Source File: DrawGlyphList.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
                          GlyphList gl) {

    int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 3
Source File: DrawGlyphList.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
                          GlyphList gl) {

    int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 4
Source File: DrawGlyphList.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
                          GlyphList gl) {

    int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 5
Source File: DrawGlyphList.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
                          GlyphList gl) {

    int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 6
Source File: DrawGlyphListAA.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest,
                            GlyphList gl)
{
    gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 7
Source File: DrawGlyphListAA.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest,
                            GlyphList gl)
{
    gl.getBounds(); // Don't delete, bug 4895493
    int num = gl.getNumGlyphs();
    Region clip = sg2d.getCompClip();
    int cx1 = clip.getLoX();
    int cy1 = clip.getLoY();
    int cx2 = clip.getHiX();
    int cy2 = clip.getHiY();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            maskop.MaskFill(sg2d, dest, sg2d.composite,
                            gx1, gy1, gx2 - gx1, gy2 - gy1,
                            alpha, off, w);
        }
    }
}
 
Example 8
Source File: GeneralRenderer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
static void doDrawGlyphList(SurfaceData sData, PixelWriter pw,
                            GlyphList gl, Region clip)
{
    int[] bounds = gl.getBounds();
    clip.clipBoxToBounds(bounds);
    int cx1 = bounds[0];
    int cy1 = bounds[1];
    int cx2 = bounds[2];
    int cy2 = bounds[3];

    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1);
    pw.setRaster(dstRast);

    int num = gl.getNumGlyphs();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            w -= (gx2 - gx1);
            for (int y = gy1; y < gy2; y++) {
                for (int x = gx1; x < gx2; x++) {
                    if (alpha[off++] < 0) {
                        pw.writePixel(x, y);
                    }
                }
                off += w;
            }
        }
    }
}
 
Example 9
Source File: BufferedTextPipe.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private void enqueueGlyphList(final SunGraphics2D sg2d,
                              final GlyphList gl)
{
    // assert rq.lock.isHeldByCurrentThread();
    RenderBuffer buf = rq.getBuffer();
    final int totalGlyphs = gl.getNumGlyphs();
    int glyphBytesRequired = totalGlyphs * BYTES_PER_GLYPH_IMAGE;
    int posBytesRequired =
        gl.usePositions() ? totalGlyphs * BYTES_PER_GLYPH_POSITION : 0;
    int totalBytesRequired = 24 + glyphBytesRequired + posBytesRequired;

    final long[] images = gl.getImages();
    final float glyphListOrigX = gl.getX() + 0.5f;
    final float glyphListOrigY = gl.getY() + 0.5f;

    // make sure the RenderQueue keeps a hard reference to the FontStrike
    // so that the associated glyph images are not disposed while enqueued
    rq.addReference(gl.getStrike());

    if (totalBytesRequired <= buf.capacity()) {
        if (totalBytesRequired > buf.remaining()) {
            // process the queue first and then enqueue the glyphs
            rq.flushNow();
        }
        rq.ensureAlignment(20);
        buf.putInt(DRAW_GLYPH_LIST);
        // enqueue parameters
        buf.putInt(totalGlyphs);
        buf.putInt(createPackedParams(sg2d, gl));
        buf.putFloat(glyphListOrigX);
        buf.putFloat(glyphListOrigY);
        // now enqueue glyph information
        buf.put(images, 0, totalGlyphs);
        if (gl.usePositions()) {
            float[] positions = gl.getPositions();
            buf.put(positions, 0, 2*totalGlyphs);
        }
    } else {
        // queue is too small to accommodate glyphs; perform
        // the operation directly on the queue flushing thread
        rq.flushAndInvokeNow(new Runnable() {
            public void run() {
                drawGlyphList(totalGlyphs, gl.usePositions(),
                              gl.isSubPixPos(), gl.isRGBOrder(),
                              sg2d.lcdTextContrast,
                              glyphListOrigX, glyphListOrigY,
                              images, gl.getPositions());
            }
        });
    }
}
 
Example 10
Source File: BufferedTextPipe.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void enqueueGlyphList(final SunGraphics2D sg2d,
                              final GlyphList gl)
{
    // assert rq.lock.isHeldByCurrentThread();
    RenderBuffer buf = rq.getBuffer();
    final int totalGlyphs = gl.getNumGlyphs();
    int glyphBytesRequired = totalGlyphs * BYTES_PER_GLYPH_IMAGE;
    int posBytesRequired =
        gl.usePositions() ? totalGlyphs * BYTES_PER_GLYPH_POSITION : 0;
    int totalBytesRequired = 24 + glyphBytesRequired + posBytesRequired;

    final long[] images = gl.getImages();
    final float glyphListOrigX = gl.getX() + 0.5f;
    final float glyphListOrigY = gl.getY() + 0.5f;

    // make sure the RenderQueue keeps a hard reference to the FontStrike
    // so that the associated glyph images are not disposed while enqueued
    rq.addReference(gl.getStrike());

    if (totalBytesRequired <= buf.capacity()) {
        if (totalBytesRequired > buf.remaining()) {
            // process the queue first and then enqueue the glyphs
            rq.flushNow();
        }
        rq.ensureAlignment(20);
        buf.putInt(DRAW_GLYPH_LIST);
        // enqueue parameters
        buf.putInt(totalGlyphs);
        buf.putInt(createPackedParams(sg2d, gl));
        buf.putFloat(glyphListOrigX);
        buf.putFloat(glyphListOrigY);
        // now enqueue glyph information
        buf.put(images, 0, totalGlyphs);
        if (gl.usePositions()) {
            float[] positions = gl.getPositions();
            buf.put(positions, 0, 2*totalGlyphs);
        }
    } else {
        // queue is too small to accommodate glyphs; perform
        // the operation directly on the queue flushing thread
        rq.flushAndInvokeNow(new Runnable() {
            public void run() {
                drawGlyphList(totalGlyphs, gl.usePositions(),
                              gl.isSubPixPos(), gl.isRGBOrder(),
                              sg2d.lcdTextContrast,
                              glyphListOrigX, glyphListOrigY,
                              images, gl.getPositions());
            }
        });
    }
}
 
Example 11
Source File: GeneralRenderer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
static void doDrawGlyphList(SurfaceData sData, PixelWriter pw,
                            GlyphList gl, Region clip)
{
    int[] bounds = gl.getBounds();
    clip.clipBoxToBounds(bounds);
    int cx1 = bounds[0];
    int cy1 = bounds[1];
    int cx2 = bounds[2];
    int cy2 = bounds[3];

    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1);
    pw.setRaster(dstRast);

    int num = gl.getNumGlyphs();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            w -= (gx2 - gx1);
            for (int y = gy1; y < gy2; y++) {
                for (int x = gx1; x < gx2; x++) {
                    if (alpha[off++] < 0) {
                        pw.writePixel(x, y);
                    }
                }
                off += w;
            }
        }
    }
}
 
Example 12
Source File: BufferedTextPipe.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private void enqueueGlyphList(final SunGraphics2D sg2d,
                              final GlyphList gl)
{
    // assert rq.lock.isHeldByCurrentThread();
    RenderBuffer buf = rq.getBuffer();
    final int totalGlyphs = gl.getNumGlyphs();
    int glyphBytesRequired = totalGlyphs * BYTES_PER_GLYPH_IMAGE;
    int posBytesRequired =
        gl.usePositions() ? totalGlyphs * BYTES_PER_GLYPH_POSITION : 0;
    int totalBytesRequired = 24 + glyphBytesRequired + posBytesRequired;

    final long[] images = gl.getImages();
    final float glyphListOrigX = gl.getX() + 0.5f;
    final float glyphListOrigY = gl.getY() + 0.5f;

    // make sure the RenderQueue keeps a hard reference to the FontStrike
    // so that the associated glyph images are not disposed while enqueued
    rq.addReference(gl.getStrike());

    if (totalBytesRequired <= buf.capacity()) {
        if (totalBytesRequired > buf.remaining()) {
            // process the queue first and then enqueue the glyphs
            rq.flushNow();
        }
        rq.ensureAlignment(20);
        buf.putInt(DRAW_GLYPH_LIST);
        // enqueue parameters
        buf.putInt(totalGlyphs);
        buf.putInt(createPackedParams(sg2d, gl));
        buf.putFloat(glyphListOrigX);
        buf.putFloat(glyphListOrigY);
        // now enqueue glyph information
        buf.put(images, 0, totalGlyphs);
        if (gl.usePositions()) {
            float[] positions = gl.getPositions();
            buf.put(positions, 0, 2*totalGlyphs);
        }
    } else {
        // queue is too small to accommodate glyphs; perform
        // the operation directly on the queue flushing thread
        rq.flushAndInvokeNow(new Runnable() {
            public void run() {
                drawGlyphList(totalGlyphs, gl.usePositions(),
                              gl.isSubPixPos(), gl.isRGBOrder(),
                              sg2d.lcdTextContrast,
                              glyphListOrigX, glyphListOrigY,
                              images, gl.getPositions());
            }
        });
    }
}
 
Example 13
Source File: GeneralRenderer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
static void doDrawGlyphList(SurfaceData sData, PixelWriter pw,
                            GlyphList gl, Region clip)
{
    int[] bounds = gl.getBounds();
    clip.clipBoxToBounds(bounds);
    int cx1 = bounds[0];
    int cy1 = bounds[1];
    int cx2 = bounds[2];
    int cy2 = bounds[3];

    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1);
    pw.setRaster(dstRast);

    int num = gl.getNumGlyphs();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            w -= (gx2 - gx1);
            for (int y = gy1; y < gy2; y++) {
                for (int x = gx1; x < gx2; x++) {
                    if (alpha[off++] < 0) {
                        pw.writePixel(x, y);
                    }
                }
                off += w;
            }
        }
    }
}
 
Example 14
Source File: GeneralRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static void doDrawGlyphList(SurfaceData sData, PixelWriter pw,
                            GlyphList gl, Region clip)
{
    int[] bounds = gl.getBounds();
    clip.clipBoxToBounds(bounds);
    int cx1 = bounds[0];
    int cy1 = bounds[1];
    int cx2 = bounds[2];
    int cy2 = bounds[3];

    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1);
    pw.setRaster(dstRast);

    int num = gl.getNumGlyphs();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            w -= (gx2 - gx1);
            for (int y = gy1; y < gy2; y++) {
                for (int x = gx1; x < gx2; x++) {
                    if (alpha[off++] < 0) {
                        pw.writePixel(x, y);
                    }
                }
                off += w;
            }
        }
    }
}
 
Example 15
Source File: GeneralRenderer.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
static void doDrawGlyphList(SurfaceData sData, PixelWriter pw,
                            GlyphList gl, Region clip)
{
    int[] bounds = gl.getBounds();
    clip.clipBoxToBounds(bounds);
    int cx1 = bounds[0];
    int cy1 = bounds[1];
    int cx2 = bounds[2];
    int cy2 = bounds[3];

    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1);
    pw.setRaster(dstRast);

    int num = gl.getNumGlyphs();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int[] metrics = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte[] alpha = gl.getGrayBits();
            w -= (gx2 - gx1);
            for (int y = gy1; y < gy2; y++) {
                for (int x = gx1; x < gx2; x++) {
                    if (alpha[off++] < 0) {
                        pw.writePixel(x, y);
                    }
                }
                off += w;
            }
        }
    }
}
 
Example 16
Source File: BufferedTextPipe.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void enqueueGlyphList(final SunGraphics2D sg2d,
                              final GlyphList gl)
{
    // assert rq.lock.isHeldByCurrentThread();
    RenderBuffer buf = rq.getBuffer();
    final int totalGlyphs = gl.getNumGlyphs();
    int glyphBytesRequired = totalGlyphs * BYTES_PER_GLYPH_IMAGE;
    int posBytesRequired =
        gl.usePositions() ? totalGlyphs * BYTES_PER_GLYPH_POSITION : 0;
    int totalBytesRequired = 24 + glyphBytesRequired + posBytesRequired;

    final long[] images = gl.getImages();
    final float glyphListOrigX = gl.getX() + 0.5f;
    final float glyphListOrigY = gl.getY() + 0.5f;

    // make sure the RenderQueue keeps a hard reference to the FontStrike
    // so that the associated glyph images are not disposed while enqueued
    rq.addReference(gl.getStrike());

    if (totalBytesRequired <= buf.capacity()) {
        if (totalBytesRequired > buf.remaining()) {
            // process the queue first and then enqueue the glyphs
            rq.flushNow();
        }
        rq.ensureAlignment(20);
        buf.putInt(DRAW_GLYPH_LIST);
        // enqueue parameters
        buf.putInt(totalGlyphs);
        buf.putInt(createPackedParams(sg2d, gl));
        buf.putFloat(glyphListOrigX);
        buf.putFloat(glyphListOrigY);
        // now enqueue glyph information
        buf.put(images, 0, totalGlyphs);
        if (gl.usePositions()) {
            float[] positions = gl.getPositions();
            buf.put(positions, 0, 2*totalGlyphs);
        }
    } else {
        // queue is too small to accommodate glyphs; perform
        // the operation directly on the queue flushing thread
        rq.flushAndInvokeNow(new Runnable() {
            public void run() {
                drawGlyphList(totalGlyphs, gl.usePositions(),
                              gl.isSubPixPos(), gl.isRGBOrder(),
                              sg2d.lcdTextContrast,
                              glyphListOrigX, glyphListOrigY,
                              images, gl.getPositions());
            }
        });
    }
}
 
Example 17
Source File: TextRenderer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        for (int i = 0; i < num; i++) {
            gl.setGlyphIndex(i);
            int metrics[] = gl.getMetrics();
            int gx1 = metrics[0];
            int gy1 = metrics[1];
            int w = metrics[2];
            int gx2 = gx1 + w;
            int gy2 = gy1 + metrics[3];
            int off = 0;
            if (gx1 < cx1) {
                off = cx1 - gx1;
                gx1 = cx1;
            }
            if (gy1 < cy1) {
                off += (cy1 - gy1) * w;
                gy1 = cy1;
            }
            if (gx2 > cx2) gx2 = cx2;
            if (gy2 > cy2) gy2 = cy2;
            if (gx2 > gx1 && gy2 > gy1 &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 18
Source File: TextRenderer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    int num = gl.getNumGlyphs();
    Region clipRegion = sg2d.getCompClip();
    int cx1 = clipRegion.getLoX();
    int cy1 = clipRegion.getLoY();
    int cx2 = clipRegion.getHiX();
    int cy2 = clipRegion.getHiY();
    Object ctx = null;
    try {
        int[] bounds = gl.getBounds();
        Rectangle r = new Rectangle(bounds[0], bounds[1],
                                    bounds[2] - bounds[0],
                                    bounds[3] - bounds[1]);
        Shape s = sg2d.untransformShape(r);
        ctx = outpipe.startSequence(sg2d, s, r, bounds);
        gl.startGlyphIteration();
        for (int i = 0; i < num; i++) {
            gl.setGlyphIndex(i);
            int metrics[] = gl.getMetrics();
            int gx1 = metrics[0];
            int gy1 = metrics[1];
            int w = metrics[2];
            int gx2 = gx1 + w;
            int gy2 = gy1 + metrics[3];
            int off = 0;
            if (gx1 < cx1) {
                off = cx1 - gx1;
                gx1 = cx1;
            }
            if (gy1 < cy1) {
                off += (cy1 - gy1) * w;
                gy1 = cy1;
            }
            if (gx2 > cx2) gx2 = cx2;
            if (gy2 > cy2) gy2 = cy2;
            if (gx2 > gx1 && gy2 > gy1 && !gl.isColorGlyph(i) &&
                outpipe.needTile(ctx, gx1, gy1, gx2 - gx1, gy2 - gy1))
            {
                byte alpha[] = gl.getGrayBits();
                outpipe.renderPathTile(ctx, alpha, off, w,
                                       gx1, gy1, gx2 - gx1, gy2 - gy1);
            } else {
                outpipe.skipTile(ctx, gx1, gy1);
            }
        }
    } finally {
        if (ctx != null) {
            outpipe.endSequence(ctx);
        }
    }
}
 
Example 19
Source File: BufferedTextPipe.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private void enqueueGlyphList(final SunGraphics2D sg2d,
                              final GlyphList gl)
{
    // assert rq.lock.isHeldByCurrentThread();
    RenderBuffer buf = rq.getBuffer();
    final int totalGlyphs = gl.getNumGlyphs();
    int glyphBytesRequired = totalGlyphs * BYTES_PER_GLYPH_IMAGE;
    int posBytesRequired =
        gl.usePositions() ? totalGlyphs * BYTES_PER_GLYPH_POSITION : 0;
    int totalBytesRequired = 24 + glyphBytesRequired + posBytesRequired;

    final long[] images = gl.getImages();
    final float glyphListOrigX = gl.getX() + 0.5f;
    final float glyphListOrigY = gl.getY() + 0.5f;

    // make sure the RenderQueue keeps a hard reference to the FontStrike
    // so that the associated glyph images are not disposed while enqueued
    rq.addReference(gl.getStrike());

    if (totalBytesRequired <= buf.capacity()) {
        if (totalBytesRequired > buf.remaining()) {
            // process the queue first and then enqueue the glyphs
            rq.flushNow();
        }
        rq.ensureAlignment(20);
        buf.putInt(DRAW_GLYPH_LIST);
        // enqueue parameters
        buf.putInt(totalGlyphs);
        buf.putInt(createPackedParams(sg2d, gl));
        buf.putFloat(glyphListOrigX);
        buf.putFloat(glyphListOrigY);
        // now enqueue glyph information
        buf.put(images, 0, totalGlyphs);
        if (gl.usePositions()) {
            float[] positions = gl.getPositions();
            buf.put(positions, 0, 2*totalGlyphs);
        }
    } else {
        // queue is too small to accommodate glyphs; perform
        // the operation directly on the queue flushing thread
        rq.flushAndInvokeNow(new Runnable() {
            public void run() {
                drawGlyphList(totalGlyphs, gl.usePositions(),
                              gl.isSubPixPos(), gl.isRGBOrder(),
                              sg2d.lcdTextContrast,
                              glyphListOrigX, glyphListOrigY,
                              images, gl.getPositions());
            }
        });
    }
}
 
Example 20
Source File: GeneralRenderer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static void doDrawGlyphList(SurfaceData sData, PixelWriter pw,
                            GlyphList gl, Region clip)
{
    int[] bounds = gl.getBounds();
    clip.clipBoxToBounds(bounds);
    int cx1 = bounds[0];
    int cy1 = bounds[1];
    int cx2 = bounds[2];
    int cy2 = bounds[3];

    WritableRaster dstRast =
        (WritableRaster) sData.getRaster(cx1, cy1, cx2 - cx1, cy2 - cy1);
    pw.setRaster(dstRast);

    int num = gl.getNumGlyphs();
    for (int i = 0; i < num; i++) {
        gl.setGlyphIndex(i);
        int metrics[] = gl.getMetrics();
        int gx1 = metrics[0];
        int gy1 = metrics[1];
        int w = metrics[2];
        int gx2 = gx1 + w;
        int gy2 = gy1 + metrics[3];
        int off = 0;
        if (gx1 < cx1) {
            off = cx1 - gx1;
            gx1 = cx1;
        }
        if (gy1 < cy1) {
            off += (cy1 - gy1) * w;
            gy1 = cy1;
        }
        if (gx2 > cx2) gx2 = cx2;
        if (gy2 > cy2) gy2 = cy2;
        if (gx2 > gx1 && gy2 > gy1) {
            byte alpha[] = gl.getGrayBits();
            w -= (gx2 - gx1);
            for (int y = gy1; y < gy2; y++) {
                for (int x = gx1; x < gx2; x++) {
                    if (alpha[off++] < 0) {
                        pw.writePixel(x, y);
                    }
                }
                off += w;
            }
        }
    }
}