protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl, int aaHint) { switch (aaHint) { case SunHints.INTVAL_TEXT_ANTIALIAS_OFF: sg2d.loops.drawGlyphListLoop. DrawGlyphList(sg2d, sg2d.surfaceData, gl); return; case SunHints.INTVAL_TEXT_ANTIALIAS_ON: sg2d.loops.drawGlyphListAALoop. DrawGlyphListAA(sg2d, sg2d.surfaceData, gl); return; case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB: case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB: sg2d.loops.drawGlyphListLCDLoop. DrawGlyphListLCD(sg2d,sg2d.surfaceData, gl); return; } }
public void drawGlyphVector(SunGraphics2D sg2d, GlyphVector gv, float x, float y) { FontRenderContext frc = gv.getFontRenderContext(); FontInfo info = sg2d.getGVFontInfo(gv.getFont(), frc); if (info.pixelHeight > OutlineTextRenderer.THRESHHOLD) { SurfaceData.outlineTextRenderer.drawGlyphVector(sg2d, gv, x, y); return; } if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) { double origin[] = {x, y}; sg2d.transform.transform(origin, 0, origin, 0, 1); x = (float) origin[0]; y = (float) origin[1]; } else { x += sg2d.transX; // don't use the glyph info origin, already in gv. y += sg2d.transY; } GlyphList gl = GlyphList.getInstance(); gl.setFromGlyphVector(info, gv, x, y); drawGlyphList(sg2d, gl, info.aaHint); gl.dispose(); }
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); }
private void drawGlyphListSegment(SunGraphics2D sg2d, GlyphList gl, int fromglyph, int toGlyph, int aaHint, boolean isColor) { if (fromglyph >= toGlyph) return; if (isColor) { sg2d.loops.drawGlyphListColorLoop. DrawGlyphListColor(sg2d, sg2d.surfaceData, gl, fromglyph, toGlyph); } else { switch (aaHint) { case SunHints.INTVAL_TEXT_ANTIALIAS_OFF: sg2d.loops.drawGlyphListLoop. DrawGlyphList(sg2d, sg2d.surfaceData, gl, fromglyph, toGlyph); return; case SunHints.INTVAL_TEXT_ANTIALIAS_ON: sg2d.loops.drawGlyphListAALoop. DrawGlyphListAA(sg2d, sg2d.surfaceData, gl, fromglyph, toGlyph); return; case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB: case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB: sg2d.loops.drawGlyphListLCDLoop. DrawGlyphListLCD(sg2d, sg2d.surfaceData, gl, fromglyph, toGlyph); return; } } }
public void drawGlyphVector(SunGraphics2D sg2d, GlyphVector gv, float x, float y) { FontRenderContext frc = gv.getFontRenderContext(); FontInfo info = sg2d.getGVFontInfo(gv.getFont(), frc); if (info.pixelHeight > OutlineTextRenderer.THRESHHOLD) { SurfaceData.outlineTextRenderer.drawGlyphVector(sg2d, gv, x, y); return; } if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) { double origin[] = {x, y}; sg2d.transform.transform(origin, 0, origin, 0, 1); x = (float) origin[0]; y = (float) origin[1]; } else { x += sg2d.transX; // don't use the glyph info origin, already in gv. y += sg2d.transY; } GlyphList gl = GlyphList.getInstance(); gl.setFromGlyphVector(info, gv, x, y); drawGlyphList(sg2d, gl, info.aaHint); gl.dispose(); }
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); } } }
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); } } }
/** * Packs the given parameters into a single int value in order to save * space on the rendering queue. Note that most of these parameters * are only used for rendering LCD-optimized text, but conditionalizing * this work wouldn't make any impact on performance, so we will pack * those parameters even in the non-LCD case. */ private static int createPackedParams(SunGraphics2D sg2d, GlyphList gl) { return (((gl.usePositions() ? 1 : 0) << OFFSET_POSITIONS) | ((gl.isSubPixPos() ? 1 : 0) << OFFSET_SUBPIXPOS) | ((gl.isRGBOrder() ? 1 : 0) << OFFSET_RGBORDER ) | ((sg2d.lcdTextContrast & 0xff) << OFFSET_CONTRAST )); }
@Override protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) { /* * The native drawGlyphList() only works with two composite types: * - CompositeType.SrcOver (with any extra alpha), or * - CompositeType.Xor */ Composite comp = sg2d.composite; if (comp == AlphaComposite.Src) { /* * In addition to the composite types listed above, the logic * in OGL/D3DSurfaceData.validatePipe() allows for * CompositeType.SrcNoEa, but only in the presence of an opaque * color. If we reach this case, we know the color is opaque, * and therefore SrcNoEa is the same as SrcOverNoEa, so we * override the composite here. */ comp = AlphaComposite.SrcOver; } rq.lock(); try { validateContext(sg2d, comp); enqueueGlyphList(sg2d, gl); } finally { rq.unlock(); } }
public void drawString(SunGraphics2D sg2d, String s, double x, double y) { FontInfo info = sg2d.getFontInfo(); if (info.pixelHeight > OutlineTextRenderer.THRESHHOLD) { SurfaceData.outlineTextRenderer.drawString(sg2d, s, x, y); return; } float devx, devy; if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) { double origin[] = {x + info.originX, y + info.originY}; sg2d.transform.transform(origin, 0, origin, 0, 1); devx = (float)origin[0]; devy = (float)origin[1]; } else { devx = (float)(x + info.originX + sg2d.transX); devy = (float)(y + info.originY + sg2d.transY); } /* setFromString returns false if shaping is needed, and we then back * off to a TextLayout. Such text may benefit slightly from a lower * overhead in this approach over the approach in previous releases. */ GlyphList gl = GlyphList.getInstance(); if (gl.setFromString(info, s, devx, devy)) { drawGlyphList(sg2d, gl); gl.dispose(); } else { gl.dispose(); // release this asap. TextLayout tl = new TextLayout(s, sg2d.getFont(), sg2d.getFontRenderContext()); tl.draw(sg2d, (float)x, (float)y); } }
public void drawChars(SunGraphics2D sg2d, char data[], int offset, int length, int ix, int iy) { FontInfo info = sg2d.getFontInfo(); float x, y; if (info.pixelHeight > OutlineTextRenderer.THRESHHOLD) { SurfaceData.outlineTextRenderer.drawChars( sg2d, data, offset, length, ix, iy); return; } if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) { double origin[] = {ix + info.originX, iy + info.originY}; sg2d.transform.transform(origin, 0, origin, 0, 1); x = (float) origin[0]; y = (float) origin[1]; } else { x = ix + info.originX + sg2d.transX; y = iy + info.originY + sg2d.transY; } GlyphList gl = GlyphList.getInstance(); if (gl.setFromChars(info, data, offset, length, x, y)) { drawGlyphList(sg2d, gl); gl.dispose(); } else { gl.dispose(); // release this asap. TextLayout tl = new TextLayout(new String(data, offset, length), sg2d.getFont(), sg2d.getFontRenderContext()); tl.draw(sg2d, ix, iy); } }