Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8242950: Files which can't be selected has different color with metal…
  • Loading branch information
prsadhuk committed Jun 15, 2020
1 parent 955a58a commit e16e7f0b61e37693641aeeca76888db188df4842
Showing 1 changed file with 23 additions and 4 deletions.
@@ -198,8 +198,7 @@
{
J2dTraceLn(J2D_TRACE_INFO, "MTLTR_InitGlyphCache");
// TODO : Need to fix RGB order in case of LCD
MTLPixelFormat pixelFormat =
lcdCache ? MTLPixelFormatBGRA8Unorm : MTLPixelFormatA8Unorm;
MTLPixelFormat pixelFormat = MTLPixelFormatBGRA8Unorm;

MTLGlyphCacheInfo *gcinfo;
// init glyph cache data structure
@@ -290,10 +289,30 @@
{w, h, 1}
};
if (!isLCD) {
NSUInteger bytesPerRow = 1 * w;
// Opengl uses GL_INTENSITY as internal pixel format to set number of
// color components in the texture for grayscale texture.
// It is mentioned that for GL_INTENSITY format,
// the GL assembles it into an RGBA element by replicating the
// intensity value three times for red, green, blue, and alpha.
// To let metal behave the same for grayscale text,
// we need to make sure we create BGRA component by replicating
// graycale pixel value as in R=G=B=A=grayscale pixel value

unsigned int imageBytes = w * h * 4;
unsigned char imageData[imageBytes];
memset(&imageData, 0, sizeof(imageData));

unsigned int dstindex = 0;
for (int i = 0; i < (w * h); i++) {
imageData[dstindex++] = glyph->image[i];
imageData[dstindex++] = glyph->image[i];
imageData[dstindex++] = glyph->image[i];
imageData[dstindex++] = glyph->image[i];
}
NSUInteger bytesPerRow = 4 * w;
[gcinfo->texture replaceRegion:region
mipmapLevel:0
withBytes:glyph->image
withBytes:imageData
bytesPerRow:bytesPerRow];
} else {
unsigned int imageBytes = w * h * 4;

0 comments on commit e16e7f0

Please sign in to comment.