summaryrefslogtreecommitdiff
path: root/libs/hwui/TextureCache.cpp
diff options
context:
space:
mode:
author Chris Craik <ccraik@google.com> 2015-01-20 14:15:51 -0800
committer Chris Craik <ccraik@google.com> 2015-01-20 14:15:51 -0800
commit37424b3d5540bf569269ec6fef55689866d943a3 (patch)
tree8177beca52dbcff404f49d174cfb63ea846d28ae /libs/hwui/TextureCache.cpp
parentc82be5f27f1dd9da665b0ca52590cc30ede4e78a (diff)
Simplify and correct texture upload unpack alignment parameter
bug:18928352 Change-Id: I484dd225ef495394d5e4283345387647345c2a07
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 8109433d8aed..119e1f5336cf 100644
--- a/libs/hwui/TextureCache.cpp
+++ b/libs/hwui/TextureCache.cpp
@@ -302,19 +302,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
@@ -323,7 +320,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;
@@ -360,6 +356,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) {