提交 7972a570 编写于 作者: P prr

7007299: FileFontStrike appears not to be threadsafe?

Reviewed-by: igor, jgodinez
上级 a345b05d
...@@ -58,7 +58,7 @@ public class FileFontStrike extends PhysicalStrike { ...@@ -58,7 +58,7 @@ public class FileFontStrike extends PhysicalStrike {
private static final int SEGINTARRAY = 3; private static final int SEGINTARRAY = 3;
private static final int SEGLONGARRAY = 4; private static final int SEGLONGARRAY = 4;
private int glyphCacheFormat = UNINITIALISED; private volatile int glyphCacheFormat = UNINITIALISED;
/* segmented arrays are blocks of 256 */ /* segmented arrays are blocks of 256 */
private static final int SEGSHIFT = 8; private static final int SEGSHIFT = 8;
...@@ -522,32 +522,33 @@ public class FileFontStrike extends PhysicalStrike { ...@@ -522,32 +522,33 @@ public class FileFontStrike extends PhysicalStrike {
} }
/* Called only from synchronized code or constructor */ /* Called only from synchronized code or constructor */
private void initGlyphCache() { private synchronized void initGlyphCache() {
int numGlyphs = mapper.getNumGlyphs(); int numGlyphs = mapper.getNumGlyphs();
int tmpFormat = UNINITIALISED;
if (segmentedCache) { if (segmentedCache) {
int numSegments = (numGlyphs + SEGSIZE-1)/SEGSIZE; int numSegments = (numGlyphs + SEGSIZE-1)/SEGSIZE;
if (longAddresses) { if (longAddresses) {
glyphCacheFormat = SEGLONGARRAY; tmpFormat = SEGLONGARRAY;
segLongGlyphImages = new long[numSegments][]; segLongGlyphImages = new long[numSegments][];
this.disposer.segLongGlyphImages = segLongGlyphImages; this.disposer.segLongGlyphImages = segLongGlyphImages;
} else { } else {
glyphCacheFormat = SEGINTARRAY; tmpFormat = SEGINTARRAY;
segIntGlyphImages = new int[numSegments][]; segIntGlyphImages = new int[numSegments][];
this.disposer.segIntGlyphImages = segIntGlyphImages; this.disposer.segIntGlyphImages = segIntGlyphImages;
} }
} else { } else {
if (longAddresses) { if (longAddresses) {
glyphCacheFormat = LONGARRAY; tmpFormat = LONGARRAY;
longGlyphImages = new long[numGlyphs]; longGlyphImages = new long[numGlyphs];
this.disposer.longGlyphImages = longGlyphImages; this.disposer.longGlyphImages = longGlyphImages;
} else { } else {
glyphCacheFormat = INTARRAY; tmpFormat = INTARRAY;
intGlyphImages = new int[numGlyphs]; intGlyphImages = new int[numGlyphs];
this.disposer.intGlyphImages = intGlyphImages; this.disposer.intGlyphImages = intGlyphImages;
} }
} }
glyphCacheFormat = tmpFormat;
} }
float getGlyphAdvance(int glyphCode) { float getGlyphAdvance(int glyphCode) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册