src/macosx/classes/sun/font/CStrike.java

Print this page




 483 
 484             super.dispose();
 485 
 486             // clean out the first array
 487             disposeLongArray(firstLayerCache);
 488 
 489             // clean out the two layer arrays
 490             if (secondLayerCache != null) {
 491                 final long[][] secondLayerLongArrayArray = secondLayerCache.cache;
 492                 for (int i = 0; i < secondLayerLongArrayArray.length; i++) {
 493                     final long[] longArray = secondLayerLongArrayArray[i];
 494                     if (longArray != null) disposeLongArray(longArray);
 495                 }
 496             }
 497 
 498             // clean up everyone else
 499             if (generalCache != null) {
 500                 final Iterator<Long> i = generalCache.values().iterator();
 501                 while (i.hasNext()) {
 502                     final long longValue = i.next().longValue();
 503                     if (longValue != -1 && longValue != 0) StrikeCache.freeLongPointer(longValue);



 504                 }
 505             }
 506 
 507             // rdar://problem/5204197
 508             // Finally, set the flag.
 509             disposed = true;
 510         }
 511 
 512         private static void disposeLongArray(final long[] longArray) {
 513             for (int i = 0; i < longArray.length; i++) {
 514                 final long ptr = longArray[i];
 515                 if (ptr != 0 && ptr != -1) StrikeCache.freeLongPointer(ptr); // free's the native struct pointer



 516             }
 517         }
 518 
 519         private static class SparseBitShiftingTwoLayerArray {
 520             final long[][] cache;
 521             final int shift;
 522             final int secondLayerLength;
 523 
 524             public SparseBitShiftingTwoLayerArray(final int size, final int shift) {
 525                 this.shift = shift;
 526                 this.cache = new long[1 << shift][];
 527                 this.secondLayerLength = size >> shift;
 528             }
 529 
 530             public long get(final int index) {
 531                 final int firstIndex = index >> shift;
 532                 final long[] firstLayerRow = cache[firstIndex];
 533                 if (firstLayerRow == null) return 0L;
 534                 return firstLayerRow[index - (firstIndex * (1 << shift))];
 535             }




 483 
 484             super.dispose();
 485 
 486             // clean out the first array
 487             disposeLongArray(firstLayerCache);
 488 
 489             // clean out the two layer arrays
 490             if (secondLayerCache != null) {
 491                 final long[][] secondLayerLongArrayArray = secondLayerCache.cache;
 492                 for (int i = 0; i < secondLayerLongArrayArray.length; i++) {
 493                     final long[] longArray = secondLayerLongArrayArray[i];
 494                     if (longArray != null) disposeLongArray(longArray);
 495                 }
 496             }
 497 
 498             // clean up everyone else
 499             if (generalCache != null) {
 500                 final Iterator<Long> i = generalCache.values().iterator();
 501                 while (i.hasNext()) {
 502                     final long longValue = i.next().longValue();
 503                     if (longValue != -1 && longValue != 0) {
 504                         removeGlyphInfoFromCache(longValue);
 505                         StrikeCache.freeLongPointer(longValue);
 506                     }
 507                 }
 508             }
 509 
 510             // rdar://problem/5204197
 511             // Finally, set the flag.
 512             disposed = true;
 513         }
 514 
 515         private static void disposeLongArray(final long[] longArray) {
 516             for (int i = 0; i < longArray.length; i++) {
 517                 final long ptr = longArray[i];
 518                 if (ptr != 0 && ptr != -1) {
 519                     removeGlyphInfoFromCache(ptr);
 520                     StrikeCache.freeLongPointer(ptr); // free's the native struct pointer
 521                 }
 522             }
 523         }
 524 
 525         private static class SparseBitShiftingTwoLayerArray {
 526             final long[][] cache;
 527             final int shift;
 528             final int secondLayerLength;
 529 
 530             public SparseBitShiftingTwoLayerArray(final int size, final int shift) {
 531                 this.shift = shift;
 532                 this.cache = new long[1 << shift][];
 533                 this.secondLayerLength = size >> shift;
 534             }
 535 
 536             public long get(final int index) {
 537                 final int firstIndex = index >> shift;
 538                 final long[] firstLayerRow = cache[firstIndex];
 539                 if (firstLayerRow == null) return 0L;
 540                 return firstLayerRow[index - (firstIndex * (1 << shift))];
 541             }