summaryrefslogtreecommitdiff
path: root/libs/hwui/TextureCache.cpp
diff options
context:
space:
mode:
author Chris Craik <ccraik@google.com> 2015-01-20 22:39:04 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2015-01-20 22:39:07 +0000
commit8076b5a8df5bdfab478c8af41b65de7b131db5b3 (patch)
tree14e1ef50484fdbbe325bb6126e084f10d0738d51 /libs/hwui/TextureCache.cpp
parenta0d17f80902468b5a4e0874daeac92abc6f71b3e (diff)
parent37424b3d5540bf569269ec6fef55689866d943a3 (diff)
Merge "Simplify and correct texture upload unpack alignment parameter"
Diffstat (limited to 'libs/hwui/TextureCache.cpp')
-rw-r--r--libs/hwui/TextureCache.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp
index b4d3708f0fd3..524f206159d3 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -300,19 +300,16 @@ void TextureCache::generateTexture(const SkBitmap* bitmap, Texture* texture, boo
switch (bitmap->colorType()) {
case kAlpha_8_SkColorType:
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
uploadToTexture(resize, GL_ALPHA, bitmap->rowBytesAsPixels(), bitmap->bytesPerPixel(),
texture->width, texture->height, GL_UNSIGNED_BYTE, bitmap->getPixels());
texture->blend = true;
break;
case kRGB_565_SkColorType:
- glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
uploadToTexture(resize, GL_RGB, bitmap->rowBytesAsPixels(), bitmap->bytesPerPixel(),
texture->width, texture->height, GL_UNSIGNED_SHORT_5_6_5, bitmap->getPixels());
texture->blend = false;
break;
case kN32_SkColorType:
- glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
uploadToTexture(resize, GL_RGBA, bitmap->rowBytesAsPixels(), bitmap->bytesPerPixel(),
texture->width, texture->height, GL_UNSIGNED_BYTE, bitmap->getPixels());
// Do this after calling getPixels() to make sure Skia's deferred
@@ -321,7 +318,6 @@ void TextureCache::generateTexture(const SkBitmap* bitmap, Texture* texture, boo
break;
case kARGB_4444_SkColorType:
case kIndex_8_SkColorType:
- glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
uploadLoFiTexture(resize, bitmap, texture->width, texture->height);
texture->blend = !bitmap->isOpaque();
break;
@@ -358,6 +354,7 @@ void TextureCache::uploadLoFiTexture(bool resize, const SkBitmap* bitmap,
void TextureCache::uploadToTexture(bool resize, GLenum format, GLsizei stride, GLsizei bpp,
GLsizei width, GLsizei height, GLenum type, const GLvoid * data) {
+ glPixelStorei(GL_UNPACK_ALIGNMENT, bpp);
const bool useStride = stride != width && Extensions::getInstance().hasUnpackRowLength();
if ((stride == width) || useStride) {
if (useStride) {