* commit '7e13d1d4a46a01ebaa412d622ef76d90bd39d12a': Correct stride for drawing to cached glyph bitmap
This commit is contained in:
@@ -214,18 +214,28 @@ void Font::drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y, uint8_t*
|
|||||||
int dstY = y + glyph->mBitmapTop;
|
int dstY = y + glyph->mBitmapTop;
|
||||||
|
|
||||||
CacheTexture* cacheTexture = glyph->mCacheTexture;
|
CacheTexture* cacheTexture = glyph->mCacheTexture;
|
||||||
|
|
||||||
uint32_t cacheWidth = cacheTexture->getWidth();
|
|
||||||
uint32_t startY = glyph->mStartY * cacheWidth;
|
|
||||||
uint32_t endY = startY + (glyph->mBitmapHeight * cacheWidth);
|
|
||||||
|
|
||||||
PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer();
|
PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer();
|
||||||
|
|
||||||
|
uint32_t formatSize = PixelBuffer::formatSize(pixelBuffer->getFormat());
|
||||||
|
uint32_t cacheWidth = cacheTexture->getWidth();
|
||||||
|
uint32_t srcStride = formatSize * cacheWidth;
|
||||||
|
uint32_t startY = glyph->mStartY * srcStride;
|
||||||
|
uint32_t endY = startY + (glyph->mBitmapHeight * srcStride);
|
||||||
|
|
||||||
const uint8_t* cacheBuffer = pixelBuffer->map();
|
const uint8_t* cacheBuffer = pixelBuffer->map();
|
||||||
|
|
||||||
for (uint32_t cacheY = startY, bitmapY = dstY * bitmapWidth; cacheY < endY;
|
for (uint32_t cacheY = startY, bitmapY = dstY * bitmapWidth; cacheY < endY;
|
||||||
cacheY += cacheWidth, bitmapY += bitmapWidth) {
|
cacheY += srcStride, bitmapY += bitmapWidth) {
|
||||||
memcpy(&bitmap[bitmapY + dstX], &cacheBuffer[cacheY + glyph->mStartX], glyph->mBitmapWidth);
|
|
||||||
|
if (formatSize == 1) {
|
||||||
|
memcpy(&bitmap[bitmapY + dstX], &cacheBuffer[cacheY + glyph->mStartX], glyph->mBitmapWidth);
|
||||||
|
} else {
|
||||||
|
for (uint32_t i = 0; i < glyph->mBitmapWidth; ++i) {
|
||||||
|
bitmap[bitmapY + dstX + i] = cacheBuffer[cacheY + (glyph->mStartX + i)*formatSize];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::drawCachedGlyph(CachedGlyphInfo* glyph, float x, float hOffset, float vOffset,
|
void Font::drawCachedGlyph(CachedGlyphInfo* glyph, float x, float hOffset, float vOffset,
|
||||||
|
|||||||
Reference in New Issue
Block a user