diff options
author | Chris Craik <ccraik@android.com> | 2014-05-09 22:00:02 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-09 22:00:02 +0000 |
commit | f9075798d7de2c23f67987d55ac1e4412de8265f (patch) | |
tree | 1b56efb5fd8ef05e76cad23220475210347d5e3c /libs | |
parent | 9c7fa9c090fd0a1016a087399f5edaf5d90d401b (diff) | |
parent | 90eaf92e325457ccb30286879a2f92b7ba517c7d (diff) | |
download | frameworks_base-f9075798d7de2c23f67987d55ac1e4412de8265f.zip frameworks_base-f9075798d7de2c23f67987d55ac1e4412de8265f.tar.gz frameworks_base-f9075798d7de2c23f67987d55ac1e4412de8265f.tar.bz2 |
am 90eaf92e: am 7e13d1d4: am f6c9c420: Merge "Correct stride for drawing to cached glyph bitmap"
* commit '90eaf92e325457ccb30286879a2f92b7ba517c7d':
Correct stride for drawing to cached glyph bitmap
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/font/Font.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp index d22cb8a..08e9a1a 100644 --- a/libs/hwui/font/Font.cpp +++ b/libs/hwui/font/Font.cpp @@ -214,18 +214,28 @@ void Font::drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y, uint8_t* int dstY = y + glyph->mBitmapTop; CacheTexture* cacheTexture = glyph->mCacheTexture; + PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer(); + uint32_t formatSize = PixelBuffer::formatSize(pixelBuffer->getFormat()); uint32_t cacheWidth = cacheTexture->getWidth(); - uint32_t startY = glyph->mStartY * cacheWidth; - uint32_t endY = startY + (glyph->mBitmapHeight * cacheWidth); + uint32_t srcStride = formatSize * cacheWidth; + uint32_t startY = glyph->mStartY * srcStride; + uint32_t endY = startY + (glyph->mBitmapHeight * srcStride); - PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer(); const uint8_t* cacheBuffer = pixelBuffer->map(); for (uint32_t cacheY = startY, bitmapY = dstY * bitmapWidth; cacheY < endY; - cacheY += cacheWidth, bitmapY += bitmapWidth) { - memcpy(&bitmap[bitmapY + dstX], &cacheBuffer[cacheY + glyph->mStartX], glyph->mBitmapWidth); + cacheY += srcStride, bitmapY += bitmapWidth) { + + 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, |