summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorChris Craik <ccraik@android.com>2014-05-19 19:35:59 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-05-19 19:35:59 +0000
commit50b843883d6906b74ba14ddde285ee8716a23782 (patch)
tree28064316e00c4968315b1f7294db2e7d19238e7e /libs
parent45d50a1363222ce5c3e352c6ba17f90e29bb3467 (diff)
parent3c769ec02b8b82bec4dec2169bf76af58be94a9a (diff)
downloadframeworks_base-50b843883d6906b74ba14ddde285ee8716a23782.zip
frameworks_base-50b843883d6906b74ba14ddde285ee8716a23782.tar.gz
frameworks_base-50b843883d6906b74ba14ddde285ee8716a23782.tar.bz2
am 3c769ec0: am 00fabcbe: am b1708e9b: Merge "Use alpha channel instead of red in drawCachedGlyphBitmap"
* commit '3c769ec02b8b82bec4dec2169bf76af58be94a9a': Use alpha channel instead of red in drawCachedGlyphBitmap
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/PixelBuffer.h19
-rw-r--r--libs/hwui/font/Font.cpp3
2 files changed, 21 insertions, 1 deletions
diff --git a/libs/hwui/PixelBuffer.h b/libs/hwui/PixelBuffer.h
index 9725a61..04225a2 100644
--- a/libs/hwui/PixelBuffer.h
+++ b/libs/hwui/PixelBuffer.h
@@ -175,6 +175,25 @@ public:
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:
/**
* Creates a new render buffer in the specified format and dimensions.
diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp
index 08e9a1a..a71db5b 100644
--- a/libs/hwui/font/Font.cpp
+++ b/libs/hwui/font/Font.cpp
@@ -217,6 +217,7 @@ void Font::drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y, uint8_t*
PixelBuffer* pixelBuffer = cacheTexture->getPixelBuffer();
uint32_t formatSize = PixelBuffer::formatSize(pixelBuffer->getFormat());
+ uint32_t alpha_channel_offset = PixelBuffer::formatAlphaOffset(pixelBuffer->getFormat());
uint32_t cacheWidth = cacheTexture->getWidth();
uint32_t srcStride = formatSize * cacheWidth;
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);
} else {
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];
}
}
}