344 StrikeCache.unsafe.getChar(images[i]+StrikeCache.widthOffset);
345 metrics[3] =
346 StrikeCache.unsafe.getChar(images[i]+StrikeCache.heightOffset);
347 metrics[4] =
348 StrikeCache.unsafe.getChar(images[i]+StrikeCache.rowBytesOffset);
349 }
350
351 public int[] getMetrics() {
352 return metrics;
353 }
354
355 public byte[] getGrayBits() {
356 int len = metrics[4] * metrics[3];
357 if (graybits == null) {
358 graybits = new byte[Math.max(len, MINGRAYLENGTH)];
359 } else {
360 if (len > graybits.length) {
361 graybits = new byte[len];
362 }
363 }
364 long pixelDataAddress;
365 if (StrikeCache.nativeAddressSize == 4) {
366 pixelDataAddress = 0xffffffff &
367 StrikeCache.unsafe.getInt(images[glyphindex] +
368 StrikeCache.pixelDataOffset);
369 } else {
370 pixelDataAddress =
371 StrikeCache.unsafe.getLong(images[glyphindex] +
372 StrikeCache.pixelDataOffset);
373 }
374 if (pixelDataAddress == 0L) {
375 return graybits;
376 }
377 /* unsafe is supposed to be fast, but I doubt if this loop can beat
378 * a native call which does a getPrimitiveArrayCritical and a
379 * memcpy for the typical amount of image data (30-150 bytes)
380 * Consider a native method if there is a performance problem (which
381 * I haven't seen so far).
382 */
383 for (int i=0; i<len; i++) {
384 graybits[i] = StrikeCache.unsafe.getByte(pixelDataAddress+i);
385 }
386 return graybits;
387 }
388
389 public long[] getImages() {
390 return images;
391 }
392
393 public boolean usePositions() {
|
344 StrikeCache.unsafe.getChar(images[i]+StrikeCache.widthOffset);
345 metrics[3] =
346 StrikeCache.unsafe.getChar(images[i]+StrikeCache.heightOffset);
347 metrics[4] =
348 StrikeCache.unsafe.getChar(images[i]+StrikeCache.rowBytesOffset);
349 }
350
351 public int[] getMetrics() {
352 return metrics;
353 }
354
355 public byte[] getGrayBits() {
356 int len = metrics[4] * metrics[3];
357 if (graybits == null) {
358 graybits = new byte[Math.max(len, MINGRAYLENGTH)];
359 } else {
360 if (len > graybits.length) {
361 graybits = new byte[len];
362 }
363 }
364 long pixelDataAddress = StrikeCache.unsafe.getAddress(images[glyphindex] + StrikeCache.pixelDataOffset);
365
366 if (pixelDataAddress == 0L) {
367 return graybits;
368 }
369 /* unsafe is supposed to be fast, but I doubt if this loop can beat
370 * a native call which does a getPrimitiveArrayCritical and a
371 * memcpy for the typical amount of image data (30-150 bytes)
372 * Consider a native method if there is a performance problem (which
373 * I haven't seen so far).
374 */
375 for (int i=0; i<len; i++) {
376 graybits[i] = StrikeCache.unsafe.getByte(pixelDataAddress+i);
377 }
378 return graybits;
379 }
380
381 public long[] getImages() {
382 return images;
383 }
384
385 public boolean usePositions() {
|