* commit '00fabcbeb035fb513293ea01d245002f40b3234f': Use alpha channel instead of red in drawCachedGlyphBitmap
This commit is contained in:
@@ -175,6 +175,25 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the alpha channel offset in the specified format.
|
||||||
|
*
|
||||||
|
* Supported formats:
|
||||||
|
* GL_ALPHA
|
||||||
|
* GL_RGBA
|
||||||
|
*/
|
||||||
|
static uint32_t formatAlphaOffset(GLenum format) {
|
||||||
|
switch (format) {
|
||||||
|
case GL_ALPHA:
|
||||||
|
return 0;
|
||||||
|
case GL_RGBA:
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
ALOGE("unsupported format: %d",format);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Creates a new render buffer in the specified format and dimensions.
|
* Creates a new render buffer in the specified format and dimensions.
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ void Font::drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y, uint8_t*
|
|||||||
PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer();
|
PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer();
|
||||||
|
|
||||||
uint32_t formatSize = PixelBuffer::formatSize(pixelBuffer->getFormat());
|
uint32_t formatSize = PixelBuffer::formatSize(pixelBuffer->getFormat());
|
||||||
|
uint32_t alpha_channel_offset = PixelBuffer::formatAlphaOffset(pixelBuffer->getFormat());
|
||||||
uint32_t cacheWidth = cacheTexture->getWidth();
|
uint32_t cacheWidth = cacheTexture->getWidth();
|
||||||
uint32_t srcStride = formatSize * cacheWidth;
|
uint32_t srcStride = formatSize * cacheWidth;
|
||||||
uint32_t startY = glyph->mStartY * srcStride;
|
uint32_t startY = glyph->mStartY * srcStride;
|
||||||
@@ -231,7 +232,7 @@ void Font::drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y, uint8_t*
|
|||||||
memcpy(&bitmap[bitmapY + dstX], &cacheBuffer[cacheY + glyph->mStartX], glyph->mBitmapWidth);
|
memcpy(&bitmap[bitmapY + dstX], &cacheBuffer[cacheY + glyph->mStartX], glyph->mBitmapWidth);
|
||||||
} else {
|
} else {
|
||||||
for (uint32_t i = 0; i < glyph->mBitmapWidth; ++i) {
|
for (uint32_t i = 0; i < glyph->mBitmapWidth; ++i) {
|
||||||
bitmap[bitmapY + dstX + i] = cacheBuffer[cacheY + (glyph->mStartX + i)*formatSize];
|
bitmap[bitmapY + dstX + i] = cacheBuffer[cacheY + (glyph->mStartX + i)*formatSize + alpha_channel_offset];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user