src/solaris/classes/sun/font/XRGlyphCache.java

Print this page




 173                 if (entry.getGlyphSet() == grayGlyphSet) {
 174                     con.XRenderAddGlyphs(grayGlyphSet, gl, tmpList, generateGlyphImageStream(tmpList));
 175                 } else {
 176                     con.XRenderAddGlyphs(lcdGlyphSet, gl, tmpList, generateGlyphImageStream(tmpList));
 177                 }
 178             }
 179         }
 180     }
 181 
 182     /**
 183      * Seperates lcd and grayscale glyphs queued for upload, and sets the
 184      * appropriate glyphset for the cache entries.
 185      */
 186     protected List<XRGlyphCacheEntry>[] seperateGlyphTypes(List<XRGlyphCacheEntry> glyphList, boolean containsLCDGlyphs) {
 187         ArrayList<XRGlyphCacheEntry> lcdGlyphs = null;
 188         ArrayList<XRGlyphCacheEntry> grayGlyphs = null;
 189 
 190         for (XRGlyphCacheEntry cacheEntry : glyphList) {
 191             if (cacheEntry.isGrayscale(containsLCDGlyphs)) {
 192                 if (grayGlyphs == null) {
 193                     grayGlyphs = new ArrayList<XRGlyphCacheEntry>(glyphList.size());
 194                 }
 195                 cacheEntry.setGlyphSet(grayGlyphSet);
 196                 grayGlyphs.add(cacheEntry);
 197             } else {
 198                 if (lcdGlyphs == null) {
 199                     lcdGlyphs = new ArrayList<XRGlyphCacheEntry>(glyphList.size());
 200                 }
 201                 cacheEntry.setGlyphSet(lcdGlyphSet);
 202                 lcdGlyphs.add(cacheEntry);
 203             }
 204         }
 205 
 206         return new List[] { grayGlyphs, lcdGlyphs };



 207     }
 208 
 209     /**
 210      * Copies the glyph-images into a continous buffer, required for uploading.
 211      */
 212     protected byte[] generateGlyphImageStream(List<XRGlyphCacheEntry> glyphList) {
 213         boolean isLCDGlyph = glyphList.get(0).getGlyphSet() == lcdGlyphSet;
 214 
 215         ByteArrayOutputStream stream = new ByteArrayOutputStream((isLCDGlyph ? 4 : 1) * 48 * glyphList.size());
 216         for (XRGlyphCacheEntry cacheEntry : glyphList) {
 217             cacheEntry.writePixelData(stream, isLCDGlyph);
 218         }
 219 
 220         return stream.toByteArray();
 221     }
 222 
 223     protected boolean containsLCDGlyphs(List<XRGlyphCacheEntry> entries) {
 224         boolean containsLCDGlyphs = false;
 225 
 226         for (XRGlyphCacheEntry entry : entries) {




 173                 if (entry.getGlyphSet() == grayGlyphSet) {
 174                     con.XRenderAddGlyphs(grayGlyphSet, gl, tmpList, generateGlyphImageStream(tmpList));
 175                 } else {
 176                     con.XRenderAddGlyphs(lcdGlyphSet, gl, tmpList, generateGlyphImageStream(tmpList));
 177                 }
 178             }
 179         }
 180     }
 181 
 182     /**
 183      * Seperates lcd and grayscale glyphs queued for upload, and sets the
 184      * appropriate glyphset for the cache entries.
 185      */
 186     protected List<XRGlyphCacheEntry>[] seperateGlyphTypes(List<XRGlyphCacheEntry> glyphList, boolean containsLCDGlyphs) {
 187         ArrayList<XRGlyphCacheEntry> lcdGlyphs = null;
 188         ArrayList<XRGlyphCacheEntry> grayGlyphs = null;
 189 
 190         for (XRGlyphCacheEntry cacheEntry : glyphList) {
 191             if (cacheEntry.isGrayscale(containsLCDGlyphs)) {
 192                 if (grayGlyphs == null) {
 193                     grayGlyphs = new ArrayList<>(glyphList.size());
 194                 }
 195                 cacheEntry.setGlyphSet(grayGlyphSet);
 196                 grayGlyphs.add(cacheEntry);
 197             } else {
 198                 if (lcdGlyphs == null) {
 199                     lcdGlyphs = new ArrayList<>(glyphList.size());
 200                 }
 201                 cacheEntry.setGlyphSet(lcdGlyphSet);
 202                 lcdGlyphs.add(cacheEntry);
 203             }
 204         }
 205         // Arrays and generics don't play well together
 206         @SuppressWarnings({"unchecked", "rawtypes"}) 
 207         List<XRGlyphCacheEntry>[] tmp =
 208             (List<XRGlyphCacheEntry>[]) (new List[] { grayGlyphs, lcdGlyphs });
 209         return tmp;
 210     }
 211 
 212     /**
 213      * Copies the glyph-images into a continous buffer, required for uploading.
 214      */
 215     protected byte[] generateGlyphImageStream(List<XRGlyphCacheEntry> glyphList) {
 216         boolean isLCDGlyph = glyphList.get(0).getGlyphSet() == lcdGlyphSet;
 217 
 218         ByteArrayOutputStream stream = new ByteArrayOutputStream((isLCDGlyph ? 4 : 1) * 48 * glyphList.size());
 219         for (XRGlyphCacheEntry cacheEntry : glyphList) {
 220             cacheEntry.writePixelData(stream, isLCDGlyph);
 221         }
 222 
 223         return stream.toByteArray();
 224     }
 225 
 226     protected boolean containsLCDGlyphs(List<XRGlyphCacheEntry> entries) {
 227         boolean containsLCDGlyphs = false;
 228 
 229         for (XRGlyphCacheEntry entry : entries) {