summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorChris Craik <ccraik@android.com>2014-05-09 21:46:43 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-05-09 21:46:43 +0000
commit7e13d1d4a46a01ebaa412d622ef76d90bd39d12a (patch)
treef5a321d52bfe4f5ba35dc842ffb7437cb9366919 /libs
parentedc31509c2ff8cba86f30c836934d32a3e249dec (diff)
parentf6c9c4204c2f8f86277d081112c9dd863ddaa778 (diff)
downloadframeworks_base-7e13d1d4a46a01ebaa412d622ef76d90bd39d12a.zip
frameworks_base-7e13d1d4a46a01ebaa412d622ef76d90bd39d12a.tar.gz
frameworks_base-7e13d1d4a46a01ebaa412d622ef76d90bd39d12a.tar.bz2
am f6c9c420: Merge "Correct stride for drawing to cached glyph bitmap"
* commit 'f6c9c4204c2f8f86277d081112c9dd863ddaa778': Correct stride for drawing to cached glyph bitmap
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/font/Font.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp
index 436dcef..1d50bd5 100644
--- a/libs/hwui/font/Font.cpp
+++ b/libs/hwui/font/Font.cpp
@@ -213,18 +213,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,