/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This class encapsulates every thing needed that distinguishes a strike.
* It is not mutatable, but contains mutatable AffineTransform objects,
* which for performance reasons it does not keep private copies of.
* Therefore code constructing these must pass in transforms it guarantees
* not to mutate.
*/
public class FontStrikeDesc {
/* Values to use as a mask that is used for faster comparison of
* two strikes using just an int equality test.
* The ones we don't use are listed here but commented out.
* ie style is already built and hint "OFF" values are zero.
* Note that this is used as a strike key and the same strike is used
* for HRGB and HBGR, so only the orientation needed (H or V) is needed
* to construct and distinguish a FontStrikeDesc. The rgb ordering
* needed for rendering is stored in the graphics state.
*/
// static final int STYLE_PLAIN = Font.PLAIN; // 0x0000
// static final int STYLE_BOLD = Font.BOLD; // 0x0001
// static final int STYLE_ITALIC = Font.ITALIC; // 0x0002
// static final int STYLE_BOLDITALIC = Font.BOLD|Font.ITALIC; // 0x0003
// static final int AA_OFF = 0x0000;
// static final int FRAC_METRICS_OFF = 0x0000;
/* devTx is to get an inverse transform to get user space values
* for metrics. Its not used otherwise, as the glyphTx is the important
* one. But it does mean that a strike representing a 6pt font and identity
* graphics transform is not equal to one for a 12 pt font and 2x scaled
* graphics transform. Its likely to be very rare that this causes
* duplication.
*/
int style;
int aaHint;
int fmHint;
private int hashCode;
private int valuemask;
public int hashCode() {
/* Can cache hashcode since a strike(desc) is immutable.*/
if (hashCode == 0) {
}
return hashCode;
}
try {
} catch (Exception e) {
/* class cast or NP exceptions should not happen often, if ever,
* and I am hoping that this is faster than an instanceof check.
*/
return false;
}
}
FontStrikeDesc() {
// used with init
}
/* This maps a public text AA hint value into one of the subset of values
* used to index strikes. For the purpose of the strike cache there are
* only 4 values : OFF, ON, LCD_HRGB, LCD_VRGB.
* Font and ptSize are needed to resolve the 'gasp' table. The ptSize
* must therefore include device and font transforms.
*/
if (aa == VALUE_TEXT_ANTIALIAS_OFF ||
return INTVAL_TEXT_ANTIALIAS_OFF;
} else if (aa == VALUE_TEXT_ANTIALIAS_ON) {
return INTVAL_TEXT_ANTIALIAS_ON;
} else if (aa == VALUE_TEXT_ANTIALIAS_GASP) {
return INTVAL_TEXT_ANTIALIAS_ON;
} else {
return INTVAL_TEXT_ANTIALIAS_OFF;
}
} else if (aa == VALUE_TEXT_ANTIALIAS_LCD_HRGB ||
return INTVAL_TEXT_ANTIALIAS_LCD_HRGB;
} else if (aa == VALUE_TEXT_ANTIALIAS_LCD_VRGB ||
return INTVAL_TEXT_ANTIALIAS_LCD_VRGB;
} else {
return INTVAL_TEXT_ANTIALIAS_OFF;
}
}
/* This maps a public text AA hint value into one of the subset of values
* used to index strikes. For the purpose of the strike cache there are
* only 4 values : OFF, ON, LCD_HRGB, LCD_VRGB.
* Font and FontRenderContext are needed to resolve the 'gasp' table.
* This is similar to the method above, but used by callers which have not
* already calculated the glyph device point size.
*/
if (aa == VALUE_TEXT_ANTIALIAS_OFF ||
return INTVAL_TEXT_ANTIALIAS_OFF;
} else if (aa == VALUE_TEXT_ANTIALIAS_ON) {
return INTVAL_TEXT_ANTIALIAS_ON;
} else if (aa == VALUE_TEXT_ANTIALIAS_GASP) {
/* FRC.isIdentity() would have been useful */
int ptSize;
} else {
/* one or both transforms is not identity */
if (tx.isIdentity()) {
} else {
if (font.isTransformed()) {
}
}
if (shearx != 0) {
}
}
return INTVAL_TEXT_ANTIALIAS_ON;
} else {
return INTVAL_TEXT_ANTIALIAS_OFF;
}
} else if (aa == VALUE_TEXT_ANTIALIAS_LCD_HRGB ||
return INTVAL_TEXT_ANTIALIAS_LCD_HRGB;
} else if (aa == VALUE_TEXT_ANTIALIAS_LCD_VRGB ||
return INTVAL_TEXT_ANTIALIAS_LCD_VRGB;
} else {
return INTVAL_TEXT_ANTIALIAS_OFF;
}
}
if (fm == VALUE_FRACTIONALMETRICS_OFF ||
return INTVAL_FRACTIONALMETRICS_OFF;
} else {
return INTVAL_FRACTIONALMETRICS_ON;
}
}
switch (aa) {
case INTVAL_TEXT_ANTIALIAS_OFF :
break;
case INTVAL_TEXT_ANTIALIAS_ON :
break;
break;
break;
default: break;
}
if (fm == INTVAL_FRACTIONALMETRICS_ON) {
}
}
// Clone the TX in this case as this is called when its known
// that "desc" is being re-used by its creator.
}
}
}